View Full Version : Shadow Map field of view

mchartings

07-05-2014, 09:43 AM

I'm implementing a shadowmap algorithm with a spot light.

My issue is that for some configuration, part of the object the light is "looking at" is out of the light frustum. As a consequence everything that is not "seen" is shadowed.

To account for this I tried to increase the field of view of the "light camera", but as a result I get very blocky shadows.

Am I doing something wrong? Is there a more clever way to make sure the light can see the whole object? If not, how can I solve the above said artefact?

Thank you!

(It is a spotlight that always look at a given object)

malexander

07-05-2014, 11:30 AM

You can increase the resolution of your shadow map texture to reduce the blockiness.

Dark Photon

07-05-2014, 01:06 PM

One way or another, with standard shadow mapping, all the objects which will be casting "dynamic" shadows in that spot light need to be in a shadow frustum of that shadow map. You can reduce the size of the frustum so that it more tightly fits the casters, and/or you can increase the resolution of the shadow map(s) or the number of shadow frustum. But you need to balance doing so against the shadow edge flickering you can get as as result.

That may be sufficient for you. There are many other shadow rendering techniques (some variations of simple shadow mapping that perform better filtering) that might be better for you depending on your requirements. For the absolute simplest increase in filtering quality, enable LINEAR filtering on the shadow map, which will (when using hardware depth testing) on some GPUs apply simple PCF.

mchartings

07-06-2014, 10:56 AM

One way or another, with standard shadow mapping, all the objects which will be casting "dynamic" shadows in that spot light need to be in a shadow frustum of that shadow map. You can reduce the size of the frustum so that it more tightly fits the casters, and/or you can increase the resolution of the shadow map(s) or the number of shadow frustum. But you need to balance doing so against the shadow edge flickering you can get as as result.

That may be sufficient for you. There are many other shadow rendering techniques (some variations of simple shadow mapping that perform better filtering) that might be better for you depending on your requirements. For the absolute simplest increase in filtering quality, enable LINEAR filtering on the shadow map, which will (when using hardware depth testing) on some GPUs apply simple PCF.

I did solved the problem of the blockiness and the "frustum" issue increasing the FOV of the perspective matrix of the light. Now I have a problem to dynamically select the FOV such as in the shadow map the object. Suppose to simplify I have a single bounding sphere whose sphere the "shadow camera" is looking at. I tried to modify the FOV using the formula: FOV = 2 * arctan(radius/distance) to give to glm:: perspective then and where distance is: distance = glm::distance(BBCentre, cameraPosition).

The problem is that if the distance becomes small, the effect I have is like a "zooming out". What's wrong? Thank you again!

Dark Photon

07-06-2014, 03:03 PM

The problem is that if the distance becomes small, the effect I have is like a "zooming out". What's wrong? Thank you again!

Not sure exactly what you mean, but a couple possibilities come to mind. Draw a picture with a big sphere, the eyepoint very close to the sphere, and the lines representing the edge of the frustum. Now ask yourself if that FOV is still described by 2*arctan(r/d)...

Also, in this case with such a large view frustum and your obj subtending such a large angle, your shadow map resolution is going to spread out pretty quickly with distance.

mchartings

07-07-2014, 02:57 AM

Not sure exactly what you mean, but a couple possibilities come to mind. Draw a picture with a big sphere, the eyepoint very close to the sphere, and the lines representing the edge of the frustum. Now ask yourself if that FOV is still described by 2*arctan(r/d)...

Also, in this case with such a large view frustum and your obj subtending such a large angle, your shadow map resolution is going to spread out pretty quickly with distance.

I mean that the object becomes smaller on screen, like I would expect with a larger FOV but without changing the distance. Regarding the 2*arctan thingy, isn't it trigonometry? r and d are perpendicular one another, so the angle to fit the sphere shouldn't always be that as long r and d are perpendicular?

(sorry for the way I calculated d, it should be asin instead of atan, but the issue is the same)

Dark Photon

07-08-2014, 05:31 AM

I mean that the object becomes smaller on screen, like I would expect with a larger FOV but without changing the distance.

That does seem odd. If you're fitting the shadow frustum to just that one object, then it shouldn't change size much if at all in that frustum.

Regarding the 2*arctan thingy, isn't it trigonometry?

If the bsphere around an object is sufficiently distant from the light, yes. Then if you consider the bsphere centered within the shadow frustum, it is touching the frustum roughly at its diameter. But up-close... not so much. This picture illustrates:

http://i.stack.imgur.com/JNmYl.png

It's still trig, but not the same problem geometry as 2*arctan presumes.

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.