USD: Implement new DomeLight_1 Schema for Import

Handle the `DomeLight_1` schema for import and translate to a World
material like what was already done for the original `DomeLight` schema.

The primary difference is that the new schema provides a `poleAxis`
attribute that authoring applications can use to remove ambiguity for
the orientation of the HDRI texture. Some care was made to match
`usdview` with a set of hand-crafted files. However, after matching,
some real scenes ended up displaying differently. These were corrected
but this could mean there's still issues that will need investigation
and fixing in the future.

Co-authored-by: Nig3l <nig3lpro@gmail.com>
Co-authored-by: Jesse Yurkovich <jesse.y@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/137761
This commit is contained in:
Maxime-Cots
2025-05-31 01:15:19 +02:00
committed by Jesse Yurkovich
parent 0f37863fba
commit efd871e9ef
12 changed files with 629 additions and 86 deletions

View File

@@ -1204,6 +1204,29 @@ class USDImportTest(AbstractUSDTest):
self.assertEqual(blender_light.shape, 'DISK') # We read as disk to mirror what USD supports
self.assertAlmostEqual(blender_light.size, 4, 3)
def test_import_dome_lights(self):
"""Test importing dome lights and verify their rotations."""
# Test files and their expected EnvironmentTexture Mapping rotation values
tests = [
("usd_dome_light_1_stageZ_poleY.usda", [0.0, 0.0, 0.0]),
("usd_dome_light_1_stageZ_poleZ.usda", [0.0, -1.5708, 0.0]),
("usd_dome_light_1_stageY_poleDefault.usda", [-1.5708, 0.0, 0.0])
]
for test_name, expected_rot in tests:
bpy.ops.wm.open_mainfile(filepath=str(self.testdir / "empty.blend"))
infile = str(self.testdir / test_name)
res = bpy.ops.wm.usd_import(filepath=infile)
self.assertEqual({'FINISHED'}, res, f"Unable to import USD file {infile}")
# Validate that the Mapping node on the World Material is set to the correct rotation
world = bpy.data.worlds["World"]
node = world.node_tree.nodes["Mapping"]
self.assertEqual(
self.round_vector(node.inputs[2].default_value), expected_rot, f"Incorrect rotation for {test_name}")
def check_attribute(self, blender_data, attribute_name, domain, data_type, elements_len):
attr = blender_data.attributes[attribute_name]
self.assertEqual(attr.domain, domain)