Imposters
Add imposter billboard LOD with baked multi-angle atlas to an SDL GPU project
by Nebulavenus★ 51 GitHub stars
Install Imposters in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
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.hwith terrain and instanced mesh supportcommon/shapes/forge_shapes.h(procedural geometry for bake source)- Compiled imposter shaders:
imposter_bake.vert/fragandimposter.vert/frag - Include shapes before scene (terrain API is gated on
FORGE_SHAPES_H)
Data structures
/* 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
#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.
/* 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
/* 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 billboar
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the Imposters skill do?
Add imposter billboard LOD with baked multi-angle atlas to an SDL GPU project
How do I install the Imposters skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the Imposters skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…