Interactive Fog
intermediate conceptsVolumetric Fog & Mist 3 · Core Concepts
With Enable Fluid Simulation on, the fog of a fog volume moves like air. Objects push it and open trails in it, scripts can blow it away, Fog Jets expel more fog into the air, Fog Obstacles make it flow around solid objects, and the fog comes back over time. The fog only reacts inside a square area around a target, usually the player, so the cost does not grow with the size of the fog volume.
Simulation Settings
| Setting | Description |
|---|---|
| Area Center | The simulated area stays centered on this object, usually the player. With no object, it stays centered on the fog volume. |
| Area Size | Size in meters of the square area where objects can push the fog. Outside this area the fog does not react. |
| Resolution | Detail of the simulated air motion. Higher values allow smaller swirls and use more memory and time. |
| Fog Resolution | Detail of the simulated fog. Higher values allow thinner trails and use more memory and time. |
| Pressure Steps | Quality of the simulation. More passes give smoother and rounder swirls and are slower. |
| Auto Simulate | Runs the simulation every frame in Play mode. Disable it to call SimulateFluid from a script. |
Fog Motion
| Setting | Description |
|---|---|
| Refill Time | Seconds that the fog takes to come back after an object clears it. |
| Air Motion Time | Seconds that the air keeps moving after a push. |
| Shape Drag Time | Seconds that the fog shapes stay stretched after the air moves them. |
| Max Shape Drag | Longest distance in meters that the moving air stretches the fog shapes. |
| Swirl | Strength of the small swirls that appear in the moving fog. |
| Pile | How much fog gathers in front of a moving object. |
When you change Coverage Amount, Patch Size, Clear Areas or Border Softness in the editor, the simulated fog goes back to rest.
Fog Pusher
Add a Fog Pusher component to an object that moves, such as the player, an animal or a vehicle. You can also create one with GameObject > Effects > Volumetric Fog & Mist 3 > Fog Pusher and make it a child of the object.
| Setting | Description |
|---|---|
| Radius | Radius in meters of the area where the object pushes the fog. |
| Push | How much of the speed of the object passes to the fog. Higher values push the fog further. |
| Clear | How much fog the object removes under it, from 0 (nothing) to 1 (all). |
| Full Clear Speed | Shown under Clear. Speed in meters per second at which the object removes the full Clear amount; a slower object removes less. With 0 the object also removes the fog when it does not move. |
| Vertical Radius | Reach in meters above and below the object. With 0 it reaches the whole height of the fog of the ground, and its Radius in the fog of a jet. |
Fog Pushers also push and clear the fog of the Fog Jets that they cross. Up to 16 Fog Pusher objects inside the simulated area act at the same time.
Fog Jet
A Fog Jet is a nozzle that expels fog through the air, for example steam from a pipe, smoke from a chimney or a fog machine. The fog leaves the nozzle along the forward direction of the object, falls or rises, curls in the air and joins the fog of the ground where it lands. Create one with GameObject > Effects > Volumetric Fog & Mist 3 > Fog Jet and turn it so that its blue arrow points where the fog must go.
The fog of the jet only moves inside the box of the jet. Drag the handles of the box in the Scene view to change its size. A smaller box shows more detail.
Area
| Setting | Description |
|---|---|
| Area Size | Size in meters of the box where the fog of the jet moves. The fog fades at the sides and at the top of the box and lands on its bottom. A larger box shows less detail. |
| Area Center | Center of the box, as an offset in meters from the nozzle. |
| Animate Off Screen | Keeps the fog of the jet moving while no camera sees its box. When disabled, the jet stops while it is out of view, which saves its cost. |
Jet
| Setting | Description |
|---|---|
| Radius | Radius in meters of the nozzle. |
| Speed | Speed in meters per second of the fog that leaves the nozzle, along the forward direction of the object (the blue arrow). |
| Emission | Fog added per second at the nozzle. Low values give a thin jet. |
| Gravity | Speed in meters per second that the fog gains each second as it falls. Negative values make the fog rise. |
| Turbulence | How much the jet shakes and breaks into puffs at the nozzle. |
| Swirl | Strength of the swirls that curl the fog while it moves through the air. |
| Fog Lifetime | Seconds that the fog of the jet lasts in the air. |
Look
| Setting | Description |
|---|---|
| Color | Color of the fog of the jet. The fog of the ground takes this color where the jet lands, and colors of different jets mix as paint does. |
| Density | How opaque the fog of the jet looks. It does not change how much fog leaves the nozzle. |
Ground
| Setting | Description |
|---|---|
| Ground Emission | How much of the fog that lands joins the fog of the ground. |
| Ground Spread | How much the fog that lands pushes the fog of the ground away. |
A Fog Jet needs a fog volume with Enable Fluid Simulation in the scene, and its fog moves in Play mode. Up to 4 Fog Jets work at the same time; the inspector shows a warning on the jets over this limit. When a Fog Jet is added or removed, all the jets start again without fog.
Fog Obstacle
Add a Fog Obstacle component to a solid object, such as a wall, a column, a rock or a vehicle. The fog of the jets and the moving fog of the ground cannot cross it: the fog hits it, spreads over it and flows around it. An obstacle that moves pushes the fog.
The obstacle takes its shape from the collider of the object. The inspector shows which shape blocks the fog.
| Object | Shape that blocks the fog |
|---|---|
| Box Collider | The box of the collider. |
| Sphere Collider | The sphere of the collider. |
| Capsule Collider | The capsule of the collider. |
| Character Controller | The capsule of the character, always upright. |
| Any other collider | The box that holds the collider. |
| No collider | The box that holds the renderer of the object, or a box with the scale of the object. |
In the fog of the ground, the obstacles act inside the simulated area. Up to 8 Fog Obstacles that touch the simulated area or a jet work at the same time. If some fog passes through a thin wall, make its collider thicker. To keep the fog out of the inside of a building, use a Fog Void.
Blasts
A blast blows the fog away from a point, for example for an explosion. Call it from any script:
using FluidFogAndMist;
// position, radius in meters, speed of the pushed fog in meters per second
FluidFog.Blast(transform.position, 6f, 12f);
// with a turn of the fog around the center and a vertical reach of 3 meters
FluidFog.Blast(transform.position, 6f, 12f, spin: 4f, verticalRadius: 3f);
The blast reaches every fog volume with Fluid Simulation on whose simulated area contains the point. Up to 8 blasts act at the same time.
Reading the Fog Amount
A script can read the amount of fog of the simulation at a position, for example to hide a character in the fog:
if (fog.GetFluidFogAmount(player.position, out float amount)) {
bool hidden = amount > 0.5f;
}
The amount goes from 0 (no fog) to 1 (full fog). The value is a few frames old. The method returns false while there is no value, which happens with the simulation off and during the first frames.
Suggest an improvement
Help us improve this documentation page.