28 lines
977 B
Plaintext
28 lines
977 B
Plaintext
shader_type canvas_item;
|
|
uniform vec4 water_color : source_color = vec4(0.0, 0.0, 1.0, 1.0);
|
|
uniform sampler2D noise_tex; // noise texture
|
|
uniform vec2 noise_speed = vec2(0.05, 0.01);
|
|
uniform float noise_strength = 0.2; // how much to lighten/darken
|
|
|
|
void fragment() {
|
|
vec2 uv = UV;
|
|
vec4 base_tex = texture(TEXTURE, uv);
|
|
float is_water = step(0.8, 1.0 - distance(base_tex.rgb, water_color.rgb));
|
|
|
|
// Scroll UVs for noise animation
|
|
vec2 noise_uv = SCREEN_UV + noise_speed * TIME;
|
|
vec4 noise_sample = texture(noise_tex, fract(noise_uv));
|
|
|
|
// Use noise (0..1) to brighten/darken the water color
|
|
float brightness = (noise_sample.r - 0.5) * 2.0 * noise_strength;
|
|
vec4 animated_water = water_color + vec4(vec3(brightness), 0.0);
|
|
|
|
|
|
COLOR = mix(base_tex, animated_water, is_water);
|
|
}
|
|
|
|
//void light() {
|
|
// // Called for every pixel for every light affecting the material.
|
|
// // Uncomment to replace the default light processing function with this one.
|
|
//}
|