fix snow
This commit is contained in:
@@ -162,6 +162,10 @@ func ApplyWeatherShaderToMaterials():
|
||||
_clear_weather_overlay_from_node(node)
|
||||
|
||||
func _apply_weather_overlay_to_node(node: Node, material: Material) -> void:
|
||||
if node.is_in_group("weather_vegetables_node"):
|
||||
_clear_weather_overlay_from_node(node)
|
||||
return
|
||||
|
||||
if node is GeometryInstance3D:
|
||||
if _geometry_uses_alpha_texture(node):
|
||||
node.material_overlay = null
|
||||
|
||||
@@ -8,10 +8,11 @@ global uniform float global_wind_speed;
|
||||
global uniform float global_wind_strength;
|
||||
global uniform vec2 global_wind_direction;
|
||||
//global uniform sampler2D global_wind_noise : filter_linear_mipmap;
|
||||
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 float global_rain_intensity;
|
||||
|
||||
// --- PARAMETRI ESTETICI ---
|
||||
@@ -32,6 +33,7 @@ uniform vec4 variance_color : source_color = vec4(0.3, 0.5, 0.2, 1.0); // Colore
|
||||
uniform float variance_intensity : hint_range(0.0, 1.0) = 0.4; // Quanto si vedono le chiazze
|
||||
|
||||
uniform vec4 snow_color : source_color = vec4(0.85, 0.9, 0.95, 1.0);
|
||||
uniform float snow_visibility : hint_range(0.0, 1.0) = 1.0;
|
||||
|
||||
// --- CONTROLLO GRADIENTE E RANDOM ---
|
||||
uniform float height_min = 0.0;
|
||||
@@ -54,6 +56,21 @@ float hash(vec3 p) {
|
||||
return fract((p.x + p.y) * p.z);
|
||||
}
|
||||
|
||||
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() {
|
||||
vec3 instance_pos = MODEL_MATRIX[3].xyz;
|
||||
v_world_pos = instance_pos; // Salviamo la posizione dell'istanza
|
||||
@@ -115,17 +132,10 @@ void fragment() {
|
||||
// Applichiamo la variazione al colore finale dell'erba
|
||||
vec3 varied_grass_color = mix(v_final_color, variance_color.rgb, noise_sample * variance_intensity);
|
||||
|
||||
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 = smoothstep(0.0, 1.0, get_snow_progress());
|
||||
|
||||
float top_mask = 1.0 - shifted_uv.y;
|
||||
float snow_mask = smoothstep(1.0 - snow_amount, 1.2 - snow_amount, top_mask);
|
||||
float snow_mask = smoothstep(0.65, 1.0, top_mask) * snow_amount * snow_visibility;
|
||||
snow_mask *= step(0.01, snow_amount);
|
||||
|
||||
vec3 dark_snow = snow_color.rgb * (1.0 - shadow_intensity);
|
||||
|
||||
@@ -2,9 +2,10 @@ shader_type spatial;
|
||||
render_mode blend_mix, cull_back, depth_draw_opaque;
|
||||
|
||||
global uniform float global_snow_start_time = -1.0;
|
||||
global uniform float global_snow_accumulation_speed = 0.1;
|
||||
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);
|
||||
|
||||
uniform float max_height : hint_range(0.02, 1.0) = 0.2;
|
||||
@@ -51,17 +52,18 @@ float fbm(vec2 p) {
|
||||
}
|
||||
|
||||
float get_snow_amount() {
|
||||
float snow_amount = 0.0;
|
||||
float snow_amount = clamp(global_snow_amount, 0.0, 1.0);
|
||||
if (global_snow_start_time >= 0.0) {
|
||||
snow_amount = clamp(
|
||||
float timed_amount = clamp(
|
||||
(TIME - global_snow_start_time) * global_snow_accumulation_speed,
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
snow_amount = max(snow_amount, timed_amount);
|
||||
}
|
||||
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);
|
||||
snow_amount = min(snow_amount, 1.0 - melt);
|
||||
}
|
||||
return snow_amount;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@ global uniform vec2 global_wind_direction;
|
||||
global uniform float global_wind_scale;
|
||||
global uniform float global_wind_strength;
|
||||
global uniform float global_wind_fade;
|
||||
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;
|
||||
global uniform float global_rain_intensity;
|
||||
|
||||
@@ -30,6 +31,7 @@ uniform float light_steps : hint_range(1.0, 10.0) = 4.0;
|
||||
uniform float random_mix : hint_range(0.0, 1.0) = 0.3;
|
||||
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
|
||||
uniform float wetness_darkening : hint_range(0.0, 0.5) = 0.25;
|
||||
uniform float snow_visibility : hint_range(0.0, 1.0) = 1.0;
|
||||
|
||||
varying vec3 v_final_color;
|
||||
varying float v_shade_factor;
|
||||
@@ -40,6 +42,21 @@ float hash(vec3 p) {
|
||||
return fract((p.x + p.y) * p.z);
|
||||
}
|
||||
|
||||
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() {
|
||||
vec3 instance_pos = MODEL_MATRIX[3].xyz;
|
||||
|
||||
@@ -88,17 +105,10 @@ void fragment() {
|
||||
vec4 tex = texture(alpha_texture, shifted_uv);
|
||||
|
||||
// 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 = pow(get_snow_progress(), 0.55);
|
||||
|
||||
float top_mask = 1.0 - shifted_uv.y;
|
||||
float snow_mask = smoothstep(1.0 - snow_amount, 1.2 - snow_amount, top_mask);
|
||||
float snow_mask = smoothstep(1.0 - snow_amount * 1.35, 1.08 - snow_amount * 1.35, top_mask) * snow_visibility;
|
||||
snow_mask *= step(0.01, snow_amount);
|
||||
|
||||
vec3 dark_snow = global_snow_color.rgb * (1.0 - shadow_intensity);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -37,10 +37,12 @@ var puddle_amount: float = 0.0
|
||||
var clouds_tween: Tween
|
||||
|
||||
var snow_tween: Tween
|
||||
var snow_weather_tween: Tween
|
||||
var snow_particles_tween: Tween
|
||||
var is_snowing: bool = false
|
||||
var is_snow_accumulated: bool = false
|
||||
var actual_snow_amount: float = 0.0
|
||||
var snow_weather_amount: float = 0.0
|
||||
|
||||
var is_storm: bool = false
|
||||
var cold_tween: Tween
|
||||
@@ -189,10 +191,10 @@ func _process(delta: float) -> void:
|
||||
var final_fog_density = lerp(base_fog_density, base_fog_density * 4.0, clamp(rain_intensity, 0.0, 1.0))
|
||||
var final_water_color = base_water_color.darkened(clamp(environment_config.water_darkening_rain, 0.0, 1.0) * clamp(rain_intensity, 0.0, 1.0))
|
||||
|
||||
final_tint = final_tint.lerp(final_tint * environment_config.snow_mode_color, actual_snow_amount)
|
||||
final_sky_top = final_sky_top.lerp(final_sky_top * environment_config.snow_mode_color, actual_snow_amount)
|
||||
final_sky_horizon = final_sky_horizon.lerp(final_sky_horizon * environment_config.snow_mode_color, actual_snow_amount)
|
||||
final_fog_color = final_fog_color.lerp(final_fog_color * environment_config.snow_mode_color, actual_snow_amount)
|
||||
final_tint = final_tint.lerp(final_tint * environment_config.snow_mode_color, snow_weather_amount)
|
||||
final_sky_top = final_sky_top.lerp(final_sky_top * environment_config.snow_mode_color, snow_weather_amount)
|
||||
final_sky_horizon = final_sky_horizon.lerp(final_sky_horizon * environment_config.snow_mode_color, snow_weather_amount)
|
||||
final_fog_color = final_fog_color.lerp(final_fog_color * environment_config.snow_mode_color, snow_weather_amount)
|
||||
|
||||
#Shader parameters for global trunk_shader
|
||||
var final_grad_top = base_grad_top.lerp(base_grad_top * weather_color, clamp(rain_intensity, 0.0, 1.0))
|
||||
@@ -206,8 +208,8 @@ func _process(delta: float) -> void:
|
||||
var night_val = clamp(day_time - 2.0, 0.0, 1.0)
|
||||
|
||||
#Snow exposure compensation
|
||||
var snow_light_attenuation = lerp(1.0, 0.55, actual_snow_amount * (1.0 - night_val))
|
||||
var snow_glow_attenuation = lerp(1.0, 0.5, actual_snow_amount)
|
||||
var snow_light_attenuation = lerp(1.0, 0.55, snow_weather_amount * (1.0 - night_val))
|
||||
var snow_glow_attenuation = lerp(1.0, 0.5, snow_weather_amount)
|
||||
var final_bloom = lerp(base_bloom, base_bloom * 0.5, rain_intensity) * snow_glow_attenuation
|
||||
|
||||
# We calculate the final exposure by applying snow damping directly to the camera exposure
|
||||
@@ -248,7 +250,7 @@ func _process(delta: float) -> void:
|
||||
sky_mat.set_shader_parameter("sun_color", final_tint)
|
||||
sky_mat.set_shader_parameter("night_intensity", night_val)
|
||||
|
||||
var cloud_density_amount: float = maxf(clamp(rain_intensity, 0.0, 1.0), clamp(actual_snow_amount, 0.0, 1.0))
|
||||
var cloud_density_amount: float = maxf(clamp(rain_intensity, 0.0, 1.0), clamp(snow_weather_amount, 0.0, 1.0))
|
||||
var current_cloud_density: float = lerp(environment_config.base_cloud_density, environment_config.rain_cloud_density, cloud_density_amount)
|
||||
|
||||
if environment_config.material_clouds:
|
||||
@@ -793,8 +795,23 @@ func toggle_snow(value: bool):
|
||||
var target_snow_amount: float = 1.0 if is_snowing else 0.0
|
||||
if snow_tween and snow_tween.is_valid():
|
||||
snow_tween.kill()
|
||||
if snow_weather_tween and snow_weather_tween.is_valid():
|
||||
snow_weather_tween.kill()
|
||||
var snow_amount_transition_duration: float = _get_snow_amount_transition_duration(is_snowing)
|
||||
snow_tween = create_tween()
|
||||
snow_tween.tween_method(init_snow_amount, actual_snow_amount, target_snow_amount, environment_config.snow_transaction_time)
|
||||
snow_tween.tween_method(
|
||||
init_snow_amount,
|
||||
actual_snow_amount,
|
||||
target_snow_amount,
|
||||
snow_amount_transition_duration
|
||||
)
|
||||
snow_weather_tween = create_tween()
|
||||
snow_weather_tween.tween_method(
|
||||
init_snow_weather_amount,
|
||||
snow_weather_amount,
|
||||
target_snow_amount,
|
||||
environment_config.snow_fade_time
|
||||
)
|
||||
_emit_weather_event_label()
|
||||
|
||||
func _emit_weather_event_label() -> void:
|
||||
@@ -818,6 +835,7 @@ func _emit_weather_event_label() -> void:
|
||||
#disable snow and set default values and shader
|
||||
func init_snow(value: float = 0.0):
|
||||
actual_snow_amount = value
|
||||
snow_weather_amount = value
|
||||
RenderingServer.global_shader_parameter_set("global_snow_amount", value)
|
||||
|
||||
if particles_snow:
|
||||
@@ -842,6 +860,9 @@ func init_snow_amount(value: float):
|
||||
actual_snow_amount = value
|
||||
RenderingServer.global_shader_parameter_set("global_snow_amount", value)
|
||||
|
||||
func init_snow_weather_amount(value: float):
|
||||
snow_weather_amount = value
|
||||
|
||||
func start_snow_accumulation() -> void:
|
||||
RenderingServer.global_shader_parameter_set("global_snow_melt_time", -1.0)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_start_time", Time.get_ticks_msec() / 1000.0)
|
||||
@@ -850,6 +871,18 @@ func start_snow_melt() -> void:
|
||||
RenderingServer.global_shader_parameter_set("global_snow_melt_time", Time.get_ticks_msec() / 1000.0)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_melt_speed", environment_config.snow_melt_speed)
|
||||
|
||||
func _get_snow_amount_transition_duration(is_accumulating: bool) -> float:
|
||||
if environment_config == null:
|
||||
return 0.0
|
||||
|
||||
var speed: float = environment_config.snow_melt_speed
|
||||
if is_accumulating:
|
||||
speed = environment_config.snow_accumulation_speed
|
||||
if speed <= 0.0:
|
||||
return environment_config.snow_transaction_time
|
||||
|
||||
return 1.0 / speed
|
||||
|
||||
#endregion
|
||||
|
||||
#region Post-Process
|
||||
|
||||
@@ -3,7 +3,7 @@ render_mode blend_mix, depth_draw_never;
|
||||
|
||||
//Snow globals
|
||||
global uniform float global_snow_start_time = -1.0;
|
||||
global uniform float global_snow_accumulation_speed = 0.1;
|
||||
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;
|
||||
@@ -72,18 +72,15 @@ float fbm(vec2 p) {
|
||||
}
|
||||
|
||||
float get_snow_progress() {
|
||||
bool has_snow_timeline = global_snow_start_time >= 0.0 || global_snow_melt_time >= 0.0;
|
||||
float snow_progress = clamp(global_snow_amount, 0.0, 1.0);
|
||||
|
||||
if (has_snow_timeline) {
|
||||
snow_progress = 0.0;
|
||||
if (global_snow_start_time >= 0.0) {
|
||||
snow_progress = 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_progress *= (1.0 - melt);
|
||||
}
|
||||
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;
|
||||
@@ -130,12 +127,13 @@ void fragment() {
|
||||
float snow_edge = smoothstep(
|
||||
global_snow_threshold - snow_edge_softness,
|
||||
global_snow_threshold + snow_edge_softness,
|
||||
facing_up + (noise_val - 0.5) * 0.4
|
||||
facing_up
|
||||
);
|
||||
float flat_accumulation = smoothstep(0.0, 0.35, v_snow_cap_mask) * snow_accumulation;
|
||||
float snow_coverage = smoothstep(0.0, 0.6, noise_val + snow_progress - 0.4 + flat_accumulation * 0.25);
|
||||
float snow_factor = max(snow_edge * snow_coverage * snow_progress, flat_accumulation);
|
||||
float snow_opacity = smoothstep(0.04, 0.28, snow_factor);
|
||||
float snow_variation = mix(0.75, 1.15, noise_val);
|
||||
float snow_coverage = clamp(snow_progress * snow_variation + flat_accumulation * 0.25, 0.0, 1.0);
|
||||
float snow_factor = max(snow_edge * snow_coverage, flat_accumulation);
|
||||
float snow_opacity = clamp(snow_factor, 0.0, 1.0);
|
||||
snow_opacity = max(snow_opacity, flat_accumulation * 0.9);
|
||||
|
||||
float shade = mix(-snow_color_variation, snow_color_variation, noise_val);
|
||||
|
||||
@@ -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