Graphics Reference
In-Depth Information
The TCS shader beziersurface.tcs is similar to the TCS shader in the
Bézier curve example. In the TCS shader for the patch we pick up the values of
the uniform slider variables uOuter* and uInner* and use them to set up the
standard variables gl_TessLevelOuter[ ] and gl_TessLevelInner[ ] .
#version 400
#extension GL_ARB_tessellation_shader : enable
uniform float uOuter02, uOuter13, uInner0, uInner1;
layout( vertices = 16 ) out;
void main( )
{
gl_out[ gl_InvocationID ].gl_Position =
gl_in[ gl_InvocationID ].gl_Position;
gl_TessLevelOuter[0] = gl_TessLevelOuter[2] = uOuter02;
gl_TessLevelOuter[1] = gl_TesslevelOuter[3] = uOuter13;
gl_TessLevelInner[0] = uInner0;
gl_TessLevelInner[1] = uInner1;
}
Figure 13.11 reminds us of the meaning of the outer and inner tessella-
tion levels for a quad interpolation patern. In this TCS, the variables uOuter*
and uInner* are copied to the elements of gl_TessLevelOuter[ ] and gl_
TessLevelInner[ ] so that opposite sides of the exterior and the interior of the
patch have the same value. This need not be the case, and an exercise suggests
that you experiment with the tessellation levels.
The TES beziersurface.tes is similar to that for the Bézier curve, but
only because it involves more control points and more
basis functions. The most important thing to note in this
shader is the parameters to the layout qualifier. While we
used an isolines patern in the curve example, here we
use a quads patern and must also specify the orientation
of each quad. When you see the output in Figure 13.12,
you will see that the tessellation is a collection of quads,
each of which is actually being drawn as two triangles. So
specifying the quads patern does not give you quads; it
gives you triangles based on a quad interpolation patern.
Finally, this TES not only outputs the required gl_
Position but also computes the partial derivatives of
the surface in both the u and v directions and, by a cross
product, the out variable normal —the normal to the sur-
Figure 13.11. The outer and inner
levels for a quad interpolation patern.
Search WWH ::




Custom Search