Explosion Fireball Shader

A fireball that swells out of nothing, burns from white to orange to red, then turns to dark smoke and breaks up. It’s one SphereMesh with this shader as Material Override. Noise pushes the surface in and out, so the outline is lumpy and every blast is a bit different.

Use a SphereMesh with radius 1, height 2 and at least 48 segments and 24 rings. Don’t scale the node to animate it, the shader grows the ball itself. Run progress from 0 to 1 over a second or two and set size to the final radius in metres. seed changes the lumps. An OmniLight3D in the same spot, fading with progress, helps a lot. The first frames used to blow out to plain white, so the default emission is lower now and you can see the lumps.

Turn Glow on. No textures, and it looked the same on Forward+, Mobile and Compatibility in 4.4 and 4.7.

The code was written with the help of an AI coding assistant.

I wrote this as a small take on the fireballs in my Explosion VFX pack for Godot 4, which has 20 explosion types with shockwaves and debris.
https://gennai.itch.io/explosion-vfx-godot-4?utm_source=godotshaders&utm_medium=referral&utm_campaign=fireball

Shader code
// Explosion Fireball on One Sphere for Godot 4
// MIT License. Copyright (c) 2026 gennai (https://gennai.itch.io)
//
// A fireball that swells out of nothing, burns white to orange to red, then turns to dark
// smoke and breaks apart. It is one SphereMesh with this shader as Material Override. The
// surface is pushed in and out by noise, so the outline is lumpy and no two blasts look
// alike. Use a SphereMesh with radius 1, height 2 and at least 48 segments and 24 rings.
// Do not scale the node to animate it: the shader grows the ball by itself.
//
// Animate progress from 0 to 1 over 1 to 2 seconds. size is the final radius of the ball in
// metres. seed changes the lumps, so two explosions next to each other are different. Add an
// OmniLight3D at the same place and fade it with progress for light on the surroundings.
// Values above 1 in emission bloom when Glow is on in the WorldEnvironment.
// No textures: the noise is computed in the shader with sin-free hashes, so it looks the
// same on every renderer.
shader_type spatial;
render_mode unshaded, blend_mix, depth_draw_never, cull_back, shadows_disabled, fog_disabled;

group_uniforms blast;
// 0 = the blast starts, 1 = nothing is left. Animate this.
uniform float progress : hint_range(0.0, 1.0) = 0.3;
// Final radius of the fireball, in metres.
uniform float size : hint_range(0.1, 20.0) = 1.2;
// How lumpy the outline is.
uniform float lumpiness : hint_range(0.0, 1.0) = 0.45;
// Size of the lumps. Higher = smaller lumps.
uniform float noise_scale : hint_range(0.5, 6.0) = 1.8;
// How fast the flames churn.
uniform float churn : hint_range(0.0, 4.0) = 1.0;
// Changes the lumps and the pattern.
uniform float seed : hint_range(0.0, 100.0) = 0.0;

group_uniforms look;
// The hottest colour at the start.
uniform vec4 color_core : source_color = vec4(1.0, 0.85, 0.5, 1.0);
// Main flame colour.
uniform vec4 color_flame : source_color = vec4(1.0, 0.45, 0.05, 1.0);
// Colour of the cooling flame.
uniform vec4 color_ember : source_color = vec4(0.6, 0.08, 0.02, 1.0);
// Colour of the smoke at the end.
uniform vec4 color_smoke : source_color = vec4(0.07, 0.065, 0.06, 1.0);
// Brightness. Values above 1 bloom when glow is on.
uniform float emission : hint_range(0.0, 8.0) = 1.9;

varying vec3 v_pos;
varying float v_lump;

float fb_hash(vec3 p) {
	vec3 p3 = fract(p * 0.1031);
	p3 += dot(p3, p3.zyx + 31.32);
	return fract((p3.x + p3.y) * p3.z);
}

float fb_noise(vec3 p) {
	vec3 i = floor(p);
	vec3 f = fract(p);
	f = f * f * (3.0 - 2.0 * f);
	float a = mix(fb_hash(i), fb_hash(i + vec3(1.0, 0.0, 0.0)), f.x);
	float b = mix(fb_hash(i + vec3(0.0, 1.0, 0.0)), fb_hash(i + vec3(1.0, 1.0, 0.0)), f.x);
	float c = mix(fb_hash(i + vec3(0.0, 0.0, 1.0)), fb_hash(i + vec3(1.0, 0.0, 1.0)), f.x);
	float d = mix(fb_hash(i + vec3(0.0, 1.0, 1.0)), fb_hash(i + vec3(1.0, 1.0, 1.0)), f.x);
	return mix(mix(a, b, f.y), mix(c, d, f.y), f.z);
}

float fb_fbm(vec3 p) {
	float s = 0.0;
	float a = 0.5;
	for (int o = 0; o < 4; o++) {
		s += fb_noise(p) * a;
		p = p * 2.02 + 7.3;
		a *= 0.5;
	}
	return s / 0.9375;
}

void vertex() {
	float t = progress;
	// The ball swells fast and slows down.
	float grow = 1.0 - pow(1.0 - clamp(t * 1.5, 0.0, 1.0), 3.0);
	vec3 dir = normalize(VERTEX);
	float n = fb_fbm(dir * noise_scale * 1.5 + vec3(0.0, -TIME * churn * 0.6, 0.0) + seed * 3.1);
	v_lump = n;
	float r = size * grow * (1.0 + (n - 0.5) * lumpiness * 1.6);
	v_pos = dir;
	VERTEX = dir * r;
}

void fragment() {
	float t = progress;
	vec3 p = v_pos * noise_scale * 2.2 + seed * 3.1;
	float n = fb_fbm(p + vec3(0.0, -TIME * churn, 0.0));
	float n2 = fb_noise(p * 3.0 - vec3(0.0, TIME * churn * 1.8, 0.0));
	float fres = pow(clamp(dot(NORMAL, VIEW), 0.0, 1.0), 0.7);
	// A burning front eats the ball from the noise's low parts: the ball breaks apart late.
	float cut = smoothstep(0.5, 1.0, t) * 0.95;
	float field = n * 0.8 + n2 * 0.2;
	float alive = smoothstep(cut * 0.95, cut * 0.95 + 0.12, field + 0.12 - cut * 0.1);
	// Heat falls over time and is higher in the middle of the view of the ball.
	float heat = clamp(1.0 - t * 1.0 + (field - 0.5) * 0.9 + fres * 0.2, 0.0, 1.0);
	vec3 col;
	if (heat > 0.66) {
		col = mix(color_flame.rgb, color_core.rgb, (heat - 0.66) / 0.34);
	} else if (heat > 0.33) {
		col = mix(color_ember.rgb, color_flame.rgb, (heat - 0.33) / 0.33);
	} else {
		col = mix(color_smoke.rgb / max(emission, 0.001), color_ember.rgb, heat / 0.33);
	}
	// Smoke takes over as the heat drops.
	float smoke = 1.0 - smoothstep(0.0, 0.45, heat);
	vec3 rgb = col * emission;
	rgb = mix(rgb, color_smoke.rgb * (0.6 + 0.8 * n), smoke * smoke);
	float a = alive * fres;
	// The flash at the very start is fully opaque, the end fades out.
	a *= 1.0 - smoothstep(0.88, 1.0, t);
	a = mix(a, min(1.0, a * 1.8), 1.0 - smoke);
	ALBEDO = rgb;
	ALPHA = clamp(a, 0.0, 1.0) * smoothstep(0.0, 0.03, t);
}
Live Preview
Tags
3d, blast, explosion, fire, fireball, noise, Procedural, Smoke, sphere, vfx
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from gennai

Related shaders

Comments 0

No comments yet.