| Volumetric fog encircles a tobacco barn. Image courtesy of Room 8. |
Early in my tenure on South of Midnight, it was communicated to me from the Art Director and Lighting Artist that fog was going to be extremely important to realizing the art direction of South of Midnight. Early on, I had Ghost of Tsushima in mind as a good example to follow, but also games like Quantum Break which had a pretty compelling mixture of particles and volumetric fog. The fog of Quantum Break was achieved in 2016 and on the previous generation of hardware, so it a fog system that is at least partially volumetric seemed viable. Around the same time in 2017, the immutable Ryan Brucks made a blog post about the then-new volumetric fog material system in Unreal Engine 4.
The lighting artist, Miguel, who is a bit of an artistic powerhouse in his own right, described a system that was used to achieve the fog on Guardians of the Galaxy. He wanted a 'Fog Volume' he could place to control the mood of locations by virtue of local atmospheric conditions. He requested a volume that could add a homogenous field of exponential height fog. After reading some documentation, I thought I could do better than that. It didn't seem that much of a leap in complexity to add local detail to the fog volume, so I set out to over-deliver.
So, after talking with the relevant stake holders, the primary user of the system, consulting the official documentation and looking at what else is out there, I went off to nail down the volumetric part.
The Fog
| Spooky fog hangs thick in the air in the swamp. Image courtesy of Room 8. |
Out in the world, fog can produce all kinds of visual effects and be evocative many different moods. It can be mysterious, beautiful, or foreboding. Likewise, just like clouds, it can be blanket-like, billowy, or wispy. Since large parts of the game would take place in magical, mysterious, or threatening environments, I really wanted to capture the wispy tendrils fog can have. I felt if I could achieve that, the fog volume would be versatile enough for many different kinds of scenarios.
In the volumetric plug in released by Epic, I saw that there were a couple of technologies demonstrated that could be useful: 3d textures and their samplers, Voronoi and curl noise fields, various ways to use noise to modulate per-pixel UVs. I thought that the careful use of these technologies could produce a wide range of effects, including the wispy fog I was after. The exponential height fog already worked with the lighting systems in unreal, so it seemed like we were well on our way to having light-reactive, art-directable, local fog in our game.
The Volume
The documentation suggests using fields of particles to drive the effect. In fact, this was the only driver available in Unreal 4.17. We were working in 4.27, and I was skeptical of the performance overhead of filling a volume with particles. So, I attempted to drive the fog with a cube shaped mesh. To my surprise, it turned out, this worked well from outside of the cube as well as inside. Placing cubes as fog volumes seemed like a quick win, requiring only basic systems to work and very little in the way of development time or future maintenance burden.
The Actor
The Actor was a very simple affair. The user could elect to use a custom material instance with settings they already set up, or they could use the params in the actor's details panel to tune the material's properties per-instance. I attempted to use custom primitive data in the static mesh component to drive the material params, but at the time there was an engine bug that prevented custom primitive data from working. Unfortunately, this bug was never corrected so we used dynamic material instances instead.
The Material
| The 'wispy motion' I was trying to achieve. This example is in 2D mode. |
The material utilized many concepts and functions from the Volumetric engine plug in. It utilized Voronoi noise for a adding cloud-like shapes, and curl noise for adding turbulence and achieving the wispy cloud effect and motion I was attempting to achieve.
It had static switches and master material instances for each of the three modes: 3D, 2D, and flat (0D?).
Aside from the noise, the material had logic to fade the fog extinction to 0 at the bounds of the cube, along each axis: X falloff, Y falloff, bottom falloff and top falloff.
The initial material had the ability to make fake shadows in the fog volume by controlling the colour of the fog albedo, and making a separate noise pass offset from the main pass in the direction of the key light vector. This made the detail in the fog much easier to see, but it was very hard to justify the expense, and we removed it.
The Results
This ended up being a very successful tool for the lighting department. It was surprisingly versatile, and ended up being one of the most utilized art systems in the game. Wherever there is fog in the playable area, one of these volumes is present. It was utilized in harmony with fog cards and particle systems, and added dimension and mood to all of our levels.
Over time, artists requested extensions or amendments to its functionality. The cheap-and-cheerful construction made it very easy to edit in response to these requests. Over time we tried out different concepts, some stuck, and some didn't. One of the last requests was to add some emissive functionality in order to add magical fog, or to accentuate the fog in areas where adding lighting would diminish the over-all mood.
After the game shipped, Xbox's internal technology group requested a copy of our fog systems, stating that they were impressed with the look of our fog and our ability to run at 60 fps with such rich visuals. This was more due to the tremendous artistic mastery of our lighting and environment teams, but I am very proud that I was able to deliver them tools and options to help them succeed.
No comments:
Post a Comment