The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers


Creating Relections and Shadows Using Stencil Buffers

Copyright 1998, 1999 by Mark J. Kilgard. Last Updated July 10, 2000 Commercial publication in written, electronic, or other forms without expressed written permission is prohibited. Electronic redistribution for educational or private use is permitted.

Online Presentation Table of Contents

This example program demonstrates stenciled shadow volume shadows, shadow volume visualization, soft shadows through stenciled shadow volumes, planar projected shadows, and a hybrid combination of shadow volumes and planar projected shadows. OpenGL graphics hardware with a hardware stencil is DEFINITELY NEEDED for good performance.
Stencil Shadow Volume shadows
Begin Here

Stencil Testing

What is Stenciling?

Per-Fragment Pipeline


Request a Stencil Buffer

Stencil Test

Stencil Operations

Stencil Write Mask

DX6 Direct3D API

DX6 Issues


Repeating that!

Pseudo Global Lighting Effects

Planar Reflections

Compare Two Versions

Stencil Maintains the Floor

Recursive Planar Mirrors

The Trick (bird’s eye view)

Next: Planar Shadows

Constructing a Shadow Matrix

How to Render the Shadow

Note Quite So Easy (1)

Note Quite So Easy (2)

Everything All At Once

Pseudo Global Lighting

Bonus Stenciled Halo Effect

Stenciled Shadow Volumes

2D Cut-away Shadow Volume

A Complex Shadow Volume

Calculating Object’s Silhouette

Complex Shadows On Objects

The Complex Shadow Volume

Stencil Shadow Algorithm

Inverting Examples

Render In and Out of Shadow

Multiple Objects and Lights

Counting Enters & Leaves

Stencil Counting

Jittered Shadow Volumes

Soft Shadows

Hybrid Shadows

Other Stencil Uses

Digital Dissolve

Co-planar Geometry

Visualizing Depth Complexity

Constructive Solid Geometry


Navigation Notes: the "i" returns you to this page, "Home" brings you to Nvidia & "A" shows you a text version of the slides

Column Header
Column Footer