Repository navigation
Description
Summary
Add a glTF 2.0 / GLB exporter that bundles the existing diffuse texture plus structured PBR channels (basecolor, ORM-packed metallic-roughness-AO, normal map, tangents) into a single self-contained file ready for Blender, Three.js, game engines, and web viewers.
Split from #11 Stage 2 — that issue tracks the full PBR programme; this one is the standalone container/exporter with no SDFStudio training dependency. Any roughness/metallic channel the model produces (e.g. enable_pred_roughness from Ref-NeRF) can be wired in as it lands; sensible defaults work without it.
Motivation
Current scripts/export.sh produces a textured .ply plus loose texture PNGs. There is no standard PBR container. glTF 2.0 metal-rough is the de-facto interchange format with native support in Blender 4+, Three.js, Babylon.js, Unity, Unreal.
Mechanical plumbing — no new training-time signal required.
Output format (glTF 2.0 metal-rough)
| Texture | Channel layout | Encoding |
|---|---|---|
baseColorTexture |
RGB | sRGB |
metallicRoughnessTexture |
R=AO, G=Roughness, B=Metallic | Linear |
normalTexture |
RGB | Linear, OpenGL (+Y) by default; DirectX flag |
Tangents: MikkTSpace.
Companion side-car exports (downstream refinement):
basecolor_srgb.png— display-readybasecolor_linear.exr— unclamped linear (init for UV-space inverse-rendering pipeline)
Tasks
- Add
--export-format {plytex,glb,gltf}flag toscripts/export.sh - Python writer using
pygltflibortrimesh.exchange.gltf - Wire basecolor from existing diffuse texture path (write both sRGB PNG and linear EXR)
- ORM packing: AO=1.0 stub (until AO bake lands), G=roughness from
enable_pred_roughnessif present else constant 0.5, B=metallic constant 0 - Reuse existing
--normal-map-convention {opengl,directx}for green-channel flip - Compute MikkTSpace tangents at export (
mikktspacePython binding or trimesh + xatlas) -
--metallic <float>override (constant scalar) for metal objects - Validation: import GLB into Blender headless, render under reference HDRI; commit reference render
Validation criteria
- GLB opens in Blender 4+ without errors and in
gltf-viewer(Khronos sample) - Material renders plausibly under at least two HDRIs (indoor + outdoor)
- Normal map deflects highlights as expected from grazing angles
- Tangent space matches MikkTSpace reference (unit test)
Non-goals
- BRDF training (covered by feat(export): PBR-ish texture extraction and BRDF-aware training #11 Stage 1 / sdfstudio#10)
- UV-space inverse rendering (separate issue)
- Material decomposition from Gaussian splats (see feat(pipeline): Hybrid SDF→Gaussian pipeline for fast rendering of SDF geometry #14)
References
- glTF 2.0 spec — materials
- Khronos glTF Sample Renderer
- Karis, Real Shading in Unreal Engine 4, SIGGRAPH 2013 — metal-rough model
- Mikkelsen, Simulation of Wrinkled Surfaces Revisited, 2008 — MikkTSpace tangent standard
Related
- feat(export): PBR-ish texture extraction and BRDF-aware training #11 — parent PBR tracking issue (this is Stage 2 split)
- feat(export): Add optional mesh retopology step #6 — retopology (clean topology improves UV layout)
Activity