Skip to content

Epic: Phase 6 — Mesh Optimization Pipeline #261

Description

@fernandotonon

Overview

Complete the game-dev export pipeline with interactive mesh optimization, texture management, and performance analysis tools. Essential for shipping assets to game engines.

Prerequisites

  • Phase 1 (mesh buffer manipulation patterns from sub-mesh editing)
  • Phase 4 (topology tools provide the mesh simplification foundation)

Scope

1. Interactive Mesh Decimation

  • Slider to reduce polygon count with real-time viewport preview
  • Target: triangle count, percentage, or vertex budget
  • Algorithm: Quadric Error Metrics (QEM) — preserves visual quality
  • Preserve UV seams and material boundaries during simplification
  • Lock vertices: exclude selected vertices/edges from decimation
  • Compare mode: split viewport showing original vs decimated side-by-side
  • Export decimated mesh directly

2. Texture Atlas Generation

  • Select multiple materials/textures → pack into a single atlas
  • Configurable atlas resolution (512, 1024, 2048, 4096)
  • UV remapping: automatically update mesh UVs to reference the atlas
  • Channel-aware packing (don't mix normal maps with diffuse)
  • Preview atlas layout before applying
  • Support: diffuse, normal, specular, emissive atlases

3. Draco Mesh Compression

  • Export to Draco-compressed glTF (.glb)
  • Configurable compression level (1-10) and quantization bits
  • Size comparison display (original vs compressed)
  • Decompression preview to verify quality

4. Draw Call Analysis

  • Overlay showing draw call count, material count, batch count
  • Color-code objects by material (same color = same draw call potential)
  • Suggestions: "Merge these 5 objects sharing MaterialX to reduce draw calls"
  • One-click merge for objects sharing the same material

5. Vertex Cache Optimization

  • Reorder index buffer for GPU vertex cache efficiency
  • Before/after ACMR (Average Cache Miss Ratio) display
  • Automatic optimization on export (optional toggle)
  • Algorithm: Tom Forsyth's linear-speed vertex cache optimization

6. Memory & VRAM Usage Display

  • Panel showing per-mesh: vertex count, index count, estimated GPU memory
  • Per-texture: resolution, format, estimated VRAM
  • Total scene budget with configurable target (e.g., "mobile: 50MB VRAM")
  • Warning indicators when assets exceed budgets
  • Export size estimation for each format

7. Batch Optimization Pipeline (CLI)

  • qtmesh optimize model.fbx -o optimized.fbx — apply all optimizations
  • qtmesh optimize model.fbx --target-tris 5000 — decimate to target
  • qtmesh atlas scene.glb -o atlased.glb --resolution 2048
  • qtmesh optimize model.fbx --draco -o model.glb
  • JSON output for CI integration

Technical Notes

  • QEM decimation: Ogre's MeshLodGenerator uses a variant; extend or replace with a full QEM implementation that preserves UV/bone weights
  • Atlas packing: Use a simple shelf/skyline bin-packing algorithm; stb_rect_pack is a lightweight option
  • Draco: Link against Google's Draco library (CMake FetchContent or bundled)
  • Vertex cache opt: Implement Forsyth's algorithm (~200 lines) or use meshoptimizer library
  • Memory estimation: vertex_count * stride + index_count * 2 (16-bit) or 4 (32-bit) for mesh; width * height * bpp for textures

Acceptance Criteria

  • Polygon reduction slider with real-time preview preserving UV/material boundaries
  • Texture atlas generation packs multiple textures and remaps UVs
  • Draco-compressed glTF export with configurable quality
  • Draw call analysis overlay with merge suggestions
  • Vertex cache optimization with before/after ACMR display
  • Memory usage panel shows per-asset and total scene budgets
  • CLI subcommands: optimize, atlas work in headless mode
  • All operations integrate with undo system where applicable

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions