From 84bdde9bbabbb475593610d072411592b3885bcf Mon Sep 17 00:00:00 2001 From: lcddisplay Date: Tue, 10 Nov 2026 21:48:28 +0100 Subject: [PATCH] Snow windscreen: thin flakes let the light through A single flake was drawn nearly opaque and lit only from the cab, a dark speck against the lit snow outside at night. A thin flake is 45% opaque now (full from 2.5 mm of snow) and the picture behind it is blurred, as through ice crystals. No assets change. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD --- shaders/ogl46/mat_snow_windscreen.frag | 7 +++++-- shaders/vk14/mat_snow_windscreen.frag | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/shaders/ogl46/mat_snow_windscreen.frag b/shaders/ogl46/mat_snow_windscreen.frag index 5bc35bb82..0ca45013c 100644 --- a/shaders/ogl46/mat_snow_windscreen.frag +++ b/shaders/ogl46/mat_snow_windscreen.frag @@ -462,6 +462,8 @@ const float snow_map_opaque = 1.8; // mm of fresh snow which lets 1/e of t const float snow_map_relief = 0.6; // how much the slopes of the snow tilt its surface const float snow_map_grain = 0.35; // the fine grain of the layer (its relief) const float snow_map_wet_bend = 0.6; // how strongly a wet glass bends the picture behind it +const float snow_map_thin = 0.45; // opacity of a single thin flake (ice crystals let most of the light through: the picture + // behind shows through it, blurred, rather than a dark speck at night) int snMapSlot = -1; uint snMapIndex = 0u; @@ -542,7 +544,7 @@ void snowMapFlakes(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float ac tile = vec2(0.0, 0.5); // fluffy else tile = vec2(0.0, 0.0); // crumbs - float alpha = spot ? smoothstep(0.03, 0.1, q.y) : smoothstep(0.05, 0.25, q.x); + float alpha = spot ? smoothstep(0.03, 0.1, q.y) : smoothstep(0.05, 0.25, q.x) * mix(snow_map_thin, 1.0, smoothstep(0.3, 2.5, q.x)); snowMapSprite(local, tile, alpha, tone, flip, c, s, lod, accRGB, accA, accN, accTr); } } @@ -559,8 +561,9 @@ void snowMapped(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float accA, vec4 qd = snMapAt(f_coord - vec2(0.0, e)); float around = (q.x + qr.x + ql.x + qu.x + qd.x) * 0.2; - // the flakes of thin snow and the water spots + // the flakes of thin snow and the water spots; the picture behind a flake is blurred (it scatters the light going through) snowMapFlakes(aspect, pixelUV, accRGB, accA, accN, accTr); + snHaze = max(snHaze, smoothstep(0.0, 0.3, accA)); // the water: the film bends the picture behind snWet = smoothstep(0.05, 0.3, q.y) * (1.0 - smoothstep(0.5, 2.0, q.x)); diff --git a/shaders/vk14/mat_snow_windscreen.frag b/shaders/vk14/mat_snow_windscreen.frag index ef3749ce5..183193b69 100644 --- a/shaders/vk14/mat_snow_windscreen.frag +++ b/shaders/vk14/mat_snow_windscreen.frag @@ -467,6 +467,8 @@ const float snow_map_opaque = 1.8; // mm of fresh snow which lets 1/e of t const float snow_map_relief = 0.6; // how much the slopes of the snow tilt its surface const float snow_map_grain = 0.35; // the fine grain of the layer (its relief) const float snow_map_wet_bend = 0.6; // how strongly a wet glass bends the picture behind it +const float snow_map_thin = 0.45; // opacity of a single thin flake (ice crystals let most of the light through: the picture + // behind shows through it, blurred, rather than a dark speck at night) int snMapSlot = -1; uint snMapIndex = 0u; @@ -547,7 +549,7 @@ void snowMapFlakes(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float ac tile = vec2(0.0, 0.5); // fluffy else tile = vec2(0.0, 0.0); // crumbs - float alpha = spot ? smoothstep(0.03, 0.1, q.y) : smoothstep(0.05, 0.25, q.x); + float alpha = spot ? smoothstep(0.03, 0.1, q.y) : smoothstep(0.05, 0.25, q.x) * mix(snow_map_thin, 1.0, smoothstep(0.3, 2.5, q.x)); snowMapSprite(local, tile, alpha, tone, flip, c, s, lod, accRGB, accA, accN, accTr); } } @@ -564,8 +566,9 @@ void snowMapped(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float accA, vec4 qd = snMapAt(f_coord - vec2(0.0, e)); float around = (q.x + qr.x + ql.x + qu.x + qd.x) * 0.2; - // the flakes of thin snow and the water spots + // the flakes of thin snow and the water spots; the picture behind a flake is blurred (it scatters the light going through) snowMapFlakes(aspect, pixelUV, accRGB, accA, accN, accTr); + snHaze = max(snHaze, smoothstep(0.0, 0.3, accA)); // the water: the film bends the picture behind snWet = smoothstep(0.05, 0.3, q.y) * (1.0 - smoothstep(0.5, 2.0, q.x));