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

Snow windscreen: a blade leaves the glass clear, not streaks of the snow it pushes

A blade going over the texel holding the snow it pushes left 3% of all of it
there, a stripe of snow for every texel of its way; it leaves 3% of the snow
up to 0.03 mm now, and a wet trace of at most 0.015 mm. A thin film of water
dries and runs off in a few seconds, the water spots are fewer, the haze
needs more snow, the packed snow is whiter. 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-10 21:33:23 +01:00
parent 6bc9a5556e
commit f67b9ae2da
4 changed files with 46 additions and 28 deletions
+9 -6
View File
@@ -507,10 +507,13 @@ void snowMapFlakes(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float ac
vec4 q = water_snow_texel(uint(snMapSlot), snMapIndex, texel);
float density = mix(0.1, 0.4, q.z);
float wet = q.y / (q.y + q.x * density + 1e-4);
bool spot = (q.x < 0.05) && (q.y > 0.015); // a flake melted into its water
bool spot = (q.x < 0.05) && (q.y > 0.03); // a flake melted into its water
if ((q.x < 0.05) && (false == spot))
continue;
uint seed = Hash(uvec3(uvec2(texel), uint(q.w * 65535.0) + 7u * uint(snMapSlot)));
// the water of a texel is a droplet only now and then: the more water the more of them
if (spot && (RandF(seed) > smoothstep(0.03, 0.2, q.y)))
continue;
vec2 center = vec2(texel) + vec2(0.15 + 0.7 * RandF(seed), 0.15 + 0.7 * RandF(seed));
float ang = RandF(seed) * 6.2831853;
float flip = (RandF(seed) < 0.5) ? -1.0 : 1.0;
@@ -518,7 +521,7 @@ void snowMapFlakes(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float ac
float tone = mix(0.94, 1.04, RandF(seed));
float aniso = mix(0.62, 1.0, RandF(seed));
// the more snow the texel holds the bigger the flake (a lump of a few flakes)
float size = snow_map_flake * mix(0.6, 1.0, RandF(seed)) * (spot ? mix(0.5, 1.1, smoothstep(0.015, 0.2, q.y))
float size = snow_map_flake * mix(0.6, 1.0, RandF(seed)) * (spot ? mix(0.5, 1.1, smoothstep(0.03, 0.3, q.y))
: mix(0.7, 1.6, smoothstep(0.05, 2.0, q.x)));
vec2 d = (p - center) * aspect;
float c = cos(ang);
@@ -539,7 +542,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.015, 0.08, 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);
snowMapSprite(local, tile, alpha, tone, flip, c, s, lod, accRGB, accA, accN, accTr);
}
}
@@ -560,11 +563,11 @@ void snowMapped(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float accA,
snowMapFlakes(aspect, pixelUV, accRGB, accA, accN, accTr);
// the water: the film bends the picture behind
snWet = smoothstep(0.02, 0.25, q.y) * (1.0 - smoothstep(0.5, 2.0, q.x));
snWet = smoothstep(0.05, 0.3, q.y) * (1.0 - smoothstep(0.5, 2.0, q.x));
snWetN = vec2(qr.y - ql.y, qu.y - qd.y) * 2.0 + (vec2(snNoise(f_coord * 900.0), snNoise(f_coord * 900.0 + 31.0)) - 0.5) * 0.6 * snWet;
smear = max(smear, snWet * snow_melt_blur * 0.6);
// thin snow hazes the picture around it
snHaze = max(snHaze, smoothstep(0.03, 0.6, around));
snHaze = max(snHaze, smoothstep(0.15, 1.0, around));
// the layer, where the snow has run together
vec2 gp = f_coord * float(WATER_MAP) * aspect;
@@ -585,7 +588,7 @@ void snowMapped(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float accA,
vec3 nT = normalize(vec3(-(slope + gf * snow_map_grain * (1.0 - 0.6 * q.z)) * snow_bump, 1.0));
vec3 fresh = vec3(0.93, 0.95, 0.98);
vec3 packed = vec3(0.84, 0.87, 0.91);
vec3 packed = vec3(0.89, 0.91, 0.94);
vec3 slush = vec3(0.60, 0.66, 0.73);
vec3 col = mix(mix(fresh, packed, q.z), slush, smoothstep(0.2, 0.7, wet));
col *= (0.80 + 0.30 * f1 * (1.0 - 0.5 * q.z)) * (0.92 + 0.12 * grain);
+14 -8
View File
@@ -36,16 +36,20 @@ const float SNOW_MOST = 40.0;
const float SNOW_REPOSE = 3.0;
// the share of the snow over the step slipping onto the neighbour in a second
const float SNOW_SLIP = 6.0;
// the share of the snow a blade leaves, of the water, and of the snow it takes which it leaves as a wet trace
// the share of the snow a blade leaves (at most SNOW_WIPE_LEFT mm: the snow it pushes along goes with it), of the water, and
// of the water of the snow it takes which it leaves as a wet trace (at most SNOW_WIPE_WET mm)
const float SNOW_WIPE_MISS = 0.03;
const float SNOW_WIPE_WATER = 0.25;
const float SNOW_WIPE_LEFT = 0.03;
const float SNOW_WIPE_WATER = 0.1;
const float SNOW_WIPE_TRACE = 0.08;
const float SNOW_WIPE_WET = 0.015;
// the longest line of texels a blade goes over in a step, texels
const int SNOW_WIPE_LINE = 12;
// the water the snow melts into at the glass a second for each degree the glass is above zero, mm
const float SNOW_MELT = 0.003;
// the water drying a second, mm
// the water drying a second, mm, and the share of a thin film going in a second (it dries and runs off as droplets)
const float SNOW_DRY = 0.0004;
const float SNOW_FILM_DRY = 0.15;
// how fast slush slides down a vertical glass, how fast dry powder goes with the air (a share of the speed of the air along the
// glass), how fast the film of water runs down a vertical glass and goes with the air, m/s
const float SNOW_SLIDE = 0.03;
@@ -261,9 +265,10 @@ void main()
}
if (crossed)
{
float taken = state.x * (1.0 - SNOW_WIPE_MISS);
state.x -= taken;
state.y = state.y * SNOW_WIPE_WATER + taken * mix(SNOW_FRESH, SNOW_PACKED, state.z) * SNOW_WIPE_TRACE;
float left = min(state.x * SNOW_WIPE_MISS, SNOW_WIPE_LEFT);
float taken = state.x - left;
state.x = left;
state.y = state.y * SNOW_WIPE_WATER + min(taken * mix(SNOW_FRESH, SNOW_PACKED, state.z) * SNOW_WIPE_TRACE, SNOW_WIPE_WET);
}
if (pushed.x + pushed.y > 0.0)
{
@@ -271,7 +276,7 @@ void main()
// pressed by the blade
state.z = (snow > 1e-4) ? clamp((state.z * state.x + max(pushed.z, pushed.x * 0.85)) / snow, 0.0, 1.0) : state.z;
state.x = snow;
state.y += pushed.y * 0.7;
state.y += pushed.y * 0.5;
}
// the flakes landing
@@ -302,7 +307,8 @@ void main()
float glass = water_up.w + water_snow.y / (1.0 + speed / 12.0);
float melted = min(SNOW_MELT * max(glass, 0.0) * seconds, state.x * density);
state.x -= melted / max(density, 1e-3);
state.y = max(state.y + melted - SNOW_DRY * seconds, 0.0);
float film = state.y * (1.0 - smoothstep(0.5, 3.0, state.x)); // the water not soaked into the snow
state.y = max(state.y + melted - (SNOW_DRY + SNOW_FILM_DRY * film) * seconds, 0.0);
state.x = clamp(state.x, 0.0, SNOW_MOST);
state.y = min(state.y, 4.0);
+9 -6
View File
@@ -512,10 +512,13 @@ void snowMapFlakes(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float ac
vec4 q = water_snow_texel(uint(snMapSlot), snMapIndex, texel);
float density = mix(0.1, 0.4, q.z);
float wet = q.y / (q.y + q.x * density + 1e-4);
bool spot = (q.x < 0.05) && (q.y > 0.015); // a flake melted into its water
bool spot = (q.x < 0.05) && (q.y > 0.03); // a flake melted into its water
if ((q.x < 0.05) && (false == spot))
continue;
uint seed = Hash(uvec3(uvec2(texel), uint(q.w * 65535.0) + 7u * uint(snMapSlot)));
// the water of a texel is a droplet only now and then: the more water the more of them
if (spot && (RandF(seed) > smoothstep(0.03, 0.2, q.y)))
continue;
vec2 center = vec2(texel) + vec2(0.15 + 0.7 * RandF(seed), 0.15 + 0.7 * RandF(seed));
float ang = RandF(seed) * 6.2831853;
float flip = (RandF(seed) < 0.5) ? -1.0 : 1.0;
@@ -523,7 +526,7 @@ void snowMapFlakes(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float ac
float tone = mix(0.94, 1.04, RandF(seed));
float aniso = mix(0.62, 1.0, RandF(seed));
// the more snow the texel holds the bigger the flake (a lump of a few flakes)
float size = snow_map_flake * mix(0.6, 1.0, RandF(seed)) * (spot ? mix(0.5, 1.1, smoothstep(0.015, 0.2, q.y))
float size = snow_map_flake * mix(0.6, 1.0, RandF(seed)) * (spot ? mix(0.5, 1.1, smoothstep(0.03, 0.3, q.y))
: mix(0.7, 1.6, smoothstep(0.05, 2.0, q.x)));
vec2 d = (p - center) * aspect;
float c = cos(ang);
@@ -544,7 +547,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.015, 0.08, 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);
snowMapSprite(local, tile, alpha, tone, flip, c, s, lod, accRGB, accA, accN, accTr);
}
}
@@ -565,11 +568,11 @@ void snowMapped(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float accA,
snowMapFlakes(aspect, pixelUV, accRGB, accA, accN, accTr);
// the water: the film bends the picture behind
snWet = smoothstep(0.02, 0.25, q.y) * (1.0 - smoothstep(0.5, 2.0, q.x));
snWet = smoothstep(0.05, 0.3, q.y) * (1.0 - smoothstep(0.5, 2.0, q.x));
snWetN = vec2(qr.y - ql.y, qu.y - qd.y) * 2.0 + (vec2(snNoise(f_coord * 900.0), snNoise(f_coord * 900.0 + 31.0)) - 0.5) * 0.6 * snWet;
smear = max(smear, snWet * snow_melt_blur * 0.6);
// thin snow hazes the picture around it
snHaze = max(snHaze, smoothstep(0.03, 0.6, around));
snHaze = max(snHaze, smoothstep(0.15, 1.0, around));
// the layer, where the snow has run together
vec2 gp = f_coord * float(WATER_MAP) * aspect;
@@ -590,7 +593,7 @@ void snowMapped(vec2 aspect, float pixelUV, inout vec3 accRGB, inout float accA,
vec3 nT = normalize(vec3(-(slope + gf * snow_map_grain * (1.0 - 0.6 * q.z)) * snow_bump, 1.0));
vec3 fresh = vec3(0.93, 0.95, 0.98);
vec3 packed = vec3(0.84, 0.87, 0.91);
vec3 packed = vec3(0.89, 0.91, 0.94);
vec3 slush = vec3(0.60, 0.66, 0.73);
vec3 col = mix(mix(fresh, packed, q.z), slush, smoothstep(0.2, 0.7, wet));
col *= (0.80 + 0.30 * f1 * (1.0 - 0.5 * q.z)) * (0.92 + 0.12 * grain);
+14 -8
View File
@@ -39,16 +39,20 @@ const float SNOW_MOST = 40.0;
const float SNOW_REPOSE = 3.0;
// the share of the snow over the step slipping onto the neighbour in a second
const float SNOW_SLIP = 6.0;
// the share of the snow a blade leaves, of the water, and of the snow it takes which it leaves as a wet trace
// the share of the snow a blade leaves (at most SNOW_WIPE_LEFT mm: the snow it pushes along goes with it), of the water, and
// of the water of the snow it takes which it leaves as a wet trace (at most SNOW_WIPE_WET mm)
const float SNOW_WIPE_MISS = 0.03;
const float SNOW_WIPE_WATER = 0.25;
const float SNOW_WIPE_LEFT = 0.03;
const float SNOW_WIPE_WATER = 0.1;
const float SNOW_WIPE_TRACE = 0.08;
const float SNOW_WIPE_WET = 0.015;
// the longest line of texels a blade goes over in a step, texels
const int SNOW_WIPE_LINE = 12;
// the water the snow melts into at the glass a second for each degree the glass is above zero, mm
const float SNOW_MELT = 0.003;
// the water drying a second, mm
// the water drying a second, mm, and the share of a thin film going in a second (it dries and runs off as droplets)
const float SNOW_DRY = 0.0004;
const float SNOW_FILM_DRY = 0.15;
// how fast slush slides down a vertical glass, how fast dry powder goes with the air (a share of the speed of the air along the
// glass), how fast the film of water runs down a vertical glass and goes with the air, m/s
const float SNOW_SLIDE = 0.03;
@@ -264,9 +268,10 @@ void main()
}
if (crossed)
{
float taken = state.x * (1.0 - SNOW_WIPE_MISS);
state.x -= taken;
state.y = state.y * SNOW_WIPE_WATER + taken * mix(SNOW_FRESH, SNOW_PACKED, state.z) * SNOW_WIPE_TRACE;
float left = min(state.x * SNOW_WIPE_MISS, SNOW_WIPE_LEFT);
float taken = state.x - left;
state.x = left;
state.y = state.y * SNOW_WIPE_WATER + min(taken * mix(SNOW_FRESH, SNOW_PACKED, state.z) * SNOW_WIPE_TRACE, SNOW_WIPE_WET);
}
if (pushed.x + pushed.y > 0.0)
{
@@ -274,7 +279,7 @@ void main()
// pressed by the blade
state.z = (snow > 1e-4) ? clamp((state.z * state.x + max(pushed.z, pushed.x * 0.85)) / snow, 0.0, 1.0) : state.z;
state.x = snow;
state.y += pushed.y * 0.7;
state.y += pushed.y * 0.5;
}
// the flakes landing
@@ -305,7 +310,8 @@ void main()
float glass = water_up.w + water_snow.y / (1.0 + speed / 12.0);
float melted = min(SNOW_MELT * max(glass, 0.0) * seconds, state.x * density);
state.x -= melted / max(density, 1e-3);
state.y = max(state.y + melted - SNOW_DRY * seconds, 0.0);
float film = state.y * (1.0 - smoothstep(0.5, 3.0, state.x)); // the water not soaked into the snow
state.y = max(state.y + melted - (SNOW_DRY + SNOW_FILM_DRY * film) * seconds, 0.0);
state.x = clamp(state.x, 0.0, SNOW_MOST);
state.y = min(state.y, 4.0);