diff --git a/src/rendering/tsl/FogOfWar.ts b/src/rendering/tsl/FogOfWar.ts index 6904c53e..af1b9f6c 100644 --- a/src/rendering/tsl/FogOfWar.ts +++ b/src/rendering/tsl/FogOfWar.ts @@ -201,9 +201,8 @@ export class TSLFogOfWar { // Update CPU texture from vision grid with temporal smoothing for (let y = 0; y < this.gridHeight; y++) { for (let x = 0; x < this.gridWidth; x++) { - // Flip Y for texture coordinates - const textureY = this.gridHeight - 1 - y; - const i = textureY * this.gridWidth + x; + // No Y-flip - matches GPU path (VisionCompute) which writes directly to (cellX, cellY) + const i = y * this.gridWidth + x; const state = visionGrid[y]?.[x] ?? 'unexplored'; // Current visibility (target) @@ -281,9 +280,8 @@ export class TSLFogOfWar { // Update CPU texture from serialized data with temporal smoothing for (let y = 0; y < this.gridHeight; y++) { for (let x = 0; x < this.gridWidth; x++) { - // Flip Y for texture coordinates - const textureY = this.gridHeight - 1 - y; - const textureIndex = textureY * this.gridWidth + x; + // No Y-flip - matches GPU path (VisionCompute) + const textureIndex = y * this.gridWidth + x; const dataIndex = y * this.gridWidth + x; const state = serializedData[dataIndex]; diff --git a/src/rendering/tsl/effects/EffectPasses.ts b/src/rendering/tsl/effects/EffectPasses.ts index c0f65566..e1bbd5c8 100644 --- a/src/rendering/tsl/effects/EffectPasses.ts +++ b/src/rendering/tsl/effects/EffectPasses.ts @@ -770,8 +770,9 @@ export function createFogOfWarPass( const worldZ = worldPos4.z; // Convert world position to vision grid UV + // Note: This codebase uses Y as depth (north-south), not Z const visionU = worldX.div(uMapDimensions.x); - const visionV = worldZ.div(uMapDimensions.y); + const visionV = worldY.div(uMapDimensions.y); const visionUV = vec2(visionU, visionV).toVar(); // Clamp to valid range