Dev asset lesson

From Nebulavenus/forge-gpu · View interactive version

Dev asset lesson is an AI agent skill from the GitHub repository Nebulavenus/forge-gpu. Add an asset pipeline lesson — hybrid Python + C track for asset processing, procedural geometry, and web frontend

How to use this skill

Skill file

Create a new asset pipeline lesson. This is a hybrid track — the pipeline

orchestrator is Python, performance-critical processing uses compiled C tools

(meshoptimizer, MikkTSpace), and procedural geometry lives in a header-only C

library (common/shapes/forge_shapes.h).

The goal is not just pedagogical. Every library, tool, and pipeline

component built in an asset lesson must be production-quality — well-tested,

documented, and designed for reuse beyond the lesson. The project's own

PLAN.md has a "Project Integration" section where forge-gpu's existing

assets (models, textures, skyboxes) are processed through the pipeline we

build. So the pipeline, plugins, and C tools are not toy examples scoped to a

single lesson — they are the actual tooling this project depends on.

Concretely this means:

pipeline/, C libraries go in common/, C tools go in tools/. The

lesson directory contains the walkthrough, not the implementation.

Python, tests/test_*.c for C). Edge cases, error paths, and realistic

inputs — not just happy-path smoke tests.

own models and textures. The C mesh tool will be invoked by the pipeline

as a subprocess. The shapes library is already used by GPU and physics

lessons. Build APIs that work for real projects.

code, write more code. Simplifying for the lesson at the cost of

correctness or reusability defeats the purpose.

When to use this skill:

Smart behavior:

CLI command, C tool, library, or web page

Arguments

The user (or you) can provide:

If any are missing, infer from context or ask.

Lesson Types

The asset pipeline track has three lesson types. Determine which type applies

before scaffolding.

Type A: Python lessons

Pipeline scaffold, texture processing, asset bundles, web frontend. These add

functionality to the shared pipeline/ package at the repo root (not

lesson-local code). The lesson directory contains only the README, diagrams,

example config, and sample assets.

Directory structure:

pipeline/                     # shared library (repo root) — code goes HERE
  __init__.py
  __main__.py
  config.py, plugin.py, scanner.py, ...
  plugins/
    <type>.py                 # built-in plugins grow lesson by lesson
tests/
  pipeline/                   # tests for the shared library
    test_<module>.py
lessons/assets/NN-topic-name/
  README.md                   # lesson walkthrough pointing at pipeline/ code
  pipeline.toml               # example config for hands-on testing
  assets/                     # sample source files, diagrams

Not added to CMakeLists.txt — Python projects are not C targets.

pyproject.toml is at the repo root — one package for the whole pipeline.

Type B: C tool lessons

Mesh processing with third-party C libraries (meshoptimizer, MikkTSpace). The

C tool is a standalone executable that the Python pipeline invokes as a

subprocess.

Directory structure:

lessons/assets/NN-topic-name/
  README.md
  main.c                    # standalone C tool
  CMakeLists.txt            # builds the tool, fetches dependencies
  tests/
    test_<tool>.c           # C test suite

Added to CMakeLists.txt — C tools need a build target. Add under an

"Asset Pipeline Lessons" section (create it if needed, after Physics Lessons

or at the end before Tests).

Type C: C library lessons

Procedural geometry and other header-only libraries that live in common/.

These produce a library, a test suite, and optionally a GPU lesson that

renders the output.

Directory structure:

common/<lib>/
  forge_<lib>.h             # header-only library
  README.md                 # API reference
lessons/assets/NN-topic-name/
  README.md                 # lesson walkthrough (may also have a GPU demo)
  PLAN.md                   # main.c decomposition (if GPU demo included)
  main.c                    # GPU showcase program (optional)
  CMakeLists.txt
  shaders/                  # if GPU demo
  assets/
tests/
  test_<lib>.c              # comprehensive test suite

Added to CMakeLists.txt — register the test target and any GPU demo.

Steps

1. Analyze what's needed

2. Create the lesson directory

Follow the directory structure for the determined lesson type (A, B, or C).

3. Create the lesson content

For Python lessons (Type A)

Package conventions:

dataclasses, pathlib)

tomli as fallback)

Create pyproject.toml:

[project]
name = "forge-asset-pipeline"
version = "0.1.0"
description = "Asset processing pipeline for forge-gpu"
requires-python = ">=3.10"
dependencies = [
    # Add per-lesson dependencies here
]

[project.optional-dependencies]
dev = [
    "pytest>=7.0",
    "ruff>=0.4",
]

[project.scripts]
forge-pipeline = "pipeline.__main__:main"
For C tool lessons (Type B)
For C library lessons (Type C)

thorough inline documentation

4. Create `README.md`

Structure varies by lesson type but always includes:

5. Update project files

only — Python lessons are not registered here)

6. Cross-reference other lessons

7. Test

Python lessons:

uv sync --extra dev
uv run pytest tests/pipeline/
uv run ruff check pipeline/
uv run ruff format --check pipeline/

C tool/library lessons:

cmake -B build
cmake --build build --config Debug --target <test-target>
ctest --test-dir build -R <test-name>

Use a Task agent with model: "haiku" for build commands per project

conventions.

8. Run markdown linting

npx markdownlint-cli2 "**/*.md"

Cross-Track Asset Pipeline Mandate

All GPU Lessons 39+ MUST use pipeline-processed assets via

forge_pipeline_load_mesh() / forge_pipeline_load_texture(). Physics

lessons use forge_shapes_*() for procedural bodies and

forge_pipeline_load_texture() for any textures. When adding pipeline

features, verify they don't break GPU lesson asset loading.

Asset Lesson Conventions

Scope

scanning, fingerprinting

format conversion

tangent generation (MikkTSpace), LOD generation (meshoptimizer), binary output

and flat normals, struct-of-arrays GPU layout

dependency tracking

editor, scene editor

Python style

C style

Follow the same conventions as all forge-gpu code:

(adjust prefix per library)

Plugin architecture

The Python pipeline uses a plugin system where each asset type registers a

processor. C tools are invoked as subprocesses by the Python plugin:

import subprocess
from pathlib import Path

class MeshPlugin(AssetPlugin):
    """Mesh processing plugin — invokes compiled C tool."""
    name = "mesh"
    extensions = [".gltf", ".glb", ".obj"]

    def process(self, source: Path, config: dict) -> AssetResult:
        result = subprocess.run(
            ["forge-mesh-tool", str(source), "--output", str(output)],
            capture_output=True, text=True
        )
        if result.returncode != 0:
            raise ProcessingError(result.stderr)
        return AssetResult(source=source, output=output, metadata={...})

Incremental builds

Every processing step must support incremental builds:

  1. Fingerprint source files (content hash, not timestamp)
  2. Compare against cached fingerprints from the last build
  3. Skip unchanged assets
  4. Track dependencies — if a texture changes, re-process meshes that

reference it

Configuration

Use TOML for pipeline and per-asset configuration:

# pipeline.toml — project-level config
[pipeline]
source_dir = "assets/raw"
output_dir = "assets/processed"
bundle_dir = "assets/bundles"

[texture]
default_format = "bc7"
max_size = 2048
generate_mipmaps = true

[mesh]
deduplicate = true
generate_tangents = true
lod_levels = [1.0, 0.5, 0.25]

Tone

Asset pipeline lessons should be practical and tool-focused. Pipeline tooling

is infrastructure that enables art and rendering — treat it with the same

rigor as the rendering code it serves. The output of these lessons is not

disposable teaching material; it is production tooling that forge-gpu itself

will use to process its own assets.

MikkTSpace — named tools and formats carry weight and help readers find

documentation

essential for pipeline lessons

before and after processing

concepts (texture formats, vertex layouts, draw calls)

for a real project, not just the lesson's sample assets

Example: Pipeline Scaffold Lesson (Type A — Python)

  1. Scope: CLI entry point, plugin discovery, asset scanning, fingerprinting,

TOML configuration

  1. Create: lessons/assets/01-pipeline-scaffold/
  2. Package: pipeline/ with __main__.py, config.py, scanner.py,

plugin.py

  1. Program: CLI that scans a directory for assets, fingerprints them, and

reports what would be processed. No actual processing yet.

  1. README: Explain plugin architecture, fingerprinting, TOML config, CLI

design

  1. Exercises: Add a new file type to the scanner, implement cache

invalidation, add --verbose output

Example: Mesh Processing Lesson (Type B — C tool)

  1. Scope: meshoptimizer for vertex/index optimization, MikkTSpace for

tangent generation, binary output format, LOD generation

  1. Create: lessons/assets/03-mesh-processing/
  2. Tool: main.c that reads glTF/OBJ, processes with meshoptimizer and

MikkTSpace, writes optimized binary output

  1. CMake: FetchContent for meshoptimizer and MikkTSpace
  2. Python plugin: plugins/mesh.py invokes the compiled tool as subprocess
  3. README: Explain vertex cache optimization, overdraw optimization, tangent

space, LOD simplification metrics

  1. Exercises: Add vertex quantization, compare draw call performance before

and after optimization

Example: Procedural Geometry Lesson (Type C — C library)

  1. Scope: forge_shapes.h — parametric surface generation (sphere,

icosphere, cylinder, cone, torus, plane, cube, capsule), struct-of-arrays

layout, smooth vs flat normals

  1. Create: common/shapes/forge_shapes.h, common/shapes/README.md,

lessons/assets/04-procedural-geometry/, tests/shapes/test_shapes.c

  1. Library: Header-only with FORGE_SHAPES_IMPLEMENTATION guard
  2. GPU demo: Five-shape showcase with Blinn-Phong lighting
  3. Tests: 28 tests covering vertex counts, normals, UVs, winding, memory
  4. README: Parametric surfaces, slices/stacks, seam duplication, smooth vs

flat normals, struct-of-arrays vs interleaved

When NOT to Create an Asset Lesson

In these cases, update existing documentation or plan for later.

Tips

add processing logic. A well-structured CLI with no-op plugins is a solid

foundation.

inputs. This validates that the pipeline produces output the C code can

actually consume.

portable. Timestamps break on copy, git clone, and CI.

load time improvements make the value of the pipeline concrete.

project served by the FastAPI backend in pipeline/server.py. The pipeline

is the lesson, not the frontend stack.

main.c will exceed 800 lines. Use the chunked-write pattern per

.claude/large-file-strategy.md.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.