Distance Fog in UE4

I’ve been working on a third person exploration and adventure game called ‘The Nomad’ for the past 6 months, and I wanted to share some of the techniques I had learned in this time.

Something that can dramatically affect the final look of your scene is the presence of fog. Even though Unreal 4 has a great lighting system, it still cannot (in my opinion) provide enough atmosphere to a scene on it’s own.

At the very least, for the type of environments that this game requires, which generally features large spaces that dwarf the player character.

Another issue is that we do not have any dedicated artists in our team. I am the producer and one of the programmers on our 6 man team, but needs dictate that I also use my modelling, texturing and animation skills in Blender and 3DS Max.

However, because I do not have the time to create a lot of props and assets to fill up the world, fog is crucial in making the large environments we create in this game feel less empty.

Compare the first screenshot below:

The scene with no fog at all

to this screenshot of the scene with Unreal’s built in exponential height fog:

Scene with exponential height fogScene with custom distance fog

to the final scene, with both the custom distance fog and exponential height fog:

Scene with exponential height fog and custom distance fog

The setup for this is quite simple. It involves using a post process material and a post process volume.

The post process material itself queries the scene color and blends (using a linear interpolation whose alpha is based on distance from the camera weighed against a fog blend distance) three different choices of fog color into the final scene texture.

It’s convenient to make these fog colors be parameters because you can then create Material instances and mess with these colors ad nausem without forcing a recompilation.

Here’s the Material itself. The output of that Lerp goes into the Emissive color input of the final material node.