diff --git a/shaders/ogl46/mat_snow_windscreen.frag b/shaders/ogl46/mat_snow_windscreen.frag index 330a7583a..138ac5e85 100644 --- a/shaders/ogl46/mat_snow_windscreen.frag +++ b/shaders/ogl46/mat_snow_windscreen.frag @@ -7,12 +7,13 @@ // // What lies on the glass comes from the simulation (water_snow.comp, water.glsl): the map of the glass keeps the snow, the water, // how packed the snow is and the shape of its flakes from frame to frame. The flakes land and stay where they landed, pile up, -// the blades push the snow into ridges at the ends of their sweeps and leave a wet trace, it melts at the warm glass, slush slides -// down. The renderer gives the glass its map through the param snow_slot (1 + its slot); a glass without a map has no snow. +// the blades wipe it as they wipe the rain (a wet trace stays), it melts at the warm glass, slush slides down. The renderer gives +// the glass its map through the param snow_slot (1 + its slot); a glass without a map has no snow. // // The look is only sprites from the atlas, as the drops of rain_windscreen and the splats of bugs_windscreen, two layers of them: // - the flakes: a sprite on every texel of the map holding snow, the more snow the bigger. Dry: crystals, flakes of a few of -// them, crumbs; wet: lumps; where only the water of a melted flake is left, a drop (it bends the picture behind, as rain does) +// them, crumbs; wet (near zero, melting): lumps of slush, grey and translucent with a frosted core; where only the water of a +// melted flake is left, a drop. The lumps and the drops bend the picture behind, as the drops of the rain // - the layer, under the flakes: a bigger sprite every three texels where the snow is thicker, clumps of flakes, then packed // snow, overlapping into a whole cover where the snow is thick; grey slush where it's wet // A thin flake lets the light through (ice crystals): the picture behind it is blurred, not hidden. @@ -140,7 +141,8 @@ void snSprite(vec2 local, int tile, float alpha, vec3 tone, vec2 rot, float flip acc.n = nT * a + acc.n * (1.0 - a); acc.tr = (1.0 - t.a * 0.55) * a + acc.tr * (1.0 - a); acc.a = a + acc.a * (1.0 - a); - if (tile == TILE_DROP) + // the drops and the wet lumps bend the picture behind them (water, slush), as the drops of the rain + if ((tile == TILE_DROP) || (tile == 8) || (tile == 9) || (tile == 14)) { snBend = snBend * (1.0 - a) + nuv * a; snBendA = snBendA * (1.0 - a) + a; @@ -216,7 +218,7 @@ void snFlakes(vec2 aspect, float pixelUV, inout sprite_acc acc) } else { - if (snWetness(q) > 0.35) + if (snWetness(q) > 0.25) tile = 8 + int(kind * 2.0); // wet lumps else if (kind < 0.25) tile = int(kind * 8.0); // star crystals (0, 1) @@ -264,7 +266,7 @@ void snLayer(vec2 aspect, float pixelUV, inout sprite_acc acc) if (false == snLocal(p, centre, size, aspect, rot, flip, aniso, local)) continue; int tile; - if (snWetness(q) > 0.45) + if (snWetness(q) > 0.35) tile = 14; // slush else if (q.x < 3.0) tile = 10 + int(kind * 2.0); // clumps @@ -272,7 +274,7 @@ void snLayer(vec2 aspect, float pixelUV, inout sprite_acc acc) tile = 12 + int(kind * 2.0); // packed snow float thick = 1.0 - exp(-q.x / (snow_opaque * mix(1.0, 0.5, q.z))); float alpha = mix(0.6, 1.0, thick); - // the ridges of the blades: packed and thick, a stronger relief + // packed thick snow: a stronger relief float bump = mix(1.0, 1.6, q.z * smoothstep(3.0, 12.0, q.x)); snSprite(local, min(tile, 14), alpha, snTone(q, random), rot, flip, snLod(pixelUV, size / cells), bump, acc); } @@ -367,7 +369,7 @@ void main() { vec4 req = vec4(0.0); float clear = 1.0 - smoothstep(0.5, 0.95, glassA); - if ((snBendA > 0.25) && (layer.a < 0.3) && (glassA < 0.5)) + if ((snBendA > 0.25) && (glassA < 0.5)) { vec2 bend = clamp(-snBend / max(snBendA, 1e-3) * snow_drop_bend, vec2(-1.0), vec2(1.0)) * smoothstep(0.25, 0.6, snBendA); req = vec4(WS_DROP_BIAS + WS_BEND_ENC * bend.x, WS_DROP_BIAS + WS_BEND_ENC * bend.y, 0.0, 1.0); diff --git a/shaders/ogl46/water_snow.comp b/shaders/ogl46/water_snow.comp index f7f60b28a..ce3a3a106 100644 --- a/shaders/ogl46/water_snow.comp +++ b/shaders/ogl46/water_snow.comp @@ -9,13 +9,12 @@ // flakes (mat_snow_windscreen.frag). in a step, in this order: // - the snow and the water move: wet heavy snow (slush) slides down the glass, dry powder is blown along it by the air at speed, // the water runs down as a film and is pushed by the air; and snow piled higher than its neighbours by more than it holds slips -// onto them (a ridge left by a blade spreads into a wedge). what goes over the edge of the glass falls off -// - the blades: a blade going over a texel in the step takes its snow (a little stays, and a wet trace of the water), and pushes -// it on in front of itself: the texel just ahead of the line of texels the blade went over gets their snow, packed (each texel -// to one texel at most: the snow pushed along is never counted twice). at the end -// of its sweep the blade leaves it there, a ridge; pushed past the edge of the glass, it's gone +// onto them. what goes over the edge of the glass falls off +// - the blades wipe, as they wipe the rain: a blade going over a texel in the step takes its snow (a little stays, and a wet +// trace of the water); what it takes is gone // - the flakes land: as many as come to the glass facing the snow coming at it against the cab (and a few in the eddies of the -// air where it doesn't face it), each bringing its snow to the texel; the faster the vehicle the more of the dry ones bounce off +// air where it doesn't face it), each bringing its snow to the texel; the faster the vehicle the more of the dry ones bounce off. +// near zero the flakes are wet: they bring some water with them (wet snow, lumps of slush) // - the snow melts: the glass is warmer than the air (the cab is heated), the less so the faster the vehicle goes; above zero the // snow melts at the glass into its water, the water dries slowly @@ -44,10 +43,12 @@ 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; +// how much warmer than the air the glass is, the share of the warmth given (water_snow.y, the cab heats it) +const float SNOW_WARMTH = 1.5; +// the share of a flake landing near zero already water (wet snow) +const float SNOW_WET_FLAKES = 0.5; // 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; @@ -58,9 +59,6 @@ const float SNOW_BLOW = 0.004; const float SNOW_RUN = 0.02; const float SNOW_RUN_AIR = 0.002; -// the neighbours of a texel -const ivec2 SNOW_AROUND[8] = ivec2[8](ivec2(-1, -1), ivec2(0, -1), ivec2(1, -1), ivec2(-1, 0), ivec2(1, 0), ivec2(-1, 1), ivec2(0, 1), ivec2(1, 1)); - uint snow_slot; uint snow_from; uint snow_axes_base; @@ -97,26 +95,6 @@ bool snow_crossed(ivec2 texel, int blade) return (now > before) ? ((place > before) && (place <= now)) : ((place < before) && (place >= now)); } -// the way the blade goes over the texel, a step of a texel (zero when it can't be told) -ivec2 snow_blade_way(ivec2 texel, int blade) -{ - float here = snow_blade(texel, blade); - float right = snow_blade(texel + ivec2(1, 0), blade); - float left = snow_blade(texel - ivec2(1, 0), blade); - float up = snow_blade(texel + ivec2(0, 1), blade); - float down = snow_blade(texel - ivec2(0, 1), blade); - // one-sided where a neighbour is out of the sweep - right = (right > 0.001) ? right : here; - left = (left > 0.001) ? left : here; - up = (up > 0.001) ? up : here; - down = (down > 0.001) ? down : here; - vec2 gradient = vec2(right - left, up - down); - if (dot(gradient, gradient) < 1e-12) - return ivec2(0); - vec2 way = normalize(gradient) * ((water_blades_now[blade] > water_blades_before[blade]) ? 1.0 : -1.0); - return ivec2(round(way)); -} - // whether no blade goes over the texel now: the snow piled there may slip onto its neighbours (in a sweep of a working blade // the snow it pushes would slip behind it, a stripe of snow left on the wiped glass for every step) bool snow_unswept(ivec2 texel) @@ -219,22 +197,6 @@ vec4 snow_move(ivec2 texel, vec4 state, float seconds) return vec4(snow, max(water, 0.0), (snow > 1e-4) ? clamp(packed / snow, 0.0, 1.0) : 0.0, state.w); } -// the snow and the water of the line of texels the blade went over in the step, ending at a texel (the blade goes on from it to -// the texel ahead), and the packing of the snow (summed for its snow) -vec3 snow_line(ivec2 last, int blade, ivec2 way) -{ - vec3 line = vec3(0.0); - for (int k = 0; k < SNOW_WIPE_LINE; ++k) - { - ivec2 texel = last - way * k; - if (false == snow_crossed(texel, blade)) - break; - vec4 state = water_snow_texel(snow_slot, snow_from, texel); - line += vec3(state.x, state.y, state.x * state.z); - } - return line; -} - void main() { snow_slot = gl_WorkGroupID.y; @@ -258,39 +220,10 @@ void main() vec4 before = water_snow_texel(snow_slot, snow_from, texel); vec4 state = snow_move(texel, before, seconds); - // the blades: taken where they went over, pushed on in front of them + // the blades: they take the snow where they went over bool crossed = false; - vec3 pushed = vec3(0.0); for (int blade = 0; blade < 4; ++blade) - { - if (snow_crossed(texel, blade)) - { - crossed = true; - continue; - } - // every texel the blade went over goes to one texel ahead at most, so the snow it pushes isn't counted twice (it would - // grow at every step): in the sweep the texel takes the line of texels behind itself along the way of the blade, off the - // sweep (the blade pushes the snow out at its edge) the line of one of its neighbours pointing at it - if (snow_blade(texel, blade) > 0.001) - { - ivec2 way = snow_blade_way(texel, blade); - if ((way != ivec2(0)) && snow_crossed(texel - way, blade)) - pushed += snow_line(texel - way, blade, way); - continue; - } - for (int k = 0; k < 8; ++k) - { - ivec2 from = texel + SNOW_AROUND[k]; - if (false == snow_crossed(from, blade)) - continue; - ivec2 way = snow_blade_way(from, blade); - if ((way != ivec2(0)) && (from + way == texel)) - { - pushed += snow_line(from, blade, way); - break; - } - } - } + crossed = crossed || snow_crossed(texel, blade); if (crossed) { float left = min(state.x * SNOW_WIPE_MISS, SNOW_WIPE_LEFT); @@ -298,14 +231,6 @@ void main() 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) - { - float snow = state.x + pushed.x; - // 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.5; - } // the flakes landing water_frame_s frame = snow_frame(texel); @@ -323,7 +248,10 @@ void main() if (count > 0.0) { float water = count * mix(SNOW_FLAKE_LEAST, SNOW_FLAKE_MOST, random.y * random.y); // mm3 - float added = water / SNOW_FRESH / max(area * 1e6, 1e-3); // mm of fresh snow over the texel + // the share of a wet flake already water (near zero) + float melting = SNOW_WET_FLAKES * smoothstep(-4.0, 0.5, water_up.w); + float added = water * (1.0 - melting) / SNOW_FRESH / max(area * 1e6, 1e-3); // mm of fresh snow over the texel + state.y += water * melting / max(area * 1e6, 1e-3); float snow = state.x + added; state.z = state.z * state.x / snow; // a flake on the bare glass has a shape of its own @@ -332,7 +260,7 @@ void main() } // the melting at the warm glass and the drying - float glass = water_up.w + water_snow.y / (1.0 + speed / 12.0); + float glass = water_up.w + water_snow.y * SNOW_WARMTH / (1.0 + speed / 25.0); float melted = min(SNOW_MELT * max(glass, 0.0) * seconds, state.x * density); state.x -= melted / max(density, 1e-3); float film = state.y * (1.0 - smoothstep(0.5, 3.0, state.x)); // the water not soaked into the snow diff --git a/shaders/vk14/mat_snow_windscreen.frag b/shaders/vk14/mat_snow_windscreen.frag index 34b24de40..1a8516b15 100644 --- a/shaders/vk14/mat_snow_windscreen.frag +++ b/shaders/vk14/mat_snow_windscreen.frag @@ -8,12 +8,13 @@ // // What lies on the glass comes from the simulation (water_snow.comp, water.glsl): the map of the glass keeps the snow, the water, // how packed the snow is and the shape of its flakes from frame to frame. The flakes land and stay where they landed, pile up, -// the blades push the snow into ridges at the ends of their sweeps and leave a wet trace, it melts at the warm glass, slush slides -// down. The renderer gives the glass its map through the param snow_slot (1 + its slot); a glass without a map has no snow. +// the blades wipe it as they wipe the rain (a wet trace stays), it melts at the warm glass, slush slides down. The renderer gives +// the glass its map through the param snow_slot (1 + its slot); a glass without a map has no snow. // // The look is only sprites from the atlas, as the drops of rain_windscreen and the splats of bugs_windscreen, two layers of them: // - the flakes: a sprite on every texel of the map holding snow, the more snow the bigger. Dry: crystals, flakes of a few of -// them, crumbs; wet: lumps; where only the water of a melted flake is left, a drop (it bends the picture behind, as rain does) +// them, crumbs; wet (near zero, melting): lumps of slush, grey and translucent with a frosted core; where only the water of a +// melted flake is left, a drop. The lumps and the drops bend the picture behind, as the drops of the rain // - the layer, under the flakes: a bigger sprite every three texels where the snow is thicker, clumps of flakes, then packed // snow, overlapping into a whole cover where the snow is thick; grey slush where it's wet // A thin flake lets the light through (ice crystals): the picture behind it is blurred, not hidden. @@ -145,7 +146,8 @@ void snSprite(vec2 local, int tile, float alpha, vec3 tone, vec2 rot, float flip acc.n = nT * a + acc.n * (1.0 - a); acc.tr = (1.0 - t.a * 0.55) * a + acc.tr * (1.0 - a); acc.a = a + acc.a * (1.0 - a); - if (tile == TILE_DROP) + // the drops and the wet lumps bend the picture behind them (water, slush), as the drops of the rain + if ((tile == TILE_DROP) || (tile == 8) || (tile == 9) || (tile == 14)) { snBend = snBend * (1.0 - a) + nuv * a; snBendA = snBendA * (1.0 - a) + a; @@ -221,7 +223,7 @@ void snFlakes(vec2 aspect, float pixelUV, inout sprite_acc acc) } else { - if (snWetness(q) > 0.35) + if (snWetness(q) > 0.25) tile = 8 + int(kind * 2.0); // wet lumps else if (kind < 0.25) tile = int(kind * 8.0); // star crystals (0, 1) @@ -269,7 +271,7 @@ void snLayer(vec2 aspect, float pixelUV, inout sprite_acc acc) if (false == snLocal(p, centre, size, aspect, rot, flip, aniso, local)) continue; int tile; - if (snWetness(q) > 0.45) + if (snWetness(q) > 0.35) tile = 14; // slush else if (q.x < 3.0) tile = 10 + int(kind * 2.0); // clumps @@ -277,7 +279,7 @@ void snLayer(vec2 aspect, float pixelUV, inout sprite_acc acc) tile = 12 + int(kind * 2.0); // packed snow float thick = 1.0 - exp(-q.x / (snow_opaque * mix(1.0, 0.5, q.z))); float alpha = mix(0.6, 1.0, thick); - // the ridges of the blades: packed and thick, a stronger relief + // packed thick snow: a stronger relief float bump = mix(1.0, 1.6, q.z * smoothstep(3.0, 12.0, q.x)); snSprite(local, min(tile, 14), alpha, snTone(q, random), rot, flip, snLod(pixelUV, size / cells), bump, acc); } @@ -372,7 +374,7 @@ void main() { vec4 req = vec4(0.0); float clear = 1.0 - smoothstep(0.5, 0.95, glassA); - if ((snBendA > 0.25) && (layer.a < 0.3) && (glassA < 0.5)) + if ((snBendA > 0.25) && (glassA < 0.5)) { vec2 bend = clamp(-snBend / max(snBendA, 1e-3) * snow_drop_bend, vec2(-1.0), vec2(1.0)) * smoothstep(0.25, 0.6, snBendA); req = vec4(WS_DROP_BIAS + WS_BEND_ENC * bend.x, WS_DROP_BIAS + WS_BEND_ENC * bend.y, 0.0, 1.0); diff --git a/shaders/vk14/water_snow.comp b/shaders/vk14/water_snow.comp index e4ea47a86..c69898985 100644 --- a/shaders/vk14/water_snow.comp +++ b/shaders/vk14/water_snow.comp @@ -9,13 +9,12 @@ // flakes (mat_snow_windscreen.frag). in a step, in this order: // - the snow and the water move: wet heavy snow (slush) slides down the glass, dry powder is blown along it by the air at speed, // the water runs down as a film and is pushed by the air; and snow piled higher than its neighbours by more than it holds slips -// onto them (a ridge left by a blade spreads into a wedge). what goes over the edge of the glass falls off -// - the blades: a blade going over a texel in the step takes its snow (a little stays, and a wet trace of the water), and pushes -// it on in front of itself: the texel just ahead of the line of texels the blade went over gets their snow, packed (each texel -// to one texel at most: the snow pushed along is never counted twice). at the end -// of its sweep the blade leaves it there, a ridge; pushed past the edge of the glass, it's gone +// onto them. what goes over the edge of the glass falls off +// - the blades wipe, as they wipe the rain: a blade going over a texel in the step takes its snow (a little stays, and a wet +// trace of the water); what it takes is gone // - the flakes land: as many as come to the glass facing the snow coming at it against the cab (and a few in the eddies of the -// air where it doesn't face it), each bringing its snow to the texel; the faster the vehicle the more of the dry ones bounce off +// air where it doesn't face it), each bringing its snow to the texel; the faster the vehicle the more of the dry ones bounce off. +// near zero the flakes are wet: they bring some water with them (wet snow, lumps of slush) // - the snow melts: the glass is warmer than the air (the cab is heated), the less so the faster the vehicle goes; above zero the // snow melts at the glass into its water, the water dries slowly @@ -47,10 +46,12 @@ 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; +// how much warmer than the air the glass is, the share of the warmth given (water_snow.y, the cab heats it) +const float SNOW_WARMTH = 1.5; +// the share of a flake landing near zero already water (wet snow) +const float SNOW_WET_FLAKES = 0.5; // 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; @@ -61,9 +62,6 @@ const float SNOW_BLOW = 0.004; const float SNOW_RUN = 0.02; const float SNOW_RUN_AIR = 0.002; -// the neighbours of a texel -const ivec2 SNOW_AROUND[8] = ivec2[8](ivec2(-1, -1), ivec2(0, -1), ivec2(1, -1), ivec2(-1, 0), ivec2(1, 0), ivec2(-1, 1), ivec2(0, 1), ivec2(1, 1)); - uint snow_slot; uint snow_from; uint snow_axes_base; @@ -100,26 +98,6 @@ bool snow_crossed(ivec2 texel, int blade) return (now > before) ? ((place > before) && (place <= now)) : ((place < before) && (place >= now)); } -// the way the blade goes over the texel, a step of a texel (zero when it can't be told) -ivec2 snow_blade_way(ivec2 texel, int blade) -{ - float here = snow_blade(texel, blade); - float right = snow_blade(texel + ivec2(1, 0), blade); - float left = snow_blade(texel - ivec2(1, 0), blade); - float up = snow_blade(texel + ivec2(0, 1), blade); - float down = snow_blade(texel - ivec2(0, 1), blade); - // one-sided where a neighbour is out of the sweep - right = (right > 0.001) ? right : here; - left = (left > 0.001) ? left : here; - up = (up > 0.001) ? up : here; - down = (down > 0.001) ? down : here; - vec2 gradient = vec2(right - left, up - down); - if (dot(gradient, gradient) < 1e-12) - return ivec2(0); - vec2 way = normalize(gradient) * ((water_blades_now[blade] > water_blades_before[blade]) ? 1.0 : -1.0); - return ivec2(round(way)); -} - // whether no blade goes over the texel now: the snow piled there may slip onto its neighbours (in a sweep of a working blade // the snow it pushes would slip behind it, a stripe of snow left on the wiped glass for every step) bool snow_unswept(ivec2 texel) @@ -222,22 +200,6 @@ vec4 snow_move(ivec2 texel, vec4 state, float seconds) return vec4(snow, max(water, 0.0), (snow > 1e-4) ? clamp(packed / snow, 0.0, 1.0) : 0.0, state.w); } -// the snow and the water of the line of texels the blade went over in the step, ending at a texel (the blade goes on from it to -// the texel ahead), and the packing of the snow (summed for its snow) -vec3 snow_line(ivec2 last, int blade, ivec2 way) -{ - vec3 line = vec3(0.0); - for (int k = 0; k < SNOW_WIPE_LINE; ++k) - { - ivec2 texel = last - way * k; - if (false == snow_crossed(texel, blade)) - break; - vec4 state = water_snow_texel(snow_slot, snow_from, texel); - line += vec3(state.x, state.y, state.x * state.z); - } - return line; -} - void main() { snow_slot = gl_WorkGroupID.y; @@ -261,39 +223,10 @@ void main() vec4 before = water_snow_texel(snow_slot, snow_from, texel); vec4 state = snow_move(texel, before, seconds); - // the blades: taken where they went over, pushed on in front of them + // the blades: they take the snow where they went over bool crossed = false; - vec3 pushed = vec3(0.0); for (int blade = 0; blade < 4; ++blade) - { - if (snow_crossed(texel, blade)) - { - crossed = true; - continue; - } - // every texel the blade went over goes to one texel ahead at most, so the snow it pushes isn't counted twice (it would - // grow at every step): in the sweep the texel takes the line of texels behind itself along the way of the blade, off the - // sweep (the blade pushes the snow out at its edge) the line of one of its neighbours pointing at it - if (snow_blade(texel, blade) > 0.001) - { - ivec2 way = snow_blade_way(texel, blade); - if ((way != ivec2(0)) && snow_crossed(texel - way, blade)) - pushed += snow_line(texel - way, blade, way); - continue; - } - for (int k = 0; k < 8; ++k) - { - ivec2 from = texel + SNOW_AROUND[k]; - if (false == snow_crossed(from, blade)) - continue; - ivec2 way = snow_blade_way(from, blade); - if ((way != ivec2(0)) && (from + way == texel)) - { - pushed += snow_line(from, blade, way); - break; - } - } - } + crossed = crossed || snow_crossed(texel, blade); if (crossed) { float left = min(state.x * SNOW_WIPE_MISS, SNOW_WIPE_LEFT); @@ -301,14 +234,6 @@ void main() 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) - { - float snow = state.x + pushed.x; - // 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.5; - } // the flakes landing water_frame_s frame = snow_frame(texel); @@ -326,7 +251,10 @@ void main() if (count > 0.0) { float water = count * mix(SNOW_FLAKE_LEAST, SNOW_FLAKE_MOST, random.y * random.y); // mm3 - float added = water / SNOW_FRESH / max(area * 1e6, 1e-3); // mm of fresh snow over the texel + // the share of a wet flake already water (near zero) + float melting = SNOW_WET_FLAKES * smoothstep(-4.0, 0.5, water_up.w); + float added = water * (1.0 - melting) / SNOW_FRESH / max(area * 1e6, 1e-3); // mm of fresh snow over the texel + state.y += water * melting / max(area * 1e6, 1e-3); float snow = state.x + added; state.z = state.z * state.x / snow; // a flake on the bare glass has a shape of its own @@ -335,7 +263,7 @@ void main() } // the melting at the warm glass and the drying - float glass = water_up.w + water_snow.y / (1.0 + speed / 12.0); + float glass = water_up.w + water_snow.y * SNOW_WARMTH / (1.0 + speed / 25.0); float melted = min(SNOW_MELT * max(glass, 0.0) * seconds, state.x * density); state.x -= melted / max(density, 1e-3); float film = state.y * (1.0 - smoothstep(0.5, 3.0, state.x)); // the water not soaked into the snow