implement-fog-of-war

Implement soft wall-aware fog of war and perception systems in Three.js games.

5.7k|685|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/MengTo/Skills --skill implement-fog-of-war
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: implement-fog-of-war
Source: https://github.com/MengTo/Skills/tree/main/agent-skills/codex/implement-fog-of-war
Command: npx skills add https://github.com/MengTo/Skills --skill implement-fog-of-war

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Building fog of war in a Three.js action game involves coordinating CPU perception math, shader rendering, gameplay targeting rules, and lifecycle state, and mistakes produce visible spokes, seams, leaked enemies, or broken targeting.

Core Features & Use Cases

  • Shared Perception Architecture: Separates deterministic CPU line-of-sight and range checks from a single full-screen fog shader fed by an angular distance lookup texture.
  • Gameplay Integration Rules: Covers hidden-enemy targeting, presentation-only visibility via render layers, asymmetric player and enemy vision ranges, and dynamic gate occlusion.
  • Calibration and Validation Playbooks: Provides proven tuning values, a tuning order, structural render-budget contracts, and deterministic test and browser verification checklists.
  • Use Case: When adding fog of war to an orthographic Three.js action game, follow the dependency-ordered steps to build the perception model, lookup texture, overlay shader, and state gating, then validate with the documented test and browser procedures.

Quick Start

Use the implement-fog-of-war skill to add a soft wall-aware fog-of-war system to my Three.js game and validate it with the documented tests.

Frequently Asked Questions about implement-fog-of-war

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement fog of war in a Three.js game?

Build a CPU perception layer that casts angular rays against obstacle footprints, encode hit distances into a one-row data texture, and render one full-screen shader overlay combining radial falloff with feathered wall occlusion. Keep gameplay visibility decisions on the CPU, never on fog pixels.

How do I fix visible spokes in a fog of war shader?

Spokes come from single angular lookup samples controlling fully dark wall wedges. Fix them by increasing wall-edge softness, applying five-tap angular smoothing with weighted neighbors, and reducing obstacle darkness so walls read as atmosphere rather than opaque rays.

Does this fog of war approach work with orthographic cameras?

Yes, the proven implementation uses an orthographic Three.js camera with four-corner unprojection onto a horizontal ground plane. For sloped or multi-level terrain, reconstruct world position from the authoritative surface or depth data instead of one flat plane.

How should enemies be hidden without breaking game simulation?

Hide unrevealed enemies through render layers or another presentation-only mechanism, never by toggling the actor root, which often controls lifecycle and simulation. Unrevealed enemies should keep pursuing, taking damage, and dying according to game rules.

Why does fog of war leak into menus or capture modes?

The overlay is being disabled after an early render branch, so a previously enabled frame persists. Hide the overlay at the start of the frame before any branch and gate it explicitly on gameplay state such as menus, inventory, review modes, and transitions.

What are the performance limits of this fog of war technique?

The architecture bounds cost with one shader material, one data texture, no extra renderer or composer, and ray counts clamped between 32 and 256, with 192 desktop and 128 mobile as proven values. CPU lookup refreshes are throttled by movement and time gates.