Image Warp Shader

It warpes the projected image using three noise textures.

Apply to a colorRect or MeshInstance2D. 


If you have any ideas on how to make the shader better, let me know.

Shader code
//shader is really unoptimised and not made by someone who knows much about shaders, 
//but someone who makes stuff that poorly work, if at all. 

shader_type canvas_item;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
uniform sampler2D noise_1;
uniform sampler2D noise_2;
uniform sampler2D noise_3;
uniform float strenght = 0.85;
uniform float speed = 5.0;

void fragment() {
	float noiseValue = 0.0;
	float time = (TIME - floor(TIME)) * speed;
	time = time - float(int(time));
	if (time  0.33 && time  godot shader

	vec2 iResolution = 1.0 / SCREEN_PIXEL_SIZE;
	vec4 fragCoord = FRAGCOORD;
	vec2 p = fragCoord.xy / iResolution.x;
	float prop = iResolution.x / iResolution.y;
	vec2 m = vec2(0.5, 0.5 / prop);
	vec2 d = p - m;
	float r = sqrt(dot(d, d)); 
	vec2 uv;
	uv = p + noiseValue / (100.0 / strenght);
	uv.y *= prop;
	vec3 col = texture(SCREEN_TEXTURE, uv).rgb;
	COLOR = vec4(col, 1.0);
Warp Noise Canvas Item
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

Perspective Warp/Skew Shader

Visual Effects with an Image Mask

Speed Lines Shader for Godot 4

Notify of

Newest Most Voted
Inline Feedbacks
View all comments
23 days ago

I don’t really know what you mean with “make the shader better”, but…
at lines 18 and 19, can’t you simply use fract(TIME)?
and the next if-else statements… can’t you combine 2 mix with step?
like: mix1= mix(noise_1, noise_2, step(0.33, time))
and then mix(mix1, noise_3, step(0.66, time))
this is because the people always says that you must avoid “ifs” in shaders. I don’t really know if it’s better or not in terms of performance to be honest.

6 days ago

Error: Redefenition of ‘SCREEN_TEXTURE’