PDA

View Full Version : Geometry shader to handle quads



satya
09-20-2011, 04:07 PM
Hi,

i am a beginner to shaders, and i read from the specification that the geometry shader supports only point, line and triangle as the input primitive type and linestrip, trianglestrip and point as the output type

am i correct in my understanding and should i have to render all my quads as triangle or triangle strips to use the geometry shader

please advise

TIA
Satya

Alfonse Reinheart
09-20-2011, 10:12 PM
What specification did you read that in? GLSL 1.50 says that geometry shaders can use as inputs: "points", "lines", "lines_adjacency", "triangles", and "triangles_adjacency". Quads were removed from core OpenGL, so they are not featured. But "lines_adjacency" is more or less GL_QUADS.

malexander
09-21-2011, 09:08 AM
In addition to triangles, you can draw quads, tristrips, trifans and polygons when the geometry shader mode is 'triangles'. Those types are all tessellated by the driver to triangles before being passed to the geometry shader. Each quad would be split into two triangles and these would be processed separately by the geometry shader. If you want to process all 4 vertices for the quad in one geometry shader invocation, then you need to use Alfonse's suggestion of drawing the quads as line-adjacency primitives, both of which have 4 vertices.

Alfonse Reinheart
09-21-2011, 11:43 AM
Those types are all tessellated by the driver to triangles before being passed to the geometry shader.

Where in the spec does it say that? Even in the compatibility specification, it states that GL_QUADS will give GL_INVALID_OPERATION when used with a geometry shader.

malexander
09-21-2011, 12:24 PM
In the Nvidia GL spec, apparently ;) Sorry for the mis-info.

satya
09-21-2011, 03:45 PM
Thanks, Alfonse Reinheart,

http://www.opengl.org/registry/specs/EXT/geometry_shader4.txt
this is where i read the specification of the geometry shader extension.

my requirement is to render quads with one normal per quad, which stops me from using vertex array, so i was thinking if i can use geometry shader to do the normal computation and still use vertex array to render quads with faceted shading

i tried duplicating the vertices, but that becomes too much and i didn't really see the benefit.

the basic glBegin() ... glEnd() suffers when the number of quads become more

Please suggest

Thanks again
Satya

Alfonse Reinheart
09-21-2011, 04:08 PM
this is where i read the specification of the geometry shader extension.

The EXT specification is not the same as the core functionality. Even the ARB version of geometry shaders is different.

Which one do you actually intend to use?

satya
09-22-2011, 10:39 AM
i was intending to use the GL_ARB_geometry_shader4, please suggest

Thanks

satya