Geometry Shaders

Mat3

Newcomer
What exactly do geometry shaders do? I've read they work on more than one triangle at a time, and they can create vertices, but what kind of effects do they allow for? Procedural generation of geometry? Some kind of truform function that rounds out rough edges?
 
I've read they work on more than one triangle at a time
Not quite - they operate on ONE triangle at a time, but they can have adjacency information (thus you effectively get 4 triangles as input). You can emit 0 or more vertices, so it is possible for a GS to completely clip a triangle - but you couldn't clip the 3 adjacenct triangles, they'd still get processed by seperate invocations of a GS.

and they can create vertices
Correct. You can stream out vertices in a triangle strip (making a "cut" call whenever you want to start a new strip).

what kind of effects do they allow for?
Lots of possibilities - chances are (hopefully!) there'll be some amazing things using them over the lifetime of D3D10 (etc..) that we haven't thought of yet ;)

Bare in mind that the GS doesn't have to be about creating information - it can be about detecting information as well. For example, you could generate a face normal or general topology-level properties (area of the triangle, plane equation...) and use these to set up inputs into the PS. For example, I've got code that will improve the performance for some lighting equations by moving discovery code from the CPU to the GPU etc...

Some kind of truform function that rounds out rough edges?
Yes, you could implement HOS techniques with the GS, but the number of vertices written out is limited (probably to around ~300 vertices if you attach simple information, potentially many less if you attach more complex attributes). I don't know how it is in reality (don't have any hardware myself), but the IHV's were hinting a while back that initial GPU's might not have enough grunt to heavily use the SO and tesselation potential of the theoretical GS...

hth
Jack
 
Lots of possibilities - chances are (hopefully!) there'll be some amazing things using them over the lifetime of D3D10 (etc..) that we haven't thought of yet ;)

Do we know what these are as yet? It's been four years so hopefully people are actually using geometry shaders and stream out for something :) What features are modern games and engines implementing using these capabilities?
 
Do we know what these are as yet? It's been four years so hopefully people are actually using geometry shaders and stream out for something :) What features are modern games and engines implementing using these capabilities?
Particle rendering and processing use both stream out and geometry shaders. Our system first processes (light, read shadow textures, animate, transform) each particle by vertex shader (one vertex = one particle) and stream outs them. We have different kind of shaders to process different kind of particles. After all particles have been processed, the particles are sorted (radix sort) and then rendered in a single draw call (premultiplied destination alpha, front to back). During particle rendering, geometry shader expands the quads around the particle vertices (four vertex two face strip per particle). In our case, the quads are not screen aligned (particles have animated rotation and stretch by velocity).

You can also use geometry shaders to add new particles to a particle system by GPU. This allows complete particle simulation (emitters included) to be performed fully by GPU.
 
What exactly do geometry shaders do? I've read they work on more than one triangle at a time, and they can create vertices, but what kind of effects do they allow for? Procedural generation of geometry? Some kind of truform function that rounds out rough edges?
From http://msdn.microsoft.com/en-us/library/bb205123(VS.85).aspx

The geometry-shader stage processes entire primitives. Its input is a full primitive (which is three vertices for a triangle, two vertices for a line, or a single vertex for a point). In addition, each primitive can also include the vertex data for any edge-adjacent primitives. This could include at most an additional three vertices for a triangle or an additional two vertices for a line. The Geometry Shader also supports limited geometry amplification and de-amplification. Given an input primitive, the Geometry Shader can discard the primitive, or emit one or more new primitives.

http://msdn.microsoft.com/en-us/library/bb205146(v=vs.85).aspx#Geometry_Shader_Stage


 
Also used to kill back facing primitives when tessellating.
GS can be used for back face culling at any time, not just when tessellating. However, unless you need a GS for other reasons I recommend letting the hardware back face cull on its own.
 
GS can be used for back face culling at any time, not just when tessellating. However, unless you need a GS for other reasons I recommend letting the hardware back face cull on its own.

I thought we were talking about real world use, not theoretical :p
 
Back
Top