fix snow and water ripples + add water colors

This commit is contained in:
2026-04-30 06:53:54 +02:00
parent ead4e557c4
commit 889334e7a3
11 changed files with 108 additions and 55 deletions

View File

@@ -2,6 +2,7 @@ shader_type spatial;
render_mode blend_mix, depth_draw_always;
global uniform float global_rain_intensity;
global uniform vec4 global_water_color = vec4(0.285, 0.534, 0.487, 1.0);
//Water color
uniform vec4 deep_water_color : source_color = vec4(0.0, 0.1, 0.2, 1.0);
@@ -44,12 +45,14 @@ void fragment() {
float water_depth_gradient = exp(-depth_difference * beer_law_factor);
vec4 base_water = mix(deep_water_color, shallow_water_color, water_depth_gradient);
float rain_intensity = clamp(global_rain_intensity, 0.0, 1.0);
base_water.rgb = mix(base_water.rgb, global_water_color.rgb, 0.7);
vec2 pos = world_pos_xz * ripple_scale;
vec2 cell = floor(pos);
vec2 local_pos = fract(pos) - 0.5;
float random_val = fract(sin(dot(cell, vec2(12.9898, 78.233))) * 43758.5453);
float is_active_cell = step(1.0 - ripple_density, random_val);
float active_ripple_density = ripple_density * rain_intensity;
float is_active_cell = step(1.0 - active_ripple_density, random_val);
float ring = 0.0;
if (is_active_cell > 0.0) {