Advertisement

How do I enforce winding order for triangles generated by my tessellation shader?

Started by July 14, 2019 02:38 PM
5 comments, last by ReaperSMS 5 years, 2 months ago

A little backstory:

I'm tessellating some simple terrain. I have some patches which are modulo translated up to their own size, so the patches are repeated while giving an effect of being an endless supply of patches to either side. I'd like to only translate them up to one unit instead, so that the far reaches of all my patches don't change by the full patch size, but only by one unit.
However, the winding order of the triangles differ, and 4 texels in the heightmap render different depending on the winding order, so I'd like to enforce the winding order for all the generated triangles.

Is there any way to dictate the triangle winding order for all the generated geometry? I'd like for them to be similar, not flipped around the center of the patch...

Thanks in advance,
/SuperVGA

tessellation.png

I am having difficulties with my imagination.

Is it correct that a single, untessellated patch has the correct winding order all over its area ? Drawing normals can reveal that. If not, then the order of the indices comes into my mind (if you're drawing elements), otherwise the order of the vertices as they are listed in the array buffer.

But if the switch happens in the tessellation stage, i would assume that there something gets out of order, but i need more info for a better guess ....

Advertisement
1 hour ago, Green_Baron said:

I am having difficulties with my imagination.

Is it correct that a single, untessellated patch has the correct winding order all over its area ? Drawing normals can reveal that. If not, then the order of the indices comes into my mind (if you're drawing elements), otherwise the order of the vertices as they are listed in the array buffer.

But if the switch happens in the tessellation stage, i would assume that there something gets out of order, but i need more info for a better guess ....

I'm convinced it happens in the tessellation stage. The patch is a single CCW quad which I render using glDrawArrays(GL_PATCHES...
I've tried reversing the winding order, starting at a different vertex, and even twisting it to a DX-style "Z" order. It still comes out like this.

The spec leaves the internal edges up to the implementation. https://www.khronos.org/opengl/wiki/Tessellation

Winding can be somewhat controlled in the TES stage.

What he's looking for isn't quite the winding, but where the quad -> tri split is. The TES is more for making sure things are culled correctly, and I doubt it would fix this particular issue...

This topic is closed to new replies.

Advertisement