GUIDE // THREE.JS

How to make a three.js fire flipbook look emissive with additive blending

Set blending to THREE.AdditiveBlending on your fire's material, with transparent set to true and depthWrite set to false, so each flame pixel adds its color to whatever is behind it and black parts disappear. Keep smoke on normal blending in a separate material, because additive smoke turns into glowing fog.

  • Godot 4 Available
  • Unity Manual setup
  • Unreal Engine Manual setup
  • Roblox Studio Manual setup
  • three.js Available

A draft compile is from $0.05, and new accounts start with $5 of usage.

FIRE_WHIRLFINAL
First frame of the fire_whirl bake
Fire whirl, 4.4 x 7.1 m, compiled with Spatial Compiler. Spec →

01 // WHAT YOU NEED

Two sheets make the flame

In a Spatial Compiler compile the flame color is the RGB of main_colour.png, and its brightness is the alpha of main_neg.png, stored as a square root against a per-clip maximum so the white-hot core keeps detail in 8 bits. layout.json records that maximum as scales.emit_max_hdr.

The flame is the color times the squared brightness times that maximum. A ShaderMaterial can read both sheets and do the decode, so you skip combining images.

02 // HOW TO

Build the fire material

  1. Load main_colour.png and main_neg.png, and leave their colorSpace at the default so the shader gets the stored values.
  2. Make a ShaderMaterial with both textures, the frame and emitMax as uniforms, and the blending settings in fireMaterial.js.
  3. Put it on a PlaneGeometry mesh and turn the mesh toward the camera each tick, as in the camera-facing guide.
  4. Set uniforms.frame.value each tick from elapsed time times 32, wrapped at 64.
  5. For a glow around the flames, add a bloom pass from the three.js postprocessing addons. Without it, values above 1 clip to white.
fireMaterial.js
const fireMaterial = new THREE.ShaderMaterial({
  uniforms: {
    colourMap: { value: colourTexture }, // main_colour.png
    negMap: { value: negTexture },       // main_neg.png
    frame: { value: 0 },
    emitMax: { value: 4.39 },            // scales.emit_max_hdr from layout.json (2 s fire)
  },
  vertexShader: `
    varying vec2 vUv;
    void main() {
      vUv = uv;
      gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
    }`,
  fragmentShader: `
    uniform sampler2D colourMap;
    uniform sampler2D negMap;
    uniform float frame;
    uniform float emitMax;
    varying vec2 vUv;
    void main() {
      vec2 cell = vec2(mod(frame, 8.0), 7.0 - floor(frame / 8.0));
      vec2 uv = (vUv + cell) / 8.0;
      float b = texture2D(negMap, uv).a;
      vec3 flame = texture2D(colourMap, uv).rgb * b * b * emitMax;
      gl_FragColor = vec4(flame, 1.0);
    }`,
  transparent: true,
  depthWrite: false,
  blending: THREE.AdditiveBlending,
});

03 // REAL OUTPUT

A steadier flame

The 2 s fire has a lower, wider core than the whirl, and the same material plays it.

FIREFINAL
First frame of the fire bake
Fire, 4.1 x 7.0 m, compiled with Spatial Compiler. Spec →

Godot 4 gets a ready scene that relights the smoke. three.js uses the documented snippet. A native six-way material is not built yet.

05 // FAQ

three.js additive fire questions

All questions →

README.THREEJS_ADDITIVE_FIRE
How do I blend flame and smoke in three.js?

Use two sprites. Put the flame on a SpriteMaterial with THREE.AdditiveBlending and the smoke on normal blending, both with depthWrite false.

How to import a fire, smoke or explosion sprite sheet into three.js?

Load the PNG with THREE.TextureLoader, set texture.repeat to one grid cell and assign it to a SpriteMaterial map. Update texture.offset to change frames.

How do I make a fire flipbook glow without lighting the smoke?

Keep flame on an unlit additive or emissive material and smoke on a lit alpha blended material so only flame triggers bloom.

How do compression, color space and HDR affect PNG and EXR VFX textures?

Compression can smear data channels, color space controls sRGB versus linear reads and HDR requires float EXR or encoded alpha.

Compile your first effect

You pay per compile and see the price before it runs. New accounts start with $5 of usage.

All effects, guides and explainers →