黃聰賢
Light Position Mesh Polygon Shadow Polygon
Clear color buffer and stencil buffer Render the scene with ambient only
Mask color buffer and depth buffer Enable back face culling Increase stencil value if depth test is passed Draw shadow polygons Stencil value = 1 Stencil value = 0
Mask color buffer and depth buffer Enable front face culling Decrease stencil value if depth test is passed Draw shadow polygons Stencil value = = 0 Stencil value = +1
Clear depth buffer Set stencil pass condition ◦ Equal to zero Render the scene with full lighting Ambient only
light
Why? =0
How? Edge A Edge B light n n n n front back Edge C n back n
Front n Back n Ensure shadow polygons face outside. ab a' b' a b a' c c