How to implement shadow mapping in DirectX 11?

How to implement shadow mapping in DirectX 11?

This tutorial will cover how to implement shadow mapping in DirectX 11 using C++ and HLSL. Before proceeding with this tutorial you should first have a clear understanding of the following concepts: Render to Texture (Tutorial 22), Projective Texturing (Tutorial 27), and Depth Buffers (Tutorial 35).

What are the different types of textures in Direct3D 11?

There are several types of textures: 1D, 2D, 3D, each of which can be created with or without mipmaps. Direct3D 11 also supports texture arrays and multisampled textures. 1D Textures; 1D Texture Arrays; 2D Textures and 2D Texture Arrays; 3D Textures; 1D Textures

Where can I find rastertek DirectX 11 tutorials?

The source code of RasterTek ‘s DirectX 11 tutorials (made ready to use in Visual Studio 2017). Documentation and further explanation can be found at RasterTek.

What do you need to know about projective texturing?

Projective texturing is one of the most critical concepts you need to have a strong understanding of to perform most of the advanced rendering techniques for real time applications. For example soft shadows, water, projective light maps, and reflections all require projective texturing.

Why do I need bias adjustment for shadow mapping?

Shadow mapping requires a bias adjustment when comparing the depth of the light and the depth of the object due to the low floating point precision of the depth map. Calculate the projected texture coordinates for sampling the shadow map (depth buffer texture) based on the light’s viewing position.

How does shadow mapping work in rastertek?

When we render the scene we will project the shadow map texture back onto the scene to get the depth of any objects that cast shadows and compare it with the position of the light on a per pixel basis in the pixel shader. If we find the light is closer to the camera then we light the pixel.

Why is shadow mapping called a shadow map?

We only sample the red component since this is a grey scale texture. The depth value we get from the texture translates into the distance to the nearest object. This is important since objects are what cast the shadows and hence why it is called a shadow map.

How are shadow maps set in a cascade?

For every cascade, a viewport is created that covers the section of the depth buffer corresponding to that cascade. A null pixel shader is bound because only the depth is needed. Finally, the correct viewport and shadow matrix are set for each cascade as the depth maps are rendered one at a time into the main shadow buffer.

What does the shadowshaderclass do in rastertek?

The ShadowShaderClass is just the LightShaderClass modified for shadows. The MatrixBufferType has been expanded to hold the view and projection matrix of the light. We now have a second clamp based sampler state.

How is pixel coverage affected by shadow maps?

The series of grids representing shadow maps with a view frustum (inverted cone in red) shows how pixel coverage is affected with different resolution shadow maps. Shadows are of the highest quality (white pixels) when there is a 1:1 ratio mapping pixels in light space to texels in the shadow map.

How does texturing and lighting work in DirectX 11?

Using the power of the programmable shader stages provided in DirectX 11, we can interpret texture data any way we want and use that texture data to determine the final look of the objects in our scene. Texturing alone often does not capture the details required to make objects in our scene seem realistic.

What are the different addressing modes in DirectX 11?

The following table summarizes the different addressing modes supported by DirectX 11 [7]. Tile the texture at every (u,v) integer junction. For example, for u values between 0 and 3, the texture is repeated three times.

What happens when texture coordinate is negative in DirectX 11?

Using this technique, the texture coordinate (3.25, 3.75) will become (0.25, 0.75). If the texture coordinate is negative, then the resulting texture coordinate will be subtracted from 1 before being applied. For example, (-0.01, -2.25) will become (0.99, 0.75). The following pseudo algorithm helps to explain this technique.