315

Tessellation Shaders

Tessellation in computer graphics is a process that divides a surface into a

smoother mesh of triangles. An example of this kind of tessellation is shown

in Figure 13.1.

What Are Tessellation Shaders?

Tessellation shaders are one of the stages available in OpenGL to create the

geometry for a scene. New with OpenGL 4.0, they interpolate geometry to cre-

ate additional geometry that can

13

316

13. Tessellation Shaders

• Let you perform adaptive subdivision based on a variety of criteria such

as size or curvature,

• Let you provide coarser models that can be rened in the GPU, giving

you a kind of geometric compression,

• Let you apply detailed displacement maps without supplying equally

detailed geometry,

• Let you adapt visual quality to the required level of detail,

• Let you create smoother silhouees, or

• Let you perform skinning more easily.

Overall this lets you increase the quality of your nal images. So why not

just add more geometric detail right in your application program? The best

answer is that tessellation shaders have access

to all the information in the graphics pipe-

line, and thus can adapt to the display situa-

tion. Tessellation shaders are at their very best

when they choose tessellation parameters, not

statically but dynamically, based on the current

transformations, curvatures, screen coverage,

etc.

How does the tessellation shader t into

our overall shader world? The tessellation

stage is applied between the vertex shader

(Chapter 7) and the next shader stage in the

pipeline, which could be either the geometry

shader (Chapter 12) or the fragment shader

(Chapter 8). This makes intuitive sense, because

the vertex shader modies vertices individu-

ally with no reference to the primitives they lie

in. The tessellation shader amplies a single

primitive, and the geometry shader can pro-

vide additional primitives based on the original

primitive. The GLSL view of the graphics pipe-

line is shown here in Figure 13.2 with the tessellation stage highlighted.

When we say “tessellation shader,” we generally mean both the tessella-

tion control shader (TCS) and the tessellation evaluation shader (TES), unless

we say otherwise.

Figure 13.1. A polygon-interpolating mesh tes-

sellation from a GLSL shader.

317

What Are Tessellation Shaders?

Tessellation Shaders or Geometry Shaders?

Both geometry shaders and tessellation shaders are capable of creating new

geometry from existing geometry, and both have uses in giving you level-of-

detail support, so you might be confused about when to use each type. While

their capabilities are in some ways similar, there are distinct dierences. A

tessellation shader gives you more geometry, but all the new geometry is of

the same sort as you started with—you can get more segments for a line, more

triangles for a triangular patch, or more isolines or quads for a quad patch, but

you always get the same geometry. You should use a tessellation shader when

you need to generate many new vertices and one of the tessellation topologies

will suit your needs, or if your required patch input involves many (more than

six

1

) vertices.

On the other hand, a geometry shader gives some dierent capabilities.

You must use a geometry shader when you need to convert to dierent geom-

etry topologies, such as presented in the silhouee and hedgehog shaders (tri-

Figure 13.2. The full shader pipeline showing the place of the tessellation shaders.

1. Why six? The input to a geometry shader can have as many as six vertices when you use the

triangles-with-adjacency topology.

Start Free Trial

No credit card required