BlueGit

timfa questward

Harden water coasts to binary shore/water and fix depth + diagonal blend.

Crossed ridged caustic layers with faster glitter; shallow/deep uses corner-averaged bilinear depth; inner land diagonals get coast proximity; shore retreat is a hard step so pixels are fully water or fully shore.

timfa Tim Falken · pushed by timfa

Authored 2026-09-04 · 2 months ago

Hash
5ef8e8a965a39ff57f9a77c50fc73c49dcbcb3eb
Parent
8c2b4349
4 files changed +177 −99
client/assets/grounds/deep-water/deep-water.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/grounds/water/water.png Binary file +0 −0

The contents of this binary file are not shown.

client/scripts/write-water-caustics-noise.mjs +59 −23
@@ -1,6 +1,7 @@
1 1 /**
2 * Bake seamless multi-octave value-noise layers into water ground PNGs.
3 * R/G/B = three independent tiling fields for sliding additive caustics.
2 * Bake seamless water noise packs:
3 * R/G = soft Perlin body layers
4 * B/A = ridged “caustic vein” sprites for crossed glitter overlays
4 5 */
5 6 import { join } from "node:path";
6 7 import { makeRgba, writeRgbaPng } from "../../server/src/assets/placeholderPng.js";
@@ -52,35 +53,62 @@ function fbm (x, y, period, seed, octaves = 4)
52 53 return sum / norm;
53 54 }
54 55
55 function bakeLayer (seed, cells)
56 function normalizeLayer (values)
56 57 {
57 const values = new Float32Array(SIZE * SIZE);
58 58 let min = Infinity;
59 59 let max = -Infinity;
60 for (let y = 0; y < SIZE; y++)
60 for (let i = 0; i < values.length; i++)
61 61 {
62 for (let x = 0; x < SIZE; x++)
63 {
64 const v = fbm((x / SIZE) * cells, (y / SIZE) * cells, cells, seed);
65 values[y * SIZE + x] = v;
66 if (v < min)
67 { min = v; }
68 if (v > max)
69 { max = v; }
70 }
62 if (values[i] < min)
63 { min = values[i]; }
64 if (values[i] > max)
65 { max = values[i]; }
71 66 }
72 67 const span = Math.max(1e-6, max - min);
73 const out = new Uint8Array(SIZE * SIZE);
68 const out = new Uint8Array(values.length);
74 69 for (let i = 0; i < values.length; i++)
75 70 { out[i] = Math.round(((values[i] - min) / span) * 255); }
76 71 return out;
77 72 }
78 73
79 function writePackedNoise (file, seeds)
74 function bakeSoft (seed, cells)
75 {
76 const values = new Float32Array(SIZE * SIZE);
77 for (let y = 0; y < SIZE; y++)
78 {
79 for (let x = 0; x < SIZE; x++)
80 { values[y * SIZE + x] = fbm((x / SIZE) * cells, (y / SIZE) * cells, cells, seed); }
81 }
82 return normalizeLayer(values);
83 }
84
85 /** Ridged / vein caustic: bright thin networks on dark. */
86 function bakeCaustic (seed, cells)
87 {
88 const values = new Float32Array(SIZE * SIZE);
89 for (let y = 0; y < SIZE; y++)
90 {
91 for (let x = 0; x < SIZE; x++)
92 {
93 const nx = (x / SIZE) * cells;
94 const ny = (y / SIZE) * cells;
95 const n1 = fbm(nx, ny, cells, seed, 5);
96 const n2 = fbm(nx + 3.1, ny - 1.7, cells, seed + 17.3, 4);
97 const ridge = 1 - Math.abs(n1 * 2 - 1);
98 const ridge2 = 1 - Math.abs(n2 * 2 - 1);
99 const veins = Math.pow(ridge, 3.2) * 0.75 + Math.pow(ridge * ridge2, 2.4) * 0.55;
100 values[y * SIZE + x] = veins;
101 }
102 }
103 return normalizeLayer(values);
104 }
105
106 function writePackedNoise (file, softSeeds, causticSeeds)
80 107 {
81 const r = bakeLayer(seeds[0], 4);
82 const g = bakeLayer(seeds[1], 5);
83 const b = bakeLayer(seeds[2], 6);
108 const r = bakeSoft(softSeeds[0], 4);
109 const g = bakeSoft(softSeeds[1], 5);
110 const b = bakeCaustic(causticSeeds[0], 7);
111 const a = bakeCaustic(causticSeeds[1], 8);
84 112 const image = makeRgba(SIZE, SIZE, [0, 0, 0, 255]);
85 113 for (let i = 0; i < SIZE * SIZE; i++)
86 114 {
@@ -88,12 +116,20 @@ function writePackedNoise (file, seeds)
88 116 image.pixels[o] = r[i];
89 117 image.pixels[o + 1] = g[i];
90 118 image.pixels[o + 2] = b[i];
91 image.pixels[o + 3] = 255;
119 image.pixels[o + 3] = a[i];
92 120 }
93 121 writeRgbaPng(file, SIZE, SIZE, image.pixels);
94 122 }
95 123
96 writePackedNoise(join(root, "grounds", "water", "water.png"), [11.3, 27.9, 41.2]);
97 writePackedNoise(join(root, "grounds", "deep-water", "deep-water.png"), [53.7, 67.1, 89.4]);
124 writePackedNoise(
125 join(root, "grounds", "water", "water.png"),
126 [11.3, 27.9],
127 [101.4, 133.8]
128 );
129 writePackedNoise(
130 join(root, "grounds", "deep-water", "deep-water.png"),
131 [53.7, 67.1],
132 [157.2, 191.6]
133 );
98 134
99 console.log(`Wrote ${SIZE}x${SIZE} RGB tiling Perlin packs for water + deep-water.`);
135 console.log(`Wrote ${SIZE}x${SIZE} RGBA soft+caustic packs for water + deep-water.`);
@@ -1,6 +1,7 @@
1/**
1/**
2 * Bake seamless multi-octave value-noise layers into water ground PNGs.
2 * Bake seamless water noise packs:
3 * R/G/B = three independent tiling fields for sliding additive caustics.
3 * R/G = soft Perlin body layers
4 * B/A = ridged “caustic vein” sprites for crossed glitter overlays
4 */
5 */
5import { join } from "node:path";
6import { join } from "node:path";
6import { makeRgba, writeRgbaPng } from "../../server/src/assets/placeholderPng.js";
7import { makeRgba, writeRgbaPng } from "../../server/src/assets/placeholderPng.js";
@@ -52,35 +53,62 @@ function fbm (x, y, period, seed, octaves = 4)
52 return sum / norm;
53 return sum / norm;
53}
54}
54
55
55function bakeLayer (seed, cells)
56function normalizeLayer (values)
56{
57{
57 const values = new Float32Array(SIZE * SIZE);
58 let min = Infinity;
58 let min = Infinity;
59 let max = -Infinity;
59 let max = -Infinity;
60 for (let y = 0; y < SIZE; y++)
60 for (let i = 0; i < values.length; i++)
61 {
61 {
62 for (let x = 0; x < SIZE; x++)
62 if (values[i] < min)
63 {
63 { min = values[i]; }
64 const v = fbm((x / SIZE) * cells, (y / SIZE) * cells, cells, seed);
64 if (values[i] > max)
65 values[y * SIZE + x] = v;
65 { max = values[i]; }
66 if (v < min)
67 { min = v; }
68 if (v > max)
69 { max = v; }
70 }
71 }
66 }
72 const span = Math.max(1e-6, max - min);
67 const span = Math.max(1e-6, max - min);
73 const out = new Uint8Array(SIZE * SIZE);
68 const out = new Uint8Array(values.length);
74 for (let i = 0; i < values.length; i++)
69 for (let i = 0; i < values.length; i++)
75 { out[i] = Math.round(((values[i] - min) / span) * 255); }
70 { out[i] = Math.round(((values[i] - min) / span) * 255); }
76 return out;
71 return out;
77}
72}
78
73
79function writePackedNoise (file, seeds)
74function bakeSoft (seed, cells)
75{
76 const values = new Float32Array(SIZE * SIZE);
77 for (let y = 0; y < SIZE; y++)
78 {
79 for (let x = 0; x < SIZE; x++)
80 { values[y * SIZE + x] = fbm((x / SIZE) * cells, (y / SIZE) * cells, cells, seed); }
81 }
82 return normalizeLayer(values);
83}
84
85/** Ridged / vein caustic: bright thin networks on dark. */
86function bakeCaustic (seed, cells)
87{
88 const values = new Float32Array(SIZE * SIZE);
89 for (let y = 0; y < SIZE; y++)
90 {
91 for (let x = 0; x < SIZE; x++)
92 {
93 const nx = (x / SIZE) * cells;
94 const ny = (y / SIZE) * cells;
95 const n1 = fbm(nx, ny, cells, seed, 5);
96 const n2 = fbm(nx + 3.1, ny - 1.7, cells, seed + 17.3, 4);
97 const ridge = 1 - Math.abs(n1 * 2 - 1);
98 const ridge2 = 1 - Math.abs(n2 * 2 - 1);
99 const veins = Math.pow(ridge, 3.2) * 0.75 + Math.pow(ridge * ridge2, 2.4) * 0.55;
100 values[y * SIZE + x] = veins;
101 }
102 }
103 return normalizeLayer(values);
104}
105
106function writePackedNoise (file, softSeeds, causticSeeds)
80{
107{
81 const r = bakeLayer(seeds[0], 4);
108 const r = bakeSoft(softSeeds[0], 4);
82 const g = bakeLayer(seeds[1], 5);
109 const g = bakeSoft(softSeeds[1], 5);
83 const b = bakeLayer(seeds[2], 6);
110 const b = bakeCaustic(causticSeeds[0], 7);
111 const a = bakeCaustic(causticSeeds[1], 8);
84 const image = makeRgba(SIZE, SIZE, [0, 0, 0, 255]);
112 const image = makeRgba(SIZE, SIZE, [0, 0, 0, 255]);
85 for (let i = 0; i < SIZE * SIZE; i++)
113 for (let i = 0; i < SIZE * SIZE; i++)
86 {
114 {
@@ -88,12 +116,20 @@ function writePackedNoise (file, seeds)
88 image.pixels[o] = r[i];
116 image.pixels[o] = r[i];
89 image.pixels[o + 1] = g[i];
117 image.pixels[o + 1] = g[i];
90 image.pixels[o + 2] = b[i];
118 image.pixels[o + 2] = b[i];
91 image.pixels[o + 3] = 255;
119 image.pixels[o + 3] = a[i];
92 }
120 }
93 writeRgbaPng(file, SIZE, SIZE, image.pixels);
121 writeRgbaPng(file, SIZE, SIZE, image.pixels);
94}
122}
95
123
96writePackedNoise(join(root, "grounds", "water", "water.png"), [11.3, 27.9, 41.2]);
124writePackedNoise(
97writePackedNoise(join(root, "grounds", "deep-water", "deep-water.png"), [53.7, 67.1, 89.4]);
125 join(root, "grounds", "water", "water.png"),
126 [11.3, 27.9],
127 [101.4, 133.8]
128);
129writePackedNoise(
130 join(root, "grounds", "deep-water", "deep-water.png"),
131 [53.7, 67.1],
132 [157.2, 191.6]
133);
98
134
99console.log(`Wrote ${SIZE}x${SIZE} RGB tiling Perlin packs for water + deep-water.`);
135console.log(`Wrote ${SIZE}x${SIZE} RGBA soft+caustic packs for water + deep-water.`);
client/src/render/worldView.js +118 −76
@@ -115,19 +115,19 @@ const WATER_GROUND_FRAG = [
115 115 "uniform float u_time;",
116 116 "uniform float u_tileX;",
117 117 "uniform float u_tileY;",
118 "uniform float u_deep;",
119 "uniform float u_nbrDeepN;",
120 "uniform float u_nbrDeepE;",
121 "uniform float u_nbrDeepS;",
122 "uniform float u_nbrDeepW;",
123 "uniform float u_blendDeepN;",
124 "uniform float u_blendDeepE;",
125 "uniform float u_blendDeepS;",
126 "uniform float u_blendDeepW;",
118 // Corner deepness (avg of liquid water tiles meeting each corner) — bilinear field.
119 "uniform float u_deepNW;",
120 "uniform float u_deepNE;",
121 "uniform float u_deepSW;",
122 "uniform float u_deepSE;",
127 123 "uniform float u_edgeN;",
128 124 "uniform float u_edgeE;",
129 125 "uniform float u_edgeS;",
130 126 "uniform float u_edgeW;",
127 "uniform float u_edgeNE;",
128 "uniform float u_edgeNW;",
129 "uniform float u_edgeSE;",
130 "uniform float u_edgeSW;",
131 131 "uniform float u_hasShore;",
132 132 "uniform float u_shoreEdgeN;",
133 133 "uniform float u_shoreEdgeE;",
@@ -139,7 +139,6 @@ const WATER_GROUND_FRAG = [
139 139 " float s = sin(a);",
140 140 " return vec2(c * p.x - s * p.y, s * p.x + c * p.y);",
141 141 "}",
142 // Wrap UV into (0,1) so CLAMP_TO_EDGE textures still tile when scrolled.
143 142 "vec2 wrapUv(vec2 uv) {",
144 143 " return fract(uv) * 0.998 + 0.001;",
145 144 "}",
@@ -160,49 +159,57 @@ const WATER_GROUND_FRAG = [
160 159 " vec2 puv = px / 16.0;",
161 160 " vec2 world = vec2(u_tileX, u_tileY) + puv;",
162 161 " float t = u_time;",
163 // Three baked Perlin channels, scrolled at different angles / speeds, additive caustics.
164 " vec2 uvR = wrapUv(rot2(world * 0.42, 0.35) + vec2(t * 0.13, t * 0.09));",
165 " vec2 uvG = wrapUv(rot2(world * 0.51, -1.05) + vec2(-t * 0.105, t * 0.145));",
166 " vec2 uvB = wrapUv(rot2(world * 0.63, 1.55) + vec2(t * 0.16, -t * 0.08));",
167 " float nR = texture2D(u_texture, uvR).r;",
168 " float nG = texture2D(u_texture, uvG).g;",
169 " float nB = texture2D(u_texture, uvB).b;",
170 " float caustic = nR * 0.45 + nG * 0.40 + nB * 0.35;",
171 " caustic += nR * nG * 0.55 + nG * nB * 0.35;",
172 " caustic = clamp(caustic * 0.72, 0.0, 1.0);",
173 " caustic = pow(caustic, 1.35);",
174 // Coast proximity first — damp caustics so water softens before the land sprite edge.
162 // Soft body layers (R/G) + crossed caustic vein sprites (B/A).
163 " vec2 uvSoftR = wrapUv(rot2(world * 0.42, 0.35) + vec2(t * 0.39, t * 0.27));",
164 " vec2 uvSoftG = wrapUv(rot2(world * 0.51, -1.05) + vec2(-t * 0.315, t * 0.435));",
165 " vec2 uvCau1 = wrapUv(rot2(world * 0.95, 0.55) + vec2(t * 0.52, -t * 0.28));",
166 " vec2 uvCau2 = wrapUv(rot2(world * 1.15, -1.25) + vec2(-t * 0.41, t * 0.58));",
167 " float softR = texture2D(u_texture, uvSoftR).r;",
168 " float softG = texture2D(u_texture, uvSoftG).g;",
169 " float cau1 = texture2D(u_texture, uvCau1).b;",
170 " float cau2 = texture2D(u_texture, uvCau2).a;",
171 " float soft = softR * 0.55 + softG * 0.45 + softR * softG * 0.25;",
172 " float veins = cau1 * 0.65 + cau2 * 0.65 + cau1 * cau2 * 0.85;",
173 " veins = clamp(veins, 0.0, 1.0);",
174 " float caustic = clamp(soft * 0.55 + veins * 0.75, 0.0, 1.0);",
175 " caustic = pow(caustic, 1.15);",
176 // Glitter: push bright caustic veins to white extremes.
177 " float glitter = pow(max(cau1, cau2), 5.5);",
178 " glitter = max(glitter, pow(cau1 * cau2, 3.2) * 1.35);",
179 " glitter = clamp(glitter, 0.0, 1.0);",
180 // Cardinal + diagonal land proximity (inner corners like WWW/WLL).
175 181 " float edgeProx = 0.0;",
176 182 " if (u_edgeN > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.y)); }",
177 183 " if (u_edgeS > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.y)); }",
178 184 " if (u_edgeW > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.x)); }",
179 185 " if (u_edgeE > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.x)); }",
180 " float causticBody = caustic * (1.0 - edgeProx * 0.72);",
181 // Shallow↔deep: approach the midpoint at the shared edge (not full swap).
182 " float deepMix = u_deep;",
183 " if (u_blendDeepN > 0.5) {",
184 " float w = smoothstep(0.55, 0.0, puv.y);",
185 " deepMix = mix(deepMix, mix(u_deep, u_nbrDeepN, 0.5), w);",
186 " if (u_edgeNE > 0.5) {",
187 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(1.0 - puv.x, puv.y))));",
186 188 " }",
187 " if (u_blendDeepS > 0.5) {",
188 " float w = smoothstep(0.55, 0.0, 1.0 - puv.y);",
189 " deepMix = mix(deepMix, mix(u_deep, u_nbrDeepS, 0.5), w);",
189 " if (u_edgeNW > 0.5) {",
190 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(puv.x, puv.y))));",
190 191 " }",
191 " if (u_blendDeepW > 0.5) {",
192 " float w = smoothstep(0.55, 0.0, puv.x);",
193 " deepMix = mix(deepMix, mix(u_deep, u_nbrDeepW, 0.5), w);",
192 " if (u_edgeSE > 0.5) {",
193 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(1.0 - puv.x, 1.0 - puv.y))));",
194 194 " }",
195 " if (u_blendDeepE > 0.5) {",
196 " float w = smoothstep(0.55, 0.0, 1.0 - puv.x);",
197 " deepMix = mix(deepMix, mix(u_deep, u_nbrDeepE, 0.5), w);",
195 " if (u_edgeSW > 0.5) {",
196 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(puv.x, 1.0 - puv.y))));",
198 197 " }",
198 " float causticBody = caustic * (1.0 - edgeProx * 0.72);",
199 " float glitterBody = glitter * (1.0 - edgeProx * 0.85);",
200 // Continuous shallow↔deep field via corner averages (seamless across tile edges + corners).
201 " float deepTop = mix(u_deepNW, u_deepNE, puv.x);",
202 " float deepBot = mix(u_deepSW, u_deepSE, puv.x);",
203 " float deepMix = mix(deepTop, deepBot, puv.y);",
199 204 " vec3 deepCol = mix(vec3(0.12, 0.36, 0.56), vec3(0.06, 0.18, 0.34), deepMix);",
200 205 " vec3 midCol = mix(vec3(0.22, 0.52, 0.70), vec3(0.12, 0.34, 0.54), deepMix);",
201 206 " vec3 litCol = mix(vec3(0.55, 0.82, 0.94), vec3(0.34, 0.60, 0.82), deepMix);",
202 " vec3 rgb = mix(deepCol, midCol, smoothstep(0.15, 0.55, causticBody));",
203 " rgb = mix(rgb, litCol, smoothstep(0.45, 0.92, causticBody));",
204 // Force darker near land so the coastline eases into the hard ground sprite.
205 " rgb = mix(rgb, deepCol, edgeProx * 0.62);",
207 " vec3 sparkCol = mix(vec3(0.92, 0.98, 1.0), vec3(0.72, 0.88, 0.98), deepMix);",
208 " vec3 rgb = mix(deepCol, midCol, smoothstep(0.12, 0.48, causticBody));",
209 " rgb = mix(rgb, litCol, smoothstep(0.40, 0.88, causticBody));",
210 " rgb = mix(rgb, sparkCol, glitterBody * 0.95);",
211 // Darken near land, but stay solid water (no pastel half-blend).
212 " rgb = mix(rgb, deepCol, edgeProx * 0.55);",
206 213 " float shoreW = 0.0;",
207 214 " vec3 shoreRgb = rgb;",
208 215 " if (u_edgeN > 0.5) {",
@@ -217,13 +224,10 @@ const WATER_GROUND_FRAG = [
217 224 " if (u_edgeE > 0.5) {",
218 225 " sampleShore(1.0, u_shoreEdgeE, vec2(1.0 - puv.x, puv.y), shoreRgb, shoreW);",
219 226 " }",
220 " float lightAmt = smoothstep(0.48, 0.82, causticBody);",
227 // Binary coast: full shore pixel or full water pixel — never a translucent mix.
221 228 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, causticBody);",
222 " vec3 edgeBlue = mix(vec3(0.50, 0.78, 0.92), vec3(0.32, 0.58, 0.80), deepMix);",
223 " rgb = mix(rgb, edgeBlue, edgeProx * lightAmt * 0.35);",
224 " if (shoreW > 0.5) {",
225 " rgb = mix(rgb, shoreRgb, edgeProx * darkAmt * 0.88);",
226 " }",
229 " float shoreMask = step(0.42, edgeProx * (0.35 + 0.65 * darkAmt)) * shoreW;",
230 " rgb = mix(rgb, shoreRgb, shoreMask);",
227 231 " float litTop = mix(u_litNW, u_litNE, v_texCoord.x);",
228 232 " float litBottom = mix(u_litSW, u_litSE, v_texCoord.x);",
229 233 " float lit = mix(litTop, litBottom, v_texCoord.y);",
@@ -3265,32 +3269,62 @@ export class WorldView
3265 3269 #waterCoastEdges (tileX, tileY)
3266 3270 {
3267 3271 const season = this.worldSeason;
3272 const liquid = (x, y) => isLiquidWaterGround(this.#groundTypeAt(x, y), season);
3273 const n = liquid(tileX, tileY - 1);
3274 const e = liquid(tileX + 1, tileY);
3275 const s = liquid(tileX, tileY + 1);
3276 const w = liquid(tileX - 1, tileY);
3277 const ne = liquid(tileX + 1, tileY - 1);
3278 const nw = liquid(tileX - 1, tileY - 1);
3279 const se = liquid(tileX + 1, tileY + 1);
3280 const sw = liquid(tileX - 1, tileY + 1);
3268 3281 return {
3269 n: !isLiquidWaterGround(this.#groundTypeAt(tileX, tileY - 1), season) ? 1 : 0,
3270 e: !isLiquidWaterGround(this.#groundTypeAt(tileX + 1, tileY), season) ? 1 : 0,
3271 s: !isLiquidWaterGround(this.#groundTypeAt(tileX, tileY + 1), season) ? 1 : 0,
3272 w: !isLiquidWaterGround(this.#groundTypeAt(tileX - 1, tileY), season) ? 1 : 0
3282 n: n ? 0 : 1,
3283 e: e ? 0 : 1,
3284 s: s ? 0 : 1,
3285 w: w ? 0 : 1,
3286 // Pure diagonal land pockets (e.g. WWW/WLL) — only when cardinals stay water.
3287 ne: (!ne && n && e) ? 1 : 0,
3288 nw: (!nw && n && w) ? 1 : 0,
3289 se: (!se && s && e) ? 1 : 0,
3290 sw: (!sw && s && w) ? 1 : 0
3273 3291 };
3274 3292 }
3275 3293
3276 /** Shallow↔deep edge blend: neighbor deepness only when both tiles are liquid water of different depth. */
3277 #waterDeepBlend (tileX, tileY, selfDeep)
3294 /**
3295 * Corner deepness = average of liquid-water tiles meeting that corner.
3296 * Bilinear sampling of these corners is continuous across shared edges/corners.
3297 */
3298 #waterDeepCorners (tileX, tileY, selfDeep)
3278 3299 {
3279 3300 const season = this.worldSeason;
3280 const self = selfDeep ? 1 : 0;
3281 const side = (x, y) =>
3301 const fallback = selfDeep ? 1 : 0;
3302 const depthAt = (x, y) =>
3282 3303 {
3283 3304 const typeId = this.#groundTypeAt(x, y);
3284 3305 if (!isLiquidWaterGround(typeId, season))
3285 { return { deep: self, blend: 0 }; }
3286 const deep = typeId === GroundType.deepWater ? 1 : 0;
3287 return { deep, blend: deep !== self ? 1 : 0 };
3306 { return null; }
3307 return typeId === GroundType.deepWater ? 1 : 0;
3308 };
3309 const corner = (offsets) =>
3310 {
3311 let sum = 0;
3312 let count = 0;
3313 for (const [dx, dy] of offsets)
3314 {
3315 const d = depthAt(tileX + dx, tileY + dy);
3316 if (d == null)
3317 { continue; }
3318 sum += d;
3319 count += 1;
3320 }
3321 return count ? sum / count : fallback;
3288 3322 };
3289 3323 return {
3290 n: side(tileX, tileY - 1),
3291 e: side(tileX + 1, tileY),
3292 s: side(tileX, tileY + 1),
3293 w: side(tileX - 1, tileY)
3324 nw: corner([[0, 0], [-1, 0], [0, -1], [-1, -1]]),
3325 ne: corner([[0, 0], [1, 0], [0, -1], [1, -1]]),
3326 sw: corner([[0, 0], [-1, 0], [0, 1], [-1, 1]]),
3327 se: corner([[0, 0], [1, 0], [0, 1], [1, 1]])
3294 3328 };
3295 3329 }
3296 3330
@@ -3310,6 +3344,14 @@ export class WorldView
3310 3344 { candidates.push({ edge: "s", tileX, tileY: tileY + 1 }); }
3311 3345 if (edges?.w)
3312 3346 { candidates.push({ edge: "w", tileX: tileX - 1, tileY }); }
3347 if (edges?.ne)
3348 { candidates.push({ edge: "e", tileX: tileX + 1, tileY: tileY - 1 }); }
3349 if (edges?.nw)
3350 { candidates.push({ edge: "w", tileX: tileX - 1, tileY: tileY - 1 }); }
3351 if (edges?.se)
3352 { candidates.push({ edge: "e", tileX: tileX + 1, tileY: tileY + 1 }); }
3353 if (edges?.sw)
3354 { candidates.push({ edge: "w", tileX: tileX - 1, tileY: tileY + 1 }); }
3313 3355 let pick = null;
3314 3356 for (const candidate of candidates)
3315 3357 {
@@ -3373,8 +3415,7 @@ export class WorldView
3373 3415 fallbackLit = 1,
3374 3416 tileX = 0,
3375 3417 tileY = 0,
3376 deep = false,
3377 deepBlend = null
3418 deepCorners = null
3378 3419 } = {})
3379 3420 {
3380 3421 if (!object?.renderer)
@@ -3389,7 +3430,10 @@ export class WorldView
3389 3430 const shoreSprite = shore?.sprite ?? null;
3390 3431 const shoreUv = shoreSprite?.getUvRect?.(0)
3391 3432 ?? { u0: 0, v0: 0, u1: 1, v1: 1 };
3392 const selfDeep = deep ? 1 : 0;
3433 const dNW = deepCorners?.nw ?? 0;
3434 const dNE = deepCorners?.ne ?? 0;
3435 const dSW = deepCorners?.sw ?? 0;
3436 const dSE = deepCorners?.se ?? 0;
3393 3437 object._lit = true;
3394 3438 object.renderer.shader = getWaterGroundShader();
3395 3439 object.renderer.secondaryMap = shoreSprite?.g_image ?? null;
@@ -3402,19 +3446,18 @@ export class WorldView
3402 3446 u_time: timeSec,
3403 3447 u_tileX: tileX | 0,
3404 3448 u_tileY: tileY | 0,
3405 u_deep: selfDeep,
3406 u_nbrDeepN: deepBlend?.n?.deep ?? selfDeep,
3407 u_nbrDeepE: deepBlend?.e?.deep ?? selfDeep,
3408 u_nbrDeepS: deepBlend?.s?.deep ?? selfDeep,
3409 u_nbrDeepW: deepBlend?.w?.deep ?? selfDeep,
3410 u_blendDeepN: deepBlend?.n?.blend ?? 0,
3411 u_blendDeepE: deepBlend?.e?.blend ?? 0,
3412 u_blendDeepS: deepBlend?.s?.blend ?? 0,
3413 u_blendDeepW: deepBlend?.w?.blend ?? 0,
3449 u_deepNW: dNW,
3450 u_deepNE: dNE,
3451 u_deepSW: dSW,
3452 u_deepSE: dSE,
3414 3453 u_edgeN: edges?.n ?? 0,
3415 3454 u_edgeE: edges?.e ?? 0,
3416 3455 u_edgeS: edges?.s ?? 0,
3417 3456 u_edgeW: edges?.w ?? 0,
3457 u_edgeNE: edges?.ne ?? 0,
3458 u_edgeNW: edges?.nw ?? 0,
3459 u_edgeSE: edges?.se ?? 0,
3460 u_edgeSW: edges?.sw ?? 0,
3418 3461 u_hasShore: shoreSprite ? 1 : 0,
3419 3462 u_shoreEdgeN: shore?.edgeN ?? 0,
3420 3463 u_shoreEdgeE: shore?.edgeE ?? 0,
@@ -3465,8 +3508,7 @@ export class WorldView
3465 3508 fallbackLit,
3466 3509 tileX: objects.tileX,
3467 3510 tileY: objects.tileY,
3468 deep,
3469 deepBlend: this.#waterDeepBlend(objects.tileX, objects.tileY, deep)
3511 deepCorners: this.#waterDeepCorners(objects.tileX, objects.tileY, deep)
3470 3512 });
3471 3513 }
3472 3514
@@ -115,19 +115,19 @@ const WATER_GROUND_FRAG = [
115 "uniform float u_time;",
115 "uniform float u_time;",
116 "uniform float u_tileX;",
116 "uniform float u_tileX;",
117 "uniform float u_tileY;",
117 "uniform float u_tileY;",
118 "uniform float u_deep;",
118 // Corner deepness (avg of liquid water tiles meeting each corner) — bilinear field.
119 "uniform float u_nbrDeepN;",
119 "uniform float u_deepNW;",
120 "uniform float u_nbrDeepE;",
120 "uniform float u_deepNE;",
121 "uniform float u_nbrDeepS;",
121 "uniform float u_deepSW;",
122 "uniform float u_nbrDeepW;",
122 "uniform float u_deepSE;",
123 "uniform float u_blendDeepN;",
124 "uniform float u_blendDeepE;",
125 "uniform float u_blendDeepS;",
126 "uniform float u_blendDeepW;",
127 "uniform float u_edgeN;",
123 "uniform float u_edgeN;",
128 "uniform float u_edgeE;",
124 "uniform float u_edgeE;",
129 "uniform float u_edgeS;",
125 "uniform float u_edgeS;",
130 "uniform float u_edgeW;",
126 "uniform float u_edgeW;",
127 "uniform float u_edgeNE;",
128 "uniform float u_edgeNW;",
129 "uniform float u_edgeSE;",
130 "uniform float u_edgeSW;",
131 "uniform float u_hasShore;",
131 "uniform float u_hasShore;",
132 "uniform float u_shoreEdgeN;",
132 "uniform float u_shoreEdgeN;",
133 "uniform float u_shoreEdgeE;",
133 "uniform float u_shoreEdgeE;",
@@ -139,7 +139,6 @@ const WATER_GROUND_FRAG = [
139 " float s = sin(a);",
139 " float s = sin(a);",
140 " return vec2(c * p.x - s * p.y, s * p.x + c * p.y);",
140 " return vec2(c * p.x - s * p.y, s * p.x + c * p.y);",
141 "}",
141 "}",
142 // Wrap UV into (0,1) so CLAMP_TO_EDGE textures still tile when scrolled.
143 "vec2 wrapUv(vec2 uv) {",
142 "vec2 wrapUv(vec2 uv) {",
144 " return fract(uv) * 0.998 + 0.001;",
143 " return fract(uv) * 0.998 + 0.001;",
145 "}",
144 "}",
@@ -160,49 +159,57 @@ const WATER_GROUND_FRAG = [
160 " vec2 puv = px / 16.0;",
159 " vec2 puv = px / 16.0;",
161 " vec2 world = vec2(u_tileX, u_tileY) + puv;",
160 " vec2 world = vec2(u_tileX, u_tileY) + puv;",
162 " float t = u_time;",
161 " float t = u_time;",
163 // Three baked Perlin channels, scrolled at different angles / speeds, additive caustics.
162 // Soft body layers (R/G) + crossed caustic vein sprites (B/A).
164 " vec2 uvR = wrapUv(rot2(world * 0.42, 0.35) + vec2(t * 0.13, t * 0.09));",
163 " vec2 uvSoftR = wrapUv(rot2(world * 0.42, 0.35) + vec2(t * 0.39, t * 0.27));",
165 " vec2 uvG = wrapUv(rot2(world * 0.51, -1.05) + vec2(-t * 0.105, t * 0.145));",
164 " vec2 uvSoftG = wrapUv(rot2(world * 0.51, -1.05) + vec2(-t * 0.315, t * 0.435));",
166 " vec2 uvB = wrapUv(rot2(world * 0.63, 1.55) + vec2(t * 0.16, -t * 0.08));",
165 " vec2 uvCau1 = wrapUv(rot2(world * 0.95, 0.55) + vec2(t * 0.52, -t * 0.28));",
167 " float nR = texture2D(u_texture, uvR).r;",
166 " vec2 uvCau2 = wrapUv(rot2(world * 1.15, -1.25) + vec2(-t * 0.41, t * 0.58));",
168 " float nG = texture2D(u_texture, uvG).g;",
167 " float softR = texture2D(u_texture, uvSoftR).r;",
169 " float nB = texture2D(u_texture, uvB).b;",
168 " float softG = texture2D(u_texture, uvSoftG).g;",
170 " float caustic = nR * 0.45 + nG * 0.40 + nB * 0.35;",
169 " float cau1 = texture2D(u_texture, uvCau1).b;",
171 " caustic += nR * nG * 0.55 + nG * nB * 0.35;",
170 " float cau2 = texture2D(u_texture, uvCau2).a;",
172 " caustic = clamp(caustic * 0.72, 0.0, 1.0);",
171 " float soft = softR * 0.55 + softG * 0.45 + softR * softG * 0.25;",
173 " caustic = pow(caustic, 1.35);",
172 " float veins = cau1 * 0.65 + cau2 * 0.65 + cau1 * cau2 * 0.85;",
174 // Coast proximity first — damp caustics so water softens before the land sprite edge.
173 " veins = clamp(veins, 0.0, 1.0);",
174 " float caustic = clamp(soft * 0.55 + veins * 0.75, 0.0, 1.0);",
175 " caustic = pow(caustic, 1.15);",
176 // Glitter: push bright caustic veins to white extremes.
177 " float glitter = pow(max(cau1, cau2), 5.5);",
178 " glitter = max(glitter, pow(cau1 * cau2, 3.2) * 1.35);",
179 " glitter = clamp(glitter, 0.0, 1.0);",
180 // Cardinal + diagonal land proximity (inner corners like WWW/WLL).
175 " float edgeProx = 0.0;",
181 " float edgeProx = 0.0;",
176 " if (u_edgeN > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.y)); }",
182 " if (u_edgeN > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.y)); }",
177 " if (u_edgeS > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.y)); }",
183 " if (u_edgeS > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.y)); }",
178 " if (u_edgeW > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.x)); }",
184 " if (u_edgeW > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, puv.x)); }",
179 " if (u_edgeE > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.x)); }",
185 " if (u_edgeE > 0.5) { edgeProx = max(edgeProx, smoothstep(0.55, 0.0, 1.0 - puv.x)); }",
180 " float causticBody = caustic * (1.0 - edgeProx * 0.72);",
186 " if (u_edgeNE > 0.5) {",
181 // Shallow↔deep: approach the midpoint at the shared edge (not full swap).
187 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(1.0 - puv.x, puv.y))));",
182 " float deepMix = u_deep;",
183 " if (u_blendDeepN > 0.5) {",
184 " float w = smoothstep(0.55, 0.0, puv.y);",
185 " deepMix = mix(deepMix, mix(u_deep, u_nbrDeepN, 0.5), w);",
186 " }",
188 " }",
187 " if (u_blendDeepS > 0.5) {",
189 " if (u_edgeNW > 0.5) {",
188 " float w = smoothstep(0.55, 0.0, 1.0 - puv.y);",
190 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(puv.x, puv.y))));",
189 " deepMix = mix(deepMix, mix(u_deep, u_nbrDeepS, 0.5), w);",
190 " }",
191 " }",
191 " if (u_blendDeepW > 0.5) {",
192 " if (u_edgeSE > 0.5) {",
192 " float w = smoothstep(0.55, 0.0, puv.x);",
193 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(1.0 - puv.x, 1.0 - puv.y))));",
193 " deepMix = mix(deepMix, mix(u_deep, u_nbrDeepW, 0.5), w);",
194 " }",
194 " }",
195 " if (u_blendDeepE > 0.5) {",
195 " if (u_edgeSW > 0.5) {",
196 " float w = smoothstep(0.55, 0.0, 1.0 - puv.x);",
196 " edgeProx = max(edgeProx, smoothstep(0.72, 0.0, length(vec2(puv.x, 1.0 - puv.y))));",
197 " deepMix = mix(deepMix, mix(u_deep, u_nbrDeepE, 0.5), w);",
198 " }",
197 " }",
198 " float causticBody = caustic * (1.0 - edgeProx * 0.72);",
199 " float glitterBody = glitter * (1.0 - edgeProx * 0.85);",
200 // Continuous shallow↔deep field via corner averages (seamless across tile edges + corners).
201 " float deepTop = mix(u_deepNW, u_deepNE, puv.x);",
202 " float deepBot = mix(u_deepSW, u_deepSE, puv.x);",
203 " float deepMix = mix(deepTop, deepBot, puv.y);",
199 " vec3 deepCol = mix(vec3(0.12, 0.36, 0.56), vec3(0.06, 0.18, 0.34), deepMix);",
204 " vec3 deepCol = mix(vec3(0.12, 0.36, 0.56), vec3(0.06, 0.18, 0.34), deepMix);",
200 " vec3 midCol = mix(vec3(0.22, 0.52, 0.70), vec3(0.12, 0.34, 0.54), deepMix);",
205 " vec3 midCol = mix(vec3(0.22, 0.52, 0.70), vec3(0.12, 0.34, 0.54), deepMix);",
201 " vec3 litCol = mix(vec3(0.55, 0.82, 0.94), vec3(0.34, 0.60, 0.82), deepMix);",
206 " vec3 litCol = mix(vec3(0.55, 0.82, 0.94), vec3(0.34, 0.60, 0.82), deepMix);",
202 " vec3 rgb = mix(deepCol, midCol, smoothstep(0.15, 0.55, causticBody));",
207 " vec3 sparkCol = mix(vec3(0.92, 0.98, 1.0), vec3(0.72, 0.88, 0.98), deepMix);",
203 " rgb = mix(rgb, litCol, smoothstep(0.45, 0.92, causticBody));",
208 " vec3 rgb = mix(deepCol, midCol, smoothstep(0.12, 0.48, causticBody));",
204 // Force darker near land so the coastline eases into the hard ground sprite.
209 " rgb = mix(rgb, litCol, smoothstep(0.40, 0.88, causticBody));",
205 " rgb = mix(rgb, deepCol, edgeProx * 0.62);",
210 " rgb = mix(rgb, sparkCol, glitterBody * 0.95);",
211 // Darken near land, but stay solid water (no pastel half-blend).
212 " rgb = mix(rgb, deepCol, edgeProx * 0.55);",
206 " float shoreW = 0.0;",
213 " float shoreW = 0.0;",
207 " vec3 shoreRgb = rgb;",
214 " vec3 shoreRgb = rgb;",
208 " if (u_edgeN > 0.5) {",
215 " if (u_edgeN > 0.5) {",
@@ -217,13 +224,10 @@ const WATER_GROUND_FRAG = [
217 " if (u_edgeE > 0.5) {",
224 " if (u_edgeE > 0.5) {",
218 " sampleShore(1.0, u_shoreEdgeE, vec2(1.0 - puv.x, puv.y), shoreRgb, shoreW);",
225 " sampleShore(1.0, u_shoreEdgeE, vec2(1.0 - puv.x, puv.y), shoreRgb, shoreW);",
219 " }",
226 " }",
220 " float lightAmt = smoothstep(0.48, 0.82, causticBody);",
227 // Binary coast: full shore pixel or full water pixel — never a translucent mix.
221 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, causticBody);",
228 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, causticBody);",
222 " vec3 edgeBlue = mix(vec3(0.50, 0.78, 0.92), vec3(0.32, 0.58, 0.80), deepMix);",
229 " float shoreMask = step(0.42, edgeProx * (0.35 + 0.65 * darkAmt)) * shoreW;",
223 " rgb = mix(rgb, edgeBlue, edgeProx * lightAmt * 0.35);",
230 " rgb = mix(rgb, shoreRgb, shoreMask);",
224 " if (shoreW > 0.5) {",
225 " rgb = mix(rgb, shoreRgb, edgeProx * darkAmt * 0.88);",
226 " }",
227 " float litTop = mix(u_litNW, u_litNE, v_texCoord.x);",
231 " float litTop = mix(u_litNW, u_litNE, v_texCoord.x);",
228 " float litBottom = mix(u_litSW, u_litSE, v_texCoord.x);",
232 " float litBottom = mix(u_litSW, u_litSE, v_texCoord.x);",
229 " float lit = mix(litTop, litBottom, v_texCoord.y);",
233 " float lit = mix(litTop, litBottom, v_texCoord.y);",
@@ -3265,32 +3269,62 @@ export class WorldView
3265 #waterCoastEdges (tileX, tileY)
3269 #waterCoastEdges (tileX, tileY)
3266 {
3270 {
3267 const season = this.worldSeason;
3271 const season = this.worldSeason;
3272 const liquid = (x, y) => isLiquidWaterGround(this.#groundTypeAt(x, y), season);
3273 const n = liquid(tileX, tileY - 1);
3274 const e = liquid(tileX + 1, tileY);
3275 const s = liquid(tileX, tileY + 1);
3276 const w = liquid(tileX - 1, tileY);
3277 const ne = liquid(tileX + 1, tileY - 1);
3278 const nw = liquid(tileX - 1, tileY - 1);
3279 const se = liquid(tileX + 1, tileY + 1);
3280 const sw = liquid(tileX - 1, tileY + 1);
3268 return {
3281 return {
3269 n: !isLiquidWaterGround(this.#groundTypeAt(tileX, tileY - 1), season) ? 1 : 0,
3282 n: n ? 0 : 1,
3270 e: !isLiquidWaterGround(this.#groundTypeAt(tileX + 1, tileY), season) ? 1 : 0,
3283 e: e ? 0 : 1,
3271 s: !isLiquidWaterGround(this.#groundTypeAt(tileX, tileY + 1), season) ? 1 : 0,
3284 s: s ? 0 : 1,
3272 w: !isLiquidWaterGround(this.#groundTypeAt(tileX - 1, tileY), season) ? 1 : 0
3285 w: w ? 0 : 1,
3286 // Pure diagonal land pockets (e.g. WWW/WLL) — only when cardinals stay water.
3287 ne: (!ne && n && e) ? 1 : 0,
3288 nw: (!nw && n && w) ? 1 : 0,
3289 se: (!se && s && e) ? 1 : 0,
3290 sw: (!sw && s && w) ? 1 : 0
3273 };
3291 };
3274 }
3292 }
3275
3293
3276 /** Shallow↔deep edge blend: neighbor deepness only when both tiles are liquid water of different depth. */
3294 /**
3277 #waterDeepBlend (tileX, tileY, selfDeep)
3295 * Corner deepness = average of liquid-water tiles meeting that corner.
3296 * Bilinear sampling of these corners is continuous across shared edges/corners.
3297 */
3298 #waterDeepCorners (tileX, tileY, selfDeep)
3278 {
3299 {
3279 const season = this.worldSeason;
3300 const season = this.worldSeason;
3280 const self = selfDeep ? 1 : 0;
3301 const fallback = selfDeep ? 1 : 0;
3281 const side = (x, y) =>
3302 const depthAt = (x, y) =>
3282 {
3303 {
3283 const typeId = this.#groundTypeAt(x, y);
3304 const typeId = this.#groundTypeAt(x, y);
3284 if (!isLiquidWaterGround(typeId, season))
3305 if (!isLiquidWaterGround(typeId, season))
3285 { return { deep: self, blend: 0 }; }
3306 { return null; }
3286 const deep = typeId === GroundType.deepWater ? 1 : 0;
3307 return typeId === GroundType.deepWater ? 1 : 0;
3287 return { deep, blend: deep !== self ? 1 : 0 };
3308 };
3309 const corner = (offsets) =>
3310 {
3311 let sum = 0;
3312 let count = 0;
3313 for (const [dx, dy] of offsets)
3314 {
3315 const d = depthAt(tileX + dx, tileY + dy);
3316 if (d == null)
3317 { continue; }
3318 sum += d;
3319 count += 1;
3320 }
3321 return count ? sum / count : fallback;
3288 };
3322 };
3289 return {
3323 return {
3290 n: side(tileX, tileY - 1),
3324 nw: corner([[0, 0], [-1, 0], [0, -1], [-1, -1]]),
3291 e: side(tileX + 1, tileY),
3325 ne: corner([[0, 0], [1, 0], [0, -1], [1, -1]]),
3292 s: side(tileX, tileY + 1),
3326 sw: corner([[0, 0], [-1, 0], [0, 1], [-1, 1]]),
3293 w: side(tileX - 1, tileY)
3327 se: corner([[0, 0], [1, 0], [0, 1], [1, 1]])
3294 };
3328 };
3295 }
3329 }
3296
3330
@@ -3310,6 +3344,14 @@ export class WorldView
3310 { candidates.push({ edge: "s", tileX, tileY: tileY + 1 }); }
3344 { candidates.push({ edge: "s", tileX, tileY: tileY + 1 }); }
3311 if (edges?.w)
3345 if (edges?.w)
3312 { candidates.push({ edge: "w", tileX: tileX - 1, tileY }); }
3346 { candidates.push({ edge: "w", tileX: tileX - 1, tileY }); }
3347 if (edges?.ne)
3348 { candidates.push({ edge: "e", tileX: tileX + 1, tileY: tileY - 1 }); }
3349 if (edges?.nw)
3350 { candidates.push({ edge: "w", tileX: tileX - 1, tileY: tileY - 1 }); }
3351 if (edges?.se)
3352 { candidates.push({ edge: "e", tileX: tileX + 1, tileY: tileY + 1 }); }
3353 if (edges?.sw)
3354 { candidates.push({ edge: "w", tileX: tileX - 1, tileY: tileY + 1 }); }
3313 let pick = null;
3355 let pick = null;
3314 for (const candidate of candidates)
3356 for (const candidate of candidates)
3315 {
3357 {
@@ -3373,8 +3415,7 @@ export class WorldView
3373 fallbackLit = 1,
3415 fallbackLit = 1,
3374 tileX = 0,
3416 tileX = 0,
3375 tileY = 0,
3417 tileY = 0,
3376 deep = false,
3418 deepCorners = null
3377 deepBlend = null
3378 } = {})
3419 } = {})
3379 {
3420 {
3380 if (!object?.renderer)
3421 if (!object?.renderer)
@@ -3389,7 +3430,10 @@ export class WorldView
3389 const shoreSprite = shore?.sprite ?? null;
3430 const shoreSprite = shore?.sprite ?? null;
3390 const shoreUv = shoreSprite?.getUvRect?.(0)
3431 const shoreUv = shoreSprite?.getUvRect?.(0)
3391 ?? { u0: 0, v0: 0, u1: 1, v1: 1 };
3432 ?? { u0: 0, v0: 0, u1: 1, v1: 1 };
3392 const selfDeep = deep ? 1 : 0;
3433 const dNW = deepCorners?.nw ?? 0;
3434 const dNE = deepCorners?.ne ?? 0;
3435 const dSW = deepCorners?.sw ?? 0;
3436 const dSE = deepCorners?.se ?? 0;
3393 object._lit = true;
3437 object._lit = true;
3394 object.renderer.shader = getWaterGroundShader();
3438 object.renderer.shader = getWaterGroundShader();
3395 object.renderer.secondaryMap = shoreSprite?.g_image ?? null;
3439 object.renderer.secondaryMap = shoreSprite?.g_image ?? null;
@@ -3402,19 +3446,18 @@ export class WorldView
3402 u_time: timeSec,
3446 u_time: timeSec,
3403 u_tileX: tileX | 0,
3447 u_tileX: tileX | 0,
3404 u_tileY: tileY | 0,
3448 u_tileY: tileY | 0,
3405 u_deep: selfDeep,
3449 u_deepNW: dNW,
3406 u_nbrDeepN: deepBlend?.n?.deep ?? selfDeep,
3450 u_deepNE: dNE,
3407 u_nbrDeepE: deepBlend?.e?.deep ?? selfDeep,
3451 u_deepSW: dSW,
3408 u_nbrDeepS: deepBlend?.s?.deep ?? selfDeep,
3452 u_deepSE: dSE,
3409 u_nbrDeepW: deepBlend?.w?.deep ?? selfDeep,
3410 u_blendDeepN: deepBlend?.n?.blend ?? 0,
3411 u_blendDeepE: deepBlend?.e?.blend ?? 0,
3412 u_blendDeepS: deepBlend?.s?.blend ?? 0,
3413 u_blendDeepW: deepBlend?.w?.blend ?? 0,
3414 u_edgeN: edges?.n ?? 0,
3453 u_edgeN: edges?.n ?? 0,
3415 u_edgeE: edges?.e ?? 0,
3454 u_edgeE: edges?.e ?? 0,
3416 u_edgeS: edges?.s ?? 0,
3455 u_edgeS: edges?.s ?? 0,
3417 u_edgeW: edges?.w ?? 0,
3456 u_edgeW: edges?.w ?? 0,
3457 u_edgeNE: edges?.ne ?? 0,
3458 u_edgeNW: edges?.nw ?? 0,
3459 u_edgeSE: edges?.se ?? 0,
3460 u_edgeSW: edges?.sw ?? 0,
3418 u_hasShore: shoreSprite ? 1 : 0,
3461 u_hasShore: shoreSprite ? 1 : 0,
3419 u_shoreEdgeN: shore?.edgeN ?? 0,
3462 u_shoreEdgeN: shore?.edgeN ?? 0,
3420 u_shoreEdgeE: shore?.edgeE ?? 0,
3463 u_shoreEdgeE: shore?.edgeE ?? 0,
@@ -3465,8 +3508,7 @@ export class WorldView
3465 fallbackLit,
3508 fallbackLit,
3466 tileX: objects.tileX,
3509 tileX: objects.tileX,
3467 tileY: objects.tileY,
3510 tileY: objects.tileY,
3468 deep,
3511 deepCorners: this.#waterDeepCorners(objects.tileX, objects.tileY, deep)
3469 deepBlend: this.#waterDeepBlend(objects.tileX, objects.tileY, deep)
3470 });
3512 });
3471 }
3513 }
3472
3514