mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 17:37:09 +01:00
Windscreen: rain rivulets run down the glass in the world, the snow as dense as before [skip ci]
- The rivulets of the weight (mat_rain_windscreen.frag) run down the glass in the world whichever way its texture lies on it: their layer is turned by a quarter turn at a time to the gravity on the glass in its UV (no turn on a glass mapped upright, so it looks the same there). - The grids of the lumps of the snow use the dense tiles again (2-5) as before the change of the tiles, the packed and wet lumps on 3% of the cells; the small clump, the dots and the scattered crystals (0, 1, 6, 7) only among the flakes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
This commit is contained in:
@@ -345,6 +345,10 @@ vec2 wsFromLayer(vec2 p)
|
||||
// the layers: 0 gravity, 1 air. WindShare: how much the air drives the water (0 standing still), WindCos / WindSin: the turn
|
||||
// of the layer of the air
|
||||
float wsWindShare = 0.0;
|
||||
// the layer of the weight turned by a quarter turn at a time so that its rivulets run down the glass in the world, whichever
|
||||
// way the texture lies on it (an island of the UV turned or upside down)
|
||||
float wsGravCos = 1.0;
|
||||
float wsGravSin = 0.0;
|
||||
float wsWindCos = 1.0;
|
||||
float wsWindSin = 0.0;
|
||||
void wsSetLayer(int layer)
|
||||
@@ -354,8 +358,8 @@ void wsSetLayer(int layer)
|
||||
wsLayerDensity = 1.0 - wsWindShare;
|
||||
wsLayerIndex = 0;
|
||||
wsLayerHead = 1.0;
|
||||
wsLayerCos = 1.0;
|
||||
wsLayerSin = 0.0;
|
||||
wsLayerCos = wsGravCos;
|
||||
wsLayerSin = wsGravSin;
|
||||
wsLayerVaried = false;
|
||||
}
|
||||
else
|
||||
@@ -554,8 +558,9 @@ void drawRivulet(inout Hit hit, Riv r, vec2 sUVr, vec2 rd1, vec2 rd2)
|
||||
float wsKept(vec2 cg, float rad, float sCW, float sCH, float gridSize)
|
||||
{
|
||||
wsSetLayer(0);
|
||||
Riv rv = getRiv(floor(cg / vec2(sCW, sCH)), sCW, sCH, gridSize);
|
||||
float kept = 1.0 - streak_sweep * rivSwept(rv, cg, rad);
|
||||
vec2 cl = wsToLayer(cg);
|
||||
Riv rv = getRiv(floor(cl / vec2(sCW, sCH)), sCW, sCH, gridSize);
|
||||
float kept = 1.0 - streak_sweep * rivSwept(rv, cl, rad);
|
||||
if (wsWindShare > 0.001)
|
||||
{
|
||||
wsSetLayer(1);
|
||||
@@ -660,6 +665,14 @@ void main()
|
||||
// to the glass UV (v up) through the tangent frame of the texture
|
||||
vec2 gravG = vec2(dot(wsGrav, Tgl), dot(wsGrav, Bgl) * flipS);
|
||||
vec2 flowG = vec2(dot(wsFlowDir, Tgl), dot(wsFlowDir, Bgl) * flipS);
|
||||
if (dot(gravG, gravG) > 1e-8)
|
||||
{
|
||||
// down the glass in its UV, to the nearest quarter turn (a finer turn would break the rivulets at the seams where a curved
|
||||
// glass bends); none on a glass lying flat
|
||||
float turn = round(atan(gravG.x, -gravG.y) / 1.5707963) * 1.5707963;
|
||||
wsGravCos = round(cos(turn));
|
||||
wsGravSin = round(sin(turn));
|
||||
}
|
||||
wsSpeed = smoothstep(0.3, 1.2, wsDrag); // 0 standing still .. 1 at speed (haze, drops)
|
||||
wsWindShare = smoothstep(0.5, 1.3, wsDrag); // how much the air drives the rivulets
|
||||
if (wsWindShare > 0.0)
|
||||
@@ -694,7 +707,8 @@ void main()
|
||||
float sCW = streak_cell / gridSize;
|
||||
float sCH = streak_run / gridSize;
|
||||
vec2 sUVg = vec2(f_coord.x, (STREAK_FLIP_Y != 0) ? 1.0 - f_coord.y : f_coord.y); // glass UV, v up
|
||||
vec2 sCell = floor(sUVg / vec2(sCW, sCH));
|
||||
vec2 sUVl = wsToLayer(sUVg); // the same in the layer of the weight (down: -v)
|
||||
vec2 sCell = floor(sUVl / vec2(sCW, sCH));
|
||||
bool sweepOn = streak_sweep > 0.0 && streak_density > 0.0 && (wind_streaks > 0.0 || wsWindShare < 1.0) && (WS_PROFILE != 2);
|
||||
|
||||
if ((rain_state.y > 0.001) && (WS_PROFILE != 5))
|
||||
@@ -835,7 +849,7 @@ void main()
|
||||
// ===================================================================
|
||||
#if WS_PROFILE != 2
|
||||
wsSetLayer(0);
|
||||
drawRivulet(hit, getRiv(sCell, sCW, sCH, gridSize), sUVg, wsRd1, wsRd2);
|
||||
drawRivulet(hit, getRiv(sCell, sCW, sCH, gridSize), sUVl, wsToLayerDir(wsRd1), wsToLayerDir(wsRd2));
|
||||
if (wsWindShare > 0.001)
|
||||
{
|
||||
for (int wl = 1; wl <= wind_layers; ++wl)
|
||||
|
||||
@@ -168,20 +168,19 @@ struct lump_grid
|
||||
};
|
||||
|
||||
// the grids of the lumps, coming one after the other as the snow piles up, each on the ones before, in the order they are laid
|
||||
// (front to back, the top one first): mostly icy fleece (the puffs and clumps of the first two rows of the atlas, tiles 0-7),
|
||||
// more and bigger, closing the glass by 2-3 mm; now and then a single lump on top: packed snow (tiles 10-13) or, more rarely, a
|
||||
// wet one with its film (tiles 8, 9)
|
||||
// (front to back, the top one first): all of them icy fleece (the dense puffs and clumps, tiles 2-5), more and bigger, closing
|
||||
// the glass by 2-3 mm; now and then a single lump on top: packed snow (tiles 10-13) or a wet one with its film (8, 9)
|
||||
const int SN_GRIDS = 9;
|
||||
const lump_grid sn_grids[SN_GRIDS] = lump_grid[SN_GRIDS](
|
||||
lump_grid(vec2(0.4, 0.6), 271u, vec2(0.6, 2.0), vec2(1.2, 1.6), 8, 6, 0.12),
|
||||
lump_grid(vec2(0.75), 251u, vec2(1.4, 2.8), vec2(2.0, 3.0), 0, 8, 1.0),
|
||||
lump_grid(vec2(0.0, 0.5), 233u, vec2(1.2, 2.4), vec2(2.0, 3.0), 0, 8, 1.0),
|
||||
lump_grid(vec2(0.5, 0.0), 199u, vec2(1.0, 2.0), vec2(2.0, 3.0), 0, 8, 1.0),
|
||||
lump_grid(vec2(0.75, 0.25), 151u, vec2(0.7, 1.6), vec2(1.8, 2.8), 4, 4, 1.0),
|
||||
lump_grid(vec2(0.25, 0.75), 113u, vec2(0.4, 1.2), vec2(1.8, 2.8), 4, 4, 1.0),
|
||||
lump_grid(vec2(0.25), 97u, vec2(0.2, 0.9), vec2(1.4, 2.4), 0, 4, 1.0),
|
||||
lump_grid(vec2(0.5), 77u, vec2(0.15, 0.7), vec2(1.4, 2.4), 0, 4, 1.0),
|
||||
lump_grid(vec2(0.0), 31u, vec2(0.02, 0.35), vec2(1.2, 2.0), 0, 4, 1.0));
|
||||
lump_grid(vec2(0.4, 0.6), 271u, vec2(0.6, 2.0), vec2(1.2, 1.6), 8, 6, 0.03),
|
||||
lump_grid(vec2(0.75), 251u, vec2(1.4, 2.8), vec2(2.0, 3.0), 4, 2, 1.0),
|
||||
lump_grid(vec2(0.0, 0.5), 233u, vec2(1.2, 2.4), vec2(2.0, 3.0), 4, 2, 1.0),
|
||||
lump_grid(vec2(0.5, 0.0), 199u, vec2(1.0, 2.0), vec2(2.0, 3.0), 4, 2, 1.0),
|
||||
lump_grid(vec2(0.75, 0.25), 151u, vec2(0.7, 1.6), vec2(1.8, 2.8), 4, 2, 1.0),
|
||||
lump_grid(vec2(0.25, 0.75), 113u, vec2(0.4, 1.2), vec2(1.8, 2.8), 4, 2, 1.0),
|
||||
lump_grid(vec2(0.25), 97u, vec2(0.2, 0.9), vec2(1.4, 2.4), 2, 4, 1.0),
|
||||
lump_grid(vec2(0.5), 77u, vec2(0.15, 0.7), vec2(1.4, 2.4), 2, 4, 1.0),
|
||||
lump_grid(vec2(0.0), 31u, vec2(0.02, 0.35), vec2(1.2, 2.0), 2, 4, 1.0));
|
||||
|
||||
const float SN_COVERED = 0.998; // the snow over the pixel covering it: the sprites under it are not looked at
|
||||
|
||||
@@ -220,7 +219,8 @@ bool snFlakeCell(vec2 p, ivec2 cell, vec2 perUV, float pixelUV, float reach, ino
|
||||
float alpha = smoothstep(0.03, 0.1, q.y);
|
||||
if (crystal)
|
||||
{
|
||||
tile = min(int(kind * 4.0), 3); // small icy puffs (the first row of the atlas)
|
||||
tile = min(int(kind * 4.0), 3); // the small clump, the dots and the scattered crystals (tiles 0, 1, 6, 7)
|
||||
tile += (tile < 2) ? 0 : 4;
|
||||
alpha = snow_thin;
|
||||
}
|
||||
snSprite(local, tile, alpha, snTone(q, random), rot, flip, snLod(pixelUV, size / max(perUV.x, perUV.y)), 1.0, acc);
|
||||
|
||||
@@ -350,6 +350,10 @@ vec2 wsFromLayer(vec2 p)
|
||||
// the layers: 0 gravity, 1 air. WindShare: how much the air drives the water (0 standing still), WindCos / WindSin: the turn
|
||||
// of the layer of the air
|
||||
float wsWindShare = 0.0;
|
||||
// the layer of the weight turned by a quarter turn at a time so that its rivulets run down the glass in the world, whichever
|
||||
// way the texture lies on it (an island of the UV turned or upside down)
|
||||
float wsGravCos = 1.0;
|
||||
float wsGravSin = 0.0;
|
||||
float wsWindCos = 1.0;
|
||||
float wsWindSin = 0.0;
|
||||
void wsSetLayer(int layer)
|
||||
@@ -359,8 +363,8 @@ void wsSetLayer(int layer)
|
||||
wsLayerDensity = 1.0 - wsWindShare;
|
||||
wsLayerIndex = 0;
|
||||
wsLayerHead = 1.0;
|
||||
wsLayerCos = 1.0;
|
||||
wsLayerSin = 0.0;
|
||||
wsLayerCos = wsGravCos;
|
||||
wsLayerSin = wsGravSin;
|
||||
wsLayerVaried = false;
|
||||
}
|
||||
else
|
||||
@@ -559,8 +563,9 @@ void drawRivulet(inout Hit hit, Riv r, vec2 sUVr, vec2 rd1, vec2 rd2)
|
||||
float wsKept(vec2 cg, float rad, float sCW, float sCH, float gridSize)
|
||||
{
|
||||
wsSetLayer(0);
|
||||
Riv rv = getRiv(floor(cg / vec2(sCW, sCH)), sCW, sCH, gridSize);
|
||||
float kept = 1.0 - streak_sweep * rivSwept(rv, cg, rad);
|
||||
vec2 cl = wsToLayer(cg);
|
||||
Riv rv = getRiv(floor(cl / vec2(sCW, sCH)), sCW, sCH, gridSize);
|
||||
float kept = 1.0 - streak_sweep * rivSwept(rv, cl, rad);
|
||||
if (wsWindShare > 0.001)
|
||||
{
|
||||
wsSetLayer(1);
|
||||
@@ -665,6 +670,14 @@ void main()
|
||||
// to the glass UV (v up) through the tangent frame of the texture
|
||||
vec2 gravG = vec2(dot(wsGrav, Tgl), dot(wsGrav, Bgl) * flipS);
|
||||
vec2 flowG = vec2(dot(wsFlowDir, Tgl), dot(wsFlowDir, Bgl) * flipS);
|
||||
if (dot(gravG, gravG) > 1e-8)
|
||||
{
|
||||
// down the glass in its UV, to the nearest quarter turn (a finer turn would break the rivulets at the seams where a curved
|
||||
// glass bends); none on a glass lying flat
|
||||
float turn = round(atan(gravG.x, -gravG.y) / 1.5707963) * 1.5707963;
|
||||
wsGravCos = round(cos(turn));
|
||||
wsGravSin = round(sin(turn));
|
||||
}
|
||||
wsSpeed = smoothstep(0.3, 1.2, wsDrag); // 0 standing still .. 1 at speed (haze, drops)
|
||||
wsWindShare = smoothstep(0.5, 1.3, wsDrag); // how much the air drives the rivulets
|
||||
if (wsWindShare > 0.0)
|
||||
@@ -699,7 +712,8 @@ void main()
|
||||
float sCW = streak_cell / gridSize;
|
||||
float sCH = streak_run / gridSize;
|
||||
vec2 sUVg = vec2(f_coord.x, (STREAK_FLIP_Y != 0) ? 1.0 - f_coord.y : f_coord.y); // glass UV, v up
|
||||
vec2 sCell = floor(sUVg / vec2(sCW, sCH));
|
||||
vec2 sUVl = wsToLayer(sUVg); // the same in the layer of the weight (down: -v)
|
||||
vec2 sCell = floor(sUVl / vec2(sCW, sCH));
|
||||
bool sweepOn = streak_sweep > 0.0 && streak_density > 0.0 && (wind_streaks > 0.0 || wsWindShare < 1.0) && (WS_PROFILE != 2);
|
||||
|
||||
if ((rain_state.y > 0.001) && (WS_PROFILE != 5))
|
||||
@@ -840,7 +854,7 @@ void main()
|
||||
// ===================================================================
|
||||
#if WS_PROFILE != 2
|
||||
wsSetLayer(0);
|
||||
drawRivulet(hit, getRiv(sCell, sCW, sCH, gridSize), sUVg, wsRd1, wsRd2);
|
||||
drawRivulet(hit, getRiv(sCell, sCW, sCH, gridSize), sUVl, wsToLayerDir(wsRd1), wsToLayerDir(wsRd2));
|
||||
if (wsWindShare > 0.001)
|
||||
{
|
||||
for (int wl = 1; wl <= wind_layers; ++wl)
|
||||
|
||||
@@ -168,20 +168,19 @@ struct lump_grid
|
||||
};
|
||||
|
||||
// the grids of the lumps, coming one after the other as the snow piles up, each on the ones before, in the order they are laid
|
||||
// (front to back, the top one first): mostly icy fleece (the puffs and clumps of the first two rows of the atlas, tiles 0-7),
|
||||
// more and bigger, closing the glass by 2-3 mm; now and then a single lump on top: packed snow (tiles 10-13) or, more rarely, a
|
||||
// wet one with its film (tiles 8, 9)
|
||||
// (front to back, the top one first): all of them icy fleece (the dense puffs and clumps, tiles 2-5), more and bigger, closing
|
||||
// the glass by 2-3 mm; now and then a single lump on top: packed snow (tiles 10-13) or a wet one with its film (8, 9)
|
||||
const int SN_GRIDS = 9;
|
||||
const lump_grid sn_grids[SN_GRIDS] = lump_grid[SN_GRIDS](
|
||||
lump_grid(vec2(0.4, 0.6), 271u, vec2(0.6, 2.0), vec2(1.2, 1.6), 8, 6, 0.12),
|
||||
lump_grid(vec2(0.75), 251u, vec2(1.4, 2.8), vec2(2.0, 3.0), 0, 8, 1.0),
|
||||
lump_grid(vec2(0.0, 0.5), 233u, vec2(1.2, 2.4), vec2(2.0, 3.0), 0, 8, 1.0),
|
||||
lump_grid(vec2(0.5, 0.0), 199u, vec2(1.0, 2.0), vec2(2.0, 3.0), 0, 8, 1.0),
|
||||
lump_grid(vec2(0.75, 0.25), 151u, vec2(0.7, 1.6), vec2(1.8, 2.8), 4, 4, 1.0),
|
||||
lump_grid(vec2(0.25, 0.75), 113u, vec2(0.4, 1.2), vec2(1.8, 2.8), 4, 4, 1.0),
|
||||
lump_grid(vec2(0.25), 97u, vec2(0.2, 0.9), vec2(1.4, 2.4), 0, 4, 1.0),
|
||||
lump_grid(vec2(0.5), 77u, vec2(0.15, 0.7), vec2(1.4, 2.4), 0, 4, 1.0),
|
||||
lump_grid(vec2(0.0), 31u, vec2(0.02, 0.35), vec2(1.2, 2.0), 0, 4, 1.0));
|
||||
lump_grid(vec2(0.4, 0.6), 271u, vec2(0.6, 2.0), vec2(1.2, 1.6), 8, 6, 0.03),
|
||||
lump_grid(vec2(0.75), 251u, vec2(1.4, 2.8), vec2(2.0, 3.0), 4, 2, 1.0),
|
||||
lump_grid(vec2(0.0, 0.5), 233u, vec2(1.2, 2.4), vec2(2.0, 3.0), 4, 2, 1.0),
|
||||
lump_grid(vec2(0.5, 0.0), 199u, vec2(1.0, 2.0), vec2(2.0, 3.0), 4, 2, 1.0),
|
||||
lump_grid(vec2(0.75, 0.25), 151u, vec2(0.7, 1.6), vec2(1.8, 2.8), 4, 2, 1.0),
|
||||
lump_grid(vec2(0.25, 0.75), 113u, vec2(0.4, 1.2), vec2(1.8, 2.8), 4, 2, 1.0),
|
||||
lump_grid(vec2(0.25), 97u, vec2(0.2, 0.9), vec2(1.4, 2.4), 2, 4, 1.0),
|
||||
lump_grid(vec2(0.5), 77u, vec2(0.15, 0.7), vec2(1.4, 2.4), 2, 4, 1.0),
|
||||
lump_grid(vec2(0.0), 31u, vec2(0.02, 0.35), vec2(1.2, 2.0), 2, 4, 1.0));
|
||||
|
||||
const float SN_COVERED = 0.998; // the snow over the pixel covering it: the sprites under it are not looked at
|
||||
|
||||
@@ -220,7 +219,8 @@ bool snFlakeCell(vec2 p, ivec2 cell, vec2 perUV, float pixelUV, float reach, ino
|
||||
float alpha = smoothstep(0.03, 0.1, q.y);
|
||||
if (crystal)
|
||||
{
|
||||
tile = min(int(kind * 4.0), 3); // small icy puffs (the first row of the atlas)
|
||||
tile = min(int(kind * 4.0), 3); // the small clump, the dots and the scattered crystals (tiles 0, 1, 6, 7)
|
||||
tile += (tile < 2) ? 0 : 4;
|
||||
alpha = snow_thin;
|
||||
}
|
||||
snSprite(local, tile, alpha, snTone(q, random), rot, flip, snLod(pixelUV, size / max(perUV.x, perUV.y)), 1.0, acc);
|
||||
|
||||
Reference in New Issue
Block a user