PDA

View Full Version : Tesselation not working



Shovel
07-24-2015, 01:51 AM
Hi,

I am struggling with tesselation and perhaps a more experienced user will see what I am doing wrong. The code is in python, but I think the problem are the tesselation shaders.

To run the program I execute the following command and pass the shaders as arguments:

python testShaders_tesselation_stripped.py C2E1v_green C2E2f_passthrough tcs_constant tes_interpolate

Without the tesselation control and evaluation shader and calling:

glDrawArrays(GL_TRIANGLES, ...)
it works. 1953

With the tesselation shaders and calling:

glDrawArrays(GL_PATCHES, ...)
noting is drawn, it remains gray and the triangle is not shown :(

GClements
07-24-2015, 03:11 AM
After converting your code to use GLUT rather than PyGame, it works on my system insofar as the triangle is rendered, but in black.

To get the correct colour, I needed to add the following to the tessellation control shader


gl_out[gl_InvocationID].gl_FrontColor = gl_in[gl_InvocationID].gl_FrontColor;
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;

and to the tessellation evaluation shader


gl_FrontColor =
(gl_TessCoord.x * gl_in[0].gl_FrontColor) +
(gl_TessCoord.y * gl_in[1].gl_FrontColor) +
(gl_TessCoord.z * gl_in[2].gl_FrontColor);


Essentially, the tessellation shaders don't automatically copy inputs to outputs. Except, the tessellation control shader did automatically copy gl_in[].gl_Position to gl_out[].gl_Position when gl_out[] wasn't explicitly assigned, but explicitly copying only the gl_FrontColor field resulted in the position not being copied, so it appears that you need to explicitly copy everything if you explicitly copy anything.

I'm not sure how much of this behaviour is actually specified. I wouldn't rule out driver bugs when using compatibility variables such as gl_FrontColor with recent features such as tessellation shaders.

The complete test program is here (http://pastebin.com/Gz227y2P)

Shovel
07-24-2015, 04:30 AM
You are right. Now it works.

It was the missing:


gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;

When I define no color, it is black. So I made a gray background. But perhaps you are right and the behaviour is undefined.

Thanks a lot :)