Graphics Reference
In-Depth Information
Figure 8.6. The smooth- (left) and Phong-shaded (right) teapots from Chapter 5.
// Assumed context:
//
//variables myNormal and myPosition are passed in and
//the ADS color is returned from the function
vec3 ADSLightModel( in vec3 myNormal, in vec4 myPosition )
{
// use the function from the Lighting chapter
}
void main( )
{
vec3 color = ADSLightModel( vNormal, vPos);
}
The figures from the lighting chapter showing how Phong shading dif-
fers from smooth shading are repeated here as Figure 8.6. Notice that the jag-
ged per-vertex artifacts in the smooth-shaded example are eliminated by using
Phong shading.
The specular highlight in the right image is much more effective than that
in the left image. The reason is that in the left image, the specular highlight is
computed at each vertex and interpolated across the polygon. If a polygon's
vertices don't get much specular lighting, then the pixels in that polygon won't
have much either, even if the specular lighting is supposed to be high in the
interior.
Shading with Analytic Normals
As good as Phong shading is, it is still not exact, because it interpolates nor-
mals linearly across each primitive, so if there is any nonlinear variation in that
Search WWH ::




Custom Search