BlueGit

timfa questward

Brighten highlights, boost contrast/speed, soften troughs, fix land-point diagonals.

Diagonal land wedges now sample the corner shore sprite for binary clip; wave flow is ~2x; crest sparkles go nearer white while trough ramps stay softer.

timfa Tim Falken · pushed by timfa

Authored 2026-09-04 · 2 months ago

Hash
c74965432797770e9c997cfb173db3d3f821fb7d
Parent
f2ce8e94
1 file changed +59 −26
client/src/render/worldView.js +59 −26
@@ -132,6 +132,10 @@ const WATER_GROUND_FRAG = [
132 132 "uniform float u_shoreEdgeE;",
133 133 "uniform float u_shoreEdgeS;",
134 134 "uniform float u_shoreEdgeW;",
135 "uniform float u_shoreEdgeNE;",
136 "uniform float u_shoreEdgeNW;",
137 "uniform float u_shoreEdgeSE;",
138 "uniform float u_shoreEdgeSW;",
135 139 "uniform vec4 u_shoreUvRect;",
136 140 // 3D simplex (Ashima / Gustavson style — OpenSimplex-class continuous field).
137 141 "vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }",
@@ -210,9 +214,10 @@ const WATER_GROUND_FRAG = [
210 214 " vec2 puv = px / 16.0;",
211 215 " vec2 world = vec2(u_tileX, u_tileY) + puv;",
212 216 " float t = u_time;",
213 " vec2 flow = vec2(t * 0.22, t * 0.14);",
217 // ~2× flow speed.
218 " vec2 flow = vec2(t * 0.44, t * 0.28);",
214 219 " float eps = 0.10;",
215 " vec3 base = vec3(world * 0.85 + flow, t * 0.35);",
220 " vec3 base = vec3(world * 0.85 + flow, t * 0.7);",
216 221 " float nC = fbm(base);",
217 222 " float nL = fbm(base + vec3(-eps, 0.0, 0.0));",
218 223 " float nR = fbm(base + vec3(eps, 0.0, 0.0));",
@@ -224,42 +229,42 @@ const WATER_GROUND_FRAG = [
224 229 " vec3 normal = normalize(vec3(nL - nR, nD - nU, 0.85));",
225 230 " float ndotl = clamp(dot(normal, normalize(vec3(-0.55, -0.5, 0.75))), 0.0, 1.0);",
226 231 " float wave = h * 0.5 + 0.5;",
227 // Brighter, tighter sparkles on crests (still matte body).
228 " float crest = smoothstep(0.62, 0.88, wave);",
229 " float glitter = max(pow(max(0.0, ndotl), 6.0) * crest, pow(crest, 3.2) * 0.65);",
232 " float crest = smoothstep(0.58, 0.90, wave);",
233 " float glitter = max(pow(max(0.0, ndotl), 5.5) * crest, pow(crest, 2.8) * 0.85);",
230 234 " float edgeProx = 0.0;",
231 235 " if (u_edgeN > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.y)); }",
232 236 " if (u_edgeS > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.y)); }",
233 237 " if (u_edgeW > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.x)); }",
234 238 " if (u_edgeE > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.x)); }",
239 // Stronger diagonal corner reach so land-point pockets clip (WWW vs land wedge).
235 240 " if (u_edgeNE > 0.5) {",
236 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(1.0 - puv.x, puv.y))));",
241 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(1.0 - puv.x, puv.y))));",
237 242 " }",
238 243 " if (u_edgeNW > 0.5) {",
239 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(puv.x, puv.y))));",
244 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(puv.x, puv.y))));",
240 245 " }",
241 246 " if (u_edgeSE > 0.5) {",
242 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(1.0 - puv.x, 1.0 - puv.y))));",
247 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(1.0 - puv.x, 1.0 - puv.y))));",
243 248 " }",
244 249 " if (u_edgeSW > 0.5) {",
245 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(puv.x, 1.0 - puv.y))));",
250 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(puv.x, 1.0 - puv.y))));",
246 251 " }",
247 252 " float waveBody = wave * (1.0 - edgeProx * 0.72);",
248 253 " float deepTop = mix(u_deepNW, u_deepNE, puv.x);",
249 254 " float deepBot = mix(u_deepSW, u_deepSE, puv.x);",
250 255 " float deepMix = mix(deepTop, deepBot, puv.y);",
251 // Deep stays blue (not near-black).
252 " vec3 deepCol = mix(vec3(0.14, 0.38, 0.58), vec3(0.08, 0.24, 0.44), deepMix);",
253 " vec3 midCol = mix(vec3(0.24, 0.52, 0.70), vec3(0.12, 0.34, 0.54), deepMix);",
254 " vec3 litCol = mix(vec3(0.50, 0.76, 0.90), vec3(0.28, 0.50, 0.70), deepMix);",
255 " vec3 sparkCol = mix(vec3(0.95, 0.99, 1.0), vec3(0.70, 0.88, 0.98), deepMix);",
256 " vec3 foamCol = vec3(0.92, 0.98, 1.0);",
257 // Gentler crest↔trough ramp.
258 " float shade = mix(0.88, 1.06, ndotl);",
259 " vec3 rgb = mix(deepCol, midCol, smoothstep(0.20, 0.68, waveBody));",
260 " rgb = mix(rgb, litCol, smoothstep(0.42, 0.95, waveBody) * 0.42);",
256 // More contrast: deeper troughs, brighter crests — still blue, not black.
257 " vec3 deepCol = mix(vec3(0.10, 0.32, 0.52), vec3(0.05, 0.18, 0.38), deepMix);",
258 " vec3 midCol = mix(vec3(0.22, 0.50, 0.68), vec3(0.10, 0.30, 0.50), deepMix);",
259 " vec3 litCol = mix(vec3(0.58, 0.82, 0.94), vec3(0.32, 0.55, 0.74), deepMix);",
260 " vec3 sparkCol = mix(vec3(1.0, 1.0, 1.0), vec3(0.82, 0.94, 1.0), deepMix);",
261 " vec3 foamCol = vec3(0.94, 0.99, 1.0);",
262 // Soft trough ramp; keep crest side relatively crisp.
263 " float shade = mix(0.82, 1.10, ndotl);",
264 " vec3 rgb = mix(deepCol, midCol, smoothstep(0.02, 0.78, waveBody));",
265 " rgb = mix(rgb, litCol, smoothstep(0.48, 0.92, waveBody) * 0.55);",
261 266 " rgb *= shade;",
262 " rgb = mix(rgb, sparkCol, clamp(glitter * 1.15, 0.0, 1.0) * (1.0 - edgeProx * 0.75));",
267 " rgb = mix(rgb, sparkCol, clamp(glitter * 1.45, 0.0, 1.0) * (1.0 - edgeProx * 0.7));",
263 268 " rgb = mix(rgb, deepCol, edgeProx * 0.45);",
264 269 " float shoreW = 0.0;",
265 270 " vec3 shoreRgb = rgb;",
@@ -275,11 +280,23 @@ const WATER_GROUND_FRAG = [
275 280 " if (u_edgeE > 0.5) {",
276 281 " sampleShore(1.0, u_shoreEdgeE, vec2(1.0 - puv.x, puv.y), shoreRgb, shoreW);",
277 282 " }",
283 // Land-point diagonals must also bind the neighbor ground (not only water-point cases).
284 " if (u_edgeNE > 0.5) {",
285 " sampleShore(1.0, max(u_shoreEdgeNE, u_hasShore), vec2(1.0 - puv.x, puv.y), shoreRgb, shoreW);",
286 " }",
287 " if (u_edgeNW > 0.5) {",
288 " sampleShore(1.0, max(u_shoreEdgeNW, u_hasShore), vec2(puv.x, puv.y), shoreRgb, shoreW);",
289 " }",
290 " if (u_edgeSE > 0.5) {",
291 " sampleShore(1.0, max(u_shoreEdgeSE, u_hasShore), vec2(1.0 - puv.x, 1.0 - puv.y), shoreRgb, shoreW);",
292 " }",
293 " if (u_edgeSW > 0.5) {",
294 " sampleShore(1.0, max(u_shoreEdgeSW, u_hasShore), vec2(puv.x, 1.0 - puv.y), shoreRgb, shoreW);",
295 " }",
278 296 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, waveBody);",
279 297 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
280 298 " float shoreClip = 0.42;",
281 299 " float shoreMask = step(shoreClip, retreat) * shoreW;",
282 // Foam on the last ~2–3 water pixels *before* the shore clip, not on the quad rim.
283 300 " float foamAmt = (1.0 - shoreMask) * smoothstep(shoreClip - 0.24, shoreClip - 0.08, retreat)",
284 301 " * (1.0 - smoothstep(shoreClip - 0.08, shoreClip, retreat));",
285 302 " rgb = mix(rgb, foamCol, foamAmt * 0.95);",
@@ -3401,13 +3418,13 @@ export class WorldView
3401 3418 if (edges?.w)
3402 3419 { candidates.push({ edge: "w", tileX: tileX - 1, tileY }); }
3403 3420 if (edges?.ne)
3404 { candidates.push({ edge: "e", tileX: tileX + 1, tileY: tileY - 1 }); }
3421 { candidates.push({ edge: "ne", tileX: tileX + 1, tileY: tileY - 1 }); }
3405 3422 if (edges?.nw)
3406 { candidates.push({ edge: "w", tileX: tileX - 1, tileY: tileY - 1 }); }
3423 { candidates.push({ edge: "nw", tileX: tileX - 1, tileY: tileY - 1 }); }
3407 3424 if (edges?.se)
3408 { candidates.push({ edge: "e", tileX: tileX + 1, tileY: tileY + 1 }); }
3425 { candidates.push({ edge: "se", tileX: tileX + 1, tileY: tileY + 1 }); }
3409 3426 if (edges?.sw)
3410 { candidates.push({ edge: "w", tileX: tileX - 1, tileY: tileY + 1 }); }
3427 { candidates.push({ edge: "sw", tileX: tileX - 1, tileY: tileY + 1 }); }
3411 3428 let pick = null;
3412 3429 for (const candidate of candidates)
3413 3430 {
@@ -3449,7 +3466,11 @@ export class WorldView
3449 3466 edgeN: 0,
3450 3467 edgeE: 0,
3451 3468 edgeS: 0,
3452 edgeW: 0
3469 edgeW: 0,
3470 edgeNE: 0,
3471 edgeNW: 0,
3472 edgeSE: 0,
3473 edgeSW: 0
3453 3474 };
3454 3475 if (pick?.edge === "n")
3455 3476 { shore.edgeN = 1; }
@@ -3459,6 +3480,14 @@ export class WorldView
3459 3480 { shore.edgeS = 1; }
3460 3481 else if (pick?.edge === "w")
3461 3482 { shore.edgeW = 1; }
3483 else if (pick?.edge === "ne")
3484 { shore.edgeNE = 1; }
3485 else if (pick?.edge === "nw")
3486 { shore.edgeNW = 1; }
3487 else if (pick?.edge === "se")
3488 { shore.edgeSE = 1; }
3489 else if (pick?.edge === "sw")
3490 { shore.edgeSW = 1; }
3462 3491 return shore;
3463 3492 }
3464 3493
@@ -3519,6 +3548,10 @@ export class WorldView
3519 3548 u_shoreEdgeE: shore?.edgeE ?? 0,
3520 3549 u_shoreEdgeS: shore?.edgeS ?? 0,
3521 3550 u_shoreEdgeW: shore?.edgeW ?? 0,
3551 u_shoreEdgeNE: shore?.edgeNE ?? 0,
3552 u_shoreEdgeNW: shore?.edgeNW ?? 0,
3553 u_shoreEdgeSE: shore?.edgeSE ?? 0,
3554 u_shoreEdgeSW: shore?.edgeSW ?? 0,
3522 3555 u_shoreUvRect: [shoreUv.u0, shoreUv.v0, shoreUv.u1, shoreUv.v1]
3523 3556 };
3524 3557 }
@@ -132,6 +132,10 @@ const WATER_GROUND_FRAG = [
132 "uniform float u_shoreEdgeE;",
132 "uniform float u_shoreEdgeE;",
133 "uniform float u_shoreEdgeS;",
133 "uniform float u_shoreEdgeS;",
134 "uniform float u_shoreEdgeW;",
134 "uniform float u_shoreEdgeW;",
135 "uniform float u_shoreEdgeNE;",
136 "uniform float u_shoreEdgeNW;",
137 "uniform float u_shoreEdgeSE;",
138 "uniform float u_shoreEdgeSW;",
135 "uniform vec4 u_shoreUvRect;",
139 "uniform vec4 u_shoreUvRect;",
136 // 3D simplex (Ashima / Gustavson style — OpenSimplex-class continuous field).
140 // 3D simplex (Ashima / Gustavson style — OpenSimplex-class continuous field).
137 "vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }",
141 "vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }",
@@ -210,9 +214,10 @@ const WATER_GROUND_FRAG = [
210 " vec2 puv = px / 16.0;",
214 " vec2 puv = px / 16.0;",
211 " vec2 world = vec2(u_tileX, u_tileY) + puv;",
215 " vec2 world = vec2(u_tileX, u_tileY) + puv;",
212 " float t = u_time;",
216 " float t = u_time;",
213 " vec2 flow = vec2(t * 0.22, t * 0.14);",
217 // ~2× flow speed.
218 " vec2 flow = vec2(t * 0.44, t * 0.28);",
214 " float eps = 0.10;",
219 " float eps = 0.10;",
215 " vec3 base = vec3(world * 0.85 + flow, t * 0.35);",
220 " vec3 base = vec3(world * 0.85 + flow, t * 0.7);",
216 " float nC = fbm(base);",
221 " float nC = fbm(base);",
217 " float nL = fbm(base + vec3(-eps, 0.0, 0.0));",
222 " float nL = fbm(base + vec3(-eps, 0.0, 0.0));",
218 " float nR = fbm(base + vec3(eps, 0.0, 0.0));",
223 " float nR = fbm(base + vec3(eps, 0.0, 0.0));",
@@ -224,42 +229,42 @@ const WATER_GROUND_FRAG = [
224 " vec3 normal = normalize(vec3(nL - nR, nD - nU, 0.85));",
229 " vec3 normal = normalize(vec3(nL - nR, nD - nU, 0.85));",
225 " float ndotl = clamp(dot(normal, normalize(vec3(-0.55, -0.5, 0.75))), 0.0, 1.0);",
230 " float ndotl = clamp(dot(normal, normalize(vec3(-0.55, -0.5, 0.75))), 0.0, 1.0);",
226 " float wave = h * 0.5 + 0.5;",
231 " float wave = h * 0.5 + 0.5;",
227 // Brighter, tighter sparkles on crests (still matte body).
232 " float crest = smoothstep(0.58, 0.90, wave);",
228 " float crest = smoothstep(0.62, 0.88, wave);",
233 " float glitter = max(pow(max(0.0, ndotl), 5.5) * crest, pow(crest, 2.8) * 0.85);",
229 " float glitter = max(pow(max(0.0, ndotl), 6.0) * crest, pow(crest, 3.2) * 0.65);",
230 " float edgeProx = 0.0;",
234 " float edgeProx = 0.0;",
231 " if (u_edgeN > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.y)); }",
235 " if (u_edgeN > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.y)); }",
232 " if (u_edgeS > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.y)); }",
236 " if (u_edgeS > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.y)); }",
233 " if (u_edgeW > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.x)); }",
237 " if (u_edgeW > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.x)); }",
234 " if (u_edgeE > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.x)); }",
238 " if (u_edgeE > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.x)); }",
239 // Stronger diagonal corner reach so land-point pockets clip (WWW vs land wedge).
235 " if (u_edgeNE > 0.5) {",
240 " if (u_edgeNE > 0.5) {",
236 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(1.0 - puv.x, puv.y))));",
241 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(1.0 - puv.x, puv.y))));",
237 " }",
242 " }",
238 " if (u_edgeNW > 0.5) {",
243 " if (u_edgeNW > 0.5) {",
239 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(puv.x, puv.y))));",
244 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(puv.x, puv.y))));",
240 " }",
245 " }",
241 " if (u_edgeSE > 0.5) {",
246 " if (u_edgeSE > 0.5) {",
242 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(1.0 - puv.x, 1.0 - puv.y))));",
247 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(1.0 - puv.x, 1.0 - puv.y))));",
243 " }",
248 " }",
244 " if (u_edgeSW > 0.5) {",
249 " if (u_edgeSW > 0.5) {",
245 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(puv.x, 1.0 - puv.y))));",
250 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(puv.x, 1.0 - puv.y))));",
246 " }",
251 " }",
247 " float waveBody = wave * (1.0 - edgeProx * 0.72);",
252 " float waveBody = wave * (1.0 - edgeProx * 0.72);",
248 " float deepTop = mix(u_deepNW, u_deepNE, puv.x);",
253 " float deepTop = mix(u_deepNW, u_deepNE, puv.x);",
249 " float deepBot = mix(u_deepSW, u_deepSE, puv.x);",
254 " float deepBot = mix(u_deepSW, u_deepSE, puv.x);",
250 " float deepMix = mix(deepTop, deepBot, puv.y);",
255 " float deepMix = mix(deepTop, deepBot, puv.y);",
251 // Deep stays blue (not near-black).
256 // More contrast: deeper troughs, brighter crests — still blue, not black.
252 " vec3 deepCol = mix(vec3(0.14, 0.38, 0.58), vec3(0.08, 0.24, 0.44), deepMix);",
257 " vec3 deepCol = mix(vec3(0.10, 0.32, 0.52), vec3(0.05, 0.18, 0.38), deepMix);",
253 " vec3 midCol = mix(vec3(0.24, 0.52, 0.70), vec3(0.12, 0.34, 0.54), deepMix);",
258 " vec3 midCol = mix(vec3(0.22, 0.50, 0.68), vec3(0.10, 0.30, 0.50), deepMix);",
254 " vec3 litCol = mix(vec3(0.50, 0.76, 0.90), vec3(0.28, 0.50, 0.70), deepMix);",
259 " vec3 litCol = mix(vec3(0.58, 0.82, 0.94), vec3(0.32, 0.55, 0.74), deepMix);",
255 " vec3 sparkCol = mix(vec3(0.95, 0.99, 1.0), vec3(0.70, 0.88, 0.98), deepMix);",
260 " vec3 sparkCol = mix(vec3(1.0, 1.0, 1.0), vec3(0.82, 0.94, 1.0), deepMix);",
256 " vec3 foamCol = vec3(0.92, 0.98, 1.0);",
261 " vec3 foamCol = vec3(0.94, 0.99, 1.0);",
257 // Gentler crest↔trough ramp.
262 // Soft trough ramp; keep crest side relatively crisp.
258 " float shade = mix(0.88, 1.06, ndotl);",
263 " float shade = mix(0.82, 1.10, ndotl);",
259 " vec3 rgb = mix(deepCol, midCol, smoothstep(0.20, 0.68, waveBody));",
264 " vec3 rgb = mix(deepCol, midCol, smoothstep(0.02, 0.78, waveBody));",
260 " rgb = mix(rgb, litCol, smoothstep(0.42, 0.95, waveBody) * 0.42);",
265 " rgb = mix(rgb, litCol, smoothstep(0.48, 0.92, waveBody) * 0.55);",
261 " rgb *= shade;",
266 " rgb *= shade;",
262 " rgb = mix(rgb, sparkCol, clamp(glitter * 1.15, 0.0, 1.0) * (1.0 - edgeProx * 0.75));",
267 " rgb = mix(rgb, sparkCol, clamp(glitter * 1.45, 0.0, 1.0) * (1.0 - edgeProx * 0.7));",
263 " rgb = mix(rgb, deepCol, edgeProx * 0.45);",
268 " rgb = mix(rgb, deepCol, edgeProx * 0.45);",
264 " float shoreW = 0.0;",
269 " float shoreW = 0.0;",
265 " vec3 shoreRgb = rgb;",
270 " vec3 shoreRgb = rgb;",
@@ -275,11 +280,23 @@ const WATER_GROUND_FRAG = [
275 " if (u_edgeE > 0.5) {",
280 " if (u_edgeE > 0.5) {",
276 " sampleShore(1.0, u_shoreEdgeE, vec2(1.0 - puv.x, puv.y), shoreRgb, shoreW);",
281 " sampleShore(1.0, u_shoreEdgeE, vec2(1.0 - puv.x, puv.y), shoreRgb, shoreW);",
277 " }",
282 " }",
283 // Land-point diagonals must also bind the neighbor ground (not only water-point cases).
284 " if (u_edgeNE > 0.5) {",
285 " sampleShore(1.0, max(u_shoreEdgeNE, u_hasShore), vec2(1.0 - puv.x, puv.y), shoreRgb, shoreW);",
286 " }",
287 " if (u_edgeNW > 0.5) {",
288 " sampleShore(1.0, max(u_shoreEdgeNW, u_hasShore), vec2(puv.x, puv.y), shoreRgb, shoreW);",
289 " }",
290 " if (u_edgeSE > 0.5) {",
291 " sampleShore(1.0, max(u_shoreEdgeSE, u_hasShore), vec2(1.0 - puv.x, 1.0 - puv.y), shoreRgb, shoreW);",
292 " }",
293 " if (u_edgeSW > 0.5) {",
294 " sampleShore(1.0, max(u_shoreEdgeSW, u_hasShore), vec2(puv.x, 1.0 - puv.y), shoreRgb, shoreW);",
295 " }",
278 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, waveBody);",
296 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, waveBody);",
279 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
297 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
280 " float shoreClip = 0.42;",
298 " float shoreClip = 0.42;",
281 " float shoreMask = step(shoreClip, retreat) * shoreW;",
299 " float shoreMask = step(shoreClip, retreat) * shoreW;",
282 // Foam on the last ~2–3 water pixels *before* the shore clip, not on the quad rim.
283 " float foamAmt = (1.0 - shoreMask) * smoothstep(shoreClip - 0.24, shoreClip - 0.08, retreat)",
300 " float foamAmt = (1.0 - shoreMask) * smoothstep(shoreClip - 0.24, shoreClip - 0.08, retreat)",
284 " * (1.0 - smoothstep(shoreClip - 0.08, shoreClip, retreat));",
301 " * (1.0 - smoothstep(shoreClip - 0.08, shoreClip, retreat));",
285 " rgb = mix(rgb, foamCol, foamAmt * 0.95);",
302 " rgb = mix(rgb, foamCol, foamAmt * 0.95);",
@@ -3401,13 +3418,13 @@ export class WorldView
3401 if (edges?.w)
3418 if (edges?.w)
3402 { candidates.push({ edge: "w", tileX: tileX - 1, tileY }); }
3419 { candidates.push({ edge: "w", tileX: tileX - 1, tileY }); }
3403 if (edges?.ne)
3420 if (edges?.ne)
3404 { candidates.push({ edge: "e", tileX: tileX + 1, tileY: tileY - 1 }); }
3421 { candidates.push({ edge: "ne", tileX: tileX + 1, tileY: tileY - 1 }); }
3405 if (edges?.nw)
3422 if (edges?.nw)
3406 { candidates.push({ edge: "w", tileX: tileX - 1, tileY: tileY - 1 }); }
3423 { candidates.push({ edge: "nw", tileX: tileX - 1, tileY: tileY - 1 }); }
3407 if (edges?.se)
3424 if (edges?.se)
3408 { candidates.push({ edge: "e", tileX: tileX + 1, tileY: tileY + 1 }); }
3425 { candidates.push({ edge: "se", tileX: tileX + 1, tileY: tileY + 1 }); }
3409 if (edges?.sw)
3426 if (edges?.sw)
3410 { candidates.push({ edge: "w", tileX: tileX - 1, tileY: tileY + 1 }); }
3427 { candidates.push({ edge: "sw", tileX: tileX - 1, tileY: tileY + 1 }); }
3411 let pick = null;
3428 let pick = null;
3412 for (const candidate of candidates)
3429 for (const candidate of candidates)
3413 {
3430 {
@@ -3449,7 +3466,11 @@ export class WorldView
3449 edgeN: 0,
3466 edgeN: 0,
3450 edgeE: 0,
3467 edgeE: 0,
3451 edgeS: 0,
3468 edgeS: 0,
3452 edgeW: 0
3469 edgeW: 0,
3470 edgeNE: 0,
3471 edgeNW: 0,
3472 edgeSE: 0,
3473 edgeSW: 0
3453 };
3474 };
3454 if (pick?.edge === "n")
3475 if (pick?.edge === "n")
3455 { shore.edgeN = 1; }
3476 { shore.edgeN = 1; }
@@ -3459,6 +3480,14 @@ export class WorldView
3459 { shore.edgeS = 1; }
3480 { shore.edgeS = 1; }
3460 else if (pick?.edge === "w")
3481 else if (pick?.edge === "w")
3461 { shore.edgeW = 1; }
3482 { shore.edgeW = 1; }
3483 else if (pick?.edge === "ne")
3484 { shore.edgeNE = 1; }
3485 else if (pick?.edge === "nw")
3486 { shore.edgeNW = 1; }
3487 else if (pick?.edge === "se")
3488 { shore.edgeSE = 1; }
3489 else if (pick?.edge === "sw")
3490 { shore.edgeSW = 1; }
3462 return shore;
3491 return shore;
3463 }
3492 }
3464
3493
@@ -3519,6 +3548,10 @@ export class WorldView
3519 u_shoreEdgeE: shore?.edgeE ?? 0,
3548 u_shoreEdgeE: shore?.edgeE ?? 0,
3520 u_shoreEdgeS: shore?.edgeS ?? 0,
3549 u_shoreEdgeS: shore?.edgeS ?? 0,
3521 u_shoreEdgeW: shore?.edgeW ?? 0,
3550 u_shoreEdgeW: shore?.edgeW ?? 0,
3551 u_shoreEdgeNE: shore?.edgeNE ?? 0,
3552 u_shoreEdgeNW: shore?.edgeNW ?? 0,
3553 u_shoreEdgeSE: shore?.edgeSE ?? 0,
3554 u_shoreEdgeSW: shore?.edgeSW ?? 0,
3522 u_shoreUvRect: [shoreUv.u0, shoreUv.v0, shoreUv.u1, shoreUv.v1]
3555 u_shoreUvRect: [shoreUv.u0, shoreUv.v0, shoreUv.u1, shoreUv.v1]
3523 };
3556 };
3524 }
3557 }