Logo de Imposters

Imposters

Comunidade
Nebulavenus
imposters

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

Visão geral

Publicado porNebulavenus
Repositórioforge-gpu
Nome da habilidadeimposters
Estrelas
46
Forks
7
Arquivos incluídos
Somente instruções
LicençaZlib
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    As habilidades de IA são escritas em Markdown simples, não em código específico de um provedor. Por isso, funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • Sem arquivos extras

    Tudo de que o modelo precisa está nas instruções — sem arquivos extras para sincronizar.

  • Código aberto

    Publicada por Nebulavenus no GitHub. Leia os arquivos da habilidade antes de instalá-la.

Instalação

Instale a habilidade de IA Imposters no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL abaixo, que aponta para a pasta da habilidade, e confirme.
    https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/imposters
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Adicionar habilidade → Via URL do GitHub. Depois, cole a URL da pasta e pressione Continuar.
2

Instalar em outro agente

Qualquer agente que leia o formato Agent Skills pode usar esta habilidade — copie a pasta para o diretório de habilidades desse agente.

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
Reinicie Claude Code após copiar para que a nova habilidade seja reconhecida.

Use no TypingMind

Ative Imposters em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Imposters automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Imposters não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

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

Perguntas frequentes

O que a habilidade de IA Imposters faz?

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

Por que usar Imposters no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. A habilidade Imposters é escrita em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. No TypingMind, você usa suas próprias chaves de API e paga diretamente aos provedores, em vez de pagar uma assinatura por licença de usuário. Suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Imposters no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/imposters. O TypingMind lê o arquivo SKILL.md e instala a habilidade para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Imposters?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Imposters?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Imposters com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Imposters é gratuita?

Sim. A habilidade é publicada no GitHub por Nebulavenus sob a licença Zlib. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, templates ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas que ele pode acionar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA dá ao modelo o conhecimento e as orientações de que ele precisa: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver lista completa

Crie seu próprio espaço de trabalho com IA agora

Inscreva-se na nossa newsletter para receber avisos sobre novos recursos e futuros sorteios 👇