SLIDE 4 4
Shadow Map
Step 2 – Use Shadow Map
Render scene from viewpoint use the saved depth buffer as a texture
which is projected from the light's position
compare the value from the texture
projected onto the point to the distance from the point to the light
Shadow Map
http://www-sop.inria.fr/reves/personnel/Marc.Stamminger/psm/
Shadow Map
Basic Z buffer algorithm
Initialize frame buffer (to background) Initialize Z-buffer (to 0) For each polygon P { For each pixel p in polygon’s projection { z = P’s z at pixel p if (z > Zbuffer at that pixel) { zBuffer at pixel = z Frame buffer at pixel = calcColor() } }
Shadow Map
Modified Z buffer algorithm
Initialize frame buffer (to background) Initialize Z-buffer (to 0) For each polygon P { For each pixel p in polygon’s projection { z = P’s z at pixel p if (z > Zbuffer at that pixel) { zBuffer at pixel = z Frame buffer at pixel = calcColor() if ( z > shadow depth) place in shadow } }
Shadow Map
Advantages
Z-buffer, projection supported in hardware
Disadvantages
Aliasing Self shadowing difficult
Building a Better Shadow Map
Filtering