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가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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:
- Let deterministic CPU perception own ranges, obstacle intersections, and gameplay visibility.
- Encode the player's angular visible distances into one fixed-size lookup texture.
- Let one full-screen shader turn that lookup into soft radial and wall-aware fog.
- 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.
댓글
- …
이 저장소의 다른 스킬
3d-cloth-material
7.2k에이전트가 Three.js에서 실 짜임, 부드러운 광택, 자연스러운 주름, 단, 솔기를 갖춘 실제 직물처럼 보이는 천을 만들도록 돕습니다.
3d-falling-leaves
7.2k에이전트가 3D 장면에 나뭇잎이 구르고 바람에 흩날리며 카메라 움직임에 따라 재사용되는 낙엽 효과를 추가하도록 돕습니다.
3d-four-seasons
7.2k에이전트가 3D 장면의 나무, 빛, 하늘, 눈을 바꿔 장면을 다시 만들지 않고 봄, 여름, 가을, 겨울을 표현하도록 돕습니다.
3d-high-poly-models
7.2k에이전트가 매끄러운 형태와 자연스러운 모서리를 가진 세밀한 3D 모델을 만들고, 웹에서 잘 돌아가는 가벼운 버전을 준비하도록 돕습니다.
비슷한 스킬
angular-developer
280k에이전트가 Angular 코드를 만들고 프로젝트 구조를 조언하도록 돕습니다. 새 프로젝트 시작, 코드 부분 생성, 성능과 접근성 개선에 유용합니다.
frontend-a11y
280k모든 사람이 웹 인터페이스를 쓸 수 있도록 에이전트를 돕습니다. 웹사이트와 앱이 화면 읽기 프로그램과 키보드 탐색에서 잘 작동하도록 합니다.
frontend-patterns
280k프론트엔드 개발의 현대적인 패턴을 적용하도록 에이전트를 돕습니다. React와 Next.js에서 성능을 최적화하고, 상태를 관리하며, 모범 사례를 따릅니다.