This topic is now archived and is closed to further replies.

Shadow Mapping with shaders and ATI hardware

This topic is 5014 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I''ve been unsuccesfully trying to implement shadow mapping for a couple of days now. I understand the general principle but I don''t understand some details. I hope you can help me. Is it true that only NVidia cards can render depth information to a texture? I''ve tried creating a texture with the DEPTHSTENCIL flag but it fails on my Radeon 9800. If so how do you get depth info on other hardware - shaders and tricks? How is projection of the shadow map handled. Can it be done by the fixed function pipeline or do you have to write shaders? Radek

Share this post

Link to post
Share on other sites
ATI has shadow map demos in both DX8 and DX9. Look on their developer website.

Depth textures are specific only to NVIDIA cards. If you want to make your shadow mapping work on all hardware, you''ll need to do it differently.

Using shaders will make it much easier. It may be possible to do shadow maps with the fixed function pipeline but I''ve never done it. Maybe someone else can comment on that.

What you have to do is render the depth of a pixel to a texture. When creating your shadow map, the depth of a pixel can be obtained extremely easily. It''s a byproduct of the standard WVP transformation. Once you''ve applied the projection matrix to your vertex, you can just use the .z coordinate as the depth. Pass this value to your pixel shader as a texture coordinate. The rasterizer will then interpolate this value across the whole polygon. In the pixel shader, just write out this value and you''re done.

Another way to compute the depth in the vertex shader would be to compute the distance from the vertex to the light in world space coordinates. Then scale this value by the range of the light source and pass it to your pixel shader.

There are tons of whitepapers and articles on shadow mapping. NVIDIA has a really good one on their developer site. I think it''s called "Hardware shadow mapping". Although it assumes that you have an NVIDIA card (naturally) and that you''re going to use depth textures, you can just render to a regular texture instead. All of the other ideas are *exactly* the same.

If you still have doubts, do a search in the Graphics Programming & Theory forum. Shadow maps have been discussed to death over there. You''ll find all the info you need.


Share this post

Link to post
Share on other sites