Cheap water shader
Unshade cheap deform water, with texture BW caustics 256px.
Shader code
shader_type spatial;
render_mode specular_schlick_ggx, unshaded, cull_back, async_visible;//
uniform vec4 tint_color : hint_color = vec4( 0.3, 0.4, 0.45, 1.0);
uniform sampler2D caustics : hint_white;
uniform float slowdown : hint_range( 0.1, 10.0, 0.1 ) = 5.0;
uniform float time_caust : hint_range( 0.01, 1.0, 0.01 ) = 0.13;
uniform float caust_form : hint_range( 0.01, 1.0, 0.01 ) = 0.15;
uniform float tile: hint_range( 0.1, 16.0, 0.1 ) = 4.0;
void fragment() {
// Caustics
float caustics_form = texture(caustics , UV * (tile + sin(TIME / slowdown) * time_caust )).r;//
vec2 caustics_uv = UV * (tile + cos(TIME / slowdown) * time_caust ) + caustics_form * caust_form ;
float caustics_final = texture(caustics, caustics_uv).r;
ALBEDO = (1.0-SCREEN_UV.y) * caustics_final * tint_color.rgb ;
ALPHA = min(SCREEN_UV.y + 0.5, 1.0 ) * tint_color.a;
}
To use this with Godot 4 you have to replace some of the shader variables with new ones.
First delete async_visible
Second replace hint_color with source_color
Third replace hint_white with hint_default_white
now you should be good to go!
I used this reference here. To find the changed shader variables hope this helps someone.
https://godot-migration.byteatati.me/
Thanks for your help!
So that wepage was taken down but I have it archived on my site here:
https://AverageGodotEnjoyer.com
Its the download link that says godot 3 shaders vs godot 4 shaders changes
You can download the zip which has the complete webpage for you to look at.
I didn’t create it I just grabbed it with the way back machine.
Happy coding everyone.