Skip to content

feat(importer): ufbx FBX importer + meshoptimizer + Bistro pipeline fixes - #668

Merged
JeanPhilippeKernel merged 6 commits into
developfrom
feat/ufbx-importer
Aug 24, 2026
Merged

feat(importer): ufbx FBX importer + meshoptimizer + Bistro pipeline fixes#668
JeanPhilippeKernel merged 6 commits into
developfrom
feat/ufbx-importer

Conversation

@JeanPhilippeKernel

@JeanPhilippeKernel JeanPhilippeKernel commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Summary

Full FBX import pipeline with ufbx, mesh optimization, and all fixes needed to render the Amazon Lumberyard Bistro exterior (8.5M vertices, 272 MB).

ufbx v0.14.3 FBX importer (FbxImporter)

  • Replaces Assimp FBX path — supports FBX 6100–7700 (2010–2023), 2–5× faster
  • Auto Y-up conversion and unit-to-meters via ufbx (target_axes, target_unit_meters)
  • Per-face vertex dedup via (pos, nrm, uv) hash map
  • V-channel flipped (FBX convention), scale applied
  • Progress callbacks at 0.2 / 0.5 / 0.8 / 1.0
  • ZGetScratch(&Arena) / ZReleaseScratch — correct engine scratch arena pattern

meshoptimizer v0.22 (MeshOptimizer.h)

  • 3-pass per-submesh: meshopt_optimizeVertexCache, meshopt_optimizeOverdraw, meshopt_optimizeVertexFetch
  • Temp buffer uses malloc/free — no arena accumulation across submeshes
  • Applied in both FbxImporter::ImportFile and GltfImporter::ImportFile

Pipeline fixes for large scenes

  • ReloadFromDisk mesh deserialization uses s_Instance->Arena (1 GB) instead of 64 MB caller scratch — prevents cold-start OOM crash on 292 MB .zemesh files
  • Arena.Clear() at start of ImportFile guards against dirty state from previous crashed import
  • Skip AssetState::Loaded records in ReloadFromDisk to prevent duplicate ingest

Memory budgets grown

Budget Before After
ImportPipeline 1 GB 3.5 GB
AssetManager 512 MB 1 GB
GLOBAL_VTX_CAPACITY 256 MB (~8M verts) 512 MB (~16M verts)
GLOBAL_IDX_CAPACITY 256 MB 512 MB
MAX_DRAW_COMMANDS 512 8192

Verified

Amazon Lumberyard Bistro exterior FBX: 8.5M vertices, 272 MB, 8000+ draw commands — imports and renders in the editor.

Closes #667

Add FbxImporter backed by ufbx v0.14.3 — a single-file C library that
supports FBX binary and ASCII formats from 2010 to 2023 (versions
6100–7700), 2–5× faster than Assimp on large files.

FbxImporter:
  - ufbx auto-converts to Y-up and meters (target_axes + target_unit_meters)
  - Per-face vertex deduplication via (pos,nrm,uv) hash map
  - UV V-channel flipped (FBX convention)
  - Per-mesh material extraction with PBR color + texture UUIDs
  - ImportOptions respected: scale, normals mode, mat/tex gating, flip UV
  - Progress callbacks at 0.2 / 0.5 / 0.8 / 1.0

AssimpImporter::CanImport now returns true only for "obj" — FBX handled
by FbxImporter which is registered first in Engine::Initialize.

CMakePresets: remove ASSIMP_BUILD_FBX_IMPORTER (no longer needed).
Assimp stays for OBJ only.

Closes #667
meshoptimizer v0.22:
  - 3-pass optimization per submesh (vertex cache, overdraw, vertex fetch)
  - Temp buffers use malloc/free — no arena accumulation across submeshes
  - Integrated in FbxImporter and GltfImporter

FbxImporter arena — use ZGetScratch/ZReleaseScratch:
  - Replace CreateSubArena(440) with ZGetScratch(&Arena) in ImportFile
  - Replace CreateSubArena(64)  with ZGetScratch(&Arena) in Import
  - Arena.Clear() at start of ImportFile guards against previous crash state
  - ZReleaseScratch at end restores cursor

ReloadFromDisk mesh deserialization:
  - Use s_Instance->Arena instead of 64MB caller scratch — prevents
    OOM crash when reloading large .zemesh files on cold start

Memory budgets:
  - ImportPipeline: 1 GB → 3.5 GB (ufbx×2=1GB, gltf×2=128MB, assimp×2=256MB)
  - AssetManager: 512 MB → 1 GB (mesh deserialization scratch)
  - GLOBAL_VTX_CAPACITY: 256 MB → 512 MB (Bistro needs ~272 MB)
  - GLOBAL_IDX_CAPACITY: 256 MB → 512 MB
  - MAX_DRAW_COMMANDS: 512 → 8192 (Bistro has ~8000+ submeshes)

Verified: Amazon Lumberyard Bistro exterior FBX (8.5M verts, 272 MB)
imports and renders in the editor.
@JeanPhilippeKernel JeanPhilippeKernel changed the title feat(importer): replace Assimp FBX path with ufbx feat(importer): ufbx FBX importer + meshoptimizer + Bistro pipeline fixes Aug 24, 2026
@JeanPhilippeKernel JeanPhilippeKernel added Feature request New feature area-rendering area-linux Work on Linux system area-window Work on Window system area-macOS Work on macOS system labels Aug 24, 2026
@JeanPhilippeKernel JeanPhilippeKernel self-assigned this Aug 24, 2026
@JeanPhilippeKernel
JeanPhilippeKernel merged commit 4d2be3e into develop Aug 24, 2026
17 checks passed
@JeanPhilippeKernel
JeanPhilippeKernel deleted the feat/ufbx-importer branch August 24, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-linux Work on Linux system area-macOS Work on macOS system area-rendering area-window Work on Window system Feature request New feature

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat(importer): replace Assimp FBX path with ufbx

1 participant