PDA

View Full Version : triangle strip: which triangle am I in?



BenFoppa
09-06-2014, 09:41 PM
When using triangle strips, is there any way for the fragment shader to know which triangle it's in? Does gl_PrimitiveID output per triangle (not per strip)? If so: I'm outputting vertices from a geometry shader, how can I get gl_PrimitiveID specified per-triangle still?

Yandersen
09-07-2014, 08:57 AM
If you are using geometry shader, you can output any per-triangle data using the "flat" modifier for it. Set this variable(s) once just before emitting the last vertex of the triangle.

BenFoppa
09-08-2014, 07:35 PM
If you are using geometry shader, you can output any per-triangle data using the "flat" modifier for it. Set this variable(s) once just before emitting the last vertex of the triangle.

Thanks! But unfortunately I've abandoned the geometry shader - it didn't seem to play nicely with just about any drivers. Is there any way for the fragment shader to know straight from the vertex shader?

Edit: Sounds like the same rules still apply https://www.opengl.org/discussion_boards/showthread.php/182805-Triangle-Strip-Per-Triangle-color