Skip to content

feat(export): glTF/GLB exporter with PBR channels (basecolor / ORM / normal) #19

Open

Description

@hummat

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-ready
  • basecolor_linear.exr — unclamped linear (init for UV-space inverse-rendering pipeline)

Tasks

  • Add --export-format {plytex,glb,gltf} flag to scripts/export.sh
  • Python writer using pygltflib or trimesh.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_roughness if 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 (mikktspace Python 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


References

Related

Activity

  1. added
    enhancement
    export
    pbr
    P2: later
    on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2: laterenhancementexportpbr

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions