🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Learning shadow mapping

posted in IfThen Software
Published May 21, 2011
Advertisement
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/
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement