Forge Instanced Rendering logo

Forge Instanced Rendering

Community
Nebulavenus
forge-instanced-rendering

Draw many copies of a mesh efficiently with per-instance vertex buffers. Use when rendering forests, particle systems, city blocks, or any scene with repeated geometry in SDL3 GPU.

Overview

PublisherNebulavenus
Repositoryforge-gpu
Skill nameforge-instanced-rendering
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 Instanced Rendering 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-instanced-rendering
  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-instanced-rendering .claude/skills/forge-instanced-rendering
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Forge Instanced Rendering 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 Instanced Rendering 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 Instanced Rendering 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.

Set up instanced rendering with per-instance transforms passed through vertex attributes. One draw call renders all instances of a mesh.

When to use

  • Drawing many copies of the same mesh at different positions/rotations
  • CPU draw-call overhead is a concern (10+ instances of the same mesh)
  • Particles, vegetation, crowds, buildings, or any repeated geometry

Core pattern

1. Instance data structure

Each instance gets a model matrix (64 bytes = 4 × float4 columns):

c
typedef struct InstanceData {
    mat4 model;   /* 4 × vec4 columns, 64 bytes total */
} InstanceData;

2. Pipeline with two vertex buffer slots

Declare per-vertex AND per-instance buffer slots:

c
SDL_GPUVertexBufferDescription vb_descs[2];

/* Slot 0: per-vertex mesh data */
vb_descs[0].slot       = 0;
vb_descs[0].pitch      = sizeof(YourVertex);
vb_descs[0].input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX;

/* Slot 1: per-instance transform data */
vb_descs[1].slot       = 1;
vb_descs[1].pitch      = sizeof(InstanceData);  /* 64 bytes */
vb_descs[1].input_rate = SDL_GPU_VERTEXINPUTRATE_INSTANCE;

3. Vertex attributes (7 total)

c
SDL_GPUVertexAttribute attrs[7];

/* Per-vertex (slot 0) */
attrs[0] = { .location=0, .buffer_slot=0, .format=FLOAT3, .offset=offsetof(V, position) };
attrs[1] = { .location=1, .buffer_slot=0, .format=FLOAT3, .offset=offsetof(V, normal) };
attrs[2] = { .location=2, .buffer_slot=0, .format=FLOAT2, .offset=offsetof(V, uv) };

/* Per-instance (slot 1) — mat4 split into 4 columns */
attrs[3] = { .location=3, .buffer_slot=1, .format=FLOAT4, .offset=0 };   /* col 0 */
attrs[4] = { .location=4, .buffer_slot=1, .format=FLOAT4, .offset=16 };  /* col 1 */
attrs[5] = { .location=5, .buffer_slot=1, .format=FLOAT4, .offset=32 };  /* col 2 */
attrs[6] = { .location=6, .buffer_slot=1, .format=FLOAT4, .offset=48 };  /* col 3 */

4. Vertex shader — reconstruct matrix from columns

hlsl
cbuffer VertUniforms : register(b0, space1) {
    column_major float4x4 vp;
};

struct VSInput {
    float3 position : TEXCOORD0;  /* per-vertex */
    float3 normal   : TEXCOORD1;
    float2 uv       : TEXCOORD2;
    float4 model_c0 : TEXCOORD3;  /* per-instance */
    float4 model_c1 : TEXCOORD4;
    float4 model_c2 : TEXCOORD5;
    float4 model_c3 : TEXCOORD6;
};

struct VSOutput {
    float4 clip_pos   : SV_Position; /* clip-space position */
    float2 uv         : TEXCOORD0;   /* texture coordinates */
    float3 world_norm : TEXCOORD1;   /* world-space normal  */
    float3 world_pos  : TEXCOORD2;   /* world-space position */
};

VSOutput main(VSInput input) {
    VSOutput output;

    /* Reconstruct column-major model matrix.
     * float4x4() takes ROWS, so transpose to get columns. */
    float4x4 model = transpose(float4x4(
        input.model_c0, input.model_c1,
        input.model_c2, input.model_c3));

    float4 wp = mul(model, float4(input.position, 1.0));
    output.clip_pos = mul(vp, wp);
    output.world_pos = wp.xyz;

    /* Normal transform: adjugate transpose (works for all matrices) */
    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]);
    output.world_norm = mul(adj_t, input.normal);

    output.uv = input.uv;

    return output;
}

5. Generate and upload instance transforms

c
InstanceData instances[MAX_INSTANCES];
for (int i = 0; i < count; i++) {
    mat4 t = mat4_translate(positions[i]);
    mat4 r = mat4_rotate_y(angles[i]);
    mat4 s = mat4_scale(scales[i]);
    instances[i].model = mat4_multiply(t, mat4_multiply(r, s));
}

SDL_GPUBuffer *instance_buffer = upload_gpu_buffer(
    device, SDL_GPU_BUFFERUSAGE_VERTEX,
    instances, count * sizeof(InstanceData));

6. Render — bind both buffers, draw instanced

c
SDL_GPUBufferBinding vb[2];
vb[0].buffer = mesh->vertex_buffer;     /* per-vertex */
vb[1].buffer = model->instance_buffer;  /* per-instance */
SDL_BindGPUVertexBuffers(pass, 0, vb, 2);

/* Bind index buffer */
SDL_GPUBufferBinding ib = { .buffer = mesh->index_buffer };
SDL_BindGPUIndexBuffer(pass, &ib, index_type);

/* THE instanced draw — instance_count is the key */
SDL_DrawGPUIndexedPrimitives(pass, index_count, instance_count, 0, 0, 0);

Common mistakes

  1. Setting instance_step_rate to non-zero — SDL3 GPU requires instance_step_rate = 0 for all vertex buffer descriptions. The VERTEXINPUTRATE_INSTANCE input rate alone controls per-instance advancement.

  2. Wrong matrix reconstruction — HLSL float4x4(a,b,c,d) treats arguments as ROWS. If your data is column-major (like forge_math.h), you must transpose() the result.

  3. Using the wrong buffer usage — instance buffers use SDL_GPU_BUFFERUSAGE_VERTEX, not a special "instance" flag. The input rate on the pipeline description is what distinguishes per-vertex from per-instance.

  4. Not checking SDL return values — every SDL_CreateGPU* and SDL_SubmitGPUCommandBuffer returns a value. Log the function name + SDL_GetError() on failure.

Uniform layout

The instanced pipeline only pushes the VP matrix as a vertex uniform (64 bytes). The model matrix comes from the instance buffer. Fragment uniforms (material + lighting) are pushed per-material, same as non-instanced rendering.

Performance notes

  • Instanced rendering reduces CPU overhead (fewer draw calls, fewer uniform pushes), not GPU work. The GPU still processes the same number of triangles.
  • One instanced draw call can replace hundreds of individual draw calls.
  • For dynamic instances (moving objects), re-upload the instance buffer each frame using the transfer buffer pattern.
  • Multiple different meshes can share the same instanced pipeline — just bind different vertex/instance buffers per mesh.

Reference

Frequently asked questions

What does the Forge Instanced Rendering AI skill do?

Draw many copies of a mesh efficiently with per-instance vertex buffers. Use when rendering forests, particle systems, city blocks, or any scene with repeated geometry in SDL3 GPU.

Why use Forge Instanced Rendering on TypingMind?

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

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

Which AI models can use Forge Instanced Rendering?

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 Instanced Rendering?

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

Is the Forge Instanced Rendering 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 👇