Hey everyone, welcome back to “Introduction to Bifrost Visual Programming”.
In the previous tutorial, we created fog using aero simulation.
Today, we are going to learn how to simulate fire.
Here we see the mesh spheres in the valley,
which we’ll use as the source geometry to create the bonfire.
You can download this file in the description to follow along.
First, let’s create a new graph.
Similar to how we started the graph for the fog simulation, we middle-drag “bifrostGraph1” into
this new graph,
get a “basic_aero_graph”,
and explode it.
We don’t need the collider in this case, so let’s delete it.
Before we set these spheres as the source geometry, it would be nice to have the ability to
shift them up and down as we need.
So let’s add a “translate_points” here,
connect “mesh_fire” to points,
right click at translation, and select “create_value_node”.
Click the 3 dots here to open the set value type window.
Uncheck array and click OK.
Get a terminal and connect the out_points to diagnostic.
Let’s connect the mountains to the output, and hide “bifrostGraph1”.
Now if we change the y value of the translation, we see the spheres moving vertically.
Connect the “out_points” to “source_air”, and we have our source geometry.
For any combustible material to burn, we need to add fuel,
and “source_fuel” is the node we use to do that.
Connect it to “additional_properties”.
And we also need to add the “aero_combustion_settings” to adjust the
parameters for combustion.
Connect it to “additional_settings”.
This is the basic set up of a combustion simulation.
Now let’s assign material to the aero volume.
Like last time, go to Hypershade, select aiStandardVolume,
go to presets, select “default Bifrost aero” and click “replace”.
Connect “out_geometry” to output.
Turn off the diagnostic view and run the simulation.
At this moment we only see dark smokes coming out, so let’s adjust some of the
parameters.
First, let’s go to “source_air”, change the resolution mode to “absolute”.
For the geo detail size, as well as the fluid detail size, we want a small number,
because the size of our spheres is pretty small, we need a higher resolution to have the details,
let’s enter 0.008.
For the fog density, let’s set it to 0.1 for now,
and change the temperature mode to set.
The default temperature is 250 Celsius, if we go to “source_fuel”, we see that the ignition
temperature is 580, which is much higher than the temperature of the air,
and that’s why we didn’t see anything burning.
Let’s reduce it to 200.
Run the simulation again, and they start to burn.
Currently they are too intense and expanding too fast.
To slow down the progression and prevent it from exploding, let’s go to the
"aero_combustion_settings" and reduce the expansion scale to 0.1.
A lower expansion scale means a smaller change in volume triggered by the change in
temperature due to the combustion.
We can also set the radiative heating to 0, this helps reducing the flame speed.
If you don’t want to see the smoke, you can turn off “Emit soot”.
Let’s also add a dissipation influence.
Now we get a less violent fire.
To change the height of the flame, we can adjust radiative cooling,
a higher value here reduces the height of the flame.
Instead of using a constant value, we can introduce variations in radiative cooling,
which in turn, varies the height of the flame, resulting in a more dynamic and natural looking
fire.
Let’s use a combination of "fractal_noise" and "time" to trigger the variation.
Connect seconds to time, this will give us a continuous evolution of the noise value.
The range of the noise is normally between -1 and 1, and as we learned before,
we can modify the range using a “change_range” node.
Connect noise to value,
set the from start and from end to be -1 and 1,
the to start and to end values will be the min and max of the radiative cooling factor,
let’s enter 0.5 and 2.5 here.
Now we noticed some changes in the height of the flame.
We can increase the frequency of the "fractal_noise" to get more local variations.
The scale of the flames still looks a bit off. Let’s go to the "aero_solver_settings" to make further
adjustments.
We can change the style from smooth to fluffy to make it look less uniform.
And use a slightly larger scene unit to see more details.
Here the buoyancy determines the upward acceleration,
if we reduce the absolute value of buoyancy, the smoke will rise slower,
for example, let’s try -3 here and run the simulation.
Here’s a comparison and we see that smaller buoyance results in a slower rise of the flames.
To make them look more like bonfires, we also need variations in temperature and fog density.
Let’s get a “vary_source_property” node,
set the property to be “temperature”, min and max values to be, say 180 and 250,
with “randomize value” and “animated” selected, the temperature will vary randomly
between 180 and 250 Celsius over time.
Copy and paste it,
set the property to be “fog_density”,
and the min and max to be 0.1 and 0.3,
we can chain multiple "vary_source_property" nodes together.
Connect the mesh spheres to geometry, and out_geometry to “source_air”.
Run it again, and we see more variations in the form of the fire.
To make the motion more dynamic, we can animate the source geometry using a noise field.
I introduced fields in tutorial 2.
To refresh your memory, a field is a function that associates a value to every point in space.
If we apply a field to the points of a geometry, we get a value for each point,
and we can use these values to displace the points.
If we animate the field, the evolving values will trigger a continuous movement of the points,
and therefore create a continuously deforming geometry
Let’s get a “fractal_noise_field”.
To provide time for a field, we need a scalar field whose value at any position is the time.
Let’s get the node “scalar_field”,
and connect seconds to it,
and the output to time.
This tells the “fractal_noise_field” at what time to sample the noise.
Now we can use the "displace_points" node to change the point positions of the mesh spheres.
Connect the “out_points” to “points”, and the "noise_field" to "weights",
connect the displaced points to the terminal, disconnect “translate_points” from it,
and turn on the diagnostic view.
Let’s decrease the magnitude and move up the spheres so that we can see them.
If we increase the frequency, we’ll start to see the noise pattern.
Adjust the magnitude to reduce the intensity of the deformation.
We can go to bifrostGraph1 to increase the resolution of the mesh spheres.
Let’s disconnect the fire from the output for a moment.
Run the animation, and we see the motion of the geometries.
Connect the fire back to the output
and move these geometries back down.
This motion of the source geometry will affect the movement of the air.
If we go to the parameters of “source_air”, the Inherit velocity here is set to 1.
Inherit velocity is the amount of the source geometry’s velocity that is added to the air.
If it is set to 1, it means 100% of the source geometry’s velocity is added to the emitted air.
This way, the undulating movement of the source geometry will push and pull the emitted
air, creating a dynamic movement of the air and the resulting smoke or flame
Let’s connect the deformed geometry to "vary_source_property",
disconnect the original geometry, turn off the diagnostic view, and run the simulation,
now we get a more dynamic bonfire.
Let’s make these few nodes into a compound.
I turned on the proxy flag just for the flags to appear on the compound so that we can control
the display from the outside.
Let’s name it “animate_source_geo”.
To adjust the color of the fire,
we can go to the volume material and change the “Blackbody Kelvin”.
A lower number reduces the brightness and gives it a warmer color.
Here’s a rendered view of the scene.
Now the questions are:
how do we have more control of the details so that we can further improve the look of it?
Is there a more efficient way of introducing variations?
How do we quickly alter the look of it to try out different design ideas?
I’ll talk about all these in the next tutorial.
Thanks for watching! Stay tuned and I’ll see you next time.