Graphics Reference
In-Depth Information
The vertex shader, pntriangles.vert , is straightforward, taking its ver-
tex location and normal from the standard variables and applying the Scale
value.
#version 400 compatibility
uniform float uScale;
out vec3 vNormal;
void main( )
{
vec3 xyz = aVertex.xyz;
xyz *= uScale;
gl_Position = uModelViewMatrix * vec4( xyz, 1. );
vNormal = normalize( uNormalMatrix * aNormal );
}
The TCS shader, pntriangles.tcs , is straightforward; it takes the posi-
tion and normal values as arrays from the primitive assembly following the
vertex shader, passes these on to the TES shader, and sets the required tessel-
lation level values for the TES operation.
#version 400 compatibility
#extension GL_ARB_tessellation_shader : enable
uniform float uOuter, uInner;
uniform float uScale;
layout( vertices = 3 ) out;
in vec3 vNormal[ ];
out vec3 tcNormals[ ];
void main( )
{
tcNormals[gl_InvocationID] =
vNormal[gl_InvocationID];
gl_out[ gl_InvocationID ].gl_Position =
gl_in[ gl_InvocationID ].gl_Position;
gl_TessLevelOuter[0] = uScale * Outer;
gl_TessLevelOuter[1] = uScale * Outer;
gl_TessLevelOuter[2] = uScale * Outer;
gl_TessLevelInner[0] = uScale * Inner;
}
The TES shader, pntriangles.tes , is the most complex piece of the pro-
cess because it sets up and executes the Bézier patch for the triangle, produc-
ing not only the position but also the normal for each vertex in the patch.
Search WWH ::




Custom Search