To display soft shadows, you'll need a 3D card with:
The basic idea is to display many times the shadows while shaking the light, and to blur them together. As GeForce hardware is not fast enough to display so many volumes at the same time, we will use time coherency to fake it. During one frame, we will display the current volume, and blur it with the volumes of the previous frames. This idea is based on Motion Blur.
We will store the volumes in the Alpha buffer. The different steps of the Soft Shadow Stencil Volumes algorithm are:
To shake the light, I add one of these eight movement to the light position:
As you can see, I select 4 corners of 2 cubes around the light, so that there are as few positions in the same plane as possible. As a result, each volume will not be totally included in the seven others.
Fading is done by displaying a quad with the following blending mode and color:
glColorMask( GL_FALSE,GL_FALSE,GL_FALSE,GL_TRUE ); glBlendFunc(GL_ZERO,GL_SRC_ALPHA); glColor4f(0,0,0,0.95f);
When the light is moving, you can chose between either shaking of not the light. Both method works fine and gives similar results.
The problem with dynamic camera is that the previous volumes are not placed where they should be.
At high frame rates, the error in the positioning of the previous volumes is not significant.
At lower frame rates, the error gets too important, and we have to reduce the number of displayed volumes, by fading them out faster.
I usually display 8 volumes when the camera is static, and 2 volumes when the camera is moving.
On faster hardware, you can display all the volumes at the same time during the same frame, and you will not need shadow motion blurring anymore.
The steps are now:
For volume = 0 To MaxVolume
email : Sly