Shadow Map best approach !
Started by SuperPixel, Aug 18 2010 10:01 AM
9 replies to this topic
#1
Posted 18 August 2010 - 10:01 AM
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.
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.
#2
Posted 18 August 2010 - 01:39 PM
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 !
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 !
#3
Posted 18 August 2010 - 04:03 PM
SuperPixel said:
...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 said:
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?
reedbeta.com - developer blog, OpenGL demos, and other projects
#4
Posted 18 August 2010 - 04:49 PM
Reedbeta said:
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 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 !!!
#5
Posted 18 August 2010 - 04:58 PM
When you look at your small demo test bed (where the shadows work properly) with PIX, do you also see black depth buffers?
reedbeta.com - developer blog, OpenGL demos, and other projects
#6
Posted 18 August 2010 - 05:25 PM
Reedbeta said:
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 ?
#7
Posted 18 August 2010 - 06:13 PM
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.
reedbeta.com - developer blog, OpenGL demos, and other projects
#8
Posted 18 August 2010 - 06:30 PM
Reedbeta said:
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
#9
Posted 19 August 2010 - 03:11 PM
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 ...
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 ...
#10
Posted 19 August 2010 - 03:26 PM
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
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
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












