0
\$\begingroup\$

For example I have 3 shadow cascades. A shadow is cast by a hill in my 2nd cascade, but the shadow itself is cast into not only the 2nd cascade but also the 1st. In the shader program, in order to locate the correct cascade, I check which bounds the Z clip space that the pixel resides within. Since the shadow was cast from the 2nd cascade, the portion of the shadow that is cast into the 1st is cut off, as shown in my image. How can I get around this? Is there something I'm missing, or is my implementation wrong?

enter image description here

\$\endgroup\$
4
  • 2
    \$\begingroup\$ A shadow caster in the 2nd cascade whose shadow extends into the 1st cascade should have had its depth recorded in both cascades, no? What is causing this information to be absent from the first cascade? \$\endgroup\$
    – DMGregory
    Nov 10, 2021 at 11:42
  • \$\begingroup\$ Maybe my implementation is wrong: Each subfrustum has its own light position (based on the centroid of the frustum, and placed backwards in light direction), its own view matrix, and its own projection matrix. Could it be that in this example, the first frustum's view cannot see the tip of that hill, therefore not recording the depth information? \$\endgroup\$
    – T. Elliott
    Nov 11, 2021 at 8:32
  • \$\begingroup\$ Following some research I just did, I found this "Choose the min/max values for z large enough, that all shadow casting objects are included, where ever the frustrum is." I added an arbitrary number -100.f to my projection matrix Z min. And I think this has solved the problem. Does this sound right? \$\endgroup\$
    – T. Elliott
    Nov 11, 2021 at 8:48
  • 1
    \$\begingroup\$ You can do better than an arbitrary number. ;) You can do it extrude the sub-frustum for this cascade back toward the light until it encompasses all shadow casters, and use a tight bound on that z range. If you've solved your problem, want to post your solution as an Answer below? \$\endgroup\$
    – DMGregory
    Nov 11, 2021 at 11:44

1 Answer 1

0
\$\begingroup\$

The 1st cascade was not showing the shadow, as pointed out by DMGregory; the depth information was not recorded. This is because the viewing position of this cascade could not see this part of the hill, because the minimum Z value of the projection was only set to the minimum Z coordinate of the subfrustum in lightspace. Solution: I have now subtracted the screenfar value from the min Z coordinate, which has solved the problem. The more difficult, but more correct solution would be to do what DMGregory suggested; extrude the sub-frustum for this cascade back toward the light until it encompasses all shadow casters.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .