OpenGL Rendering Pipeline
Since OpenGL 4.0 the specification defines tessellation to be "a process that reads a patch primitive and generates new primitives used by subsequent pipeline stages. The generated primitives are formed by subdividing a single triangle or quad primitive[..]".
The tessellation process is divided into three stages which form an optional part of the rendering pipeline, two of which are programmable and one which is fixed as follows (in order).
This programmable stage executes an optional tessellation control shader. If no control shader is active in the current program or program pipeline, default values are used by the subsequent stage. Values most important for the tessellation process are the so called inner and outer tessellation levels. There exist two built-in 'output' arrays in the tessellation control language, gl_TessLevelInner and gl_TessLevelOuter, which in part control how the subsequent stage generates new primitives.
Tessellation Primitive Generation
Primitive generation is a fixed-function stage responsible for creating a set of new primitives from the input patch. This stage is only executed if a tessellation evaluation shader is active in the current program or program pipeline. Primitive generation is affected by two factors:
- the input primitive type defined by the subsequent evaluation shader which may be one of triangles, quads or isolines
- the tessellation levels, which may have been altered by a control shader in the previous stage
Depending on the primitive type, the primitive generator evaluates a different number of tessellation levels and applies different tesselation algorithms. Each generated vertex is assigned a normalized position (i.e. in [0, 1]) denoted or . The coordinates are accessible using the built-in in vec3 gl_TessCoord during tesselation evalutation where gl_TessCoord.xyz is equivalent to the triple .
The first inner tessellation level and the first three outer tessellation levels are used. The algorithm is required to produce smaller triangles. The resulting vertex positions are barycentric coordinates, which specify weights of the vertices of the input triangle for which the condition holds.
For quads all six tessellation levels are used to subdivide the input rectangle into smaller triangles.
They are only affected by the first two outer tessellation levels. The generator will create independent lines, which will be subdivided into segments with vertices, where
The coordinates of the vertices are determined by subdividing the line along the -axis and determining a constant value along the -axis for every vertex on the current line using the formula
As can be seen, the the generator will not create a line at . During isoline tessellation, the -coordinate is ignored.
Tessellation stages operate on patches, a new primitive type denoted by the constant GL_PATCHES, which are simply arrays of vertices written by a vertex shader.
|This article is a stub. You can help the OpenGL Wiki by expanding it.|