Skip to main content
GameDev.net gamedev.net
🔒 Locked

question about shadow map?

Started by Khanh Oct 19, 2003 at 11:40 PM 2 replies 450+ views
Original Post
Khanh
Khanh
hello all, After a while for researching shadow map, I come down to a couple of questions. Can anyone shine them to me? 1)when get shadow map from light point, what should be projection matrix? I can see the shadow is different by FOV. My current light projection is the same as camera projection. 2)I heard I can get shadow map from color buffer insetad of depth buffer, typically color texture is 3-D texture and depth texture is 4-D texture (mean D3DTTFF_COUNT3 and D3DTTFF_COUNT4 when projecting respectively). What makes the different? I can still use 4-D texture for color buffer but the results of shadow are distinct between 3-D texture and 4-D texture for color buffer!!! why? 3)Although the hardware supports depth shadow map (CheckDeviceFormat with D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE) but my depth texture is quite white!!!! no geometry at all??? why??? I am sure I set render target and restore the state perfectly. FYI: my video card is GEForce FX 5200, 128 M Thanks in advance Khanh
DaJudge
DaJudge
quote:

1)when get shadow map from light point, what should be projection matrix? I can see the shadow is different by FOV. My current light projection is the same as camera projection.


Imagine your light point is a camera. Setup a view-direction and a FOV and use that as view / projection matrix just the same way you would do for your screen-camera. That''s the reason why you can only have spotlights with shadowmaps (unless you want to use cubemaps). However, Splinter Cell did look awsome even with that limitation so for ease of use stick to spotlights for the moment.

quote:

2)I heard I can get shadow map from color buffer insetad of depth buffer, typically color texture is 3-D texture and depth texture is 4-D texture (mean D3DTTFF_COUNT3 and D3DTTFF_COUNT4 when projecting respectively). What makes the different? I can still use 4-D texture for color buffer but the results of shadow are distinct between 3-D texture and 4-D texture for color buffer!!! why?


I believe it''s basically for perspective correct projective mapping. Since it''s a projection transformation it suffers the same problems as your screen projection and thus can be solved using 4-component coords (3 for x,y,z and the 4th for making a perspective division possible).

quote:

3)Although the hardware supports depth shadow map (CheckDeviceFormat with D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE) but my depth texture is quite white!!!! no geometry at all??? why??? I am sure I set render target and restore the state perfectly.
FYI: my video card is GEForce FX 5200, 128 M


I am having EXACTLY the same problem (same graphics gard, same setup etc.). I try to solve it for over a week now without any success...

Here some references
http://developer.nvidia.com/attach/5704
The shadowmap sample in the NVSDK (working!)
http://www.paulsprojects.net/direct3d/projects1.html (not working here...)
Demo shipping with the book ''Cg Tutorial'' (not working here)

Cheers,
Alex
Alexander Stockinger
Programmer
Foxhound
Foxhound
Hi,

About the depth-texture being white...
I''ve read post of other people with the same problem, the thing is: what do you expect of using a depth-texture as a texture? A gray-scaled image of the depth?? All different colors showing the depth? well, that''s not the case! When you select a depth-texture in a texture stage the result wil be white or black.
The reason is very simple. When you select a depth texture on a texture stage the graphics card will automaticly compare the depth-value in the depth-texture with the z-texturecoordinate.
When the depth of the z-coordinate at the rendered pixel is greater than the depth sampled from the depth-texture the result wil be black. If the z is less than the sampled depth value the result wil be white.
In your case the result is allways white becouse you did not use x,y,z texture coordinates, but only x,y, OR your z-value is allway smaller than the value sampled from your depth-texture.

Please note that the range of depth sample from the depth-texture is not [0..1] but [0..2^bitdepth-1], where bitdepth is the bits used for storing depth.

Hope this is a bit clear, and you can solf your problems...
(it does make shadowmaps very easy to implement)

Cheers,
DaJudge
DaJudge
I am well aware about that z-compare mechanism. Yet I can''t seem to get depth mapping working properly...
Alexander Stockinger
Programmer

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.