Presentation is loading. Please wait.

Presentation is loading. Please wait.

Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering Cass Everitt and Mark J. Kilgard Speaker: Alvin Date: 5/28/2003 NVIDIA.

Similar presentations


Presentation on theme: "Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering Cass Everitt and Mark J. Kilgard Speaker: Alvin Date: 5/28/2003 NVIDIA."— Presentation transcript:

1 Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering Cass Everitt and Mark J. Kilgard Speaker: Alvin Date: 5/28/2003 NVIDIA Corporation 2002

2 Outline Shadow Volume Stenciled Shadow Volume (Zpass) Zfail Approach Robust Shadow Volumes Requirements Result Conclusion

3 Shadow Volume A shadow volume is simply the half-space defined by a light source and a occluder.

4 Shadow Volume

5 Shadow Volume Example

6 Shadow Volume Advantages Omni-directional approach Automatic self-shadowing Window-space shadow determination Required stencil buffer broadly supported today

7 Shadow Volume Disadvantages Ideal light sources only Lack soft shadow Requires polygonal models with connectivity Silhouette computations are required Inherently multi-pass algorithm Consumes lots of GPU fill rate

8 Outline Shadow Volume Stenciled Shadow Volume (Zpass) Zfail Approach Robust Shadow Volumes Requirements Result Conclusion

9 Stenciled Shadow Volume (Zpass) Render scene with only ambient and emissive lighting contribution, and initialize depth buffer PS: Depth values indicate the closest visible fragments Use a stencil enter/leave counting approach Draw shadow volume twice using face culling 1st pass: render front faces and increment when depth test passes 2nd pass: render back faces and decrement when depth test passes Don ’ t update depth or color Afterward, pixel ’ s stencil is non-zero if pixel in shadow, and zero if illuminated

10 Visualizing the Stencil Buffer

11 Counting

12 Illuminated Object

13 Shadowed Object

14 Visualizing the Stencil Buffer

15 Near Clip Plane Problem

16 Outline Shadow Volume Stenciled Shadow Volume (Zpass) Zfail Approach Robust Shadow Volumes Requirements Result Conclusion

17 Zfail Approach Render scene with only ambient and emissive lighting contribution, and initialize depth buffer PS: Depth values indicate the closest visible fragments Use a stencil enter/leave counting approach Draw shadow volume twice using face culling 1st pass: render back faces and increment when depth test fails 2nd pass: render front faces and decrement when depth test fails Don ’ t update depth or color Afterward, pixel ’ s stencil is non-zero if pixel in shadow, and zero if illuminated

18 Illuminated Object

19 Shadowed Object

20 Far Clip Plane Problem

21 The Solution for Far Clip Plane Problem

22 Standard glFrustum Projection Matrix

23 glFrustum Matrix for Far Plane is Moved to Infinity

24 Outline Shadow Volume Stenciled Shadow Volume (Zpass) Zfail Approach Robust Shadow Volumes Requirements Result Conclusion

25 Robust Shadow Volumes Use Zfail Stenciling Approach Must render geometry to close shadow volume extrusion on the model and at infinity. Use the P inf Projection Matrix No worries about far plane clipping. Losses some depth buffer precision. Draw the infinite vertices of the shadow volume using homogeneous coordinates (w=0)

26 Infinite Shadow Volume Polygons To be robust, the shadow volume geometry must be closed, even at infinity. Three sets of polygons close the shadow volume: 1. Possible silhouette edges extruded to infinity away from the light. 2. All of the occluder ’ s back-facing triangles projected away from the light to infinity. 3. All of the occluder ’ s front-facing triangles. We assume the object vertices and light position are homogeneous coordinates Where w ≡ 0.

27 Possible Silhouette Edges Assuming: 1. A and B are vertices of an occluder model ’ s possible silhouette edge. 2. 2. L is the light position. For all A and B on silhouette edges of the occluder model, render the quad. (next page) What is a possible silhouette edge? A edge shared by two triangles in a model where one faces L while the other faces away L.

28 Possible Silhouette Edges Quad

29 Examples of Possible Silhouette Edges

30 Occluder ’ s Back-Facing Triangles Assuming A, B, and C are each vertices of occluder model ’ s back-facing triangles. These vertices are effectively directions. (w=0)

31 Occluder ’ s Front-Facing Triangles Assuming A, B, and C are each vertices of occluder model ’ s front front-facing triangles.

32 Outline Shadow Volume Stenciled Shadow Volume (Zpass) Zfail Approach Robust Shadow Volumes Requirements Result Conclusion

33 Requirements Models must be composed of triangles only (avoiding non-planar polygons) Models must be closed (2-manifold) and have a consistent winding order Homogeneous object coordinates are permitted, assuming w ≡ 0 Ideal light sources only Directional or positional, assuming w ≡ 0

34 Requirements Connectivity information for occluding models must be available. So silhouette edges positions can be determined at shadow volume construction time. Projection matrix must be perspective. Render must guarantee “ watertight ” rasterization. No double hitting pixels at shared polygon edges. No missed pixels at shared polygon edges.

35 Requirements Enough stencil bits Rendering features provided by OpenGL 1.0 or DirectX 6

36 Outline Shadow Volume Stenciled Shadow Volume (Zpass) Zfail Approach Robust Shadow Volumes Requirements Result Conclusion

37 Result

38 Result

39 Result

40 Result

41 Result

42 Result

43 Result

44 Outline Shadow Volume Stenciled Shadow Volume (Zpass) Zfail Approach Robust Shadow Volumes Requirements Result Conclusion

45 Robust Shadow Volumes 1. 1. Use Zfail stenciling approach 2. 2. Use the P inf projection matrix 3. infinite shadow volume polygons 3. Draw the infinite shadow volume polygons 4. No near clip plane problem or far clip plane problem. 5. Only requires hardware functionality that is ubiquitous today.


Download ppt "Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering Cass Everitt and Mark J. Kilgard Speaker: Alvin Date: 5/28/2003 NVIDIA."

Similar presentations


Ads by Google