Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Shadow Map field of view

  1. #1
    Newbie Newbie
    Join Date
    Jul 2014
    Posts
    3

    Shadow Map field of view

    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)

  2. #2
    Member Regular Contributor malexander's Avatar
    Join Date
    Aug 2009
    Location
    Ontario
    Posts
    324
    You can increase the resolution of your shadow map texture to reduce the blockiness.

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,216
    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.

  4. #4
    Newbie Newbie
    Join Date
    Jul 2014
    Posts
    3
    Quote Originally Posted by Dark Photon View Post
    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!

  5. #5
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,216
    Quote Originally Posted by mchartings View Post
    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.

  6. #6
    Newbie Newbie
    Join Date
    Jul 2014
    Posts
    3
    Quote Originally Posted by Dark Photon View Post
    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)
    Last edited by mchartings; 07-07-2014 at 03:44 AM.

  7. #7
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,216
    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:



    It's still trig, but not the same problem geometry as 2*arctan presumes.
    Last edited by Dark Photon; 07-08-2014 at 06:39 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •