18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 14:16:48 +01:00

Snow windscreen: no big star flakes, dry powder bounces off a moving glass

The small lumps of dry snow were drawn with the tiles of a few star
crystals, a glass covered in big stars at speed. They're crumbs now (a
flake breaks up hitting the glass); single crystals are rarer (5% of the
texels) and smaller (~5 mm). Dry flakes (below -3 deg C, on dry glass)
bounce off a moving glass: 85% of them from 25 m/s, so dry snow builds up
slowly at speed; the wet ones stay. No assets change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
This commit is contained in:
lcddisplay
2026-11-11 19:44:34 +01:00
parent 02420c32d7
commit 331b480d48
4 changed files with 18 additions and 14 deletions
+5 -5
View File
@@ -14,7 +14,7 @@
// - the lumps: one in a cell of a few texels at most, as the drops of the rain, the more snow around the likelier and bigger,
// from a few mm to a few cm (most of them small), clear glass between them until the snow gets thick, then packed snow
// overlapping into a cover. Wet (near zero, melting): lumps of slush, grey, translucent with a frosted core, bending the
// picture behind; dry: clumps of flakes
// picture behind; dry: crumbs and clumps of the flakes broken on the glass
// - single crystals of dry snow between them, and drops where a flake has melted (they bend the picture behind, as rain does)
// A thin flake lets the light through (ice crystals): the picture behind it is blurred, not hidden.
//
@@ -66,8 +66,8 @@ layout(binding = 2) uniform sampler2D wipermask;
layout(binding = 3) uniform sampler2D normalmap;
// --- tuning ------------------------------------------------------------------------------------------------------------------
const float snow_flake = 1.4; // size of a single crystal or a drop, texels of the map
const float snow_crystals = 0.12; // share of the texels with a little dry snow showing a single crystal
const float snow_flake = 1.1; // size of a single crystal or a drop, texels of the map (~5 mm)
const float snow_crystals = 0.05; // share of the texels with a little dry snow showing a single crystal
const float snow_drops = 0.35; // share of the texels with the water of a melted flake showing a drop (more with more water)
const float snow_layer = 0.6; // mm of snow around which a cell surely has a lump (fewer, smaller below)
const float snow_layer_cell = 4.0; // a lump at most every this many texels (~2 cm)
@@ -270,8 +270,8 @@ void snLayer(vec2 aspect, float pixelUV, inout sprite_acc acc)
tile = (wet > 0.35) ? 14 : 12 + int(kind * 2.0); // slush, packed snow
else if (wet > 0.2)
tile = 8 + int(kind * 2.0); // wet lumps
else if (size < 0.7)
tile = 4 + int(kind * 2.0); // flakes of a few crystals
else if (size < 0.8)
tile = 6 + int(kind * 2.0); // crumbs (a flake breaks up hitting the glass)
else
tile = 10 + int(kind * 2.0); // clumps
float thick = 1.0 - exp(-q.x / (snow_opaque * mix(1.0, 0.5, q.z)));
+4 -2
View File
@@ -240,8 +240,10 @@ void main()
float speed = water_snow.z;
float density = mix(SNOW_FRESH, SNOW_PACKED, state.z);
float wet = state.y / (state.y + state.x * density + 1e-4);
// the dry flakes bounce off a fast glass, the ones landing on wet snow or water stay
float sticking = 1.0 - 0.6 * smoothstep(15.0, 35.0, speed) * (1.0 - smoothstep(0.1, 0.4, wet));
// the dry flakes bounce off a moving glass (powder is blown away), the wet ones (near zero) and those landing on wet snow or
// water stay
float dry = (1.0 - smoothstep(0.1, 0.4, wet)) * (1.0 - smoothstep(-3.0, 0.0, water_up.w));
float sticking = 1.0 - 0.85 * smoothstep(5.0, 25.0, speed) * dry;
float landings = water_snow.x / max(water_air.w, 0.1) * facing * area * seconds * sticking;
vec4 random = water_random(place, snow_slot, water_counts.x, 0x5e0du);
float count = min(floor(landings) + ((random.x < fract(landings)) ? 1.0 : 0.0), 4.0);
+5 -5
View File
@@ -15,7 +15,7 @@
// - the lumps: one in a cell of a few texels at most, as the drops of the rain, the more snow around the likelier and bigger,
// from a few mm to a few cm (most of them small), clear glass between them until the snow gets thick, then packed snow
// overlapping into a cover. Wet (near zero, melting): lumps of slush, grey, translucent with a frosted core, bending the
// picture behind; dry: clumps of flakes
// picture behind; dry: crumbs and clumps of the flakes broken on the glass
// - single crystals of dry snow between them, and drops where a flake has melted (they bend the picture behind, as rain does)
// A thin flake lets the light through (ice crystals): the picture behind it is blurred, not hidden.
//
@@ -71,8 +71,8 @@ layout(set = MATERIAL_SET, binding = MATERIAL_TEXTURE_FIRST + 2) uniform sampler
layout(set = MATERIAL_SET, binding = MATERIAL_TEXTURE_FIRST + 3) uniform sampler2D normalmap;
// --- tuning ------------------------------------------------------------------------------------------------------------------
const float snow_flake = 1.4; // size of a single crystal or a drop, texels of the map
const float snow_crystals = 0.12; // share of the texels with a little dry snow showing a single crystal
const float snow_flake = 1.1; // size of a single crystal or a drop, texels of the map (~5 mm)
const float snow_crystals = 0.05; // share of the texels with a little dry snow showing a single crystal
const float snow_drops = 0.35; // share of the texels with the water of a melted flake showing a drop (more with more water)
const float snow_layer = 0.6; // mm of snow around which a cell surely has a lump (fewer, smaller below)
const float snow_layer_cell = 4.0; // a lump at most every this many texels (~2 cm)
@@ -275,8 +275,8 @@ void snLayer(vec2 aspect, float pixelUV, inout sprite_acc acc)
tile = (wet > 0.35) ? 14 : 12 + int(kind * 2.0); // slush, packed snow
else if (wet > 0.2)
tile = 8 + int(kind * 2.0); // wet lumps
else if (size < 0.7)
tile = 4 + int(kind * 2.0); // flakes of a few crystals
else if (size < 0.8)
tile = 6 + int(kind * 2.0); // crumbs (a flake breaks up hitting the glass)
else
tile = 10 + int(kind * 2.0); // clumps
float thick = 1.0 - exp(-q.x / (snow_opaque * mix(1.0, 0.5, q.z)));
+4 -2
View File
@@ -243,8 +243,10 @@ void main()
float speed = water_snow.z;
float density = mix(SNOW_FRESH, SNOW_PACKED, state.z);
float wet = state.y / (state.y + state.x * density + 1e-4);
// the dry flakes bounce off a fast glass, the ones landing on wet snow or water stay
float sticking = 1.0 - 0.6 * smoothstep(15.0, 35.0, speed) * (1.0 - smoothstep(0.1, 0.4, wet));
// the dry flakes bounce off a moving glass (powder is blown away), the wet ones (near zero) and those landing on wet snow or
// water stay
float dry = (1.0 - smoothstep(0.1, 0.4, wet)) * (1.0 - smoothstep(-3.0, 0.0, water_up.w));
float sticking = 1.0 - 0.85 * smoothstep(5.0, 25.0, speed) * dry;
float landings = water_snow.x / max(water_air.w, 0.1) * facing * area * seconds * sticking;
vec4 random = water_random(place, snow_slot, water_counts.x, 0x5e0du);
float count = min(floor(landings) + ((random.x < fract(landings)) ? 1.0 : 0.0), 4.0);