I-HATE-THE-FUCKING-HORSE-GAME/addons/godot-rapier2d/water_shader.gdshader
2025-07-23 17:01:02 -06:00

22 lines
No EOL
631 B
Text

shader_type canvas_item;
uniform float threshold = 0.8;
uniform vec4 water_color: source_color = vec4(0.12,0.24,0.45,0.65);
uniform vec4 test_color: source_color = vec4(1,0,1,1);
uniform float speed = 0.1; // Speed of movement
uniform float amplitude = 0.1; // Amplitude of movement
uniform sampler2D water_texture;
void fragment(){
float displacement = sin(TIME * speed) * amplitude;
vec4 screen_tex = texture(TEXTURE, SCREEN_UV).rgba;
float color_distance = screen_tex.r;
if (color_distance > threshold) {
COLOR = texture(water_texture, SCREEN_UV + displacement).rgba * water_color;
} else {
COLOR = vec4(0.0);
}
}