improve snow
This commit is contained in:
@@ -8,7 +8,9 @@ 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;
|
||||
const float SNOW_VISUAL_RESPONSE = 0.55;
|
||||
uniform float snow_edge_softness : hint_range(0.01, 0.5) = 0.15;
|
||||
uniform float snow_noise_scale : hint_range(0.01, 1.0) = 0.15;
|
||||
uniform float snow_color_variation : hint_range(0.0, 0.15) = 0.05;
|
||||
|
||||
|
||||
@@ -50,6 +52,18 @@ float get_snow_progress() {
|
||||
return snow_progress;
|
||||
}
|
||||
|
||||
float get_visual_snow_progress(float snow_progress) {
|
||||
return pow(clamp(snow_progress, 0.0, 1.0), SNOW_VISUAL_RESPONSE);
|
||||
}
|
||||
|
||||
float get_snow_noise_mask(vec3 world_pos, float snow_progress) {
|
||||
float detail_noise = texture(noise_texture, world_pos.xz * snow_noise_scale).r;
|
||||
float broad_noise = texture(noise_texture, world_pos.xz * snow_noise_scale * 0.35 + vec2(19.1, 7.4)).r;
|
||||
float combined_noise = mix(detail_noise, broad_noise, 0.35);
|
||||
float threshold = mix(0.92, 0.08, snow_progress);
|
||||
return smoothstep(threshold - 0.18, threshold + 0.18, combined_noise);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec3 world_pos = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
||||
|
||||
@@ -57,14 +71,15 @@ void fragment() {
|
||||
float facing_up = 1.0;
|
||||
|
||||
// Snow accumulation
|
||||
float snow_amount = get_snow_progress();
|
||||
float snow_amount = get_visual_snow_progress(get_snow_progress());
|
||||
|
||||
// Plain surfaces fade in uniformly to avoid patchy strip-like accumulation.
|
||||
float snow_mask = smoothstep(0.0, 1.0, snow_amount);
|
||||
// Plain surfaces accumulate through world-space noise so flat snow is not uniform.
|
||||
float snow_noise_mask = get_snow_noise_mask(world_pos, snow_amount);
|
||||
float snow_mask = mix(snow_amount * 0.35, snow_amount, snow_noise_mask);
|
||||
snow_mask *= step(0.01, snow_amount);
|
||||
|
||||
// Snow color with slight variation
|
||||
float shade = fract(sin(dot(UV, vec2(12.9898, 78.233))) * 43758.5453);
|
||||
float shade = texture(noise_texture, world_pos.xz * snow_noise_scale * 2.0 + vec2(3.7, 11.2)).r;
|
||||
shade = mix(-snow_color_variation, snow_color_variation, shade);
|
||||
vec3 snow_albedo = clamp(global_snow_color.rgb + vec3(shade), 0.0, 1.0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user