Shadow Map best approach !

Cd586a7130b6cb95bed9ae57223fad5c
0
SuperPixel 101 Aug 18, 2010 at 10:01

Hi all,

I’ve got to the point in which I have to integrate shadow mapping in my deferred renderer. I’ve got them working in my test bed manager ( which it uses just a forward shading tech ). Now it comes the time to let them working in the main engine, which is deferred. I succesfully generate the shadow map but when it comes the time to project it onto the scene I get actually a bit confused because I use the light volume optimization to process only those pixel that actually affect the scene. Well thing is that the projection space that I’ll use for the shadow depth test can’t be extracted from the position of the light volume, but I would need to render again the scene … could it be possibile to reconstruct the light space position from the shadowmap as I do for the scene depth texture before to perform lighting ?

Thanks for any clarification.

9 Replies

Please log in or register to post a reply.

Cd586a7130b6cb95bed9ae57223fad5c
0
SuperPixel 101 Aug 18, 2010 at 13:39

I think there is another main problem, that I’m noticing right now. I set a render target to draw my shadowmap into and a depth/stencil surface as well. The strange thing is that the depth buffer doesn’t get updated during the shadow map generation (I checked that in PIX). The pointer to the depth stencil surface is valid and all the call return S_OK (checked that in pix too).
I obviously clear the depth buffer after that I set it.

Does anyone know what could be the problem or just a small hint that will point me in the right direction for debugging?

Thanks for any reply !

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Aug 18, 2010 at 16:03

@SuperPixel

…when it comes the time to project it onto the scene I get actually a bit confused because I use the light volume optimization to process only those pixel that actually affect the scene.

What is the “light volume optimization”? Can you describe in more detail?
@SuperPixel

Well thing is that the projection space that I’ll use for the shadow depth test can’t be extracted from the position of the light volume, but I would need to render again the scene…

I don’t understand the problem…normally you (1) decide on the projection - based on light and camera positions etc. - then (2) render the shadow map with that projection and (3) apply it to the camera view with the same projection. So I’m not sure what you are trying to do with “extracting” the projection?

Cd586a7130b6cb95bed9ae57223fad5c
0
SuperPixel 101 Aug 18, 2010 at 16:49

@Reedbeta

What is the “light volume optimization”? Can you describe in more detail?

I don’t understand the problem…normally you (1) decide on the projection - based on light and camera positions etc. - then (2) render the shadow map with that projection and (3) apply it to the camera view with the same projection. So I’m not sure what you are trying to do with “extracting” the projection?

I’ll get straight to the point, sorry for my poor explanation. Actually I’ve

implemented hardware shadow map with PCF. They workj perfect in my small

demo test bed.

Then I tried in integrating them in my deferred renderer.

I use one render target format R32F for depth and a depth/stencil surface. I

set both of them before to render from the light point of view. One thing

that I’ve noiced is that the depth buffer it doesn’t get updated at all while

rendering… it’s just stays black !!! this is going to happen with the main depth buferr as well as my depthstencil surface that I use during shadow map generation, I see just black depth buffer !!!

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Aug 18, 2010 at 16:58

When you look at your small demo test bed (where the shadows work properly) with PIX, do you also see black depth buffers?

Cd586a7130b6cb95bed9ae57223fad5c
0
SuperPixel 101 Aug 18, 2010 at 17:25

@Reedbeta

When you look at your small demo test bed (where the shadows work properly) with PIX, do you also see black depth buffers?

No in the small demo I can see clearly the depth buffer updating! thereofore it’s

not black and it works fine. So, why in the main deferred renderer it’s not

working ? maybe a render state somewhere bha … still couldn’t find anything ! I’m quite sure that ZWrite is enabled so I don’t know what it could be !

Any ideas ?

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Aug 18, 2010 at 18:13

Double check that the Z parts of the projection matrix are set up properly, and that you’re not clearing the buffer in the wrong place. Beyond that, all I can say is divide and conquer: try turning off as much code beyond the basic renderer as you can and see if you can get the depth buffer to show up. Then gradually turn things back on until you find where it goes black again, and you’ll get a clue as to what is messing it up.

Cd586a7130b6cb95bed9ae57223fad5c
0
SuperPixel 101 Aug 18, 2010 at 18:30

@Reedbeta

Double check that the Z parts of the projection matrix are set up properly, and that you’re not clearing the buffer in the wrong place. Beyond that, all I can say is divide and conquer: try turning off as much code beyond the basic renderer as you can and see if you can get the depth buffer to show up. Then gradually turn things back on until you find where it goes black again, and you’ll get a clue as to what is messing it up.

Yeah ! I think I’m definitely going for that approach. It sounds to be the most logical

to me. I’ll let you know.

Cheers

Cd586a7130b6cb95bed9ae57223fad5c
0
SuperPixel 101 Aug 19, 2010 at 15:11

I tried to get really really close to an object and I can see the depth buffer, but it’s really really light almost black … ! could it be the near/far plane not properly set ?
The range of the scene it’s quite large, since the sponza model from ctyek spans a lot along the it’s longest edge … So I use for my main projection values like:

Near = 1.0
Far = 3000.0
fov = 60 degrees

could it be that the far plane it’s too big ?

Plus Shouldn’t be black near the viewver and white further for the depth buffer?

Why it’s white close to the viewer and black as it goes ?… I use a Left Handed for projection as well as for look at …

Cd586a7130b6cb95bed9ae57223fad5c
0
SuperPixel 101 Aug 19, 2010 at 15:26

Ok there we go ! My scene scale is quite big so I start seeing clearly the depth buffer with Near = 10 ( so values that are greater than 1 ). That means that a unit for me in the case of my scene is something like 20 - 30 for a meaningful step to be evident ! So with near = 1 the depth range was too wide I guess that’s why black !

Plus I have still one doubt: Why the depth is white closer to the viewer instead of being black closer and white as it goeas away from the eye ? Shouldn’t be from 0 to 1 (0 at the camera position and 1 at the far plane in clipping space ? )

Cheers