PDA

View Full Version : Geometry Shaders

Mat3
09-Nov-2006, 17:00
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?

Razor1
09-Nov-2006, 20:07
Yes pretty much procedure geometry,

For more info, ths is for mental ray, but it will give you a good idea.

probably one of the first or more abudent uses will be adaptive tesselation and displacement all on the GPU, saves bandwidth, memory space.

JHoxley
09-Nov-2006, 21:19
I've read they work on more than one triangle at a timeNot 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 verticesCorrect. 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 :wink:

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

trinibwoy
10-Nov-2010, 11:01
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 :wink:

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?

3dcgi
11-Nov-2010, 03:03
GS isn't widely used. One example is DICE uses it for decals.

sebbbi
18-Nov-2010, 19:44
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.

trinibwoy
20-Nov-2010, 21:39
Interesting, thanks. Is the radix sort CS based or are the processed particles sent back to the CPU?

ronvalencia
27-Jan-2012, 06:03
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.

Rodéric
27-Jan-2012, 10:15
Also used to kill back facing primitives when tessellating.

3dcgi
27-Jan-2012, 21:16
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.

Rodéric
28-Jan-2012, 11:22
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