Implement fog of war

From MengTo/Skills · View interactive version

Implement fog of war is an AI agent skill from the GitHub repository MengTo/Skills. Implement, tune, debug, or validate soft wall-aware fog of war and gameplay perception in Three.js action games. Use for orthographic or isometric visibility masks, obstacle-aware line of sight, player and enemy vision ranges, hidden-enemy targeting rules, fog shader artifacts such as spokes or seam

How to use this skill

Skill file

Implement Fog of War

Build fog of war as a shared perception system with a restrained presentation layer.

Preserve the architecture

Keep these responsibilities separate:

  1. Let deterministic CPU perception own ranges, obstacle intersections, and gameplay visibility.
  2. Encode the player's angular visible distances into one fixed-size lookup texture.
  3. Let one full-screen shader turn that lookup into soft radial and wall-aware fog.
  4. Let gameplay consume perception results directly; never infer combat truth from fog pixels.

Read mechanics.md before implementing or changing the algorithm. It records the proven obstacle model, shader composition, calibrated values, state rules, enemy behavior, lighting constraints, and telemetry.

Inspect before editing

Implement in dependency order

1. Define perception truth

2. Build the visibility lookup

3. Render one soft overlay

4. Integrate gameplay

5. Integrate state and lifecycle

Tune in the right order

  1. Validate obstacle geometry and eye height.
  2. Validate player and enemy ranges.
  3. Set the fully clear inner radius.
  4. Set the outer radial falloff and maximum opacity.
  5. Set wall-edge softness.
  6. Add angular smoothing until spokes disappear.
  7. Reduce obstacle darkness until walls feel like occlusion rather than black rays.
  8. Adjust ray budgets only after visual correctness and measured performance.

Do not hide bad obstacle data with extra blur. Do not make the entire scene darker to compensate for weak visibility boundaries.

Validate

Read validation.md before claiming completion. Run:

Use normal gameplay for visual verification when review modes intentionally disable fog. Judge motion, camera movement, wall edges, gates, seams, and menu transitions—not only a still frame.

Protect the proven qualities

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.