Fejwin
Fejwin

Reputation: 727

OpenGL - How to Jump in a Single TRIANGLE_STRIP without affecting Texturing?

If one puts the same vertex A into a triangle strip several times, then takes another vertex B and puts this one several times into the triangle strip also (the amount depending on the triangle orientation one wants to continue with), then one effectively can have two separate triangle strips to be rendered with only one draw call (the first containing all triangles before vertex A and the second consisting of all triangles after vertex B).

My question:

I am afraid, even though the complete triangle strip draw call will draw a geometrically simply connected mesh, I will encounter problems when attempting to texture the mesh due to the jumps in between. I am not quite there yet, so I cannot test it. Is my assumption correct? Is my jumping in the triangle strip at any rate a valid technique in the "drawing meshes" industry? Is there any way to texture the result appropriately, or an equivalent better behaving alternative to the jumping?

Upvotes: 4

Views: 984

Answers (2)

Brett Hale
Brett Hale

Reputation: 22318

Consider a 'mesh' consisting of a triangle subdivided into 4 similar triangles:

      2
       /\
      /  \
   1 /____\3
    /\    /\
   /  \  /  \
0 /____\/4___\5

Assume CCW (glFrontFace) winding, the triangles: {0,4,1}, {1,4,3}, {3,2,1} are encoded as a strip: {0,4,1,3,2}. The trick is adding the triangle: {4,5,3} by adding degenerate (zero-area) triangles, while maintaining the correct winding. In short:

{0,4,1,3,2,2,3,3,5,4}, adds the zero-area triangles: {3,2,2}, {2,2,3}, {3,3,5}.

This adds a negligible amount of extra geometry for a larger mesh, provided that efficient mesh striping is used.

Upvotes: 3

Nicol Bolas
Nicol Bolas

Reputation: 473537

Rasterizers draw the area of a triangle. A "triangle" that has two points that are the same has no area. Therefore, there is no area of the triangle to render.

Degenerate triangles (the technical term for triangles where two of the points are the same) are a common technique for connecting multiple strips. This is typically done in the index array by just adding more indices; nothing about the actual topology of the mesh needs to change.

Upvotes: 2

Related Questions