Walkthrough: Implement shadow volumes using depth buffers in Direct3D 11
This walkthrough demonstrates how to render shadow volumes using depth maps, using Direct3D 11 on devices of all Direct3D feature levels.
Learn how to create the Direct3D device resources necessary to support depth testing for shadow volumes.
Render from the point of view of the light to create a two-dimensional depth map representing the shadow volume.
Create a shadow effect by adding depth testing to your vertex (or geometry) shader and your pixel shader.
Render higher-fidelity shadows on faster devices and faster shadows on less powerful devices.
Windows 8 adde d depth comparison functionality to feature level 9_1 and 9_3. Now you can migrate rendering code with shadow volumes to DirectX 11, and the Direct3D 11 renderer will be downlevel compatible with feature level 9 devices. This walkthrough shows how any Direct3D 11 app or game can implement traditional shadow volumes using depth testing. The code covers the following process:
- Creating Direct3D device resources for shadow mapping.
- Adding a rendering pass to create the depth map.
- Adding depth testing to the main rendering pass.
- Implementing the necessary shader code.
- Options for fast rendering on downlevel hardware.
Upon completing this walkthrough, you should be familiar with how to implement a basic compatible shadow volume technique in Direct3D 11 that's compatible with feature level 9_1 and above.
You should Prepare your dev environment for Windows Store DirectX game development. You don't need a template yet, but you'll need Microsoft Visual Studio 2013 to build the code sample for this walkthrough.
Download the ShadowMapping SDK sample. This sample includes all code shown in this walkthrough.
- Developing for different Direct3D feature levels
- Writing HLSL Shaders in Direct3D 9
- Create a new DirectX 11 project for Windows Store
- Shadow mapping technical articles
- Common Techniques to Improve Shadow Depth Maps
- Cascaded Shadow Maps