Graphics Reference
In-Depth Information
layout( vertices = 3 ) out;
void main( )
{
gl_out[ gl_InvocationID ].gl_Position =
gl_in[ gl_InvocationID ].gl_Position;
gl_TessLevelOuter[0] = uRadius * uOuter0;
gl_TessLevelOuter[1] = uRadius * uOuter1;
gl_TessLevelOuter[2] = uRadius * uOuter2;
gl_TessLevelInner[0] = uRadius * uInner;
}
The TES shader created by the file octantsubd.tes below interpolates
the input vertices with the tessellation coordinates gl_TessCoord[ ] using the
triangles patern. It applies the modelview matrix to get the position of each
vertex in the tessellated output.
#version 400 compatibility
#extension GL_ARB_tessellation_shader : enable
uniform float uRadius;
layout( triangles, equal_spacing, ccw) in;
void main( )
{
vec3 p0 = gl_in[0].gl_Position.xyz;
vec3 p1 = gl_in[1].gl_Position.xyz;
vec3 p2 = gl_in[2].gl_Position.xyz;
float u = gl_TessCoord.x;
float v = gl_TessCoord.y;
float w = gl_TessCoord.z;
gl_Position = uModelViewMatrix *
vec4(uRadius*normalize(u*p0+v*p1+w*p2),1.);
}
The expression uRadius*normalize(...) is in the gl_Position compu-
tation to “puff” out the points to be a constant-radius spherical surface instead
of a planar triangle.
Search WWH ::




Custom Search