Greetings:
I am trying to write a program to draw a Bezier curve and its 4 control points. Stand-alone separate programs to do these work fine. The point-drawing program has VS - FS shaders, the curve program has VS - TCS - TES - FS.
In order to render control points and curve together I am trying to write a program with two pipelines generated with glGenProgramPipelines(2, pipeline) and bound with glBindProgramPipeline(pipeline[0/1]), etc. Obviously, the points pipeline is VS - FS and the curve pipeline VS - TCS - TES - FS. In fact, the VS and FS are same, the points pipeline dropping the TCS and TES and draw call changing from GL_PATCHES to GL_POINTS.
Here’s the problem: the point pipeline seems to be drawing points correctly but the curve pipeline seems to be doing nothing.
Since the shader logic seems correct (stand-alone programs work) and the app program ok (at least one pipeline functions) I am guessing the problem is in the interface between shaders. I declare
out gl_PerVertex
{
vec4 gl_Position;
};
in the VS but I am not sure what to do in the other shaders. My FS is a one line color declaration while my TCS and TES are copied from Bailey/Cunningham:
TCS:
#version 400
#extension GL_ARB_tessellation_shader: enable
uniform float uOuter1;
layout( vertices = 4 ) out; // same size as input,
// (but doesn’t have to be)
void main( )
{
gl_out[ gl_InvocationID ].gl_Position =
gl_in[ gl_InvocationID ].gl_Position;
gl_TessLevelOuter[0] = 1.;
gl_TessLevelOuter[1] = uOuter1;
}
TES:
#version 400
#extension GL_ARB_tessellation_shader: enable
layout( isolines, equal_spacing) in;
void main( )
{
vec4 p0 = gl_in[0].gl_Position;
vec4 p1 = gl_in[1].gl_Position;
vec4 p2 = gl_in[2].gl_Position;
vec4 p3 = gl_in[3].gl_Position;
float u = gl_TessCoord.x;
// the basis functions:
float b0 = (1.-u) * (1.-u) * (1.-u);
float b1 = 3. * u * (1.-u) * (1.-u);
float b2 = 3. * u * u * (1.-u);
float b3 = u * u * u;
gl_Position = b0*p0 + b1*p1 + b2*p2 + b3*p3;
}
Really appreciate if you could say how to write the interfaces or suggest other possible issues.
Thanks,
Sam