I am sending a triangle down the pipeline and want to tessellate it into an sierpinski gasket. It feels like this would be so much easier with instancing of the geometry shader, therefore please tell me if the idea of doing it with tessellation shaders is simply wrong.
During tessellation control I check the ID against 0-11
and store the vertex position and color on the position of the current ID.
I define glPatchParameteri(GL_PATCH_VERTICES, 3);
and layout(vertices = 12) out;
for my tesselation control shader as I want each triangle tesselated into 4 triangles.
It looks like during my tessellation evaluation shader the in vec3 tcPosition[];
and in vec3 tcColor[];
arrays contain the correct 12
values in the correct order. However: How do I associate them correctly during evaluation? Is there anything like gl_primitiveID
during tessellation evaluation? I would need a replacement for gl_primitiveID
which is 0
for all generated vertices as they are spawned from the same patch. Currently I just use the information of the first three vertices (0
,1
,2
) but I would need to shift those indices by 3 after each generated triangle.
void main(){
vec3 p0 = gl_TessCoord.x * tcPosition[0];
vec3 p1 = gl_TessCoord.y * tcPosition[1];
vec3 p2 = gl_TessCoord.z * tcPosition[2];
tePosition = p0 + p1 + p2;
teColor = gl_TessCoord.x * tcColor[0] + gl_TessCoord.y * tcColor[1] + gl_TessCoord.z * tcColor[2];
gl_Position = mvp * vec4(tePosition, 1);
}
Any insights or ideas how to cleverly tessellate the triangle such that I am later able to use transform feedback for ping-pong rendering are highly appreciated.