Triangle tessellation in GL_ARB_tessellation_shade

I’ve been reading through today because I wanted to know how exactly triangles are tessellated when using a tessellation shader.

However, there’s a part I found strange - maybe I don’t understand if fully (math/vocabulary wise). In “Section 2.X.2.1, Triangle Tessellation” there is a part about how the vertices for inner triangles are created. Specifically:

If I understand this right, it works like illustrated in this picture (assuming an inner tessellation level of 4):

However, if this was correct, it would be flawed, in that for obtuse triangles it would be possible that the inner vertices are placed outside the original triangle.

I’ve tested it on an NVidia card, where the tessellation clearly results in correct concentric triangles.

Thanks in advance.

Ah, I’ve somehow overlooked the part where it says that this is for “equilateral triangles”… which is even more disturbing since then I cannot find a general description/algorithm in this text. Well I’ll have the chance to test on different cards soon, so I’ll see how much they differ… I hope that it’s not too much :stuck_out_tongue:

Hmm, thinking about it a bit more I think that the described algorithm should suffice anyway, as it should be possible to apply the same barycentric coordinates to any triangle then?

I think there is a mistake in the description… :-S
The right algorithm should be :
“the inner triangle corner is produced at the intersection of two lines extended parallel to the corner’s two adjacent edges…”
Otherwise as you point obtuse triangles can cause problems.

Same mistake in the openGl 4.0 specification (page 104).
That’s strange.

Parallel would result in different vertices though. But (I think) I have found the solution anyway.
It really only needs to be done for one triangle, the one with vertices (1, 0, 0), (0, 1, 0), (0, 0, 1). Which is an equilateral triangle where the algorithm works correctly. The resulting vertices can be used as barycentric coordinates for any triangle.
So basically, for each tessellation-level parameters, the tessellation only needs to be done once, and the resulting data can be used for any other triangle.
Some shots of my software implementation in action:

(Maybe they’ve written it that way to confuse ATI :stuck_out_tongue: seeing that the unigine engine seems to behave incorrectly at times, and/or crashes even… but only on ATI cards)