diff --git a/shaders/ogl46/mat_snow_windscreen.frag b/shaders/ogl46/mat_snow_windscreen.frag index 5d4ce8097..5bc35bb82 100644 --- a/shaders/ogl46/mat_snow_windscreen.frag +++ b/shaders/ogl46/mat_snow_windscreen.frag @@ -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); diff --git a/shaders/ogl46/water_snow.comp b/shaders/ogl46/water_snow.comp index ed0c8e34b..67dfc38d2 100644 --- a/shaders/ogl46/water_snow.comp +++ b/shaders/ogl46/water_snow.comp @@ -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); diff --git a/shaders/vk14/mat_snow_windscreen.frag b/shaders/vk14/mat_snow_windscreen.frag index b0f14979c..ef3749ce5 100644 --- a/shaders/vk14/mat_snow_windscreen.frag +++ b/shaders/vk14/mat_snow_windscreen.frag @@ -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); diff --git a/shaders/vk14/water_snow.comp b/shaders/vk14/water_snow.comp index d241d5fe3..edea8be2a 100644 --- a/shaders/vk14/water_snow.comp +++ b/shaders/vk14/water_snow.comp @@ -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);