Daniel Elliott

Volumetric Scattering in Unreal Engine 4 ideas

There already exists solutions for Atmospheric Fog and Exponential height fog in UE4 but no real solution exists for god rays and light scattering through objects like trees.

One idea I’ve had is to use the Global Distance field as a way to accelerate the ray tracing required to get proper offscreen light rays. This idea is outlined in this blog post.

I made a quick sketch to work out the tracing steps required. The only drawbacks I see are as follows…..

  • The Global Distance Field in UE4 is updated every frame by moving static meshes but any world position offset isn’t taken into account. This meant that any tree anim would not cause any change to the final result.
  • Characters would need invisible static meshes to be parented to their body for them to contribute to the occluding of the media.
  • Distant objects are in a lower resolution clip map (this might not be much of an issue, anyway there are cvars to be able to increase the distance field res if so required and you had a beefy GPU).
  • Still could be costly as while the initial traces can be a lot faster, you still need to step along those lengths at equal spaces to get a nice result (although those inner shadow/occlusion traces are also able to use the distance field to skip empty space).
  • If you want to do occlusion from clouds you will need some static mesh distance field representation of what you have in place in the sky. That brings me to my next idea which is ray traced distance field clouds. Most current methods of tracing clouds to it at constant step sizes. It is possible to use the same optimisation by representing clouds as noisy sdfs. hmm, think I’m on to something there. It means you could skip really dense internal regions and only have to trace more often around the edges where there are small details.



Anyway, when I get time I’ll give this a go.

Leave a Reply

Your email address will not be published. Required fields are marked *