Original Post
I'm adapting MJP's Deferred Cascaded Shadow Map code from XNA to DX9.
I'm facing the following issues currently:
1. My shadows render but they do not occlude correctly based on depth, instead they are just plastered on top of the object and occlude the top of the object as well as the ground beneath. Inside the pixel shader for computing the shadow occlusion factor, i have verified that my gbuffer's linear depth comes in correctly and yields the expected CSM splits. I've also verified that the depth as seen by the light appears as expected. However the depth read from the shadow map looks suspicious because whilst it seems to come from the correct part of the shadow map, it is either 0 or 1 there are no in between gradients. I render my GBuffer depth in linear depth and also my shadowmap pixel shader outputs linear depth (though I have tried both ways with my shadowmap PS and neither worked any better) If I just hardcode my shadowmap pixel shader to output a value close to 0 like 0.1f it shows as pure black and if I output 0.0f it shows as pure white.
2. I'm fairly sure that I adapted the 4 split orthographic frustums correctly from MJP's code. Not only can I render them in world space and they look OK, but they also show up correctly when using the color output from the occlusion pixel shader. However, when I use these view/projection matrices to render my shadowcasters, the shadows appear to displace more and more as the main camera's view matrix rotates about. It almost seems like there is some sort of translation before rotation issue. Admittedly I did have trouble converting this part of the code from XNA RH to DX9 LH.
3. The cascade splits seem to disappear when the main camera's view angle is very close to parallel to the ground. If I have a very tall column in the middle of a flat ground plane, the column will cast a shadow across all 4 CSM split frustums. This looks fine if the column is viewed from "above", but if viewed from the ground and looking at a certain angle along the ground, the shadows flit in and out and sometimes are completely absent.
Please if anybody could give me some pointers or help me it would be appreciated. I can post whatever code/screenshots are required, but I didn't want to spam the forums with a huge code post just yet.
I'm facing the following issues currently:
1. My shadows render but they do not occlude correctly based on depth, instead they are just plastered on top of the object and occlude the top of the object as well as the ground beneath. Inside the pixel shader for computing the shadow occlusion factor, i have verified that my gbuffer's linear depth comes in correctly and yields the expected CSM splits. I've also verified that the depth as seen by the light appears as expected. However the depth read from the shadow map looks suspicious because whilst it seems to come from the correct part of the shadow map, it is either 0 or 1 there are no in between gradients. I render my GBuffer depth in linear depth and also my shadowmap pixel shader outputs linear depth (though I have tried both ways with my shadowmap PS and neither worked any better) If I just hardcode my shadowmap pixel shader to output a value close to 0 like 0.1f it shows as pure black and if I output 0.0f it shows as pure white.
2. I'm fairly sure that I adapted the 4 split orthographic frustums correctly from MJP's code. Not only can I render them in world space and they look OK, but they also show up correctly when using the color output from the occlusion pixel shader. However, when I use these view/projection matrices to render my shadowcasters, the shadows appear to displace more and more as the main camera's view matrix rotates about. It almost seems like there is some sort of translation before rotation issue. Admittedly I did have trouble converting this part of the code from XNA RH to DX9 LH.
3. The cascade splits seem to disappear when the main camera's view angle is very close to parallel to the ground. If I have a very tall column in the middle of a flat ground plane, the column will cast a shadow across all 4 CSM split frustums. This looks fine if the column is viewed from "above", but if viewed from the ground and looking at a certain angle along the ground, the shadows flit in and out and sometimes are completely absent.
Please if anybody could give me some pointers or help me it would be appreciated. I can post whatever code/screenshots are required, but I didn't want to spam the forums with a huge code post just yet.







