Noise-Based Moving Smoke Effect

This shader creates a dynamic, moving smoke effect with customizable parameters. It uses a noise texture to distort and animate the smoke over time, giving it a natural flowing appearance. You can control the color of the smoke, adjust the distortion speed, and specify a noise texture to define the pattern of movement. Ideal for adding atmospheric effects or creating organic, evolving textures in your Godot projects. Make sure to add noise texture for smoke like effect. Change the width and the height of the noise texture for various densities.

Shader code
shader_type canvas_item;

uniform sampler2D noise_texture: repeat_enable;
uniform vec4 smoke_color: source_color;
uniform float distortion_speed: hint_range(0.0, 5.0, 0.1) = .5;

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

void vertex() {
	VERTEX.x += sin(TIME * cos(TIME) * length(random(UV * random(vec2(.5)))) * distortion_speed/ 3.0) * length(random(UV)) * 50.0;
	VERTEX.y += cos(TIME * sin(TIME) * length(random(UV)) * distortion_speed/ 3.0) * length(random(UV)) * 50.0;

}
void fragment() {

	vec4 color = texture(noise_texture, UV + vec2(sin(TIME / 10.0)));
    vec2 uv = UV;

    vec2 centered_uv = uv - vec2(0.5);

    float distance = length(centered_uv);

    float radius = 0.2; // Adjust for how far the effect should extend
    float softness = -0.3; // Adjust for the smoothness of the transparency gradient

    // Compute the transparency based on the distance
    float alpha = smoothstep(radius, radius - softness, distance);

    COLOR = vec4(smoke_color.rgb, color.r);
    COLOR.a *= 1.0 - alpha;

}
Tags
2d fog, 2d shader, color smoke, fog 2d, fog shader, moving smoke in 2d, Smoke, smoke shader 2d
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.

More from gamifiedsoul

Circular Pattern Shader

Related shaders

Moving circles effect with size depending on a gradient

Smoke Shader

Industrial Smoke

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments