Unreal Engine Discoveries - Volumetric Fog Challenges

Unreal Engine Discoveries - Volumetric Fog Challenges

Note: With this post I'm writing up any discoveries / possible solutions as I continue to figure out how it all works. The information on here may change as time goes on with an increase in understanding and any corrections that need to be applied.

I recently completed an Unreal Engine project for my portfolio which was encountering a few issues with volumetric fog. The problem was mostly apparent after rendering via the movie render queue, but also visible directly in the viewport, and looked a little bit like this:

So essentially it seems that two problems were showing themselves:

1) The rather ugly banding / gradient on the back of the laptop
2) The very low resolution of the fog (seen here on the lamp, but also visible on other screenshots)

Banding / Gradient Artifacts

Unfortunately I was unable to fully fix the banding problem, however after some useful information about how the volumetric fog in Unreal Engine works, the cause was pinned to the surface of the laptop mesh being too thing. And due to a light source being on the other side, that same light was leaking through via the fog voxels.

As a quick solution I decided to create multiple light sources which would activate based on a boolean parameter per instance:

The original light source was left where it was, and would be used on any scene which didn't need to look at the back of the laptop (which was most of them).

Two more lights were added, one again at the same place as the original, with volumetric scattering disabled so a light would still be given off but no fog would leak through, and a secondary light to apply the volumetric scattering effect, this has a low intensity to keep it contained.

Thanks to the laptop blocking the start of the volumetric light source, I was able to fake where things began and ended.

This solution was really just to get things working, and will be something I'll return to fix properly.

Fog Resolution

As mentioned earlier, volumetric fog works in voxels. And whilst it looks great, when the resolution is too low it can create some quite harsh blend edges:

This was apparent in the editor viewport as well as the movie render queue, after quite a while trying to figure it out, I finally landed on something that worked for the project:

So, you can directly edit the properties of the fog in the console. Two of which I made heavy use of:

r.VolumetricFog.GridSizeZ (number of fog 'cells' to use in z)
r.VolumetricFog.GridPixelSize (xy size of the cell in the voxel grid)

Changing these seemed to fix the problem, however, results my vary. I've gotten mixed results by setting GridSizeZ to 256, and GridPixelSize to 3 (in the viewport at least).

The result above is actually a render, and within the movie render pipeline settings I added them as console variables (it caused terrible fps having them set to higher values the entire time).

Whilst this seemed to smooth things out, it did have one large setback and that was down to my current GFX 1080 not quite having enough memory to keep up with the increase in resolution and continuous usage. Again this was a bit of a problem, but it was made a little easier by adding a 'high resolution' setting in the rendering pipeline with at least 2 tiles.

This allowed for the GFX to keep up a little better thankfully, and although it was still somewhat unstable, it was enough to get the renders done.

Conclusion

Whilst a couple of solutions have arrived, I'm not 100% sure they're the best... or... if they're solutions at all. I'm also curious how much of the problem was due to hardware, but either way, another idea that was suggested was to go back to a more traditional lighting method (baking and such), which might actually be worth keeping in mind for future projects.

Cheers.