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;
		
}
Tags
sea, water
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 WaltGD

Cheap terrain with fake normal map or POM

Cheap caustics

Related shaders

Simple, cheap stylized tree shader

Cheap terrain with fake normal map or POM

Cheap caustics

Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
AverageGodotEnjoyer
6 months ago

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/

alefranart
alefranart
3 months ago

Thanks for your help!