Textured Fireworks

Looks especially good on a pixel res game. Make the explosion_value higher to see instant results.

Shader code
shader_type canvas_item;

uniform float explosion_value = 0.0;
uniform float particle_size = 0.2;
uniform float number_of_particles = 50.0;

uniform float expansion_multiplier = 1.0;
uniform float fall_multiplier = 1.0;

uniform float falloff_point = 2.0;
uniform float falloff_spread = 0.5;

float random (vec2 uv) {
	return fract(sin(dot(uv.xy,
		vec2(12.9898,78.233))) * 43758.5453123);
}

float is_particle(in vec2 expanded_uv, in float expand_value) {
	float random_displacement = 0.0;
	expanded_uv.y += -random(round(expanded_uv * number_of_particles)) * expand_value * 0.2;
	expanded_uv.x += random(round(expanded_uv * (number_of_particles + 1.0))) * expand_value * 0.1;
	float is_circle = length((round(expanded_uv * number_of_particles)) - (expanded_uv * number_of_particles));
	return is_circle;
}

void fragment() {
	float expand_value = max(0.001, explosion_value * expansion_multiplier);
	float clamped_explosion_value = max(0.1, explosion_value);
	vec2 centered_uv = UV - vec2(0.5);
	vec2 expanded_uv = (centered_uv / (expand_value));

	expanded_uv.y -= (clamped_explosion_value * -cos(centered_uv.x) * fall_multiplier);
	expanded_uv.y -= clamped_explosion_value * fall_multiplier;
	vec4 pixel_color = texture(TEXTURE, expanded_uv + 0.5);
	float multiplier = 50.0;

	float new_particle_size = min(particle_size,
	(falloff_point - clamped_explosion_value) - (random(round(expanded_uv * number_of_particles)) * expand_value * falloff_spread));
	COLOR = (is_particle(expanded_uv, clamped_explosion_value) > new_particle_size ? vec4(0.0) : pixel_color);
}
Live Preview
Tags
2d, fireworks, Textured
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments