Geometry shader for multiple primitives

Posted by Byte56 on Game Development See other posts from Game Development or by Byte56
Published on 2012-10-13T04:26:11Z Indexed on 2012/10/13 9:53 UTC
Read the original article Hit count: 376

Filed under:
|
|
|

How can I create a geometry shader that can handle multiple primitives? For example when creating a geometry shader for triangles, I define a layout like so:

layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;

But if I use this shader then lines or points won't show up. So adding:

layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
layout(lines) in;
layout(line_strip, max_vertices=2) out;

The shader will compile and run, but will only render lines (or whatever the last primitive defined is).

So how do I define a single geometry shader that will handle multiple types of primitives? Or is that not possible and I need to create multiple shader programs and change shader programs before drawing each type?

© Game Development or respective owner

Related posts about opengl

Related posts about shaders