Shadow Zbuffer
A shadow algorithm based on the zbuffer.
Works in two stages using the same approach as zbuffer (without shading):
- Render scene from lights POV (without lighting calculations).
- Render scene from eyes POV (with lighting calculations).
We define a shadow-map/depth-map as the depth of each pixel in the zbuffer produced by rendering from the lights POV. After the 1st stage we start rendering from the eyes POV and use the [see page 23, shadow-map] to determine the position and size of shadows.
Note: for a point light (eg. sphere) we create a cube encompassing the source and render from each face of the cube. See [see page 35, here].
The process is actually transforming each drawn pixel between the two coordinate systems and using the shadow-map to get into the eyes frame of reference. Each pixel is either [see page 24, lighter], [see page 25, darker] or the [see page 26, same] in the the shadow-map. Pixels that're darker are [see page 23, assumed] to be in a shadow.
Warn: This approach relies on floating point calculations which can have [see page 27, issues]. Use of an appropriate bias can alleviate this.
Pros
This approach supports [see page 28, multiple] light sources.
Cons
- This approach just darkens regions in a shadow, but specular highlights should be invisible when in a shadow.
- The resolution of the buffer matches the screen resolution meaning you can have [see page 29, aliasing] issues.
Note: You can get a smoother curve and avoid aliasing issues by using [see page 31, percentage closer filtering]. Basically find the average coverage of a pixels shadow-map (based on it's neighbours) to determine how intense the shadow in it is.