Stylized Aurora Borealis
Goal of this project:
The goal of this project was to generate Aurora Borealis procedurally. My intention was to get this effect into our game projcet Flare, hence the style. Due to limitations of our engine, this effect was never implemented. As a result, I only have the prototype that I built inside of Unreal Engine 4.
Looking into how other games implemented northern lights, I found one thing in common. They all had a shader applied to a mesh that had a vertex animation. They were however static and not fully procedural in the way I imagined. That's when I remembered another project and decided to try generating the effect, using Parallax Occlusion Mapping. (POM)
To the left you can see an overview of the material. The POM is copied from the existing function in Unreal, though, I had to clean it and break it down in order to write the HLSL shader for our engine.
My approach has been to generate masks and packing those into a texture in Substance Designer. I then fed that texture into Unreal Engine 4 and set up a material to both warp and pan the texture on a plane that covers the entire sky. That plane has a slight curve to look better near the horizon.
The advantage is definitely that the northern lights are fully procerdural. With the correct setup, it is also very easy to use and highly tweakable. Since the whole idea originated from using a texture, you can get vastly different results by building different masks. As it also warps, it feels less repedetive.
The limitations however would be performance. Because of this effect being a texture and covering the whole sky, I needed at least a 2048 x 2048 texture to get rid of the jagginess the pixels would produce. On top of that, I needed at least 1024 layers in my POM to get decent looking results. In my presentation I have 2048 layers. Therefore, I would not recommend using this effect in a project where a lot of other thing are going to need performance.
I did manage to optimize it a bit though so that I get an average of 120 FPS on my workstation. (The frame dips in editor whenever a key is pressed because of the engine.)
The Bug Hunt:
When writing the code for our own engine, it became apparent that something was really wrong. I looked into my code over and over and even started to change it fundamentally with the help of my collegues, but it didn't work. A lot of time was spent on this bug hunt since this was supposed to be quite a big piece of our game, but in the end we decided to cut in once we found out what was wrong. It turned out that the matrices used in our engine was built incorrectly and we could therefore not access the right data. To fix those matrices wouldn't be the issue, to adjust all the existing code would be since at this point, we didn't have much time left. To the left you can see the work in progress state inside of our own engine.
When doing complex work such as this one, I need to communicate better with the team. Very much of my time was spent on research that I didn't really think of what our engine was capable of. If I'd talk to my programmers earlier about this, we would most likely gotten this effect into our project.