add new snow shader

This commit is contained in:
2026-03-31 15:07:46 +02:00
parent ade67a3b90
commit 222c3c88d3
19 changed files with 611 additions and 7 deletions

View File

@@ -258,7 +258,7 @@ draw_pass_1 = SubResource("QuadMesh_ruhh7")
[node name="Particles_Rain" type="GPUParticles3D" parent="." unique_id=1543042897]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 30, 0)
cast_shadow = 0
extra_cull_margin = 10.0
extra_cull_margin = 16384.0
emitting = false
amount = 5000
lifetime = 1.5

View File

@@ -8,6 +8,12 @@ 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);
uniform sampler2D noise_texture : filter_linear_mipmap, repeat_enable;
uniform float noise_scale : hint_range(0.01, 1.0) = 0.15;
uniform float noise_edge_softness : hint_range(0.01, 0.5) = 0.2;
uniform float roughness_variation : hint_range(0.0, 0.3) = 0.15;
uniform float color_variation : hint_range(0.0, 0.15) = 0.05;
void fragment() {
float snow_amount = 0.0;
if (global_snow_start_time >= 0.0) {
@@ -19,12 +25,27 @@ void fragment() {
snow_amount = snow_amount * (1.0 - melt);
}
vec3 world_pos = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
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;
float facing_up = clamp(world_normal.y, 0.0, 1.0);
ALBEDO = global_snow_color.rgb;
ROUGHNESS = 0.15;
float noise_val = texture(noise_texture, world_pos.xz * noise_scale).r;
float edge = smoothstep(
global_snow_threshold - noise_edge_softness,
global_snow_threshold + noise_edge_softness,
facing_up + (noise_val - 0.5) * 0.4
);
float coverage = smoothstep(0.0, 0.6, noise_val + snow_amount - 0.4);
float snow_factor = edge * coverage * snow_amount;
float shade = mix(-color_variation, color_variation, noise_val);
vec3 snow_albedo = clamp(global_snow_color.rgb + vec3(shade), 0.0, 1.0);
float snow_roughness = mix(0.15 - roughness_variation, 0.15 + roughness_variation, noise_val);
ALBEDO = snow_albedo;
ROUGHNESS = snow_roughness;
METALLIC = 0.0;
ALPHA = snow_factor;
}

View File

@@ -5,3 +5,7 @@
[resource]
render_priority = 0
shader = ExtResource("1_vwtmf")
shader_parameter/noise_scale = 0.15
shader_parameter/noise_edge_softness = 0.2
shader_parameter/roughness_variation = 0.15
shader_parameter/color_variation = 0.05