I'm using MJP's Cascade Shadow Map code and I'm having major issues with the shadows moving with the camera. Here a video to demonstrate what's going on. Also, is there a way to fix the dueling frustum issue? It's annoying seeing them pop in and out of corners of the screen.

Video of the shadows

c# and shader code

  • \$\begingroup\$ +1 for videos. Looks pretty awesome to me, where's the problem? \$\endgroup\$ – ashes999 May 6 '12 at 0:39
  • 1
    \$\begingroup\$ If you look at the shadows. You can see them move. When they are suppose to be static. \$\endgroup\$ – Goss May 6 '12 at 1:13

It looks to me like your shadow render is lagging one frame behind the geometry render (or vice versa). I've had this in my own projects before now. Check your update and render order: you may be doing something like:

a) Update world/camera state
b) Draw Geometry
c) Draw shadows
d) Calc shadows with current (i.e. OLD) geom state

I'm not familiar with cascade shadow mapping (yet) but that sort of thing seems to happen in simple shadow mapping too, when using wrong parameters in the calculation of the shadow projections.

This should help (with near/far planes too): http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324(v=vs.85).aspx

In your video the shadow edge seems to move bit more than just a 'shimmering' but it could be the result of a really far light source.

  • \$\begingroup\$ Here an image of the render targets. i.imgur.com/UMfXh.jpg I don't think it's how the near or far planes are being calculated. My far plane is only 400. \$\endgroup\$ – Goss May 6 '12 at 18:29
  • \$\begingroup\$ Here the code to MJP's shadow code mynameismjp.wordpress.com/2009/02/17/… \$\endgroup\$ – Goss May 6 '12 at 18:54
  • \$\begingroup\$ In the link i posted before there's a part (# 17) where it's suggested to set a lower/upper limit to the calculations, exactly to avoid that 'camera-dependent shadows' effect. Even if it's not when updating the near/far plane, any approximation due to cascade-split switch or shadowcoords calculations could lead to the same pixel having different values depending on the camera position. That's as far as I can help I guess, hope it works for you. \$\endgroup\$ – Darkwings May 8 '12 at 19:24
  • \$\begingroup\$ @Goss On MJP's site that you linked to, there's a commenter who posted: "I’ve updated the code to support stable cascaded shadow maps (so that the shadows don’t shimmer when the camera moves or rotates)." Have you tried incorporating that change? \$\endgroup\$ – Nathan Reed Jul 11 '12 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.