Reputation: 435
How it possible to pass data through shaders, when using vertex, tess. control, tess. evaluation, geometry and fragment shaders. I've tried using interface block this way.
//vertex shaders
out VS_OUT { ... } vs_out;
Than I wrote this code in tessellation control shader:
in VS_OUT { ... } tc_in;
out TC_OUT { ... } tc_out;
So, tesselation control shader called once for every vertex. Does it mean that tc_in must be not array but single variable. I'm not really sure about that because of sneaky gl_InvocationID.
Then things become tough. Tessellation evaluation shader. Something tells me that evaluation shader should take interface block as array.
in TC_OUT { ... } te_in[];
out TE_OUT { ... } te_out[];
Moving to geometry shader. Geometry shader takes multiple vertices, so, definitely array interface block.
in TE_OUT { ... } gs_in[];
out vec3 random_variable;
...
random_variable = gs_in[whatever_index];
Seems legit for me, but data didn't come to fragment shader.
I would appreciate any advice.
Upvotes: 0
Views: 1378
Reputation: 5421
Tessellation control shaders take the vertices of a patch as modify them in some way, so their input and output is
in VS_OUT { ... } tc_in[];
out TC_OUT { ... } tc_out[];
The control shader gets called for every patch vertex (see which one by using gl_InvocationID
), so you usually don't need any loops to implement it.
Tessellation evaluation shaders take these modified vertices and output a single vertex per invocation, thus we have
in TC_OUT { ... } te_in[];
out TE_OUT { ... } te_out;
Geometry shaders take multiple vertices and may output a different number of vertices, but these are constructed explicitly using EmitVertex
and EmitPrimitive
, so there is only one output element that has to be filled before each call of EmitVertex
:
in TE_OUT { ... } gs_in[];
out GS_OUT { ... } gs_out;
But don't forget to set glPosition
in your geometry shader, otherwise OpenGL won't know where to place your vertices.
The interpolated values of gs_out
are then passed to the fragment shader.
Upvotes: 2