Skip to content

fix: correct fog of war coordinate system (Y vs Z axis mismatch)#1241

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

fix: correct fog of war coordinate system (Y vs Z axis mismatch)#1241
braedonsaunders merged 1 commit into
mainfrom
claude/fix-fog-of-war-BqamZ

Conversation

@braedonsaunders

Copy link
Copy Markdown
Owner

The fog of war was broken on some maps (100% coverage) and inverted on others (moving south revealed north) due to coordinate system mismatches:

  1. VisionSystem used transform.y (altitude) instead of transform.z (depth) when calculating vision grid cells
  2. CPU texture path had an inconsistent Y-flip that didn't match GPU path or shader expectations
  3. Map dimensions weren't being passed to the fog shader, causing hardcoded 256x256 to mismatch actual map sizes (e.g., 320x320)

Changes:

  • VisionSystem.ts: Use transform.z for all vision calculations
  • FogOfWar.ts: Remove Y-flip in CPU path to match GPU/shader
  • EffectPasses.ts: Add setMapDimensions() for dynamic map sizing
  • PostProcessing.ts: Use setMapDimensions() with cell size
  • VisionCompute.ts: Rename worldY→worldZ for clarity
  • BuildingRenderer.ts, UnitRenderer.ts: Use transform.z for checks
  • Minimap.tsx: Use transform.z for position and vision checks

https://claude.ai/code/session_013Hqn3PxBW8h7hpMNMKKv1e

The fog of war was broken on some maps (100% coverage) and inverted
on others (moving south revealed north) due to coordinate system
mismatches:

1. VisionSystem used transform.y (altitude) instead of transform.z
   (depth) when calculating vision grid cells
2. CPU texture path had an inconsistent Y-flip that didn't match
   GPU path or shader expectations
3. Map dimensions weren't being passed to the fog shader, causing
   hardcoded 256x256 to mismatch actual map sizes (e.g., 320x320)

Changes:
- VisionSystem.ts: Use transform.z for all vision calculations
- FogOfWar.ts: Remove Y-flip in CPU path to match GPU/shader
- EffectPasses.ts: Add setMapDimensions() for dynamic map sizing
- PostProcessing.ts: Use setMapDimensions() with cell size
- VisionCompute.ts: Rename worldY→worldZ for clarity
- BuildingRenderer.ts, UnitRenderer.ts: Use transform.z for checks
- Minimap.tsx: Use transform.z for position and vision checks

https://claude.ai/code/session_013Hqn3PxBW8h7hpMNMKKv1e
@braedonsaunders braedonsaunders merged commit dea4949 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