From a0f4a2a16b55e2a2a5baa8bfcc2e8b266112cd8a Mon Sep 17 00:00:00 2001 From: Yutaka Yoshisaka Date: Tue, 27 Jan 2026 17:15:08 +0900 Subject: [PATCH] Disabled specular workflow --- tests/testAssetStructure.py | 11 +---------- tests/testMaterial.py | 24 +----------------------- tests/util/ConverterTestCase.py | 6 ------ urdf_usd_converter/_impl/material.py | 10 ---------- 4 files changed, 2 insertions(+), 49 deletions(-) diff --git a/tests/testAssetStructure.py b/tests/testAssetStructure.py index 6fa3e97..fe61686 100644 --- a/tests/testAssetStructure.py +++ b/tests/testAssetStructure.py @@ -498,17 +498,8 @@ def test_no_layer_structure_material_texture(self): texture_file_attr = value_attrs[0] self.assertEqual(texture_file_attr.Get().path, "./Textures/opacity.png") + # Specular Workflow is currently disabled. material_prim = stage.GetPrimAtPath(f"/{robot_name}/Materials/specular_workflow_with_texture_mat") self.assertTrue(material_prim.IsValid()) shader = usdex.core.computeEffectivePreviewSurfaceShader(UsdShade.Material(material_prim)) self.assertTrue(shader) - - texture_input: UsdShade.Input = shader.GetInput("specularColor") - connected_source = texture_input.GetConnectedSource() - texture_shader_prim = UsdShade.Shader(connected_source[0].GetPrim()) - - # The values are defined in the material interface, not in the shader - value_attrs = UsdShade.Utils.GetValueProducingAttributes(texture_shader_prim.GetInput("file")) - self.assertEqual(value_attrs[0].GetPrim(), material_prim) - texture_file_attr = value_attrs[0] - self.assertEqual(texture_file_attr.Get().path, "./Textures/specular.png") diff --git a/tests/testMaterial.py b/tests/testMaterial.py index b5300f0..55d24b5 100644 --- a/tests/testMaterial.py +++ b/tests/testMaterial.py @@ -346,16 +346,12 @@ def test_material_mesh_color(self): self.assertEqual(opacity, 1.0) ior = self.get_material_ior(green_material) self.assertAlmostEqual(ior, 1.5, places=6) - specular_workflow = self.get_material_specular_workflow(green_material) - self.assertFalse(specular_workflow) red_material_prim = material_scope_prim.GetChild("red_mat") self.assertTrue(red_material_prim.IsValid()) self.assertTrue(red_material_prim.IsA(UsdShade.Material)) red_material = UsdShade.Material(red_material_prim) self.assertTrue(red_material) - specular_workflow = self.get_material_specular_workflow(red_material) - self.assertFalse(specular_workflow) diffuse_color = self.get_material_diffuse_color(red_material) diffuse_color = usdex.core.linearToSrgb(diffuse_color) @@ -374,14 +370,8 @@ def test_material_mesh_color(self): self.assertTrue(box_specular_workflow_prim.IsA(UsdShade.Material)) box_specular_workflow_material = UsdShade.Material(box_specular_workflow_prim) self.assertTrue(box_specular_workflow_material) - ior = self.get_material_ior(box_specular_workflow_material) self.assertAlmostEqual(ior, 1.45, places=6) - specular_workflow = self.get_material_specular_workflow(box_specular_workflow_material) - self.assertTrue(specular_workflow) - specular_color = self.get_material_specular_color(box_specular_workflow_material) - specular_color = usdex.core.linearToSrgb(specular_color) - self.assertTrue(Gf.IsClose(specular_color, Gf.Vec3f(0.5, 0.2, 0.1), 1e-6)) mesh_prim = two_boxes_prim.GetChild("Cube_Green") self.assertTrue(mesh_prim.IsValid()) @@ -502,15 +492,12 @@ def test_material_mesh_texture(self): wrap_mode = self.get_material_wrap_mode(texture_specular_workflow_material) self.assertEqual(wrap_mode, "repeat") + # Specular Workflow is currently disabled. diffuse_color = self.get_material_diffuse_color(texture_specular_workflow_material) diffuse_color = usdex.core.linearToSrgb(diffuse_color) self.assertTrue(Gf.IsClose(diffuse_color, Gf.Vec3f(0.4, 0.4, 0.4), 1e-6)) ior = self.get_material_ior(texture_specular_workflow_material) self.assertAlmostEqual(ior, 1.45, places=6) - specular_workflow = self.get_material_specular_workflow(texture_specular_workflow_material) - self.assertTrue(specular_workflow) - specular_texture_path = self.get_material_texture_path(texture_specular_workflow_material, "specularColor") - self.assertEqual(specular_texture_path, pathlib.Path("./Textures/specular.png")) self.check_material_binding(box_with_texture_prim, texture_material) self.check_material_binding(box_with_texture_opacity_prim, texture_opacity_material) @@ -698,13 +685,8 @@ def test_dae_materials(self): diffuse_color = self.get_material_diffuse_color(specular_material) diffuse_color = usdex.core.linearToSrgb(diffuse_color) self.assertTrue(Gf.IsClose(diffuse_color, Gf.Vec3f(0.2, 0.2, 0.2), 1e-6)) - specular_color = self.get_material_specular_color(specular_material) - specular_color = usdex.core.linearToSrgb(specular_color) - self.assertTrue(Gf.IsClose(specular_color, Gf.Vec3f(0.8, 0.7, 0.1), 1e-6)) opacity = self.get_material_opacity(specular_material) self.assertAlmostEqual(opacity, 1.0, places=6) - specular_workflow = self.get_material_specular_workflow(specular_material) - self.assertTrue(specular_workflow) material_prim = material_scope_prim.GetChild("specular_texture_mat") self.assertTrue(material_prim.IsValid()) @@ -714,12 +696,8 @@ def test_dae_materials(self): diffuse_color = self.get_material_diffuse_color(specular_texture_material) diffuse_color = usdex.core.linearToSrgb(diffuse_color) self.assertTrue(Gf.IsClose(diffuse_color, Gf.Vec3f(0.2, 0.2, 0.2), 1e-6)) - specular_texture_path = self.get_material_texture_path(specular_texture_material, "specularColor") - self.assertEqual(specular_texture_path, pathlib.Path("./Textures/specular.png")) opacity = self.get_material_opacity(specular_texture_material) self.assertAlmostEqual(opacity, 1.0, places=6) - specular_workflow = self.get_material_specular_workflow(specular_texture_material) - self.assertTrue(specular_workflow) material_prim = material_scope_prim.GetChild("Material_red") self.assertTrue(material_prim.IsValid()) diff --git a/tests/util/ConverterTestCase.py b/tests/util/ConverterTestCase.py index b3d4acb..1637ef7 100644 --- a/tests/util/ConverterTestCase.py +++ b/tests/util/ConverterTestCase.py @@ -44,12 +44,6 @@ def get_material_diffuse_color(self, material: UsdShade.Material) -> Gf.Vec3f | def get_material_emissive_color(self, material: UsdShade.Material) -> Gf.Vec3f | None: return self._get_material_input_value(material, "emissiveColor") - def get_material_specular_color(self, material: UsdShade.Material) -> Gf.Vec3f | None: - return self._get_material_input_value(material, "specularColor") - - def get_material_specular_workflow(self, material: UsdShade.Material) -> bool: - return self._get_material_input_value(material, "useSpecularWorkflow") == 1 - def get_material_opacity(self, material: UsdShade.Material) -> float: return self._get_material_input_value(material, "opacity") diff --git a/urdf_usd_converter/_impl/material.py b/urdf_usd_converter/_impl/material.py index 570c9df..5966a42 100644 --- a/urdf_usd_converter/_impl/material.py +++ b/urdf_usd_converter/_impl/material.py @@ -108,7 +108,6 @@ def _convert_material( The material prim. """ diffuse_color = usdex.core.sRgbToLinear(material_data.diffuse_color) - specular_color = usdex.core.sRgbToLinear(material_data.specular_color) emissive_color = usdex.core.sRgbToLinear(material_data.emissive_color) # Build kwargs for material properties @@ -147,15 +146,6 @@ def _convert_material( if material_data.opacity_texture_path: usdex.core.addOpacityTextureToPreviewMaterial(material_prim, _get_texture_asset_path(material_data.opacity_texture_path, texture_paths, data)) - # If the specular color is not black or the specular texture exists, use the specular workflow. - if specular_color != [0, 0, 0] or material_data.specular_texture_path: - surface_shader.CreateInput("useSpecularWorkflow", Sdf.ValueTypeNames.Int).Set(1) - surface_shader.CreateInput("specularColor", Sdf.ValueTypeNames.Color3f).Set(specular_color) - if material_data.specular_texture_path: - _add_color_texture_to_preview_material( - material_prim, "specularColor", "SpecularTexture", _get_texture_asset_path(material_data.specular_texture_path, texture_paths, data) - ) - # Add the emissive color to the preview material. if emissive_color != [0, 0, 0] or material_data.emissive_texture_path: surface_shader.CreateInput("emissiveColor", Sdf.ValueTypeNames.Color3f).Set(emissive_color)