To create a shader program that will generate a Bezier curve from a patch of four control points, use the following steps:
- Use the following code for the vertex shader. Note that we send the vertex position along to the TCS unmodified:
layout (location = 0 ) in vec2 VertexPosition; void main() { gl_Position = vec4(VertexPosition, 0.0, 1.0); }
- Use the following code as the tessellation control shader:
layout( vertices=4 ) out; uniform int NumSegments; uniform int NumStrips; void main() { // Pass along the vertex position unmodified gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position; // Define the tessellation levels gl_TessLevelOuter[0] = float(NumStrips); gl_TessLevelOuter[1] = float(NumSegments); ...