Skip to content

fix: remove incorrect V-flip from fog shader - use direct worldZ/mapH…#1248

Merged
braedonsaunders merged 1 commit into
mainfrom
claude/fix-fog-of-war-BqamZ
Feb 2, 2026
Merged

fix: remove incorrect V-flip from fog shader - use direct worldZ/mapH…#1248
braedonsaunders merged 1 commit into
mainfrom
claude/fix-fog-of-war-BqamZ

Conversation

@braedonsaunders

Copy link
Copy Markdown
Owner

…eight

The shader UV calculation had an incorrect Y-flip that inverted vision:

  • OLD: visionV = 1.0 - worldZ/mapHeight (WRONG)
  • NEW: visionV = worldZ/mapHeight (CORRECT)

Root cause analysis:

  • Game transform.y (depth) → Three.js position.z → shader worldZ
  • Vision grid stores visionGrid[cellY] where cellY = floor(worldZ/cellSize)
  • Texture row cellY maps to UV v = cellY/gridHeight
  • Therefore visionV should equal worldZ/mapHeight with NO flip

This was causing:

  • 6p test map: wrong starting base revealed (y=60/320 → v=0.81 → sampled north)
  • Both maps: moving south revealed north (inverted direction)

Also updated VisionCompute.ts comment to clarify coordinate transformation.

https://claude.ai/code/session_013Hqn3PxBW8h7hpMNMKKv1e

…eight

The shader UV calculation had an incorrect Y-flip that inverted vision:
- OLD: visionV = 1.0 - worldZ/mapHeight (WRONG)
- NEW: visionV = worldZ/mapHeight (CORRECT)

Root cause analysis:
- Game transform.y (depth) → Three.js position.z → shader worldZ
- Vision grid stores visionGrid[cellY] where cellY = floor(worldZ/cellSize)
- Texture row cellY maps to UV v = cellY/gridHeight
- Therefore visionV should equal worldZ/mapHeight with NO flip

This was causing:
- 6p test map: wrong starting base revealed (y=60/320 → v=0.81 → sampled north)
- Both maps: moving south revealed north (inverted direction)

Also updated VisionCompute.ts comment to clarify coordinate transformation.

https://claude.ai/code/session_013Hqn3PxBW8h7hpMNMKKv1e
@braedonsaunders braedonsaunders merged commit 4b9f16b into main Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants