From 6c80e24b38665876d7ce0df4dc5b385e74f43d62 Mon Sep 17 00:00:00 2001 From: Zhaoxi Chen <35674081+FrozenBurning@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:12:26 +0800 Subject: [PATCH] Update visual.gloss.specular_to_pbr to align gltf 2.0 material specs --- tests/test_gltf.py | 3 ++- trimesh/visual/gloss.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_gltf.py b/tests/test_gltf.py index 8794c48bd..10207f895 100644 --- a/tests/test_gltf.py +++ b/tests/test_gltf.py @@ -307,7 +307,8 @@ def test_specular_glossiness(self): ) assert metallic_roughness.shape[0] == 84 and metallic_roughness.shape[1] == 71 - metallic = metallic_roughness[:, :, 0] + # https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#metallic-roughness-material + metallic = metallic_roughness[:, :, 2] roughness = metallic_roughness[:, :, 1] assert g.np.allclose(metallic[0, 0], 0.231, atol=0.004) diff --git a/trimesh/visual/gloss.py b/trimesh/visual/gloss.py index 8c4065685..ffad0e125 100644 --- a/trimesh/visual/gloss.py +++ b/trimesh/visual/gloss.py @@ -360,7 +360,7 @@ def convert_texture_lin2srgb(texture): # we need to use RGB textures, because 2 channel textures can cause problems result["metallicRoughnessTexture"] = toPIL( np.concatenate( - [metallic, 1.0 - glossiness, np.zeros_like(metallic)], axis=-1 + [np.zeros_like(metallic), 1.0 - glossiness, metallic], axis=-1 ), mode="RGB", )