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.
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
- Load
main_colour.pngandmain_neg.png, and leave theircolorSpaceat the default so the shader gets the stored values. - Make a
ShaderMaterialwith both textures, the frame andemitMaxas uniforms, and the blending settings infireMaterial.js. - Put it on a
PlaneGeometrymesh and turn the mesh toward the camera each tick, as in the camera-facing guide. - Set
uniforms.frame.valueeach tick from elapsed time times 32, wrapped at 64. - For a glow around the flames, add a bloom pass from the three.js postprocessing addons. Without it, values above 1 clip to white.
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.
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.
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.