Underwater Camera effect
I modified this:
To work with 3d and have a customizable tint.
To use: put this shader on a plane, put the plane over the camera your using.
Shader code
shader_type spatial;
render_mode unshaded;
uniform vec4 tint : hint_color; // tint effect
uniform float wave_speed = 3.0; // wave loop speed
uniform float wave_freq = 10.0; // wave vertical freq
uniform float wave_width = 1; // wave width
void fragment(){
vec2 scale_UV = SCREEN_UV;
vec2 wave_uv_offset;
wave_uv_offset.x = cos((TIME*wave_speed)+UV.x+UV.y*wave_freq*2.0)*wave_width*0.01;
ALBEDO = texture(SCREEN_TEXTURE, SCREEN_UV+wave_uv_offset).rgb*tint.rgb;
}
Hi! Cool shader but I don’t understand how to use it. What do you mean by “on a plane”? Is it a Quad Mesh? A 2D Rect? Thank you
Create a meshinstance, in the “Mesh” slot inside it, give it a “PlaneMesh” (the same way you would make a box or a sphere).
Then give it a shader material, put this shader in the material you just added to the meshinstance, put the mesh in front of the camera and you should see the effect.
For anyone wanting to use this: Note that this shader doesn’t handle transparency correctly. Not sure why.
Turns out it has to do with godots rendering pipeline and some other things.
Similar to what you see here:
https://godotengine.org/qa/33794/transparent-material-behind-material-refraction-visible
Set ALPHA = 0.3;
does not work in Godot 4, big sad.