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;
}
Tags
glass, noise, normalmap, screen texture
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 miskatonicstudio

Aurora Borealis

Engine flame

Hexagon pattern

Related shaders

Simple 3D Glass

Procedural Stained-Glass Shader

Glass Square Effect Shader

guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Lucas Thomaz
2 months ago

Nice! to make it work in godot 4 add the following line:

uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;