This repository has been archived on 2025-09-28. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
rectangular/addons/godot-rapier2d/water_shader.gdshader

22 lines
631 B
Text
Raw Permalink Normal View History

2024-09-25 21:18:58 +02:00
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);
}
}