Frosted glass
A shader that creates an effect of a frosted glass surface. By default it works with a noise texture, but if a normalmap texture is used instead, it can create any glass surface type (e.g. lens).
Shader code
shader_type spatial;
uniform float distortion_size = 0.4;
uniform sampler2D glass;
void fragment() {
vec2 d = texture(glass, UV).xy - vec2(0.5);
ALBEDO = texture(SCREEN_TEXTURE, SCREEN_UV + d * distortion_size).rgb;
}
Nice! to make it work in godot 4 add the following line:
This is great! I tweaked it a little so you can change its color and opacity.
You may also find you get better results by changing this line:
vec2 d = texture(glass, UV).xy – vec2(0.5);
To this:
vec2 d = texture(glass, UV).xy – vec2(0.25);
The distortion gets more intense as you travel further. I made a slight modification to the shader to fix that here: https://godotshaders.com/shader/improved-frosted-glass/