31 lines
1.1 KiB
Plaintext
31 lines
1.1 KiB
Plaintext
shader_type spatial;
|
|
render_mode blend_mix, depth_draw_never;
|
|
|
|
global uniform float global_snow_start_time = -1.0;
|
|
global uniform float global_snow_accumulation_speed = 0.1;
|
|
global uniform float global_snow_melt_time = -1.0;
|
|
global uniform float global_snow_melt_speed = 0.1;
|
|
global uniform float global_snow_threshold = 0.5;
|
|
global uniform vec4 global_snow_color = vec4(0.92, 0.96, 1.0, 1.0);
|
|
|
|
void fragment() {
|
|
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 = snow_amount * (1.0 - melt);
|
|
}
|
|
|
|
vec3 world_normal = (INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
|
|
float facing_up = clamp(world_normal.y, 0.0, 1.0);
|
|
float snow_factor = smoothstep(global_snow_threshold, 1.0, facing_up) * snow_amount;
|
|
|
|
ALBEDO = global_snow_color.rgb;
|
|
ROUGHNESS = 0.15;
|
|
METALLIC = 0.0;
|
|
ALPHA = snow_factor;
|
|
}
|