Search code examples
opengltessellation

What is the ordering of vertices being tessellated as quads?


What are the consecutive tessellation coordinates of the four vertices of a quad? In section 11.2 Tessellation of the OpenGL 4.6 documentation, the four vertices of a quad are addressed by their tessellation coordinates and their relation to the outer and inner tessellation levels is defined. However, the way gl_InvocationID maps to the tessellation coordinates is not defined there.


Solution

  • However, the way gl_InvocationID maps to the tessellation coordinates is not defined there.

    It isn't supposed to be. Providing that mapping is your job.

    The tessellation primitive generator works on the basis of an abstract patch. You don't provide a quad to be tessellated. The system tessellates an abstract, unit quad, and it provides the vertex positions in the abstract quad's space to your TES. It is your TES's job to generate, from that vertex position in the abstract space, the actual vertex data using the patch data provided by the TCS/rendering command.

    How you use that patch data to do this is entirely up to you.

    The order of the vertices in the TCS non-patch output variables is the same as the order of the vertices in the TES non-patch input variables. So if you write to index 1 in the TCS, the value you read in the TES from index 1 will be that value. So you know which values in the TES came from which invocations in the TCS (or lacking a TCS, which vertices from the patch primitive).

    That's all you need to know. Which vertex in the patch corresponds to (0, 0) in the quad? That's up to you and how you write your TES. Your TES doesn't even have to have a single vertex that directly corresponds to it; it all depends on how you want to generate the vertex data for your tessellated data.