OpenGL 3.3 - How to change tesselataionlevel during run time?

405 Views Asked by At

How can I change the tesselation leveln during runtime?
My only idea is to create a bufferobject with only one variable, which I have to pass through... Are there any better solutions?

I have a tesselation control shader file which works fine:

[...]
void main()
{
    if(gl_InvocationID==0)
    {
    gl_TessLevelInner[0]= 5.0;
    gl_TessLevelOuter[0]=5.0;
    gl_TessLevelOuter[1]=5.0;
    gl_TessLevelOuter[2]=5.0;
    }
 gl_out[gl_InvocationID].gl_Position =gl_in[gl_InvocationID].gl_Position;
}
1

There are 1 best solutions below

0
On

You can pass the tessellation values as uniforms or (as the values are constant for each draw call) bypass the tessellation control shader altogether. If no TCS is linked to your shader program, the values supplied with -

GLfloat outer_values[4];
GLfloat inner_values[2];
// outer_values and inner_values should be set here
glPatchParameterfv​(GL_PATCH_DEFAULT_OUTER_LEVEL​, outer_values​​);
glPatchParameterfv​(GL_PATCH_DEFAULT_INNER_LEVEL​, inner_values​​);

will be used instead. In this case the tessellation evaluation shader uses the values output from the vertex shader.