|
|
|
|
| |
Arbitrary Shaped Shadows with Vertex
Shaders and Per Pixel Lighting

Figure 1 - Shadows and Per Pixel True Phong Shading
|
|
|
The sample RadeonShadowShader uses a stencil shadow volume technique along with mutlitexturing for per pixel lighting. The room geometry is simply six large quads. The final result is shown in Figure 1. For each light and object, a volume representing the shadow is calculated with a vertex shader using static geometry on the GPU. The geometry used to create the shadow volumes can be any arbitrary shape as long as it is has no holes, as seen in Figure 2.
| |
|

Figure 2 - Shadow Volumes
| |
|
Since a vertex shader is doing the shadow calculations, vertex shader hardware can offload these calculations from the CPU. Any pixels inside the volume are in shadow, and the result is left in the stencil buffer. For each light, either a single pass version 1.4 pixel shader is used if available, otherwise the fixed function pipeline is used.
The pixel shader is a true per pixel Phong shader including light and view vector renormalization, half angle vector calculation and renormalization, distance attenuation, and an arbitrary specular exponent through a dependent texture fetch. The final light color is then masked out by the result of the stencil shadow volume creating the shadows.
| |
|
If the fixed function pipeline is used, a volumetric texture is used to calculate the attenuation of the light based on distance. Diffuse and specular components are calculated from the dot product of the tangent space normal with a light or half angle vector that is interpolated and renormalized with a cubic environment map. The final light color is then masked out by the result of the stencil shadow volume creating the shadows.
- RadeonShadowShader Controls
-
- Shift+F - Toggle Free Fly Mode
- Left Drag - Rotate
- Right Drag - Mode Up/Down/Left/Right
- Middle Drag - Move Forward/Back
- E,D,S,F - Move Up/Down/Left/Right
- A,Z - Move Forward/Back
- W,R - Roll Left/Right
- Arrows - Rotate
- Shift+V - Toggle shadow volume visualization
- Shift+S - Toggle shadow volumes
- Shift+G - Toggle gravity
- Shift+L - Animate Lights
- Shift+I - Toggle Wireframe Mode
- Shift+P - Toggle Physics
- + - Add Ball
- - Delete Ball
- * - Add Light
- / - Delete Light
- 0-9 - Select lit rendering technique for the
room.
- Shift+0-9 - Select ambient rendering technique
for the room.
- [SPACE] - Advance Frame-by-frame
- [ENTER] - stop advancing Frame-by-frame
- [F2] - Prompts user to select a new rendering
device or display mode
- [ESC] - Quit
| |
|
Downloads
RadeonShadowShader.zip
| |
|
| |
 |
|
|
|