Home Software Articles Photos

FAST CORRECT SOFT SHADOWS for NVIDIA GPUs

technique of generating PENUMBRA SHADOWS
(September 2004)

shot1shot 2shot 3
Images from scene10.mgf (using accumulation buffer).


Soft shadows vs Penumbra shadows

Penumbra shadows are physically correct shadows from area lights. They have penumbra.
Soft shadows are hard shadows with blurred edges. They don't simulate penumbra.
At the time of writing this article, I called penumbra shadows "correct soft shadows", but it's confusing.

Technique overview

Penumbra shadows are created by overlapping multiple soft shadows. Soft shadows are created by shadow mapping with bilinear filtering.
-> This is not new technique, just demonstration, that it works and that it's faster than more complex approaches.

Although not fully visible, scene contains 100 rooms, 83k triangles and 167k vertices. There are no optimizations, whole scene is processed in each frame. On GF4 Ti 4200, 1152x864x32, scene with arbitrarily moving linear light (6 spot lights) is rendered at 16fps (up to 80fps when parts of scene get outside viewport).

Current implementation is based on nVidia proprietary OpenGL extensions (requires GF3 or higher). Future versions may work on any OpenGL 2.0 card.


Advantages
  1. Speed (fastest technique for lower quality shadows, probably not fastest for high quality solutions).
  2. Simplicity.
  3. Converges to correct solution.
  4. Easy control over speed/quality (from extremely fast/blurred hard shadows to very slow/nearly correct penumbra shadows).

Disadvantages
  1. Banding artifacts appear without accumulation buffer - low bits of color are lost. Images on this page were captured with accumulation buffer, which is much slower on GF4Ti 4200, but probably equally fast on new hardware. In case that accum has high penalty even on new hardware, blending could be improved to reduce artifacts.
  2. Edges are often visible inside penumbras. It's easy to add more pointlights, but then speed is lost.
  3. Sometimes jagged shadow edges appear (caused by shadow mapping, reduced by bilinear filtering and overlapping).
  4. Sometimes light or shadow appears near polygon edge (caused by shadow mapping).
  5. Sometimes thin shadow pattern appears on lit faces (caused by bilinear filtering of shadow map).
  6. This mostly fixed-pipeline implementation may cause errors in light attenuation which can be demonstrated on special scene. Problem is not visible in common situations and will be fixed in next version using programmable pipeline.
Btw, there is trade between 2. which can be solved by decreasing shadow map resolution and 3., 4., 5. which can be solved by increasing shadow map resolution. Everything can be traded for speed (increased shadow map resolution, increased number of pointlights, accumulation buffer).


Conclusion

Most realtime algorithms aim not to provide absolutely exact solutions, but to fool human brain to believe it's exact.
Existing artifacts make this technique unsuitable for artificial environments with large geometrically simple blockers and planar receivers where human brain easily predicts shape of shadows and perceives even tiny intensity fluctuations as errors. On the other hand, natural environments with complex non planar geometry make tiny errors much harder to spot and make this technique optimal.


Download

Download FAST CORRECT SOFT SHADOWS + source code (1MB, binary is compiled for Windows)

MGFlib (library necessary to recompile)


Author

Stepan Hrbek, homepage