coding-agents
Implement Fog of War in Three.js with Agent Skill
Learn how the implement-fog-of-war skill helps developers build deterministic, shader-based fog of war in Three.js action games.
Where this fits
You're building an isometric action game in Three.js and need fog of war that respects walls and reveals enemies only when they're actually visible. You've tried a naive shader approach, but you're seeing spokes and seams, and your mobile ray budget is blowing up. This skill guides an agent to implement a shared perception system with deterministic CPU logic, a fixed-size lookup texture, and a single full-screen shader—solving both correctness and performance without guessing.
Why agents benefit
- Follows a proven architecture: The skill enforces separation between CPU perception, GPU encoding, and presentation, preventing common architectural mistakes.
- Debugging artifacts systematically: It includes references for calibrating shader values and fixing spokes, seams, and other visual glitches without trial-and-error.
- Handles lifecycle and state: It provides rules for integrating fog with menu states, pausing, and scene transitions, so agents don't break gameplay flow.
- Deterministic testing: Includes guidance for writing deterministic fog-of-war tests, ensuring agents can validate behavior without flaky visual checks.
- Optimizes for mobile: Offers ray budget strategies and performance constraints, so agents can tune for low-end devices without sacrificing quality.
Practical scenarios
Debugging shader artifacts in a procedurally generated map
Your agent can use the skill to identify why fog spokes appear near diagonal walls and apply the documented fix—adjusting the angular step and texture resolution—rather than randomly tweaking uniforms.
Tuning enemy vision ranges for stealth gameplay
Instead of hardcoding vision cones, the agent can adjust the CPU perception module to change enemy sight distances and obstacle intersection rules, then verify via the deterministic test suite that the gameplay behavior matches design specs.
Integrating fog with a pause menu and scene transitions
When the game pauses or switches levels, the fog shader must reset or freeze correctly. The skill's state rules let an agent wire up lifecycle hooks cleanly, avoiding visual artifacts or memory leaks.
Add it to your agent workflow
Install the skill with:
npx skills add MengTo/Skills --skill implement-fog-of-war
Then instruct your agent: "Implement fog of war for our Three.js game using the implement-fog-of-war skill. Follow the architecture in mechanics.md, and ensure the shader handles wall-aware visibility with no seams." The agent will pull the skill's references and apply the exact algorithm.
Compare before adopting
Before committing, compare this skill against alternatives: check if the referenced mechanics.md is actively maintained, whether the calibration values match your target platforms, and if the deterministic test approach fits your CI pipeline. Also consider if the skill's opinionated architecture aligns with your existing codebase or if you'd need to refactor.
Why it is worth tracking
With 5,688 stars and a clear, focused scope, this skill shows strong community trust and real-world usage. It's worth tracking because fog of war is a recurring challenge in action games, and the skill's deterministic approach reduces debugging time significantly. Re-evaluate it whenever you start a new Three.js project or hit fog-related performance issues—it could save your team days of shader debugging. For more details, see the skill on OpenAgentSkill.
Featured Skill
implement-fog-of-war
Skill by MengTo