本文へスキップ
Skillpedia
Webサイトと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がスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/MengTo/Skills/blob/main/agent-skills/codex/implement-fog-of-war/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“私のアイソメトリックのゲームに戦場の霧を追加してください。壁が視界を遮り、敵は私が見えるときにだけ私に気づくようにしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、壁の判定を使って、見通しの計算をプロセッサーで行います。その結果を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

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル