Walkthrough: Implement shadow volumes using depth buffers in Direct3D 11
[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]
This walkthrough demonstrates how to render shadow volumes using depth maps, using Direct3D 11 on devices of all Direct3D feature levels.
In this section
Topic | Description |
---|---|
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. |
Shadow mapping application to Direct3D 9 desktop porting
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.
Prerequisites
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.
Note The ShadowMapping SDK sample requires Windows 8.1 because it uses the latest version of Direct3D and DXGI interfaces. The technique shown in this walkthrough also works on Windows 8.
Related topics
Direct3D
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