fix snow
This commit is contained in:
@@ -3,6 +3,12 @@ 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);
|
||||
global uniform float global_snow_start_time = -1.0;
|
||||
global uniform float global_snow_accumulation_speed = 0.005;
|
||||
global uniform float global_snow_melt_time = -1.0;
|
||||
global uniform float global_snow_melt_speed = 0.1;
|
||||
global uniform float global_snow_amount = 0.0;
|
||||
global uniform vec4 global_snow_color = vec4(0.92, 0.96, 1.0, 1.0);
|
||||
|
||||
//Water color
|
||||
uniform vec4 deep_water_color : source_color = vec4(0.0, 0.1, 0.2, 1.0);
|
||||
@@ -29,6 +35,21 @@ uniform sampler2D depth_texture : hint_depth_texture, filter_linear_mipmap;
|
||||
varying vec2 world_pos_xz;
|
||||
varying vec2 local_uv;
|
||||
|
||||
float get_snow_progress() {
|
||||
float snow_progress = clamp(global_snow_amount, 0.0, 1.0);
|
||||
|
||||
if (global_snow_start_time >= 0.0) {
|
||||
float timed_progress = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
|
||||
snow_progress = max(snow_progress, timed_progress);
|
||||
}
|
||||
if (global_snow_melt_time >= 0.0) {
|
||||
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
|
||||
snow_progress = min(snow_progress, 1.0 - melt);
|
||||
}
|
||||
|
||||
return snow_progress;
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
world_pos_xz = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xz;
|
||||
local_uv = UV;
|
||||
@@ -82,8 +103,15 @@ void fragment() {
|
||||
float is_sky = step(ref_depth_raw, 0.00001); // Protezione anti-cielo
|
||||
reflection_mask *= (1.0 - is_sky);
|
||||
|
||||
vec3 final_rgb = mix(base_water.rgb, screen_ref, reflection_strength * reflection_mask);
|
||||
float snow_progress = get_snow_progress();
|
||||
float active_snowfall = step(0.0, global_snow_start_time) * (1.0 - step(0.0, global_snow_melt_time));
|
||||
float reflection_snow_damping = max(smoothstep(0.0, 0.08, snow_progress), active_snowfall * 0.75);
|
||||
float effective_reflection_strength = reflection_strength * (1.0 - reflection_snow_damping * 0.85);
|
||||
|
||||
vec3 final_rgb = mix(base_water.rgb, screen_ref, effective_reflection_strength * reflection_mask);
|
||||
final_rgb = mix(final_rgb, ripple_color.rgb, ring * ripple_color.a);
|
||||
float water_snow_amount = smoothstep(0.15, 1.0, snow_progress) * 0.18;
|
||||
final_rgb = mix(final_rgb, global_snow_color.rgb, water_snow_amount);
|
||||
|
||||
ALBEDO = final_rgb;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user