Forge Planar Reflections logo

Forge Planar Reflections

Community
Nebulavenus
forge-planar-reflections

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

Overview

PublisherNebulavenus
Repositoryforge-gpu
Skill nameforge-planar-reflections
Stars
46
Forks
7
Bundled files
Instructions only
LicenseZlib
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Nebulavenus on GitHub. Read the source before you install it.

Installation

Install the Forge Planar Reflections AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-planar-reflections
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Forge Planar Reflections in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Forge Planar Reflections on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Forge Planar Reflections is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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);
*/

Frequently asked questions

What does the Forge Planar Reflections AI skill do?

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

Why use Forge Planar Reflections on TypingMind?

Because you install it once and use it with any model. Forge Planar Reflections is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Forge Planar Reflections in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-planar-reflections. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Forge Planar Reflections?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Forge Planar Reflections?

As many as you like. As long as a model supports skills, you can use Forge Planar Reflections with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Forge Planar Reflections AI skill free?

Yes. It is published on GitHub by Nebulavenus under the Zlib license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇