a question about VSM.

Started by
5 comments, last by AndyTX 16 years, 8 months ago
I use the Parallel-Split Shadow Map and VSM for sun light,so i use the orthographic projection. Because VSM need all object(caster and receiver)'s z in light space is between 0 and 1.0,so when i calculate the projection matrix,i must include the receiver in the view volume. In my app the receiver is much biger than caster,so only a small area of shadow map is used. I want to only include caster in the view volume,anybody can give me some suggestion? Thanks. [Edited by - ChenA on August 15, 2007 6:06:31 AM]
hehe.
Advertisement
You only need the portion of the receiver that will be shadowed. Then in your shader if the compute shadow map texture coordinates lie outside of [0, 1] (in either dimension), simply consider the area "lit".

Thus you need only make the projection large enough to cover the castors, plus any blurring that you do to soften shadow edges. Note that you still need to render the receiver into the shadow map (as usual for VSM), but you don't need to include regions that won't contain any shadows.
Quote:Original post by AndyTX
You only need the portion of the receiver that will be shadowed. Then in your shader if the compute shadow map texture coordinates lie outside of [0, 1] (in either dimension), simply consider the area "lit".

Thus you need only make the projection large enough to cover the castors, plus any blurring that you do to soften shadow edges. Note that you still need to render the receiver into the shadow map (as usual for VSM), but you don't need to include regions that won't contain any shadows.


First,thanks for you reply.

Yeah,you are right,i need to render the receiver into the shadow map.
But if the receiver's z is greater than 1.0,i can't render it to the shadow map.

See the picture:




The blue aabb is the boy's world space aabb,the red aabb is the boy's light space aabb.Only the green rectangle render to the shadow map(the blue rectangle in the shadow map),other part is cliped.


If i can render the part which z is greater than 1.0 to the shadow map,the result is right.

I have two method:
1.Extend the aabb to include the receiver's light space min z and max z.This method need additional calculate.
2.Use viewport.Set the viewport's maxZ to 100.0f(receiver's z won't exceed it).
I try this method,but it don't have effect.Is SetViewport don't have effect to shader?

AndyTX,do you have a better method?

Thanks.

[Edited by - ChenA on August 15, 2007 6:59:24 AM]
hehe.
Yes certainly you can't be clamping/clipping the depth values of the receiver. You need to include it properly in the projection (i.e. extend the far plane or fix your depth metric). This is the same as normal shadow maps except that you need to consider receivers as well as occluders.

Still, unless you're using fp16, constraining the depth range isn't that critical. fp32 has plenty of precision. If you're using the former, check out the recent thread on these forums for suggestions on how to get more precision if that turns out to be a problem.
Quote:Original post by AndyTX
Yes certainly you can't be clamping/clipping the depth values of the receiver. You need to include it properly in the projection (i.e. extend the far plane or fix your depth metric). This is the same as normal shadow maps except that you need to consider receivers as well as occluders.

Still, unless you're using fp16, constraining the depth range isn't that critical. fp32 has plenty of precision. If you're using the former, check out the recent thread on these forums for suggestions on how to get more precision if that turns out to be a problem.


I use your method and get the right result.
Thank you for the patience to help me.
Thanks again.


hehe.
Quote:Original post by AndyTX
This is the same as normal shadow maps except that you need to consider receivers as well as occluders.


why do we need to include receivers into the shadow map frustum for VSM only ?


Quote:Original post by zoret
why do we need to include receivers into the shadow map frustum for VSM only ?

Because VSM requires that you render receivers into the shadow map as well as castors for proper filtering (an object cannot be *just* a castor - the receiver of a shadow must also be represented in the filter region).

This topic is closed to new replies.

Advertisement