Forge Planar Reflectionsのロゴ

Forge Planar Reflections

コミュニティ
Nebulavenus
forge-planar-reflections

Add planar reflections with oblique near-plane clipping and Fresnel-blended water to an SDL GPU project.

概要

公開者Nebulavenus
リポジトリforge-gpu
スキル名forge-planar-reflections
スター
46
フォーク
7
同梱ファイル
指示のみ
ライセンスZlib
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    NebulavenusがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Forge Planar Reflections」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-planar-reflections
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Nebulavenus/forge-gpu.git /tmp/forge-gpu
mkdir -p .claude/skills
cp -r /tmp/forge-gpu/.claude/skills/forge-planar-reflections .claude/skills/forge-planar-reflections
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでForge Planar Reflectionsを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にForge Planar Reflectionsを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Forge Planar Reflectionsは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Add a reflective water surface (or any flat mirror) to an SDL3 GPU scene using planar reflections. The technique mirrors the camera across the reflection plane, renders the scene from that mirrored viewpoint into an offscreen texture, and composites the result using Fresnel blending. Use this skill when you need pixel-perfect reflections on flat surfaces — water, polished floors, or wall mirrors.

See GPU Lesson 30 — Planar Reflections for the full walkthrough.

Key API calls

FunctionPurpose
mat4_reflect(a, b, c, d)Build a 4x4 reflection matrix for plane ax+by+cz+d=0
mat4_oblique_near_plane(proj, clip_plane_view)Replace the near plane of a projection matrix with an arbitrary clip plane (Lengyel's method)
SDL_CreateGPUTextureCreate the offscreen reflection color and depth textures
SDL_BeginGPURenderPassBegin the reflection render pass with the mirrored camera
SDL_BindGPUFragmentSamplersBind the reflection texture for sampling in the water shader

Correct order

  1. Shadow pass — render depth from the directional light
  2. Reflection pass — mirror the camera, apply oblique near-plane clip, render the scene (minus water and floor) into an offscreen texture
  3. Main scene pass — standard forward render to the swapchain
  4. Water pass — alpha-blended quad sampling the reflection texture with Fresnel blending

Common mistakes

  • Forgetting oblique near-plane clipping. Without it, geometry below the water plane leaks into the reflection texture. Use mat4_oblique_near_plane() on the mirrored projection matrix.

  • Not reversing winding order. The reflection matrix flips triangle winding. Set the front-face to SDL_GPU_FRONTFACE_CLOCKWISE for the reflection pass pipeline (or vice versa if your normal pipeline uses CW).

  • Rendering the water or floor in the reflection pass. The reflection should only contain objects above the water plane. Rendering the water surface creates infinite recursion; rendering the floor shows geometry that should be clipped.

  • Missing Y-flip in screen-space UV. Vulkan/Metal texture coordinates have V increasing downward, but clip-space Y increases upward. The water shader must flip: screen_uv.y = 1.0 - screen_uv.y.

  • Submitting or canceling the command buffer incorrectly. After acquiring a swapchain texture, you must submit (not cancel) the command buffer, even on error. Cancel is only valid before swapchain acquisition.

  • Using the main camera's projection for the reflection pass. The reflection pass needs its own projection matrix with the oblique near plane. Reusing the main projection skips the clip and shows underwater artifacts.

Ready-to-use template

c
/* ── Reflection matrix ──────────────────────────────────────────── */

static mat4 mat4_reflect(float a, float b, float c, float d)
{
    mat4 m;
    m.m[0]  = 1.0f - 2.0f*a*a;  m.m[1]  =      -2.0f*a*b;
    m.m[2]  =      -2.0f*a*c;   m.m[3]  = 0.0f;
    m.m[4]  =      -2.0f*b*a;   m.m[5]  = 1.0f - 2.0f*b*b;
    m.m[6]  =      -2.0f*b*c;   m.m[7]  = 0.0f;
    m.m[8]  =      -2.0f*c*a;   m.m[9]  =      -2.0f*c*b;
    m.m[10] = 1.0f - 2.0f*c*c;  m.m[11] = 0.0f;
    m.m[12] = -2.0f*a*d;        m.m[13] = -2.0f*b*d;
    m.m[14] = -2.0f*c*d;        m.m[15] = 1.0f;
    return m;
}

/* ── Oblique near-plane clipping (Lengyel 2005) ─────────────────── */

static float signf_of(float x)
{
    if (x > 0.0f) return  1.0f;
    if (x < 0.0f) return -1.0f;
    return 0.0f;
}

static mat4 mat4_oblique_near_plane(mat4 proj, vec4 clip_plane_view)
{
    vec4 q;
    q.x = (signf_of(clip_plane_view.x) + proj.m[8])  / proj.m[0];
    q.y = (signf_of(clip_plane_view.y) + proj.m[9])  / proj.m[5];
    q.z = -1.0f;
    q.w = (1.0f + proj.m[10]) / proj.m[14];

    float dot = clip_plane_view.x * q.x + clip_plane_view.y * q.y +
                clip_plane_view.z * q.z + clip_plane_view.w * q.w;
    if (SDL_fabsf(dot) < 1e-6f) return proj;

    float scale = 1.0f / dot;
    proj.m[2]  = clip_plane_view.x * scale;
    proj.m[6]  = clip_plane_view.y * scale;
    proj.m[10] = clip_plane_view.z * scale;
    proj.m[14] = clip_plane_view.w * scale;
    return proj;
}

/* ── Per-frame reflection setup ─────────────────────────────────── */

/* Mirror camera across the water plane Y = WATER_LEVEL. */
vec3 reflected_cam = cam_position;
reflected_cam.y = 2.0f * WATER_LEVEL - reflected_cam.y;

mat4 reflect_mat = mat4_reflect(0.0f, 1.0f, 0.0f, -WATER_LEVEL);
mat4 reflected_view = mat4_multiply(view, reflect_mat);

/* Transform water plane to reflected view space for oblique clipping. */
mat4 vit = mat4_transpose(mat4_inverse(reflected_view));
float pw[4] = { 0.0f, 1.0f, 0.0f, -WATER_LEVEL };
vec4 cpv;
cpv.x = vit.m[0]*pw[0] + vit.m[4]*pw[1] + vit.m[8]*pw[2]  + vit.m[12]*pw[3];
cpv.y = vit.m[1]*pw[0] + vit.m[5]*pw[1] + vit.m[9]*pw[2]  + vit.m[13]*pw[3];
cpv.z = vit.m[2]*pw[0] + vit.m[6]*pw[1] + vit.m[10]*pw[2] + vit.m[14]*pw[3];
cpv.w = vit.m[3]*pw[0] + vit.m[7]*pw[1] + vit.m[11]*pw[2] + vit.m[15]*pw[3];

mat4 oblique_proj = mat4_oblique_near_plane(proj, cpv);
mat4 reflected_vp = mat4_multiply(oblique_proj, reflected_view);

/* ── Water fragment shader (HLSL) ───────────────────────────────── */
/*
float2 screen_uv = proj_pos.xy / proj_pos.w;
screen_uv = screen_uv * 0.5 + 0.5;
screen_uv.y = 1.0 - screen_uv.y;

float3 reflection = reflection_tex.Sample(linear_sampler, screen_uv).rgb;

float3 N = float3(0, 1, 0);
float3 V = normalize(eye_pos - world_pos);
float NdotV = saturate(dot(N, V));

float fresnel = fresnel_f0 + (1.0 - fresnel_f0) * pow(1.0 - NdotV, 5.0);
float3 color = lerp(water_tint.rgb, reflection, fresnel);
float  alpha = lerp(0.6, 1.0, fresnel);
*/

よくある質問

AIスキル「Forge Planar Reflections」では何ができますか?

Add planar reflections with oblique near-plane clipping and Fresnel-blended water to an SDL GPU project.

TypingMindでForge Planar Reflectionsを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Forge Planar Reflectionsはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにForge Planar Reflectionsをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-planar-reflectionsを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Forge Planar Reflectionsを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Forge Planar Reflectionsで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもForge Planar Reflectionsを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Forge Planar Reflections」は無料ですか?

はい。NebulavenusがZlibライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇