diffrp.loaders.gltf_loader#
- diffrp.loaders.gltf_loader.ensure_mode(img: Image, mode: str)#
- diffrp.loaders.gltf_loader.force_rgba(color: Tensor)#
- diffrp.loaders.gltf_loader.from_trimesh_scene(scene: Trimesh | Scene, compute_tangents=False, allow_convert=True) Scene#
Convert a trimesh.Trimesh or trimesh.Scene to a DiffRP Scene.
- Supported metadata:
namefor each mesh object (may beNone);camera(type PerspectiveCamera) if exists.
- Parameters:
scene (trimesh.Trimesh | trimesh.Scene) – A trimesh loaded scene or mesh.
compute_tangents (bool) – If set, tangents will be computed according to the MikkTSpace algorithm. Execution of the algorithm requires
gccin the path. Defaults toFalse. Note that computing tangents are not thread-safe.allow_convert (bool) – DiffRP always try to interpret the materials as PBR materials. If set, allow a default conversion from simple materials (e.g., from obj and ply formats) to PBR materials.
- Returns:
The loaded scene.
- diffrp.loaders.gltf_loader.load_gltf_scene(path: str | BinaryIO, compute_tangents=False) Scene#
Load a glb file as a DiffRP Scene.
- Supported metadata:
namefor each mesh object (may beNone);camera(type PerspectiveCamera) if exists.
- Parameters:
path (str | BinaryIO) – path to a
.glb/.gltffile, or opened.glbfile in binary mode.compute_tangents (bool) – If set, tangents will be computed according to the MikkTSpace algorithm. Execution of the algorithm requires
gccin the path. Defaults toFalse. Note that computing tangents are not thread-safe.
- Returns:
The loaded scene.
- diffrp.loaders.gltf_loader.to_gltf_material(verts: Tensor, visual, material_cache: dict = {}, allow_convert=False)#