Jump to content
  • Advertisement
  • entries
  • comments
  • views

Learning shadow mapping

Sign in to follow this  


I read through the section in RTR on shadow mapping and I think I know enough about the basics to get some kind of shadow system into the test project. Shadow mapping involves rendering the scene's depth information from the light's perspective. You then render the scene from the camera's perspective, detecting if a pixel is in shadow by transforming the pixel's world coordinates (passed to the pixel shader as an interpolated value from the vertex shader) to the light's clip space, projecting onto the depth map and comparing the depth of the pixel with the depth value in the depth map. If the pixel you are drawing has a greater depth value (assuming z is directed into the screen) than the value in the depth map, it is in shadow since it is behind whatever caused that value to be placed in the depth map.

Ambient light is probably achieved by making a normal render pass, only including ambient lighting, before you do the light shadowing passes. Now that I think about it, multiple lights are likely handled this same way; perform a set of 2 passes per light, one for creating the depth map and one for filling the color buffer. Each lighting pass would add to the color in the color buffer.

I should note that the above is a mixture of things I have read and "filling in the blanks". I don't have any actual experience with shadow mapping yet, so I may find that it's not quite what I am expecting. A perfect example of this is with creating the depth map. I assumed that an actual depth buffer was used, which would be set as a texture for the camera rendering pass. However, it appears as though Direct3D9 does not let you access the depth buffer like that. Instead, you need to create a texture and set it as the render target, and output depth values rather than colors from the pixel shader.

[size="3"] Resources
These are some resources which I found while researching shadow mapping.
Soft-Edged Shadows
Cubic Shadow Mapping in Direct3D

[size="1"]Reposted from http://invisiblegdev.blogspot.com/
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!