Volumetric Shadows Effect

I’m trying to do an effect where the shadowed volumes shown as darker on the screen, but adjusting the fog/sun scattering settings also makes the lit areas too bright/foggy:

Here’s what standard fog achieves:

And here’s what I want (made in PS):

Is there any way to make the unlit fog darker?

I’ve also thought that a raymarching post-process effect could do this, but I’ve yet to find a way to check whether a world location is lit by the sun via a shader. Is there some function I’m missing, or some other way to check this?

Maybe someone knows a different solution? Would greatly appreciate any ideas or tips

I’m using Unreal 5.1.1, Lumen GI, virtual shadow maps

You would render an ortho depth map from a scene capture oriented to the light then check the position at every step of the ray march to determine if it is in shadow or not.

This will work for the directional light, if you want it to affect all lights in the scene you have no good way of doing that.

Will it work? Yes
Should you do this? Not if you value performance.

There is a screenspace effect in the sun light called light shaft occlusion which can be used to darken the shafts, but because it is screen space it doesn’t do a great job and it also tends to cause banding artifacts.

Thank you for the possible solution! But yeah, I guess this effect is far too performance-heavy. Will try to make do without it

That sounds like an interesting challenge for learning. Is there a tutorial which talks about rendering an orthographic map from the perspective of a light ? And how would one go and overlay that over the scene in real-time ?

You don’t do that. You use the world position at the point of the raymarch transformed to light space so that you can check whether the distance from that position to the light is greater than the distance in the depth map. If it is then you know the position is in shadow. This is called shadowmapping.

Tutorial about shadowmapping is here: LearnOpenGL - Shadow Mapping (this technique is not Unreal specific)

Tutorial about transforming a RT into lightspace is here: Projecting a Texture in Worldspace | Tutorial (a light is not used here but it is no different, just make sure the light position/fov is the same as the scene capture)

This tutorial covers making a shadow depth map for a custom shadow map. Some of the steps would be transferrable to what you are looking to accomplish.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.