Frosted glass
This shader uses a normalmap texture to distort the view and create a frosted glass effect. The repo provides 2 textures: a .png file (created using Blender) and an instance of NoiseTexture2D (built into Godot Engine).
The day environment HDRI is in public domain and can be downloaded from ambientCG.
Shader code
shader_type spatial;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
uniform sampler2D glass_normal : hint_normal;
uniform float distortion_size = 0.2;
void fragment() {
vec2 d = texture(glass_normal, UV).rg * 2.0 - vec2(1.0);
ALBEDO = texture(SCREEN_TEXTURE, SCREEN_UV + d * distortion_size).rgb;
}
Nice! to make it work in godot 4 add the following line:
Hi and sorry for a super delay, I don’t get any notifications from this website π
Thank you for your contribution! The shader was upgraded to Godot 4, so now it includes that line of code π
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);
Hi and sorry for the delay, I don’t get any notifications from this website π
Thank you for this improvement! I added a GitHub issue to implement it at some point (when I find the time π ):
https://github.com/miskatonicstudio/godot-experiments/issues/19
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/
Hi and sorry for the delay, I donβt get any notifications from this website π
Thank you for the updated version! I like learning how to improve my work π
I created a GitHub issue to implement your changes (assuming I will find some time π ):
https://github.com/miskatonicstudio/godot-experiments/issues/20