The shadow volume shown figure formed appending the indices


| 564 |
|
|---|
This information (silhouette edges, front-facing triangles, and back-facing triangles) are enough to generate the shadow volumes. Front-facing triangles are left
untouched; they form the near capping
of the volume. Back-facing trian-
gles are extruded away from the
light; they form the far capping.Finally, a quadrilateral is gener-
ated from a silhouette edge and
its extruded equivalent. These
form the sides of the volume.
Figure 5: Simple vertex buffer format for shadow volume extrusion in a vertex shader
| 565 |
|---|
For each triangle T of the mesh,
Let N be the number of vertices in the mesh (the vertex buffer has a length of 2N vertices),
Let V0, V1, and V2 be the mesh indices of the vertices of the triangle T, If T is back-facing the light,
/// one triangle for the far capping
Append the indices (V0 + N), (V1 + N) and (V2 + N) to I
Else
/// one triangle for the near capping
Append the indices V0, V1 and V2 to I,/// now form the shadow volume sides from the silhouette edges If edge defined by V0-V1 is a silhouette edge,
Append the indices V0, V1, (V0 + N), (V1 + N) to I
Else if edge defined by V1-V2 is a silhouette edge,
Append the indices V1, V2, (V1 + N), (V2 + N) to I, Else if edge defined by V2-V0 is a silhouette edge,
Append the indices V2, V0, (V2 + N), (V0 + N) to I



