Screen Smoke/Fog

Quite useful for 2D and UI effects.

ColorRect node is recommended as it’s the lightest drawable Control node.

In the shader parameters:

Create a Noise Texture,
Set the width and height to a multiplier of your aspect ratio, ideally 160×90,
Set noise_type to Simplex (optional)
Enable seamless,
Set seamless_blend_skirt to 1.0,
Disable normalized

You’re good to go, enjoy

Shader code
shader_type canvas_item;

// Uniforms for customization
uniform sampler2D noise_texture : repeat_enable;
uniform vec3 smoke_color : source_color = vec3(0.8);
uniform float distortion_speed : hint_range(0.0, 5.0) = 0.2;
uniform float density : hint_range(0.0, 1.0) = 1.0;

void fragment() {
    // Pre-calculate time-based offsets
    float time_offset_1 = TIME * distortion_speed * 0.1;
    float time_offset_2 = TIME * distortion_speed * 0.2;
    
    // Sample noise with distortion
    vec4 noise = texture(noise_texture, UV + time_offset_1);
    
    // Create distorted UV and sample final noise
    vec2 distorted_uv = UV + noise.rg * 0.1 - 0.05 + time_offset_2;
    float final_noise = texture(noise_texture, distorted_uv).r;
    
    float smoke_alpha = final_noise * density;
    
    // Output color
    COLOR = vec4(smoke_color, smoke_alpha);
}
Live Preview
Tags
Fog, Smoke
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

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
tomek
tomek
3 months ago

hi,

i am using the shader for my game.

is there any change to give the shader a margin so that if one is using the fog on non white background to avoid the “hardline” of the fog?