I took an upcoming AI powered fluid simulation tool for a test dive to see if it would allow me to add realistic, interactive smoke to the game.

The final realtime fluid simulations in the game build.

Deciding to add fluid simulations to the game

As my game has a a stationary camera, it would be easy for me to add pre-rendered full screen fluid simulations on top of the image and it should match perfectly. I decided to use the Maglev train sequence as a prototype scenario.

I was going to use a software called EmberGen. It is realtime, but in order to get the fluid simulations to your game engine, you need to export them as pre rendered flip-book animations. Flip-book animations are simply an image with all of the animation frames in it.

Embergen fluid simulation sprite sheet
EmberGen generated flip-book of the train smoke when it arrives at the station

For this fluid simulation to work, my first step would be to get the train animation to EmberGen. This is very easy with the Unity FBX exporter. It can be easily installed from the package manager.

The FBX exporter worked great and the animations loaded up in EmberGen without a hitch! Setting up the fluid sim to emit from the train was easy and it looked great! I rendered the simulation and jumped over to Unity. Next I needed to make the velocity blending capable flip book renderer…

Pivoting to real-time 3D fluid simulation

But at this point I remembered that I had seen a realtime, AI fluid simulation smoke and fire plugin for Unity https://zibra.ai/zibra-smoke-fire. For sure the fluid simulations would be better rendered in realtime, not baked to choppy flip-books with very limited duration! Maybe the realtime tool was worth a try? It being an AI tool it would also be a great fit for this project!

Also, when the fluid sim is actually in 3D space, the moving characters will blend with it better and it will also automatically composite correctly with scene elements in depth.

Zebra AI Smoke & Fire promotional video

My only concern was performance. I had experimented with Niagara fluids in Unreal 5 and they eat up quite a bit of performance. To the point of being unusable for now.

Luckily, I had direct connection to the Zibra guys and they showed me some demos of their AI fluid simulation running on the iPhone. It ran amazingly well! The quality was great, the frame rate butter smooth. It is amazing what you can do with AI! I have never seen 3D fluid simulations as complex as this on a phone. Ever.

I quickly gave up on using EmberGen and committed fully to Zibra Smoke & Fire!

AI fluid simulation preview scene in Unity
The Smoke & Fire example scene

When I loaded up Zibra for the first time (after enabling it in the URP renderer) I am greeted with a simple demo scene that has some fire and a teapot. The fire in this scene looks amazing and runs blazing fast. I asked Zibra what evil AI magic they are doing to make this so fast, how was the AI used to run their simulations?

We use it’s as a acceleration component.
We use neural network to represent the object’s shape in the form of compact SDF (Signed Distance Field), making it possible to create performant colliders for objects of arbitrary shape, and set up interaction with complex 3D objects in just a few clicks.

Alex from Zibra

SDFs are indeed amazing. I use them on Pax Dei for a crazy number of things. Such a handy concept!

Setting up the smoke simulations

Maglev station location with AI fluid simulation emitters in Unity
The smoke emitter in the Unity scene

Setting up the fluid sim in the maglev scene was very simple. I used Zibra’s components to add a cylinder emitter to the train. It is important to enable the “Use Object Velocity” feature as the train is moving and this will add very nice motion to the smoke.

AI fluid simulation manipulator settings in Unity
Smoke & Fire cover component with the Manipulators set up

This element is then linked to the solver component. I also created a ground collision shape and a force field that adds random forces & twirls to the smoke to make it look more interesting and natural.

Zibra smoke and fire color settings in Unity
The smoke’s lighting settings

It really did not take me all that long to set this up and have it going in the scene. Most of the time was actually spent on matching the smoke color to the scene. It was pretty straightforward with the tools provided. Zibra Smoke & Fire has a couple of dozen sliders for controlling the look of the smoke, and I did not get to thoroughly study all of them yet in this quick test.

As I do not really have any lighting in the game, I lit the fluids with one directional light that has its contribution to any 3D objects set to off. As zebra is not lit conventionally, the directional light was still visible on the smoke. Then it was just a matter of finding a light direction that made most sense for the scene and tweaking the absorption, scattering and shadow colours to match the location image as well as possible.

I found matching the smoke lights with the scenes pretty intuitive.

In conclusion, I am absolutely amazed how well this system works! the smoke rendering added about 2 ms to my frame times based on the unity stats inspector. That is absolutely amazing. This is a full screen fluid simulation with complex scene interactions!

If the plugin proves to be stable and reliable even when left running for hours, I might end up adding some fluid sim smokes and dusts to all of my scenes. It just looks so good!

I also used a Zibra Effects plugin for water!

2 responses to “AI powered fluid simulations”

  1. […] I was already using Zibra fluids in the game, I wanted to integrate them into the Adventure Creator action list system so they could be enabled […]

  2. […] closely by the post about modeling a utilitarian robot character and the third place goes to the AI powered fluid simulations piece. I do not expect any post ever to beat the virality of the first […]

Leave a Reply

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

Recent Posts


Social Links