Graphics Reference
In-Depth Information
Figure 12.10. Three views of the bunny, with minimal lighting from below, showing the silhouete edges.
The input and output geometry types for this geometry shader are tri-
angles with adjancey and line strip, respectively. The glman ObjAdj command
is similar to the Obj command, but it parses the original Obj file to determine
adjacency information, so that triangle-with-adjacency primitives are avail-
able to the geometry shader.
As before, the vertex and fragment shader iles are omited. The vertex
shader only performs the ModelViewProjection transformation, and the frag-
ment shader only sets the pixel color; these are completely routine.
The geometry shader works by taking a triangle with adjacency and cal-
culating the face normal to each of the four triangles, making sure that each
normal faces correctly with the standard triangle conventions. The vertex
shader has already placed the vertices into 3D eye space, so the normals can
be compared by simply comparing their z components. If there is a sign dif-
ference between the z component of the normal of the center triangle and the
z component of the normal of an adjacent triangle, then their common edge
is drawn by emiting two vertices and ending the primitive. Notice that each
edge of the middle triangle is checked because, in principle, the silhouete
could include any of them. The result of this shader is shown in Figure 12.10.
Geometry Shader silh.geom
#version 330
#extension GL_EXT_geometry_shader4: enable
Search WWH ::




Custom Search