Forge Scene Model Loading logo

Forge Scene Model Loading

Community
Nebulavenus
forge-scene-model-loading

Load and render pipeline-processed 3D models (.fscene + .fmesh + .fmat) through forge_scene.h with per-primitive materials, mesh instancing, and scene hierarchy traversal.

Overview

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

Use it in TypingMind

Enable Forge Scene Model 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 Scene Model 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 Scene Model 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.

forge-scene-model-loading

Load pipeline-processed 3D models through forge_scene.h. One forge_scene_load_model() call handles file loading, GPU buffer upload, and per-material texture loading. The draw functions traverse the scene node hierarchy and bind materials per-submesh.

Prerequisites

Models must be processed through the asset pipeline tools first:

bash
# Process mesh (produces .fmesh + .fmat)
./build/tools/mesh/forge_mesh_tool input.gltf output.fmesh --verbose

# Process scene hierarchy (produces .fscene)
./build/tools/scene/forge_scene_tool input.gltf output.fscene --verbose

# Copy textures alongside the .fmat file
cp source_textures/*.png output_dir/

Usage pattern

c
#define SDL_MAIN_USE_CALLBACKS 1
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include "math/forge_math.h"

#define FORGE_PIPELINE_IMPLEMENTATION
#include "pipeline/forge_pipeline.h"

#define FORGE_SCENE_MODEL_SUPPORT
#define FORGE_SCENE_IMPLEMENTATION
#include "scene/forge_scene.h"

typedef struct {
    ForgeScene      scene;
    ForgeSceneModel model;
} app_state;

SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
{
    app_state *state = (app_state *)SDL_calloc(1, sizeof(*state));
    if (!state) return SDL_APP_FAILURE;
    *appstate = state;

    ForgeSceneConfig cfg = forge_scene_default_config("Model Viewer");
    cfg.cam_start_pos = vec3_create(0.0f, 2.0f, 5.0f);
    cfg.font_path = "assets/fonts/liberation_mono/LiberationMono-Regular.ttf";

    if (!forge_scene_init(&state->scene, &cfg, argc, argv))
        return SDL_APP_FAILURE;

    /* Load a pipeline-processed model.
     * base_dir is where textures are found (same dir as .fmat). */
    if (!forge_scene_load_model(&state->scene, &state->model,
                                "assets/MyModel/MyModel.fscene",
                                "assets/MyModel/MyModel.fmesh",
                                "assets/MyModel/MyModel.fmat",
                                "assets/MyModel")) {
        SDL_Log("Failed to load model");
        return SDL_APP_FAILURE;
    }

    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
{
    app_state *state = (app_state *)appstate;
    return forge_scene_handle_event(&state->scene, event);
}

SDL_AppResult SDL_AppIterate(void *appstate)
{
    app_state *state = (app_state *)appstate;
    ForgeScene *s = &state->scene;

    if (!forge_scene_begin_frame(s)) return SDL_APP_CONTINUE;

    mat4 placement = mat4_translate(vec3_create(0.0f, 0.0f, 0.0f));

    /* Shadow pass */
    forge_scene_begin_shadow_pass(s);
    forge_scene_draw_model_shadows(s, &state->model, placement);
    forge_scene_end_shadow_pass(s);

    /* Main pass */
    forge_scene_begin_main_pass(s);
    forge_scene_draw_model(s, &state->model, placement);
    forge_scene_draw_grid(s);
    forge_scene_end_main_pass(s);

    return forge_scene_end_frame(s);
}

void SDL_AppQuit(void *appstate, SDL_AppResult result)
{
    (void)result;
    app_state *state = (app_state *)appstate;
    if (!state) return;
    if (forge_scene_device(&state->scene)) {
        if (!SDL_WaitForGPUIdle(forge_scene_device(&state->scene))) {
            SDL_Log("SDL_WaitForGPUIdle failed: %s", SDL_GetError());
        }
        forge_scene_free_model(&state->scene, &state->model);
    }
    forge_scene_destroy(&state->scene);
    SDL_free(state);
}

Key defines

Both defines must appear before including forge_scene.h:

DefinePurpose
FORGE_SCENE_MODEL_SUPPORTEnables model types and functions (pulls in forge_pipeline.h)
FORGE_SCENE_IMPLEMENTATIONCompiles the implementation (one .c file only)
FORGE_PIPELINE_IMPLEMENTATIONCompiles the pipeline library (one .c file only)

ForgeSceneModelVertex layout

The model pipeline uses a 48-byte vertex with tangent data for normal mapping:

FieldTypeSizeOffsetHLSL
positionfloat312 B0TEXCOORD0
normalfloat312 B12TEXCOORD1
uvfloat28 B24TEXCOORD2
tangentfloat416 B32TEXCOORD3

ForgeSceneModel struct

After forge_scene_load_model, the struct contains:

FieldTypeDescription
scene_dataForgePipelineSceneNode hierarchy with world transforms
meshForgePipelineMeshVertex/index data, submeshes, LODs
materialsForgePipelineMaterialSetPBR material descriptions
vertex_bufferSDL_GPUBuffer *Uploaded 48-byte vertices
index_bufferSDL_GPUBuffer *Uploaded uint32 indices
mat_textures[]ForgeSceneModelTexturesPer-material GPU textures
draw_callsuint32_tUpdated each draw_model call

Pipeline variants

The renderer selects a pipeline per-submesh based on material properties:

VariantConditionBehavior
model_pipelineDefault (opaque)Cull back, depth test + write
model_pipeline_blendalpha_mode == BLENDAlpha blend, no depth write
model_pipeline_doubledouble_sided == trueCull none, depth test + write

Texture slots and fallbacks

Each material binds up to 5 textures. Missing slots use 1x1 fallbacks:

SlotTextureFallbacksRGB
0Base colorWhite (1,1,1,1)Yes
1Normal mapFlat (0.5,0.5,1)No
2Metallic-roughnessWhite (1,1,1,1)No
3OcclusionWhite (1,1,1,1)No
4EmissiveBlack (0,0,0,1)Yes
5Shadow mapScene shadow mapNo

CMakeLists.txt

Models require cJSON for .fmat parsing:

cmake
add_executable(my-lesson WIN32
    main.c
    ${CMAKE_SOURCE_DIR}/third_party/cJSON/cJSON.c)
target_include_directories(my-lesson PRIVATE
    ${FORGE_COMMON_DIR}
    ${CMAKE_SOURCE_DIR}/third_party/cJSON)
target_link_libraries(my-lesson PRIVATE SDL3::SDL3
    $<$<NOT:$<C_COMPILER_ID:MSVC>>:m>)

# Copy model assets to build output
add_custom_command(TARGET my-lesson POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_directory
        ${CMAKE_CURRENT_SOURCE_DIR}/assets
        $<TARGET_FILE_DIR:my-lesson>/assets)

Common mistakes

  • Forgetting FORGE_SCENE_MODEL_SUPPORT. Without this define, the model types and functions are not compiled. You get "unknown type" errors for ForgeSceneModel.

  • Forgetting FORGE_PIPELINE_IMPLEMENTATION. The pipeline library must be compiled in exactly one .c file. Without it, you get linker errors for forge_pipeline_load_scene, etc.

  • Wrong texture paths. The .fmat stores source-relative texture paths from the original glTF. forge_scene_load_model extracts just the filename and looks for it in base_dir. Textures must be copied alongside the .fmat file.

  • Not freeing models before forge_scene_destroy. Call forge_scene_free_model for each loaded model before destroying the scene. The model holds GPU resources (buffers, textures) that reference the device.

  • Applying redundant scale. Some glTF models (e.g., Duck) have scale transforms baked into their scene hierarchy. Check the node world transforms before applying additional scaling in the placement matrix.

Reference

  • Source: common/scene/forge_scene.h (model support section)
  • Shaders: common/scene/shaders/scene_model.vert.hlsl, scene_model.frag.hlsl
  • Lesson: lessons/gpu/41-scene-model-loading/
  • Pipeline types: common/pipeline/forge_pipeline.h

Frequently asked questions

What does the Forge Scene Model Loading AI skill do?

Load and render pipeline-processed 3D models (.fscene + .fmesh + .fmat) through forge_scene.h with per-primitive materials, mesh instancing, and scene hierarchy traversal.

Why use Forge Scene Model Loading on TypingMind?

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

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

Which AI models can use Forge Scene Model 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 Scene Model Loading?

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

Is the Forge Scene Model 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 👇