Graphics Reference
In-Depth Information
{
V[0] = gl_PositionIn[0].xyz;
V[1] = gl_PositionIn[1].xyz;
V[2] = gl_PositionIn[2].xyz;
CG = ( V[0] + V[1] + V[2] ) / 3.;
ProduceVertex( 0 );
ProduceVertex( 1 );
ProduceVertex( 2 );
}
And finally we have the fragment shader, pntriangles.frag , which
takes the light intensity and applies it to the surface color.
#version 400 compatibility
in float gLightIntensity;
out vec4 fFragColor;
const vec3 COLOR = vec3( 1., 1., 0. );
void main( )
{
fFragColor = vec4( gLightIntensity*COLOR, 1. );
}
The result of this treatment of PN triangles is shown in the treatment of a
face defined as a triangle mesh, from [45]. Different treatments of the model's
triangles yield different kinds of output quality. You should be careful when
you use a technique such as this; you may end up creating an image that is too
smooth to represent the reality your model has. Not all interpolations repre-
sent a reasonable approximation of reality!
A good example of the effect of using this tessellation on PN triangles is
given by a detail of the cow model we saw in Chapter 12 on geometry shad-
ers. In Figure 13.24 we see the detail at the base of the tail in the cow model.
In the top row, the left-hand image is the simple Gouraud shading of the tri-
angles in the tail, while the right-hand image improves the outer tessellation
(outer = 2, inner = 1). Notice how much improvement there is just by increasing
the outer tessellation. This is because smooth shading already helps the inner
parts of triangles, but does nothing for the silhouetes. In the lower left image,
the inner tessellation is also improved (outer = 2, inner = 2), while the lower
right image shows the triangle structure by slightly shrinking all the triangles.
Search WWH ::




Custom Search