Skip to content

Commit bf158b9

Browse files
authored
Merge pull request #65 from ft-lab/dev/disable_specular_workflow
Disabled specular workflow
1 parent 7a1a1f2 commit bf158b9

File tree

4 files changed

+2
-49
lines changed

4 files changed

+2
-49
lines changed

tests/testAssetStructure.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -520,17 +520,8 @@ def test_no_layer_structure_material_texture(self):
520520
texture_file_attr = value_attrs[0]
521521
self.assertEqual(texture_file_attr.Get().path, "./Textures/opacity.png")
522522

523+
# Specular Workflow is currently disabled.
523524
material_prim = stage.GetPrimAtPath(f"/{robot_name}/Materials/specular_workflow_with_texture_mat")
524525
self.assertTrue(material_prim.IsValid())
525526
shader = usdex.core.computeEffectivePreviewSurfaceShader(UsdShade.Material(material_prim))
526527
self.assertTrue(shader)
527-
528-
texture_input: UsdShade.Input = shader.GetInput("specularColor")
529-
connected_source = texture_input.GetConnectedSource()
530-
texture_shader_prim = UsdShade.Shader(connected_source[0].GetPrim())
531-
532-
# The values are defined in the material interface, not in the shader
533-
value_attrs = UsdShade.Utils.GetValueProducingAttributes(texture_shader_prim.GetInput("file"))
534-
self.assertEqual(value_attrs[0].GetPrim(), material_prim)
535-
texture_file_attr = value_attrs[0]
536-
self.assertEqual(texture_file_attr.Get().path, "./Textures/specular.png")

tests/testMaterial.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,12 @@ def test_material_mesh_color(self):
346346
self.assertEqual(opacity, 1.0)
347347
ior = self.get_material_ior(green_material)
348348
self.assertAlmostEqual(ior, 1.5, places=6)
349-
specular_workflow = self.get_material_specular_workflow(green_material)
350-
self.assertFalse(specular_workflow)
351349

352350
red_material_prim = material_scope_prim.GetChild("red_mat")
353351
self.assertTrue(red_material_prim.IsValid())
354352
self.assertTrue(red_material_prim.IsA(UsdShade.Material))
355353
red_material = UsdShade.Material(red_material_prim)
356354
self.assertTrue(red_material)
357-
specular_workflow = self.get_material_specular_workflow(red_material)
358-
self.assertFalse(specular_workflow)
359355

360356
diffuse_color = self.get_material_diffuse_color(red_material)
361357
diffuse_color = usdex.core.linearToSrgb(diffuse_color)
@@ -374,14 +370,8 @@ def test_material_mesh_color(self):
374370
self.assertTrue(box_specular_workflow_prim.IsA(UsdShade.Material))
375371
box_specular_workflow_material = UsdShade.Material(box_specular_workflow_prim)
376372
self.assertTrue(box_specular_workflow_material)
377-
378373
ior = self.get_material_ior(box_specular_workflow_material)
379374
self.assertAlmostEqual(ior, 1.45, places=6)
380-
specular_workflow = self.get_material_specular_workflow(box_specular_workflow_material)
381-
self.assertTrue(specular_workflow)
382-
specular_color = self.get_material_specular_color(box_specular_workflow_material)
383-
specular_color = usdex.core.linearToSrgb(specular_color)
384-
self.assertTrue(Gf.IsClose(specular_color, Gf.Vec3f(0.5, 0.2, 0.1), 1e-6))
385375

386376
mesh_prim = two_boxes_prim.GetChild("Cube_Green")
387377
self.assertTrue(mesh_prim.IsValid())
@@ -502,15 +492,12 @@ def test_material_mesh_texture(self):
502492
wrap_mode = self.get_material_wrap_mode(texture_specular_workflow_material)
503493
self.assertEqual(wrap_mode, "repeat")
504494

495+
# Specular Workflow is currently disabled.
505496
diffuse_color = self.get_material_diffuse_color(texture_specular_workflow_material)
506497
diffuse_color = usdex.core.linearToSrgb(diffuse_color)
507498
self.assertTrue(Gf.IsClose(diffuse_color, Gf.Vec3f(0.4, 0.4, 0.4), 1e-6))
508499
ior = self.get_material_ior(texture_specular_workflow_material)
509500
self.assertAlmostEqual(ior, 1.45, places=6)
510-
specular_workflow = self.get_material_specular_workflow(texture_specular_workflow_material)
511-
self.assertTrue(specular_workflow)
512-
specular_texture_path = self.get_material_texture_path(texture_specular_workflow_material, "specularColor")
513-
self.assertEqual(specular_texture_path, pathlib.Path("./Textures/specular.png"))
514501

515502
self.check_material_binding(box_with_texture_prim, texture_material)
516503
self.check_material_binding(box_with_texture_opacity_prim, texture_opacity_material)
@@ -698,13 +685,8 @@ def test_dae_materials(self):
698685
diffuse_color = self.get_material_diffuse_color(specular_material)
699686
diffuse_color = usdex.core.linearToSrgb(diffuse_color)
700687
self.assertTrue(Gf.IsClose(diffuse_color, Gf.Vec3f(0.2, 0.2, 0.2), 1e-6))
701-
specular_color = self.get_material_specular_color(specular_material)
702-
specular_color = usdex.core.linearToSrgb(specular_color)
703-
self.assertTrue(Gf.IsClose(specular_color, Gf.Vec3f(0.8, 0.7, 0.1), 1e-6))
704688
opacity = self.get_material_opacity(specular_material)
705689
self.assertAlmostEqual(opacity, 1.0, places=6)
706-
specular_workflow = self.get_material_specular_workflow(specular_material)
707-
self.assertTrue(specular_workflow)
708690

709691
material_prim = material_scope_prim.GetChild("specular_texture_mat")
710692
self.assertTrue(material_prim.IsValid())
@@ -714,12 +696,8 @@ def test_dae_materials(self):
714696
diffuse_color = self.get_material_diffuse_color(specular_texture_material)
715697
diffuse_color = usdex.core.linearToSrgb(diffuse_color)
716698
self.assertTrue(Gf.IsClose(diffuse_color, Gf.Vec3f(0.2, 0.2, 0.2), 1e-6))
717-
specular_texture_path = self.get_material_texture_path(specular_texture_material, "specularColor")
718-
self.assertEqual(specular_texture_path, pathlib.Path("./Textures/specular.png"))
719699
opacity = self.get_material_opacity(specular_texture_material)
720700
self.assertAlmostEqual(opacity, 1.0, places=6)
721-
specular_workflow = self.get_material_specular_workflow(specular_texture_material)
722-
self.assertTrue(specular_workflow)
723701

724702
material_prim = material_scope_prim.GetChild("Material_red")
725703
self.assertTrue(material_prim.IsValid())

tests/util/ConverterTestCase.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ def get_material_diffuse_color(self, material: UsdShade.Material) -> Gf.Vec3f |
4444
def get_material_emissive_color(self, material: UsdShade.Material) -> Gf.Vec3f | None:
4545
return self._get_material_input_value(material, "emissiveColor")
4646

47-
def get_material_specular_color(self, material: UsdShade.Material) -> Gf.Vec3f | None:
48-
return self._get_material_input_value(material, "specularColor")
49-
50-
def get_material_specular_workflow(self, material: UsdShade.Material) -> bool:
51-
return self._get_material_input_value(material, "useSpecularWorkflow") == 1
52-
5347
def get_material_opacity(self, material: UsdShade.Material) -> float:
5448
return self._get_material_input_value(material, "opacity")
5549

urdf_usd_converter/_impl/material.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def _convert_material(
111111
The material prim.
112112
"""
113113
diffuse_color = usdex.core.sRgbToLinear(material_data.diffuse_color)
114-
specular_color = usdex.core.sRgbToLinear(material_data.specular_color)
115114
emissive_color = usdex.core.sRgbToLinear(material_data.emissive_color)
116115

117116
# Build kwargs for material properties
@@ -150,15 +149,6 @@ def _convert_material(
150149
if material_data.opacity_texture_path:
151150
usdex.core.addOpacityTextureToPreviewMaterial(material_prim, _get_texture_asset_path(material_data.opacity_texture_path, texture_paths, data))
152151

153-
# If the specular color is not black or the specular texture exists, use the specular workflow.
154-
if specular_color != [0, 0, 0] or material_data.specular_texture_path:
155-
surface_shader.CreateInput("useSpecularWorkflow", Sdf.ValueTypeNames.Int).Set(1)
156-
surface_shader.CreateInput("specularColor", Sdf.ValueTypeNames.Color3f).Set(specular_color)
157-
if material_data.specular_texture_path:
158-
_add_color_texture_to_preview_material(
159-
material_prim, "specularColor", "SpecularTexture", _get_texture_asset_path(material_data.specular_texture_path, texture_paths, data)
160-
)
161-
162152
# Add the emissive color to the preview material.
163153
if emissive_color != [0, 0, 0] or material_data.emissive_texture_path:
164154
surface_shader.CreateInput("emissiveColor", Sdf.ValueTypeNames.Color3f).Set(emissive_color)

0 commit comments

Comments
 (0)