all games: Fix a case of dynamic shadows bleeding through thin surfaces
Description
CClientShadowMgr::ComputeExtraClipPlanes builds clip planes from the shadow bounding box corner farthest along the shadow direction to prevent dynamic shadows poking through surfaces.
If that corner goes through a brush it would cause the shadow to render on the other side of the brush's surface. This can happen when a model stands near a thin brush wall.
To fix this, this PR updates the compute routine to do a trace from the caster's render origin to our bounding box corner and push the corner's origin along the surface normal towards the caster as needed so the clip planes won't be positioned through solids.
Note that this doesn't address the lack of dynamic shadow clipping through walls in the shadow direction because of the engine's hard-coded limit of max 4 clip planes per shadow. If the limit were to be incremented by 3 (1 plane for each axis) it would suffice to provide a fix for that.
Comparison screenshots of some problematic spots on Dustbowl:
| Before | After |
|---|---|
Closes https://github.com/ValveSoftware/Source-1-Games/issues/52
Note that this doesn't address lack of dynamic shadow clipping oriented towards the shadow direction so it doesn't bleed through walls there because of the engine's hard-coded limit of max 4 clip planes per shadow.
I presume, in layman's terms, this means that improper shadows which are in the direction of the shadow will still appear, like so?
| With shadows | Shadows disabled |
|---|---|
(note shadows at crosshair)
Replying to https://github.com/ValveSoftware/source-sdk-2013/pull/1686#issuecomment-3604450928
Yes.
Though if Valve were to raise the limit of clip planes it would've been possible to fix this a similar way to this PR.
note: this has been implemented in gmod for 2 weeks now and there hasn't been any issues so far