Graphics Reference
In-Depth Information
angles → lines) or the explosion shader (triangles → points), or if you need
some sort of geometry processing to come after the tessellation shader (such
as the shrink shader you saw earlier, which we will use here to show what the
tessellation stages are actually doing).
Finally, the fact that geometry shaders follow tessellation shaders in the
vertex pipeline creates a limitation on using tessellation shaders. A tessellation
shader can only emit line segments and triangles; it cannot emit any geometry
with adjacency. If you need to create new geometry in a geometry shader and
this geometry requires adjacency, the geometry shader cannot follow a tessel-
lation shader and so you cannot use tessellation shaders.
Tessellation Shader Concepts
Tessellation shaders are conceptually simple but, like textures, require quite a
bit of detail to set up.
Input to the tessellation shaders uses a new graphics primitive: the patch .
This is specified in your OpenGL program with
glBegin( GL_PATCHES );
glVertex3f( . . . );
glVertex3f( . . . );
glEnd( );
Even if you are using vertex arrays or buffers instead of glBegin - glEnd ,
the topology type is still GL_PATCHES . There is no implied order in the list of
vertices. The meaning of the order is up to you. You just need to pick a consis-
tent convention for the type of geometry you are tessellating. As we will see in
some later examples, the vertex values need not even be actual coordinates;
we can even use them as geometric parameters. You also need to set up some
data that describes the patch. The function
glPatchParameteri( GL_PATCH_VERTICES, num );
defines the number of vertices in the patch. Like other OpenGL topologies,
you don't need a glEnd - glBegin to start a new primitive. Just keep listing
vertices. In this case, one patch is complete after num vertices, and a new one
gets started.
As you see in Figure 13.2, there are two tessellation shader types that
work together. The first is the tessellation control shader (TCS). Its function is
to prepare the final control points and to determine how much to tessellate.
It is invoked once for each output control point and takes as input num trans-
Search WWH ::




Custom Search