SupaLidlGame/Shaders/Water.gdshader

20 lines
744 B
Plaintext
Raw Normal View History

2023-08-01 02:10:55 -07:00
shader_type canvas_item;
uniform float alpha : hint_range(0.0, 1.0) = 0.75;
uniform float water_speed = 0.05;
uniform float wave_distortion = 0.2;
uniform sampler2D noise_texture : repeat_enable;
uniform sampler2D noise_texture2 : repeat_enable;
2023-08-01 23:49:48 -07:00
uniform vec2 reflection_offset = vec2(0, 0);
2023-08-01 02:10:55 -07:00
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
void fragment() {
vec2 scroll1 = vec2(water_speed);
vec2 scroll2 = vec2(-water_speed);
float depth = texture(noise_texture, UV + scroll1 * TIME).r *
texture(noise_texture2, UV + scroll2 * TIME).r;
2023-08-01 23:49:48 -07:00
vec4 screen = texture(SCREEN_TEXTURE,
SCREEN_UV + wave_distortion * vec2(depth) + reflection_offset);
2023-08-01 02:10:55 -07:00
COLOR = screen;
COLOR.a = alpha;
}