Wednesday, September 7, 2016

Define: Geometry Shaders ..

Geometry-Shader


Geometry Shader


INPUT primitive types
points
lines
triangles
line_adjacency
triangle_adjacency

OUTPUT primitive types
points
line_strip
triangle_strip



Working with Geometry Shaders


...
It will take a triangle as input, find its centroid, and then subdivide the original triangle into 3-triangles. The triangle data will come from Vertex-Shader, which won't do anything besides passing vertices further into geometry shader.

...
Notice one thing - everything except vertex position is transferred to geometry shader using OUT variable. Vertex position is transferred using built-in variable gl_Position, which can be read in geometry shader as well. Also, all matrix transformation are now performed in geometry shader (it's not necessary, but it's better this way), that's why no uniform matrix variables are in vertex shader.


...
Moreover, the centroid point can be moved in the direction of normal of original triangle forwards and backwards, so that it will "bend" the original triangle (fBender value in code and in application tells, how far from triangle should be centroid moved).. So for every input triangle, the shader outputs 3-triangles further into pipeline.. Now let's get into geometry shader code finally...


...
EmitVertex()

...
EndPrimitive();





......

No comments:

Post a Comment