fix: material override pipeline — pass --material-override CLI arg to Blender scripts

The initial implementation only overrode the material_map dict in the task,
but the Blender USD primvar path bypassed it. Now:
- Added --material-override named CLI arg parsed in _blender_args.py
- Both Mode A (factory) and Mode B (template) in _blender_scene_setup.py
  override usd_material_lookup and material_map when set
- Passed through full chain: task → step_processor → render_blender → CLI → Blender
- Tested: 175-part bearing rendered with single Steel-Bare material (1/1 materials)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-14 14:19:21 +01:00
parent 7c606953ec
commit c054236d22
5 changed files with 42 additions and 2 deletions
@@ -65,6 +65,14 @@ def _setup_mode_b(args, lap_fn: Callable[[str], None]) -> None:
apply_sharp_edges_from_occ(parts, _occ_pairs)
lap_fn("smooth_shading")
# Apply material override: replace all material lookups with a single material
if getattr(args, 'material_override', None):
print(f"[blender_render] material_override active: all parts → {args.material_override}", flush=True)
if usd_material_lookup:
usd_material_lookup = {k: args.material_override for k in usd_material_lookup}
if args.material_map:
args.material_map = {k: args.material_override for k in args.material_map}
if args.material_library_path and usd_material_lookup:
# USD primvar path: direct material assignment (no name-matching needed)
apply_material_library_direct(
@@ -136,6 +144,14 @@ def _setup_mode_a(args) -> None:
assign_failed_material(part)
print(f"[blender_render] smooth+fallback-material: {len(parts)} parts ({_time.time()-_t:.2f}s)", flush=True)
# Apply material override: replace all material lookups with a single material
if getattr(args, 'material_override', None):
print(f"[blender_render] material_override active (Mode A): all parts → {args.material_override}", flush=True)
if usd_material_lookup:
usd_material_lookup = {k: args.material_override for k in usd_material_lookup}
if args.material_map:
args.material_map = {k: args.material_override for k in args.material_map}
if args.material_library_path and usd_material_lookup:
# USD primvar path: direct material assignment
apply_material_library_direct(