120 likes | 279 Views
Shadow Volume. 黃聰賢. Introduction. Light Position. Mesh Polygon. Shadow Polygon. Top View. Camera. Screen. Side View. Camera View. Pass 1. Clear color buffer and stencil buffer Render the scene with ambient only. Pass 2. Mask color buffer and depth buffer
E N D
Shadow Volume 黃聰賢
Introduction Light Position Mesh Polygon Shadow Polygon
Top View Camera Screen Side View Camera View
Pass 1 • Clear color buffer and stencil buffer • Render the scene with ambient only
Pass 2 • Mask color buffer and depth buffer • Use glColorMask and glDepthMask • Enable back face culling • glCullFace(GL_BACK); • Increase stencil value if depth test is passed • Draw shadow polygons Stencil value = 1 Stencil value = 0
Pass 3 • Mask color buffer and depth buffer • Enable front face culling • glCullFace(GL_FRONT); • Decrease stencil value if depth test is passed • Draw shadow polygons Stencil value = +1 -1 = 0 Stencil value = +1
Pass 4 • Clear depth buffer • Set stencil pass condition • Equal to zero • Render the scene with full lighting (There are many ways to combine color.) Camera 0 Screen 0 1 0 Ambient only
Silhouette Edges light
Silhouette Edge Detection • Why? -1 +1 +1-1 =0
n front • How? n front light Edge A n front back Edge B n Edge C back back n n
Orientation Back Front b n c c n a b a b' b' a' a' Ensure shadow polygons face outside.