Graphics Reference
In-Depth Information
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;
}
In this example, the amount of tessellation is set by uniform variables for
simplicity. But, in fact, those levels could also have been set by examining the
geometry's coordinate size, screen extent, zoom factors, curvature, etc. That's
the advantage of placing this capability in the pipeline as a programmable
shader.
The tessellation evaluation shader defines the way interpolation com-
putations are to be done, and the tessellation evaluation shader for the figure
is shown below. Part of a long set of assignments is omited, but you should
think of pij as the [i,j] entry in the 2D control points array that is passed in
from the tessellation control shader. The real function of this particular shader
is to set up the Bézier basis functions and the computations for position and
normal for any point in an interpolated patch. This should be familiar to those
who have writen their own Bézier patch code. The vertices of the patch are
computed with fixed-function computations based on the tessellation levels
from the tessellation control shader, and the output of this shader is a set of
triangle vertices that are assembled for the next piece of the pipeline.
#version 400
#extension GL_ARB_tessellation_shader : enable
layout( quads, equal_spacing, ccw) in;
out vec3 teNormal;
void main( )
{
vec3 p00 = gl_in[ 0 ].gl_Position;
...
vec3 p33 = gl_in[ 15 ].gl_Position;
float u = gl_TessCoord.x;
float v = gl_TessCoord.y;
Search WWH ::




Custom Search