Add Blender reader writer adapters#44
Conversation
📝 WalkthroughWalkthroughThe PR introduces a Blender material adapter framework to standardize conversion workflows and adds USD identifier safety for collision-free prim naming. New ChangesBlender Material Adapter Framework
USD Prim Naming Safety
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_usd_json_conversion.py (1)
245-279: ⚡ Quick winConsider covering the collision-suffix path.
This test exercises name sanitization, but the new
_unique_child_path()collision handling (the_2,_3suffixing) is the other half of this PR and currently has no coverage. Two sibling nodes whose names sanitize to the same identifier (e.g."My Node"and"My/Node") would hit that branch.A small case with two such shaders asserting both distinct prims exist would lock in the dedup behavior.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_usd_json_conversion.py` around lines 245 - 279, Add a second NodeInfo whose name sanitizes to the same identifier so the _unique_child_path() collision branch is exercised: in test_usd_recreator_sanitizes_material_and_shader_prim_names create a second NodeInfo (e.g., node_name="Principled/BSDF", node_path="/mat/My Material/Principled/BSDF") alongside the existing one, include both in nodeinfo_list passed to USDMaterialRecreator (keep the existing OutputConnection for the output shader), run .run(), and then assert both shader prims exist under the material (e.g., UsdShade.Shader.Get(stage, Sdf.Path("/materials/My_Material/Principled_BSDF")) and UsdShade.Shader.Get(stage, Sdf.Path("/materials/My_Material/Principled_BSDF_2"))), to lock in the collision-suffix behavior from _unique_child_path().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_usd_json_conversion.py`:
- Around line 245-279: Add a second NodeInfo whose name sanitizes to the same
identifier so the _unique_child_path() collision branch is exercised: in
test_usd_recreator_sanitizes_material_and_shader_prim_names create a second
NodeInfo (e.g., node_name="Principled/BSDF", node_path="/mat/My
Material/Principled/BSDF") alongside the existing one, include both in
nodeinfo_list passed to USDMaterialRecreator (keep the existing OutputConnection
for the output shader), run .run(), and then assert both shader prims exist
under the material (e.g., UsdShade.Shader.Get(stage,
Sdf.Path("/materials/My_Material/Principled_BSDF")) and
UsdShade.Shader.Get(stage,
Sdf.Path("/materials/My_Material/Principled_BSDF_2"))), to lock in the
collision-suffix behavior from _unique_child_path().
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9206cf64-cad3-4f2f-9570-1ab3a273463e
📒 Files selected for processing (8)
src/materials_processor/dcc/blender/adapters.pysrc/materials_processor/dcc/blender/addon.pysrc/materials_processor/dcc/blender/runtime.pysrc/materials_processor/mappings.pysrc/materials_processor/usd/graph_builder.pytests/test_blender_support.pytests/test_public_imports.pytests/test_usd_json_conversion.py
Summary
BlenderMaterialReaderandBlenderMaterialWriterimplementations for the core adapter contractsConversionServiceReal asset check
Tested against copied local asset
Tie Defender.blend, materialT_TieDefender_01_CS_Mat:mtlx,arnold, andopenpbrtargetsShaderNodeUVMap,ShaderNodeSeparateColor, image alpha/vector mapping, and texture path packagingValidation
uv --native-tls run pytest tests/test_blender_support.py tests/test_usd_json_conversion.pyuv --native-tls run pytest tests/test_blender_support.py tests/test_blender_runtime.py tests/test_usd_json_conversion.py tests/test_public_imports.py tests/test_core_conversion.pyuv --native-tls run pytest -m blenderuv --native-tls run python scripts/validate_blender_runtime.py --smoke-material --timeout 120uv --native-tls run ruff check src tests scriptsuv --native-tls run pytestuv --native-tls buildSummary by CodeRabbit
Release Notes
New Features
Bug Fixes
Tests