본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)7.2k · #13337

implement-fog-of-war

하는 일

이 스킬은 Three.js 액션 게임에서 벽이 플레이어의 시야를 막는 안개 전쟁을 만드는 과정을 안내합니다. 위에서 내려다보거나 등각 시점 게임에 가시성과 적의 감지 기능을 추가하는 게임 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓플레이어가 시선이 닿는 곳만 보도록 하고 싶을 때.
  • ✓적이 설정된 범위와 시야 안에서만 플레이어를 알아차려야 할 때.
  • ✓안개에 이상한 선이나 이음새가 보여서 고쳐야 할 때.

스킬 링크

https://github.com/MengTo/Skills/blob/main/agent-skills/codex/implement-fog-of-war/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/MengTo/Skills/blob/main/agent-skills/codex/implement-fog-of-war/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 등각 게임에 안개 전쟁을 추가해 주세요. 벽이 시야를 막고, 적은 제가 보일 때만 저를 발견하게 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 벽 검사와 함께 프로세서에서 가시성을 계산하고, 그 결과를 하나의 안개 셰이더에 넘깁니다. 게임플레이와 시각적 안개를 분리해 두고, 가시성 규칙에 대한 테스트도 추가합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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

  • Locate the authoritative player position, camera, obstacles, scene lifecycle, frame loop, targeting, enemy perception, and render layers.
  • Confirm the gameplay ground model. The proven corner-unprojection method assumes a locally horizontal plane; use authoritative surface or terrain reconstruction when elevation varies across the visible area.
  • Find existing scene fog, post-processing, renderer creation, review modes, menus, captures, transitions, and disposal paths.
  • Read the current tests and recent fog/perception commits before changing constants or ownership.
  • Confirm whether obstacle state changes at runtime. Reuse the same active obstacle collection used by navigation or collision when its geometry is suitable for sight.
  • Check the working tree early and preserve unrelated changes.

Implement in dependency order

1. Define perception truth

  • Represent each sight blocker with a stable footprint, vertical span, and active state.
  • Intersect a 3D sight segment or ray with both the horizontal footprint and vertical span.
  • Ignore inactive blockers and cover below the eye-to-target sight line.
  • Expose:
    • point-to-point perception for enemies, targeting, and attacks;
    • a deterministic angular distance fill for the fog lookup.
  • Use explicit player and enemy ranges. Allow them to differ when the encounter design needs enemies to acquire beyond the player's reveal edge.

2. Build the visibility lookup

  • Allocate the distance array, byte pixels, and data texture once.
  • Cast a fixed number of evenly spaced horizontal rays around the player's eye point.
  • Normalize hit distances by the player vision radius and quantize them into a one-row red-channel texture.
  • Use linear filtering, horizontal repeat wrapping, no mipmaps, and a bounded mobile/desktop ray budget.
  • Refresh after meaningful player motion or a short maximum interval. Do not allocate in the frame loop.

3. Render one soft overlay

  • Use one clip-space plane and one transparent shader material.
  • Reconstruct each fragment's ground-plane position from the four camera-corner intersections.
  • Combine:
    • a clear inner radius and soft outer radial falloff;
    • a feathered wall boundary sampled from the angular lookup.
  • Smooth obstacle visibility across neighboring angles. Weight wall fog below the outer radial fog so blockers read as atmosphere, not opaque wedges.
  • Combine radial and obstacle fog with max, then cap final opacity.
  • Disable depth test, depth write, and tone mapping; render after the world.
  • Do not introduce a second renderer, render target, composer, or per-ray meshes.

4. Integrate gameplay

  • Keep simulation presence separate from presentation visibility.
  • Hide unrevealed enemy renderables through layers or a presentation-only mechanism; do not toggle the actor root if root visibility also controls lifecycle or simulation.
  • Exclude unrevealed enemies from target lock, aim selection, nearest-target search, HUD counts, and player hit eligibility.
  • Hide telegraphs that would leak an unseen enemy.
  • Let enemy acquisition and attacks use their own range plus the same line-of-sight truth.
  • Clear an active target lock as soon as perception invalidates it.
  • Cache perception within a simulation phase and refresh after movement when downstream systems need current positions.

5. Integrate state and lifecycle

  • Enable fog only during active gameplay.
  • Disable it for menus, inventory, review/capture modes, paused or non-playing states, and stage transitions unless the product explicitly requires otherwise.
  • Disable it before any early-render branch so a previous frame cannot leak into another state.
  • Keep atmospheric
자주 묻는 질문

안개는 화면 모습만 바꾸나요?

아닙니다. 스킬은 게임플레이가 안개 픽셀이 아니라 지각 결과를 직접 사용한다고 설명합니다.

휴대폰도 고려하나요?

네. 모바일 광선 예산을 다뤄서, 느린 기기에서 가시성 검사의 비용도 고려합니다.

어떤 게임 종류에 맞나요?

정사영 및 등각 액션 게임이 주된 대상입니다.

상세 정보

작성자의 원본 설명

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 seams, mobile ray budgets, lifecycle and menu-state integration, and deterministic fog-of-war tests.

repo: MengTo/Skills

인기도

GitHub 스타
7.2k
순위
#13337
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬