Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions tests/testAssetStructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
24 changes: 1 addition & 23 deletions tests/testMaterial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand All @@ -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())
Expand Down
6 changes: 0 additions & 6 deletions tests/util/ConverterTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
10 changes: 0 additions & 10 deletions urdf_usd_converter/_impl/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading