Graphics Reference
In-Depth Information
Tessellation Shaders
Tessellation shaders follow the vertex shader in the
shader pipeline. They take vertex data and can inter-
polate the original vertices to create additional ver-
tices in your geometry. (Note that this interpolation
is quite different from the interpolations in fragment
shaders.) Among other things, tessellation shaders let
you perform adaptive subdivision of your geometry
to increase the quality of your images, manage level-
of-detail (LOD) image quality, or apply displacement
maps without defining detailed geometry.
There are actually two kinds of tessellation shad-
ers, as you saw in Figures 3.1 and 3.2: tessellation con-
trol shaders let you set up the parameters for the inter-
polations to be carried out, and tessellation evaluation
shaders let you define the computation that will be
used in creating the actual output geometry.
Figure 3.6 illustrates the subdivision capability
of tessellation shaders. It shows a surface built from
a single 4 × 4 vertex patch, with each triangle in the surface shrunken slightly
so you can see how the surface is created. 1
Two key concepts in tessellation shaders are the patch , or basic geometry
the shader is to work on, and the tessellation level , or the number of subdivi-
sions into which a patch is divided. The vertices in the patch for this figure are
set in the glib file for the example using glman , and are available on the topic's
website. The tessellation control shader for the figure is shown below. It speci-
fies the number of vertices in a patch and passes the input geometry in gl_in
to the geometry gl_out for the tessellation evaluation shader to use. It also
takes tessellation levels as uniform variables and sets up the required variables
gl_TessLevelOuter and gl_TessLevelInner .
Figure 3.6. A Bézier surface interpolated
from a 4 × 4 patch by tessellation shaders.
#version 400
#extension GL_ARB_tessellation_shader : enable
uniform float uOuter02, uOuter13, uInner0, uInner1;
layout( vertices = 16 ) out;
1. This example is explained in more detail in Chapter 13.
Search WWH ::




Custom Search