0
\$\begingroup\$

i am about to add shadow mapping to my simple game, i have a map level structured in an octree the camera culls out the octree nodes out of the vieweing frusutm and everything runs smooth. Now i want shadows and i have a doubt , the directional light runs is set at an infinite distance so basically it encompasses all the octree destroying the purpose of node culling. How can i add a directional shadow map and cull nodes outside the light frusutm if it is at an infinite distance ? thanks in advance

\$\endgroup\$
0
\$\begingroup\$

You only care about shadows that are visible in the camera's frustum. If something casts a shadow on a surface out of the camera's view, you never see it, so you can ignore those receivers.

That lets you start with just the octree nodes that survived the camera's frustum culling pass, encompassing all visible shadow receivers.

Shadow casters that cast shadows on these receivers could be anywhere in this volume or upstream / toward the light from here. So next you extrude the camera's frustum back toward the light until it...

  • encompasses the maximum bounds of your scene / loaded chunks

  • reaches a maximum defined shadow-casting distance [for this cascade], if you find that including all arbitrarily-distant casters is impractical for your case.

Either way, you get a finite volume that needs to be drawn to your shadow map(s), letting you select a finite number of octree nodes to include in this pass.

If you need to do directional light shadows over truly immense distances that could have geometry all along the way — like a shadow of a mountain stretching all the way across the neighbouring valley at sunset — then you can swap to an alternate method of handling these, like the "terrain shadows clipmap" used in the Witcher 3, as described around 33 minutes into this GDC Talk, while keeping your conventional shadow map for the more detailed nearby shadow-casters.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I am sorry but i cannot follow you, if i cast shadows only on nodes which survived the frustum culling i could skip shadows cast by nodes outside the fruustm, a node could not be visible but it might still cast a shadow \$\endgroup\$ – vinnythepoo Jan 11 at 19:20
  • \$\begingroup\$ Right, that's why the answer continues after the second paragraph. In the third paragraph and onward, the answer talks about extruding this volume to include shadow-casters outside the camera's frustum. \$\endgroup\$ – DMGregory Jan 11 at 19:21

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.