shadow mapping

Started by
3 comments, last by blueShadow 12 years, 11 months ago
Hi !

My problem is that, trying to generate my depth map, i see the scene in white and the background in black, therefore there are only two values in the map.

I use [font="Consolas"][font="Consolas"]D3DXMatrixPerspectiveFovLH(&lightWVProjMatrix, D3DXToRadian(60.0f) , 1.0f, 1.0f, 100000.0f );

from the light position.

Can you help me ?


PS : The capture is the depth map in A8R8G8B8, there is a plan and objects (non visible here) in the middle of the plan.[attachment=2099:shadow map.bmp]

[/font][/font]
Advertisement
Hi!

trying to generate my depth map, i see the scene in white and the background in black, therefore there are only two values in the map.[/quote]I think you might have a misunderstanding here :)

In shadow mapping, you want to write the DEPTH (the distance to the camea) of each pixel to the shadow map, which can be a floating-point format (F16 or however they are called). You need the depth of each pixel, not the color.

As I'm working on the same problem, I'll give you some hins:

1. I'd use the depth map in the format D3DFMT_R32F and just use the first channel (red) for storing the depth. This will give you a higher precision, and maybe even fix your problem.

2. Second, make sure you divide the depth (so the .z-value) by the .w-value of the position (has to be float4) from lights view OR by the far-clip-plane of the light (I can't tell which one of these to choose, theoretically they should both be corret, but sometimes I have to use former, sometimes latter). This will clip the depth-value from 0.0 to 1.0, and make you able to distinguise it on the screen. the reason everything is white know may be that all depth values are > 1.0, and as this means full color any value above can't be displayed (though floating-point-textures like R32F are able to store these values, while normal textures like you used aren't).

3. Try using D3DX_PI / 2.0f instead of D3DXToRadion(60.0f). Don't know if it helps but I'm using it and basically it works for me, while other values caused some strange problems.

4. Outputting the values directly may be tricky. Even know I seem to be hardly able to output the actual stored depth value, though my depth-comparison works. To sum up: If you used my points 1-3 then don't trust the direct output of the stored depth values, and rather write the full shadow mapping algorythm first to see if it really works.

Hope that helps. I'm still working on my own shadow mapping but at least I'm pass the problems you have (I had them before too and spend many many hours trying to solve em :/ ).
First of all, your depth seems to be inverted, so you are probably not outputting the correct values. (Black should be near the camera, but your object is all white.)

Second, 100000.0f is a very large value for a farplane, so there's a good change anything near to the camera will (appear to) be the same color, especially in the capture which is only 8bit.
You could try a lower farplane value like 1000.0, 100.0 (or an extremely low value like 10.0) and see if that works any better.
Ok thanks guys, i'll try what you said.

This topic is closed to new replies.

Advertisement