Imposters logo

Imposters

Community
Nebulavenus
imposters

Add imposter billboard LOD with baked multi-angle atlas to an SDL GPU project

Overview

PublisherNebulavenus
Repositoryforge-gpu
Skill nameimposters
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 Imposters 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/imposters
  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/imposters .claude/skills/imposters
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Imposters 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 Imposters 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 Imposters 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.

imposters

Add distance-based LOD to a scene by replacing far 3D instances with camera-facing billboard imposters. Near objects render as full meshes; beyond a transition zone they render as textured quads sampled from a pre-baked multi-angle atlas.

Prerequisites

  • common/scene/forge_scene.h with terrain and instanced mesh support
  • common/shapes/forge_shapes.h (procedural geometry for bake source)
  • Compiled imposter shaders: imposter_bake.vert/frag and imposter.vert/frag
  • Include shapes before scene (terrain API is gated on FORGE_SHAPES_H)

Data structures

c
/* Per-instance data for imposter billboards — 96 bytes, vertex buffer slot 1 */
typedef struct ImposterInstance {
    mat4  transform;    /* 64B — world position + scale                  */
    float atlas_uv[4]; /* 16B — u_offset, v_offset, u_scale, v_scale    */
    float alpha;        /* 4B  — cross-fade alpha [0..1]                 */
    float color[3];     /* 12B — RGB tint (multiplied with atlas)        */
} ImposterInstance;

/* Push constants for the imposter vertex shader (slot 0) */
typedef struct ImposterVertUniforms {
    mat4  vp;           /* camera view-projection matrix                 */
    float cam_pos[3];   /* world-space camera position for billboard facing */
    float _pad;         /* explicit padding to 80 bytes                  */
} ImposterVertUniforms;

/* Push constants for the bake vertex shader (slot 0) — one MVP per angle */
typedef struct BakeVertUniforms {
    mat4 mvp;
} BakeVertUniforms;

/* Push constants for the bake fragment shader (slot 0, space3) */
typedef struct BakeFragUniforms {
    float base_color[4]; /* RGBA base color for trunk or crown draw call */
    float light_dir[3];  /* world-space light direction (normalized)     */
    float ambient;       /* ambient light floor [0, 1]                   */
} BakeFragUniforms;

Atlas layout

c
#define ATLAS_FRAMES      8     /* azimuth angles at 45° intervals */
#define ATLAS_COLS        4     /* frames per row                  */
#define ATLAS_ROWS        2
#define ATLAS_FRAME_SIZE  256   /* pixels per cell                 */
#define ATLAS_WIDTH       (ATLAS_COLS * ATLAS_FRAME_SIZE)  /* 1024 */
#define ATLAS_HEIGHT      (ATLAS_ROWS * ATLAS_FRAME_SIZE)  /* 512  */

Frames are laid out row-major: [0][1][2][3] / [4][5][6][7]. Frame 0 is at azimuth 0, each subsequent frame adds TAU / ATLAS_FRAMES.

Atlas baking procedure

Baking is a one-shot startup operation. Create and destroy the bake pipeline inside the bake function — only the atlas texture and sampler persist.

c
/* 1. Create atlas texture: COLOR_TARGET + SAMPLER usage */
tex_info.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM;
tex_info.width  = ATLAS_WIDTH;
tex_info.height = ATLAS_HEIGHT;
tex_info.usage  = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER;

/* 2. Create depth texture: D32_FLOAT, DEPTH_STENCIL_TARGET usage only */

/* 3. Create bake pipeline */
/*    - Color target: R8G8B8A8_UNORM, blending disabled               */
/*    - Depth: D32_FLOAT, write + test with LESS                      */
/*    - Vertex input: ForgeSceneVertex (FLOAT3 pos at 0, FLOAT3 normal at 12) */
/*    - Back-face cull: BACK (tree mesh is solid)                     */

/* 4. One render pass covers all 8 frames — viewport + scissor change per frame */
SDL_GPUColorTargetInfo ct = { .load_op = SDL_GPU_LOADOP_CLEAR,
                               .clear_color = {0,0,0,0} }; /* transparent black */

for (int i = 0; i < ATLAS_FRAMES; i++) {
    float angle = (float)i * (FORGE_TAU / (float)ATLAS_FRAMES);
    vec3 eye = vec3_create(SDL_sinf(angle) * view_dist, slight_elevation,
                           SDL_cosf(angle) * view_dist);
    mat4 view = mat4_look_at(eye, tree_center, world_up);
    mat4 mvp  = mat4_multiply(ortho_proj, view);

    /* Set viewport and scissor to the atlas cell for this frame */
    int cell_x = (i % ATLAS_COLS) * ATLAS_FRAME_SIZE;
    int cell_y = (i / ATLAS_COLS) * ATLAS_FRAME_SIZE;
    /* SDL_SetGPUViewport + SDL_SetGPUScissor ... */

    /* Push BakeVertUniforms with mvp, then draw trunk and crown as separate
     * calls with different BakeFragUniforms base_color values. */
}

/* 5. Submit, SDL_WaitForGPUIdle, then release bake depth + bake pipeline */

/* 6. Create atlas sampler: LINEAR filter, CLAMP_TO_EDGE on U and V
 *    Clamping prevents bleeding between adjacent atlas cells. */

Use mat4_orthographic sized to the model's bounding volume. A slight Y elevation on the camera (≈ 15% of model height) avoids flat top-down angles.

Billboard quad

c
/* Unit quad in XY plane: X from -0.5..+0.5, Y from 0..1, normal +Z */
/* Two CCW triangles: (0,1,2) and (0,2,3) */
verts[0].position = vec3_create(-0.5f, 0.0f, 0.0f);
verts[1].position = vec3_create( 0.5f, 0.0f, 0.0f);
verts[2].position = vec3_create( 0.5f, 1.0f, 0.0f);
verts[3].position = vec3_create(-0.5f, 1.0f, 0.0f);

The vertex shader expands the quad using billboard basis vectors derived from the pivot-to-camera direction projected onto the XZ plane (cylindrical billboard — no vertical tilt).

Imposter pipeline

Two vertex buffer slots are required:

c
/* Slot 0: per-vertex quad geometry */
vb_descs[0].pitch      = sizeof(ForgeSceneVertex); /* 24 bytes */
vb_descs[0].input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX;
vb_descs[0].instance_step_rate = 0;  /* MUST be 0 in SDL3 GPU */

/* Slot 1: per-instance imposter data */
vb_descs[1].pitch      = sizeof(ImposterInstance); /* 96 bytes */
vb_descs[1].input_rate = SDL_GPU_VERTEXINPUTRATE_INSTANCE;
vb_descs[1].instance_step_rate = 0;

Eight vertex attributes (TEXCOORD0–7):

LocationSlotTypeOffsetPurpose
00FLOAT30Quad position
10FLOAT312Quad normal (unused)
21FLOAT40Transform column 0
31FLOAT416Transform column 1
41FLOAT432Transform column 2
51FLOAT448Transform column 3
61FLOAT464Atlas UV rect
71FLOAT480Alpha (x) + RGB tint (yzw)

Alpha blending: SRC_ALPHA / ONE_MINUS_SRC_ALPHA (standard over-compositing). Disable back-face culling (CULLMODE_NONE) — precision at edge-on angles can flip winding. Depth test and write both enabled.

Per-frame LOD classification

c
float cell_u = 1.0f / (float)ATLAS_COLS;
float cell_v = 1.0f / (float)ATLAS_ROWS;

for each tree {
    float dist = vec3_length(vec3_sub(cam_pos, tree_pos));

    if (dist < lod_far)  /* near or transition — add to near_cpu */
    if (dist > lod_near) /* transition or far — add to far_cpu   */

    /* Azimuth frame selection */
    float angle = SDL_atan2f(diff.x, diff.z);
    if (angle < 0.0f) angle += FORGE_TAU;
    int frame = ((int)(angle / FORGE_TAU * ATLAS_FRAMES + 0.5f)) % ATLAS_FRAMES;

    fi->atlas_uv[0] = (float)(frame % ATLAS_COLS) * cell_u;  /* u offset */
    fi->atlas_uv[1] = (float)(frame / ATLAS_COLS) * cell_v;  /* v offset */
    fi->atlas_uv[2] = cell_u;   /* u scale */
    fi->atlas_uv[3] = cell_v;   /* v scale */

    /* Imposter fades in during transition; mesh stays fully opaque */
    fi->alpha = (dist < lod_far) ? (dist - lod_near) / (lod_far - lod_near) : 1.0f;
}

Trees in the transition zone appear in both arrays — the full mesh renders at full opacity and the imposter fades in on top with increasing alpha. At the far boundary the mesh stops rendering and the imposter takes over.

Rendering order

c
/* 1. Classify instances into near_cpu / far_cpu arrays */
classify_instances(state, cam_pos);

/* 2. Upload both arrays via deferred copy pass */
forge_scene_begin_deferred_uploads(s);
near_buf = forge_scene_upload_buffer_deferred(s, SDL_GPU_BUFFERUSAGE_VERTEX,
               near_cpu, near_count * sizeof(ForgeSceneColoredInstance));
far_buf  = forge_scene_upload_buffer_deferred(s, SDL_GPU_BUFFERUSAGE_VERTEX,
               far_cpu, far_count * sizeof(ImposterInstance));
forge_scene_end_deferred_uploads(s);

/* 3. Shadow pass — terrain + near mesh only (imposters skip shadow casting) */
forge_scene_begin_shadow_pass(s);
forge_scene_draw_terrain_shadow(s);
forge_scene_draw_shadow_mesh_instanced_colored(s, tree_vb, tree_ib,
    tree_index_count, near_buf, near_count);
forge_scene_end_shadow_pass(s);

/* 4. Main pass — terrain, near mesh, then imposter draw */
forge_scene_begin_main_pass(s);
forge_scene_draw_terrain(s);
forge_scene_draw_mesh_instanced_colored(s, tree_vb, tree_ib,
    tree_index_count, near_buf, near_count, white);

/* Switch to imposter pipeline for billboard draw */
SDL_BindGPUGraphicsPipeline(forge_scene_main_pass(s), imposter_pipeline);
SDL_PushGPUVertexUniformData(forge_scene_cmd(s), 0, &ivu, sizeof(ivu));
SDL_BindGPUFragmentSamplers(pass, 0, &atlas_bind, 1);
/* Bind slot 0 = quad_vb, slot 1 = far_buf */
SDL_DrawGPUIndexedPrimitives(pass, 6, far_count, 0, 0, 0);
forge_scene_end_main_pass(s);

/* 5. UI pass */

Heightmap from asset pipeline

c
/* Load pipeline-generated BMP; fall back to procedural fBm if absent */
float *hmap = forge_scene_load_heightmap_image(path, &w, &h);
if (!hmap) {
    /* generate with forge_noise_fbm2d, normalize to [0,1] */
}
forge_scene_set_terrain(&scene, hmap, w, h);

forge_scene_load_heightmap_image reads an 8-bit or 16-bit grayscale BMP and returns a float[] normalized to [0, 1]. The caller owns the allocation and must SDL_free it when done.

Common mistakes

  • instance_step_rate non-zero — SDL3 GPU requires 0 for all slots. VERTEXINPUTRATE_INSTANCE alone controls per-instance advancement.
  • Atlas bleed — use CLAMP_TO_EDGE on both U and V axes of the atlas sampler; REPEAT causes adjacent frame pixels to bleed into each other.
  • Bake pipeline not destroyed — the bake pipeline and depth texture are one-shot. Release them after SDL_WaitForGPUIdle to free GPU memory.
  • Wrong azimuth frame — use atan2(diff.x, diff.z) (not atan2(diff.z, diff.x)). The bake orbit uses (sin(angle), y, cos(angle)), so atan2(x, z) measures from +Z to match frame 0. Swapping the arguments produces a 90-degree offset between bake and selection.
  • Imposters cast no shadows — far imposters are not submitted to the shadow pass. At typical LOD distances the shadow error is imperceptible and avoids a matching shadow billboard pipeline.

Reference

  • Lesson: lessons/gpu/49-imposters/
  • Shaders: lessons/gpu/49-imposters/shaders/imposter.vert/frag.hlsl and imposter_bake.vert/frag.hlsl
  • Heightmap API: common/scene/forge_scene.h (forge_scene_load_heightmap_image)
  • Terrain setup: height-map-terrain skill
  • Instanced rendering: forge-instanced-rendering skill

Frequently asked questions

What does the Imposters AI skill do?

Add imposter billboard LOD with baked multi-angle atlas to an SDL GPU project

Why use Imposters on TypingMind?

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

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

Which AI models can use Imposters?

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 Imposters?

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

Is the Imposters 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 👇