Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/rendering/tsl/FogOfWar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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];

Expand Down
3 changes: 2 additions & 1 deletion src/rendering/tsl/effects/EffectPasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading