Forge Mesh Loading logo

Forge Mesh Loading

Community
Nebulavenus
forge-mesh-loading

Load a 3D model from an OBJ file, create a textured mesh with mipmaps, and render with a fly-around camera. Use when someone needs to load geometry from a file, parse OBJ models, or render textured 3D meshes in SDL3 GPU.

Overview

PublisherNebulavenus
Repositoryforge-gpu
Skill nameforge-mesh-loading
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 Mesh Loading 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-mesh-loading
  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-mesh-loading .claude/skills/forge-mesh-loading
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Forge Mesh Loading 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 Mesh Loading 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 Mesh Loading 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.

Mesh Loading — OBJ Parsing, Textured Rendering, Camera

This skill teaches how to load and render 3D models from Wavefront OBJ files. It builds on textures-and-samplers (Lesson 04), mipmaps (Lesson 05), depth-and-3d (Lesson 06), and camera-and-input (Lesson 07).

When to use

  • Loading 3D models from OBJ files
  • Rendering textured meshes with a camera
  • Parsing vertex positions, normals, and UV coordinates from files
  • Setting up non-indexed rendering (de-indexed vertices)
  • Combining texture loading + mipmaps + depth testing + camera in one app

Key API calls (ordered)

  1. forge_obj_load(path, &mesh) — parse OBJ into de-indexed vertex array
  2. SDL_CreateGPUBuffer + transfer upload — upload vertices to GPU
  3. SDL_LoadSurface + SDL_ConvertSurface — load PNG texture
  4. SDL_CreateGPUTexture with SAMPLER | COLOR_TARGET — mipmapped texture
  5. SDL_GenerateMipmapsForGPUTexture — auto-generate mip chain
  6. SDL_CreateGPUSampler — trilinear, REPEAT address mode
  7. SDL_CreateGPUGraphicsPipeline — 3 vertex attributes, depth test, back-face cull
  8. SDL_BindGPUFragmentSamplers — bind diffuse texture + sampler
  9. SDL_DrawGPUPrimitives — non-indexed draw (de-indexed vertices)

Libraries

c
#include "obj/forge_obj.h"     /* OBJ parser */
#include "math/forge_math.h"   /* vectors, matrices, quaternions */

Code template

Loading the mesh

c
/* Build path relative to executable */
const char *base_path = SDL_GetBasePath();
char obj_path[512];
SDL_snprintf(obj_path, sizeof(obj_path), "%smodels/model.obj", base_path);

ForgeObjMesh mesh;
if (!forge_obj_load(obj_path, &mesh)) {
    SDL_Log("Failed to load model");
    return SDL_APP_FAILURE;
}

/* Upload to GPU vertex buffer via transfer buffer */
Uint32 vertex_data_size = mesh.vertex_count * (Uint32)sizeof(ForgeObjVertex);
/* ... standard transfer buffer pattern from Lesson 02 ... */

Uint32 mesh_vertex_count = mesh.vertex_count;
forge_obj_free(&mesh);  /* CPU-side data no longer needed */

Loading texture with mipmaps

c
SDL_Surface *surface = SDL_LoadSurface(tex_path);
SDL_Surface *converted = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ABGR8888);
SDL_DestroySurface(surface);

int num_levels = (int)forge_log2f((float)converted->w) + 1;

SDL_GPUTextureCreateInfo tex_info;
SDL_zero(tex_info);
tex_info.type     = SDL_GPU_TEXTURETYPE_2D;
tex_info.format   = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB;
tex_info.usage    = SDL_GPU_TEXTUREUSAGE_SAMPLER | SDL_GPU_TEXTUREUSAGE_COLOR_TARGET;
tex_info.width    = converted->w;
tex_info.height   = converted->h;
tex_info.num_levels = num_levels;
/* ... upload base level, then: */
SDL_GenerateMipmapsForGPUTexture(cmd, texture);

Vertex layout (3 attributes)

c
/* ForgeObjVertex: position (float3) + normal (float3) + uv (float2) */

vertex_attributes[0].location = 0;  /* TEXCOORD0 = position */
vertex_attributes[0].format   = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3;
vertex_attributes[0].offset   = offsetof(ForgeObjVertex, position);

vertex_attributes[1].location = 1;  /* TEXCOORD1 = normal */
vertex_attributes[1].format   = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3;
vertex_attributes[1].offset   = offsetof(ForgeObjVertex, normal);

vertex_attributes[2].location = 2;  /* TEXCOORD2 = uv */
vertex_attributes[2].format   = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2;
vertex_attributes[2].offset   = offsetof(ForgeObjVertex, uv);

Rendering (non-indexed)

c
SDL_BindGPUVertexBuffers(pass, 0, &vertex_binding, 1);

SDL_GPUTextureSamplerBinding tex_binding;
SDL_zero(tex_binding);
tex_binding.texture = diffuse_texture;
tex_binding.sampler = sampler;
SDL_BindGPUFragmentSamplers(pass, 0, &tex_binding, 1);

/* Non-indexed draw — de-indexed vertices, every 3 form a triangle */
SDL_DrawGPUPrimitives(pass, mesh_vertex_count, 1, 0, 0);

HLSL shaders

Vertex shader:

hlsl
cbuffer Uniforms : register(b0, space1) { column_major float4x4 mvp; };

struct VSInput {
    float3 position : TEXCOORD0;
    float3 normal   : TEXCOORD1;
    float2 uv       : TEXCOORD2;
};

struct VSOutput {
    float4 position : SV_Position;
    float2 uv       : TEXCOORD0;
};

VSOutput main(VSInput input) {
    VSOutput output;
    output.position = mul(mvp, float4(input.position, 1.0));
    output.uv = input.uv;
    return output;
}

Fragment shader:

hlsl
Texture2D    diffuse_tex : register(t0, space2);
SamplerState smp         : register(s0, space2);

float4 main(float4 pos : SV_Position, float2 uv : TEXCOORD0) : SV_Target {
    return diffuse_tex.Sample(smp, uv);
}

Common mistakes

  1. Forgetting UV flip — OBJ uses V=0 at bottom; GPU uses V=0 at top. The forge_obj.h parser handles this automatically (1.0 - v).

  2. Using indexed draw for de-indexed mesh — Use SDL_DrawGPUPrimitives, not SDL_DrawGPUIndexedPrimitives, since vertices are already expanded.

  3. Wrong pixel format — SDL_LoadSurface may return any format. Always convert to SDL_PIXELFORMAT_ABGR8888 for GPU R8G8B8A8.

  4. Missing COLOR_TARGET usage — Required for mipmap generation. Without it, SDL_GenerateMipmapsForGPUTexture silently fails.

  5. Not copying model files in CMake — The OBJ and texture must be next to the executable. Use add_custom_command(POST_BUILD ...) to copy them.

  6. Loading JPG — SDL_LoadSurface only supports BMP and PNG. Convert JPG textures to PNG first (e.g. with Python Pillow).

CMakeLists.txt pattern

cmake
# Copy model files next to executable
add_custom_command(TARGET my-target POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E make_directory
        $<TARGET_FILE_DIR:my-target>/models/model-name
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        ${CMAKE_CURRENT_SOURCE_DIR}/models/model-name/model.obj
        $<TARGET_FILE_DIR:my-target>/models/model-name/model.obj
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        ${CMAKE_CURRENT_SOURCE_DIR}/models/model-name/texture.png
        $<TARGET_FILE_DIR:my-target>/models/model-name/texture.png
)

References

Frequently asked questions

What does the Forge Mesh Loading AI skill do?

Load a 3D model from an OBJ file, create a textured mesh with mipmaps, and render with a fly-around camera. Use when someone needs to load geometry from a file, parse OBJ models, or render textured 3D meshes in SDL3 GPU.

Why use Forge Mesh Loading on TypingMind?

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

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

Which AI models can use Forge Mesh Loading?

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 Mesh Loading?

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

Is the Forge Mesh Loading 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 👇