Forge Normal Maps logo

Forge Normal Maps

Community
Nebulavenus
forge-normal-maps

Add tangent-space normal mapping to an SDL GPU project. Extends the vertex layout with tangent vectors, constructs a TBN matrix in the vertex shader, and samples/decodes normal maps in the fragment shader for per-texel surface detail.

Overview

PublisherNebulavenus
Repositoryforge-gpu
Skill nameforge-normal-maps
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 Normal Maps 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-normal-maps
  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-normal-maps .claude/skills/forge-normal-maps
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Forge Normal Maps 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 Normal Maps 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 Normal Maps 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.

Normal Maps Skill

Add tangent-space normal mapping to a 3D scene rendered with SDL's GPU API. Normal maps add surface detail (bumps, grooves, patterns) without increasing triangle count.

When to use

  • You have a textured 3D mesh and want to add surface detail
  • Your model has a normal map texture (tangent-space, glTF convention)
  • You need to compute tangent vectors for a mesh that doesn't supply them
  • You want to implement the TBN (tangent-bitangent-normal) pipeline

Prerequisites

  • Working 3D rendering with Blinn-Phong lighting (Lesson 10 / /forge-basic-lighting)
  • Texture sampling already set up (Lesson 04 / /forge-textures-and-samplers)
  • glTF or OBJ model loading (Lesson 09 / /forge-scene-loading)

Key concepts

Vertex layout

Extend your vertex struct with a vec4 tangent:

c
typedef struct SceneVertex {
    vec3 position;    /* TEXCOORD0 */
    vec3 normal;      /* TEXCOORD1 */
    vec2 uv;          /* TEXCOORD2 */
    vec4 tangent;     /* TEXCOORD3 — xyz = direction, w = handedness */
} SceneVertex;

Tangent computation (Lengyel's method)

For models without supplied tangents, compute them from triangle edges:

  1. For each triangle, solve for T and B from edge vectors and UV deltas
  2. Accumulate per-vertex (average across sharing triangles)
  3. Orthogonalize T against N using Gram-Schmidt: T' = normalize(T - N * dot(N, T))
  4. Compute handedness: sign(dot(cross(N, T), B))

Vertex shader — TBN construction

hlsl
/* Normal: adjugate transpose for non-uniform scale */
float3x3 m = (float3x3)model;
float3x3 adj_t;
adj_t[0] = cross(m[1], m[2]);
adj_t[1] = cross(m[2], m[0]);
adj_t[2] = cross(m[0], m[1]);
float3 N = normalize(mul(adj_t, input.normal));

/* Tangent: transform by model matrix */
float3 T = normalize(mul(m, input.tangent.xyz));

/* Gram-Schmidt re-orthogonalization */
T = normalize(T - N * dot(N, T));

/* Bitangent with handedness */
float3 B = cross(N, T) * input.tangent.w;

Fragment shader — normal map sampling

hlsl
/* Build TBN matrix (T, B, N as rows) */
float3x3 TBN = float3x3(
    normalize(input.world_tangent),
    normalize(input.world_bitan),
    normalize(input.world_normal));

/* Decode normal map: [0,1] → [-1,1] */
float3 map_normal = normal_tex.Sample(normal_smp, input.uv).rgb;
map_normal = map_normal * 2.0 - 1.0;

/* Transform to world space */
float3 N = normalize(mul(map_normal, TBN));

Pipeline setup

Fragment shader resources

The fragment shader needs 2 samplers (diffuse + normal map):

c
#define FS_NUM_SAMPLERS 2

Binding textures

c
SDL_GPUTextureSamplerBinding bindings[2];
bindings[0].texture = diffuse_texture;
bindings[0].sampler = sampler;
bindings[1].texture = normal_texture;
bindings[1].sampler = sampler;
SDL_BindGPUFragmentSamplers(pass, 0, bindings, 2);

Flat normal map placeholder

For materials without a normal map, use a 1x1 texture encoding (128, 128, 255) which decodes to tangent-space normal (0, 0, 1) — no perturbation.

Common mistakes

  1. Forgetting handedness — The tangent.w sign must be used when computing the bitangent. Without it, mirrored UVs produce inverted normal maps.

  2. Wrong normal map convention — glTF uses OpenGL convention (Y up / right-handed). DirectX-convention normal maps need Y flipped.

  3. Not re-orthogonalizing — After different transforms (adjugate for N, direct for T), the basis vectors may not be perpendicular. Gram-Schmidt fixes this.

  4. Normalizing in VS only — After rasterizer interpolation, the TBN vectors are no longer unit length. Always re-normalize in the fragment shader.

  5. mul order in HLSL — mul(map_normal, TBN) with TBN rows = T, B, N gives the correct tangent-to-world transformation.

glTF parser extension

The forge-gpu glTF parser stores tangents in ForgeGltfPrimitive.tangents (a separate vec4 array) and normal map paths in ForgeGltfMaterial.normal_map_path.

Reference

  • Lesson 17 source
  • Eric Lengyel, "Foundations of Game Engine Development, Volume 2: Rendering"
  • glTF 2.0 specification: tangent vectors and normal textures

Frequently asked questions

What does the Forge Normal Maps AI skill do?

Add tangent-space normal mapping to an SDL GPU project. Extends the vertex layout with tangent vectors, constructs a TBN matrix in the vertex shader, and samples/decodes normal maps in the fragment shader for per-texel surface detail.

Why use Forge Normal Maps on TypingMind?

Because you install it once and use it with any model. Forge Normal Maps 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 Normal Maps in TypingMind?

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

Which AI models can use Forge Normal Maps?

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 Normal Maps?

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

Is the Forge Normal Maps 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 👇