Presented at SIGGRAPH 2004 in Los Angeles on Tuesday, August 10th during the "Real-Time Shadowing Techniques" course. Jan Kautz and Marc Stamminger organized the course. The presentation covers robust shadow volume rendering techniques for GPUs.
12. Shadow Volume Basics Shadowing object Light source Shadow volume ( infinite extent ) A shadow volume [Crow 77] is simply the half-space defined by a light source and a shadowing object
13. Shadow Volume Basics (2) Partially shadowed object Surface inside shadow volume (shadowed) Surface outside shadow volume (illuminated) Simple rule: samples within a shadow volume are in shadow.
14. Shadow Volume of a 3D Triangle Shadow volume of a single 3D triangle is a truncated infinite pyramid
22. Stencil Buffer & Stencil Testing Red 8-bit Green 8-bit Blue 8-bit Depth 24-bit Stencil 8-bit One pixel (x, y) Stencil buffer state Stencil testing s = readBuffer(stencil, x, y); if (s == state.reference) { // Spass z = readBuffer(depth, x, y); if (fragment.z < z) { // Zpass // INCR op writeBuffer(stencil, x, y, s+1); } else { // Zfail // ZERO op writeBuffer(stencil, x, y, 0); } } else { // Sfail // KEEP, no stencil update }
23.
24. Visualizing the Stencil Buffer Counts red = stencil value of 1 green = stencil value of 0 Shadowed scene Stencil buffer contents GLUT shadowvol example credit: Tom McReynolds Stencil counts beyond 1 are possible for multiple or complex occluders.
25. Why Eye-to-Object Stencil Counting Approach Works Shadowing object Light source Eye position zero zero +1 +1 +2 +2 +3
27. Shadowed, Nested in Shadow Volumes ( Two-pass Zpass ) Shadowing object Light source Eye position zero zero +1 +1 +2 +2 +3 Shadowed object Shadow Volume Count = +1+1+1-1 = 2 + - + +
28. Illuminated, In Front of Shadow Volumes ( Two-pass Zpass ) Shadowing object Light source Eye position zero zero +1 +1 +2 +2 +3 Unshadowed object Shadow Volume Count = 0 (no depth tests pass)
29. Nested Shadow Volumes: Stencil Counts Beyond One Shadowed scene Stencil buffer contents green = stencil value of 0 red = stencil value of 1 darker reds = stencil value > 1
30. Animation of Stencil Updates From Shadow Volumes Every frame is 5 additional stencil shadow volume polygon updates. Note how various intermediate stencil values do not reflect the final state. Fully shaded scene Final stencil state
31. Problem Created by Near Clip Plane ( Two-pass Zpass ) zero zero +1 +1 +2 +2 +3 Near clip plane Far clip plane Missed shadow volume intersection due to near clip plane clipping; leads to mistaken count
34. Shadowed, Nested in Shadow Volumes ( One-pass Zfail ) Shadowing object Light source Eye position zero zero +1 +1 +2 +2 +3 Shadow Volume Count = +1+1 = 2 Shadowed object + +
35. Illuminated, In Front of Shadow Volumes ( One-pass Zfail ) Shadowing object Light source Eye position zero zero +1 +1 +2 +2 +3 Shadowed object Shadow Volume Count = -1-1-1+1+1+1 = 0 - + - - + +
36. But Now, Problem Created by Far Clip Plane ( One-pass Zfail ) zero Near clip plane Far clip plane Missed shadow volume intersection due to far clip plane clipping; leads to mistaken count +1 +1 +2 +2 +3 zero
37. Problem Solved by Eliminating Far Clip zero +1 +1 +2 +2 +3 Near clip plane
38.
39.
40.
41.
42.
43.
44.
45. Examples of Possible Silhouette Edges for Quake2 Models An object viewed from the same basic direction that the light is shining on the object has an identifiable light-view silhouette An object’s light-view silhouette appears quite jumbled when viewed form a point-of-view that does not correspond well with the light’s point-of-view
46.
47.
48.
49.
50.
51.
52. One-Pass Zfail Infinite Shadow Volumes in Practice (1) Scene with shadows. Yellow light is embedded in the green three-holed object. P inf is used for all the following scenes. Same scene visualizing the shadow volumes.
53. One-Pass Zfail Infinite Shadow Volumes in Practice (2) Details worth noting . . . Fine details: Shadows of the A, N, and T letters on the knight’s armor and shield. Hard case: The shadow volume from the front-facing hole would definitely intersect the near clip plane.
54. One-Pass Zfail Infinite Shadow Volumes in Practice (3) Alternate view of same scene with shadows. Yellow lines indicate previous view’s view frustum boundary. Recall shadows are view-independent. Shadow volumes from the alternate view.
55. One-Pass Zfail Infinite Shadow Volumes in Practice (4) Clip-space view. Original view’s scene seen from clip space. The back plane is “at infinity” with very little effective depth precision near infinity. Clip-space view of shadow volumes. Back-facing triangles w.r.t. light are seen projected onto far plane at infinity.
56. Stenciled Shadow Volumes & Multiple Lights Three colored lights. Diffuse/specular bump mapped animated characters with shadows.
57. Stenciled Shadow Volumes for Simulating Soft Shadows Cluster of 12 dim lights approximating an area light source. Generates a soft shadow effect; watch out for bad banding. The cluster of point lights.
58. Shadows in a Real Game Scene Abducted g ame images courtesy Joe Riedel of Contraband Entertainment
60. Blow-up of Shadow Detail Notice cable shadows on player model Notice player’s own shadow on floor
61. Scene’s Shadow Volume Geometric Complexity Wireframe shows geometric complexity of shadow volume geometry Shadow volume geometry projects away from the light source
62. Visible Geometry versus Shadow Volume Geometry << Visible geometry Shadow volume geometry Typically, shadow volumes generate considerably more pixel updates than visible geometry
63. Other Example Scenes (1 of 2) Visible geometry Shadow volume geometry Dramatic chase scene with shadows Abducted g ame images courtesy Joe Riedel at Contraband Entertainment
64. Other Example Scenes (2 of 2) Visible geometry Shadow volume geometry Scene with multiple light sources Abducted g ame images courtesy Joe Riedel at Contraband Entertainment
65. When Shadow Volumes Are Too Expensive Chain-link fence’s shadow appears on truck & ground with shadow maps Chain-link fence is shadow volume nightmare! Fuel g ame image courtesy Nathan d’Obrenan at Firetoad Software
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81. Computing Window Space Bounds depth bounds zmax zmin Shadow volume constrained by light bounds light bounds Light bounds (scissor and depth) can be used as conservative bounds scissor
82. Computing Window Space Bounds depth bounds zmax zmin Shadow volume constrained by environment environment (floor) scissor
83.
84.
85.
86. Shadow Volume Culling Example Light and occluder both outside the view frustum. But occluder still casts shadow into the view frustum. Must consider shadow volume of the occluder even though the occluder could be itself view frustum culled!
87. Photograph of Shadows of Unseen Objects Photograph of shadow cast by a light post and the photographer that are otherwise not seen in the photograph Credit: Caroline Elizabeth Kennedy, used with permission
88.
89.
90. Shadow Volume Culling Example Reconsidered (1) Light and occluder both outside the view frustum. But occluders still within convex hull formed by the light and view frustum Must consider shadow volume of the purple occluder even though the purple occluder could be itself view frustum culled!
91. Shadow Volume Culling Example Reconsidered (2) Light and occluder both outside the view frustum. But purple occluders still also outside convex hull formed by the light and view frustum No need to render the purple occluders or their shadow volumes! Green occluder must be considered however!
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106. Bloating the Original Triangle Mesh Original triangle mesh 6 vertexes 4 triangles Bloated triangle mesh 12 vertexes 10 triangles 1 2 3 4 5 6 1 2a 3a 4b 5 6 2b 2c 3d 3b 4c 4d A B C D A B C D A lot of extra geometry! Formula for geometry: v bloat = 3 * t orig t bloat = t orig + 2 * e orig Bloated geometry based only on number of triangles and edges of original geometry.
138. Another Example (1) Original eye’s view. Again, yellow light is embedded in the green three-holed object. P inf is used for all the following scenes. Eye-space view of previous eye’s view. Clipped to the previous eye’s P inf view frustum. Shows knight’s projection to infinity.
139. Another Example (2) Clip-space view of previous eye’s view. Shows shadow volume closed at infinity and other shadow volume’s intersection with the near clip plane. Original eye’s far clip plane Original eye’s near clip plane
140.
141.
142.
143.
144.
Notas do Editor
NVIDIA Graphics Software Engineer
Two items of note: Proper self-shadowing Hard shadow edges, light sources modeled as points
Doom circa 1994
just 79,000 pixels Notice the “border” to further reduce the rendered area to improve performance Utterly free of both shadows and lighting
Doom3 circa 2004 No one would confuse this scene with a photograph but impressive leap forward
1600x1200 is 25x the original 320x240 4x multisampling makes that actually 100x 3x the color makes the memory per rendered scene 300x the Doom from 10 years ago
multiple light source combine in additive fashion
Spider leg in the shadow of the left wall
What’s really new? SHADOWS
Frank Crow introduced shadow volumes to Computer Graphics at SIGGRAPH 77
Before we get to deep in the nitty-gritty of shadow volumes Truth in advertising I want to highlight the high-level advantages and disadvantages of shadow volumes
We’ll revisit other progress on addressing these disadvantages later
More discussion of shadow volumes versus shadow maps later in the course
Fill rate optimizations—reducing the rasterization overhead Culling optimizations—send fewer shadow volumes by eliminating shadow volume polygon sets More efficient silhouette determination—minimize the CPU overhead Miscellaneous