DYNAMIC SMOKE SYSTEM

đź’ˇ
Find the most up-to-date documentation on northdock.games.
Chat with me on
Discord.
❤️
If you like Dynamic Smoke System, please consider leaving a review on the Asset Store page!

Jump to:

Setup

  1. Drag the Dynamic Smoke System prefab from Assets/Dynamic Smoke System/Prefabs into your scene.
  1. Add the DynamicSmokeSystemCameraDepth.cs script to your camera.
  1. Ensure there is at least one directional light that affects the Dynamic Smoke System.
    đź’ˇ
    Without a directional light, the smoke will be lit incorrectly.
  1. For URP users only: unpack the URP_Unpack_Me.unitypackage
  1. For HDRP users only: unpack the HDRP_Unpack_Me.unitypackage

Usage

  1. Find the reference to the Dynamic Smoke System in your scene, for example:
    var dynamicSmokeController = GameObject.FindObjectOfType<DynamicSmokeSystemController>();

  1. Use dynamicSmokeController.Emit(Vector3 position) to make the smoke appear.
    đź’ˇ
    You can also provide an additional argument float disperseDelay to automatically make the smoke disperse after the provided delay.

  1. Shoot bullets or other projectiles through the smoke by using the following method:
    var projectile = new LineProjectileModel(startPosition, endPosition, radius);
    dynamicSmokeSystemController.AddProjectile(projectile);

  1. Create explosions or other effects that should displace smoke by using the following method:
    var projectile = new SphereProjectileModel(position, radius);
    smokeSystemController.AddProjectile(projectile);

  1. Customize the appear, stay and disappear durations of a projectile:
    var projectile = new SphereProjectileModel(position, radius);
    
    // The duration that the projectile will grow.
    projectile.GrowDuration = 0.1f;
    
    // The duration that the projectile will exist.
    projectile.StayDuration = 2;
    
    // The duration that the projectile will shrink until it is disappeared.
    projectile.ShrinkDuration = 3;
    
    // Makes all durations above multiplied by 2 (default = 1).
    projectile.DurationMultiplier = 2;
    
    smokeSystemController.AddProjectile(projectile);

  1. Disperse the smoke with the following method:
    dynamicSmokeSystemController.Disperse();

Customization

  1. You can customize the behaviour of the smoke in the Dynamic Smoke System Controller component on the prefab:

    Amount: the amount of cells that the smoke will try to fill. Be careful with values higher than 20k, since it will impact performance.

    Amount Max Per Frame: the maximum amount of cells the smoke attempts to fill per frame. Higher values will cause bigger frame drops.

    Cell Size: the size of one cell in world space. Lower values will yield more accurate results, however will make the final “size” of the cloud smaller.

    Smooth: the amount of smoothing applied on the cells of the smoke. Lower values will smooth more, but will make the smoke less accurate (causing possible clipping through walls and such).

    Layer Mask: the layer mask that will be used to determine if a cell is blocked by level geometry. Performance can be improved by minimizing the amount of objects that are in the selected layers.

    SDF Texture Resolution: the resolution of the internal 3D texture used to render the cloud. A higher value will be less performant, but can give more accuracy for projectiles used in the smoke. Keeping it to 32 should suffice for most uses.

  1. You can customize the visuals of the smoke in material properties:

    Density Step Count: a higher number will yield more accurate smoke rendering, but will cost more performance.

    Light Step Count: a higher number will yield more accurate light calculation in the smoke, but will cost more performance.

    Depth Bias: if you experience glitches with smoke appearing through walls, it can help to change the depth bias. Make sure your walls are not too thin, the cell size is tuned to your level geometry and your Smooth value is not too high.

Troubleshooting

Q: Why does the cloud look incorrect / unlit?

A1: Make sure there is a directional light that affects the Dynamic Smoke System.

A2: For URP and HDRP users, try forcing the Depth Texture setting in the inspector of your camera to “ON”.

A3: Make sure the Dynamic Smoke System prefabs are not parented to any other object; they need to be in the root of the scene.

Q: When calling Emit(), I don’t see any smoke?

A: Usually when this happens, you’re trying to emit smoke inside a collider or under the ground. A common scenario is emitting at the position of your smoke grenade, but Dynamic Smoke System’s layer mask is still including the layer mask of the grenade. Either emit with an offset, or remove the layer of the grenade in the layer mask of the Dynamic Smoke System.

Q: Why are transparent objects / particles not layered correctly with the smoke?

A: Layering transparent objects can look incorrect with smoke. It can be resolved by enabling “use alpha dithering”: this will cause the smoke to be an opaque object, which fixes layering with transparent objects. If you want to keep it transparent, you can change the render queue values in the materials of the objects to force an object to render in front of or behind the smoke.

Q: The smoke is not visible in orthographic view, is it supported?

A: No, orthographic rendering is currently not supported.

Q: Which pipelines are supported?

A: Built-in and URP.

Q: Is VR supported?

A: Probably not, but I didn’t test it.

Q: Is WebGL or WebGPU supported?

A: No, they are unsupported.

Q: Where is the the “alpha dithering” option?

A: It can be found as a toggle on the material. It’s currently only supported for built-in and URP, not for HDRP yet.