Hey everyone, welcome back to “Introduction to Bifrost Visual Programming”.
In the previous tutorial, we scattered points and created instances as a preparation for
simulating fog and bonfires.
Today, we’ll take a small break from the landscape, coz I want to go over the basic
setup of a simulation for you to have a good understanding of the system,
before we apply it to more complex scenes.
There are 3 types of systems that we can simulate in Bifrost,
aero, such as smoke and fire,
particles, like dusts and fireworks,
and MPM, which stands for material point method, some examples of this system
include snow and sand.
Whichever system you are simulating, the basic setup is the same.
This diagram shows the basic setup for any simulation.
We need a simulation engine where all the calculations occur,
for it to run, we need to provide it with a source,
from which the properties or materials are emitted.
For example, if we want to simulate smoke, we need to provide air,
if we want fire, we also need fuel.
In addition to the source, we need to provide the engine with settings of the environment,
like the ambient temperature, as well as the simulation accuracy like the step size.
The engine, source and settings are the only 3 required components for a simulation to run.
Optionally, we can add colliders, such as walls and ceilings, to act as barriers,
and we can add influences like wind, dissipation and vorticity to change the
properties.
Now let’s see how to set it up in Bifrost.
Here I created a little monster. There’s a link in the description for you to download the file
if you want to follow along.
Say, I want to have smokes coming out of his antennae like in this picture.
To simulate that, let’s get a “simulate_aero” node, which is the core solver, or say,
the engine for aero and combustion simulations.
To provide the source, we use the node “source_air”.
It asks for a geometry.
I’ve created 2 ellipses as the emitter geometry. Let’s bring them into Bifrost Graph Editor,
and combine them using “merge_geometry”.
Here right click, and select “fan-in”,
this allows the port to receive multiple inputs at the same time.
Alternatively, we can drag both geometries into Bifrost as an “input by path”.
Wire the merged geometry into the “source_air”,
and now we have our emitter ready.
For the simulation engine to function, we also need to provide solver settings,
in this case, we use the node “aero_solver_settings”,
connect it to the “settings” here.
Connect the "aero_volume" to the output,
play it,
and we have our simulation working.
To better visualize it, we can assign a material to the smoke. Go to Hypershade,
under Arnold, select “aiStandardVolume”,
click “presets”, under “default_bifrost_aero”, select “replace”.
This sets the density channel to be the “voxel_fog_density” from our simulation,
and we can pick a color.
Let’s middle-drag it into Bifrost,
get an “assign_material”
and connect the material to “volume_material”.
At this moment the resolution is pretty low and the smoke looks too uniform.
To modify the properties, first let's go to the parameter tab of "source_air" and take a look
at the parameters.
The current resolution mode is “relative”, meaning that the voxel size is proportional to
the size of the emitter,
this makes the simulation a lot faster for large objects, but at the expense of the resolution.
If we switch to Absolute mode, then the voxel size is the same as the fluid detail size,
which is the size of the smallest detail in the smoke or other property emitted from the
source.
Run it again, we see a much smaller detail size and a higher resolution.
We can also change the fog density, say, 20,
and it produces a lot more smoke per unit space.
And we can give it an initial speed upward so that it travels faster.
Now, instead of applying a constant fog density, we can also vary the density to make it more
dynamic. The way to do it is to get a “vary_source_property” node,
place it between the mesh geometry and source air.
This node allows us to change a property based on the values we provide,
for example, in this case, we want variations in fog density,
if we set the min and max to be 5 and 20, with randomize value selected,
it will generate a random value between 5 and 20 as the fog density for each voxel of the
source. If animated is selected, this randomization will also vary over time.
Here’s a complete list of properties that can be varied.
You can try varying, say, temperature or initial speed to see how it affects the simulation.
Right now the smoke still looks too uniform. To make it appear more natural, there are a few
things that we can do. For instance, we can go to the settings, and change the style from
“smooth” to “fluffy”.
And we can use “vorticity_influence” to stir up the smoke.
Connect this to “influences”,
and we start to see some swirling movement. If it is too much, we can tone it down here.
In real world, smokes dissipate, to simulate that, let’s add a “dissipation” influence.
And we can adjust the rate here to control how fast it decays.
If we play the simulation for a little while, we’ll see that the smoke penetrates this structure,
if we want this structure to act as a barrier, we can set it as a collider,
connect it to geometry, and the output to colliders,
this will make the smoke flow around the structure.
We can use a smaller detail size to eliminate the gap between the smoke and the barrier
surface.
Let’s also bring the monster into Bifrost and add it to the collider as well.
This prevents the smoke from permeating the body of the monster.
Here’s a rendered animation of this simulation.
Another commonly used influence for aero simulation is wind.
We can adjust the speed, direction and drag to drive the movement of the smoke.
That’s how we set up a typical aero simulation.
We have the simulation engine, source, settings, and optionally, colliders and influences.
In the future, to speed up the setup, we can get the node “basic_aero_graph”,
explode it and start from there.
Basic graphs for other types of simulation are also available.
For other types of simulations, the graph follows the same structure.
For example, if we want to simulate particles, we use the node “simulate_particles”
as the engine, and use “source_particles” and “particle_solver_settings”
to provide the source and settings.
And if you go to windows, open Bifrost Browser, you’ll find examples of different kinds
of visual effects, and you can import any of these graphs into the Bifrost graph editor.
That's all for today. In the next tutorial, we are going to apply what we've learned today to
generate fog for our landscape. Thanks for watching! Stay tuned and I'll see you next time.