fix snow
This commit is contained in:
@@ -2,10 +2,11 @@ shader_type spatial;
|
||||
render_mode blend_mix, depth_draw_never, cull_disabled;
|
||||
|
||||
// Snow globals
|
||||
global uniform float global_snow_start_time;
|
||||
global uniform float global_snow_accumulation_speed;
|
||||
global uniform float global_snow_melt_time;
|
||||
global uniform float global_snow_melt_speed;
|
||||
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;
|
||||
uniform float snow_edge_softness : hint_range(0.01, 0.5) = 0.15;
|
||||
uniform float snow_color_variation : hint_range(0.0, 0.15) = 0.05;
|
||||
@@ -34,6 +35,21 @@ float ripple_ring(vec2 uv, float time_offset) {
|
||||
return ring * fade;
|
||||
}
|
||||
|
||||
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 fragment() {
|
||||
vec3 world_pos = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
||||
|
||||
@@ -41,18 +57,10 @@ void fragment() {
|
||||
float facing_up = 1.0;
|
||||
|
||||
// Snow accumulation
|
||||
float snow_amount = 0.0;
|
||||
if (global_snow_start_time >= 0.0) {
|
||||
snow_amount = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
|
||||
}
|
||||
if (global_snow_melt_time >= 0.0) {
|
||||
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
|
||||
snow_amount *= (1.0 - melt);
|
||||
}
|
||||
float snow_amount = get_snow_progress();
|
||||
|
||||
// UV-based snow mask: accumulates from the top of the quad
|
||||
float top_mask = 1.0 - UV.y;
|
||||
float snow_mask = smoothstep(1.0 - snow_amount, 1.0 - snow_amount + snow_edge_softness, top_mask);
|
||||
// Plain surfaces fade in uniformly to avoid patchy strip-like accumulation.
|
||||
float snow_mask = smoothstep(0.0, 1.0, snow_amount);
|
||||
snow_mask *= step(0.01, snow_amount);
|
||||
|
||||
// Snow color with slight variation
|
||||
|
||||
Reference in New Issue
Block a user