BlueGit

timfa questward

Fix fluid atlas N/S hole placement via paired mirrorY.

FBO sampling flips V vs Framework sprites: mirror each tile draw and the
chunk atlas GameObject so sandbank gaps and coasts share the same upright space.

timfa Tim Falken · pushed by timfa

Authored 2026-09-13 · 2 months ago

Hash
b1fcdd5d4be228c1fa6110a4223cd8a15b2962ad
Parent
2cb8f51c
2 files changed +10 −3
client/src/render/fluidChunkAtlas.js +6 −3
@@ -2,9 +2,10 @@
2 2 * Per-chunk fluid (water / lava) atlas: render procedural shaders at true
3 3 * SPRITE_SIZE_PX, then nearest-upscale the atlas to chunk world size.
4 4 *
5 * Tile placement uses the same Y-down screen space as Framework drawSprite
6 * (no extra FBO Y-flip — that put N/S coasts on the wrong sides).
5 * Tile placement is Y-down (localY). FBO↔sprite V mismatch is corrected by
6 * mirrorY on each tile draw and on the atlas GameObject (holes + coasts).
7 7 */
8
8 9 import { CHUNK_SIZE, SPRITE_SIZE_PX } from "/shared/protocol/constants.js";
9 10 import { frameworkImageFromCanvas } from "./canvasSprite.js";
10 11
@@ -159,7 +160,9 @@ export function drawFluidAtlasTile (glCtx, {
159 160 h: SPRITE_SIZE_PX,
160 161 rotationDeg: 0,
161 162 mirrorX: false,
162 mirrorY: false,
163 // FBO sampling is V-flipped vs Framework sprites; pre-flip tile content
164 // so a mirrored atlas GameObject shows correct coasts + hole positions.
165 mirrorY: true,
163 166 alpha: 1,
164 167 uvRect: uvRect ?? { u0: 0, v0: 0, u1: 1, v1: 1 },
165 168 shader,
@@ -2,9 +2,10 @@
2 * Per-chunk fluid (water / lava) atlas: render procedural shaders at true
2 * Per-chunk fluid (water / lava) atlas: render procedural shaders at true
3 * SPRITE_SIZE_PX, then nearest-upscale the atlas to chunk world size.
3 * SPRITE_SIZE_PX, then nearest-upscale the atlas to chunk world size.
4 *
4 *
5 * Tile placement uses the same Y-down screen space as Framework drawSprite
5 * Tile placement is Y-down (localY). FBO↔sprite V mismatch is corrected by
6 * (no extra FBO Y-flip — that put N/S coasts on the wrong sides).
6 * mirrorY on each tile draw and on the atlas GameObject (holes + coasts).
7 */
7 */
8
8import { CHUNK_SIZE, SPRITE_SIZE_PX } from "/shared/protocol/constants.js";
9import { CHUNK_SIZE, SPRITE_SIZE_PX } from "/shared/protocol/constants.js";
9import { frameworkImageFromCanvas } from "./canvasSprite.js";
10import { frameworkImageFromCanvas } from "./canvasSprite.js";
10
11
@@ -159,7 +160,9 @@ export function drawFluidAtlasTile (glCtx, {
159 h: SPRITE_SIZE_PX,
160 h: SPRITE_SIZE_PX,
160 rotationDeg: 0,
161 rotationDeg: 0,
161 mirrorX: false,
162 mirrorX: false,
162 mirrorY: false,
163 // FBO sampling is V-flipped vs Framework sprites; pre-flip tile content
164 // so a mirrored atlas GameObject shows correct coasts + hole positions.
165 mirrorY: true,
163 alpha: 1,
166 alpha: 1,
164 uvRect: uvRect ?? { u0: 0, v0: 0, u1: 1, v1: 1 },
167 uvRect: uvRect ?? { u0: 0, v0: 0, u1: 1, v1: 1 },
165 shader,
168 shader,
client/src/render/worldView.js +4 −0
@@ -4446,6 +4446,10 @@ export class WorldView
4446 4446 object.transform.position.x = Math.round(left + chunkPx / 2);
4447 4447 object.transform.position.y = Math.round(top + chunkPx / 2);
4448 4448 object.transform.size = new vector(chunkPx, chunkPx);
4449 // FBO color attachment is V-flipped vs Framework sprite UVs — mirror so
4450 // sandbank holes sit on the correct N/S side (tile draws also mirrorY).
4451 if (object.renderer)
4452 { object.renderer.mirrorY = true; }
4449 4453 if (kind === "bloom")
4450 4454 {
4451 4455 this.#setLayer(object, this.#depthLayer(top + chunkPx, SORT_BLOCK));
@@ -4446,6 +4446,10 @@ export class WorldView
4446 object.transform.position.x = Math.round(left + chunkPx / 2);
4446 object.transform.position.x = Math.round(left + chunkPx / 2);
4447 object.transform.position.y = Math.round(top + chunkPx / 2);
4447 object.transform.position.y = Math.round(top + chunkPx / 2);
4448 object.transform.size = new vector(chunkPx, chunkPx);
4448 object.transform.size = new vector(chunkPx, chunkPx);
4449 // FBO color attachment is V-flipped vs Framework sprite UVs — mirror so
4450 // sandbank holes sit on the correct N/S side (tile draws also mirrorY).
4451 if (object.renderer)
4452 { object.renderer.mirrorY = true; }
4449 if (kind === "bloom")
4453 if (kind === "bloom")
4450 {
4454 {
4451 this.#setLayer(object, this.#depthLayer(top + chunkPx, SORT_BLOCK));
4455 this.#setLayer(object, this.#depthLayer(top + chunkPx, SORT_BLOCK));