Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between tessellation shaders and Geometry shaders

Tags:

I'm trying to develop a high level understanding of the graphics pipeline. One thing that doesn't make much sense to me is why the Geometry shader exists. Both the Tessellation and Geometry shaders seem to do the same thing to me. Can someone explain to me what does the Geometry shader do different from the tessellation shader that justifies its existence?

like image 642
Andi Jay Avatar asked Aug 29 '14 14:08

Andi Jay


People also ask

How does a geometry shader work?

A geometry shader takes as input a set of vertices that form a single primitive e.g. a point or a triangle. The geometry shader can then transform these vertices as it sees fit before sending them to the next shader stage.

Does metal support geometry shader?

For example, Unity supports tessellation shaders on Metal graphics, but Metal doesn't support geometry shaders.

Does WebGL support geometry shader?

WebGL currently only supports pixel shaders and vertex shaders not geometry shaders.

What is hull shader?

The Hull Shader (HS) stage is one of the tessellation stages, which efficiently break up a single surface of a model into many triangles. The Hull Shader (HS) stage produces a geometry patch (and patch constants) that correspond to each input patch (quad, triangle, or line).


1 Answers

The tessellation shader is for variable subdivision. An important part is adjacency information so you can do smoothing correctly and not wind up with gaps. You could do some limited subdivision with a geometry shader, but that's not really what its for.

Geometry shaders operate per-primitive. For example, if you need to do stuff for each triangle (such as this), do it in a geometry shader. I've heard of shadow volume extrusion being done. There's also "conservative rasterization" where you might extend triangle borders so every intersected pixel gets a fragment. Examples are pretty application specific.

Yes, they can also generate more geometry than the input but they do not scale well. They work great if you want to draw particles and turn points into very simple geometry. I've implemented marching cubes a number of times using geometry shaders too. Works great with transform feedback to save the resulting mesh.

Transform feedback has also been used with the geometry shader to do more compute operations. One particularly useful mechanism is that it does stream compaction for you (packs its varying amount of output tightly so there are no gaps in the resulting array).

The other very important thing a geometry shader provides is routing to layered render targets (texture arrays, faces of a cube, multiple viewports), something which must be done per-primitive. For example you can render cube shadow maps for point lights in a single pass by duplicating and projecting geometry 6 times to each of the cube's faces.

Not exactly a complete answer but hopefully gives the gist of the differences.

See Also:

  • http://rastergrid.com/blog/2010/09/history-of-hardware-tessellation/
like image 99
jozxyqk Avatar answered Oct 07 '22 22:10

jozxyqk