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:
@@ -73,6 +73,11 @@ def parse_args() -> SimpleNamespace:
|
||||
_sw_idx = sys.argv.index("--sensor-width")
|
||||
sensor_width_mm_override = float(sys.argv[_sw_idx + 1]) if _sw_idx + 1 < len(sys.argv) else None
|
||||
|
||||
material_override = None
|
||||
if "--material-override" in sys.argv:
|
||||
_mo_idx = sys.argv.index("--material-override")
|
||||
material_override = sys.argv[_mo_idx + 1] if _mo_idx + 1 < len(sys.argv) else None
|
||||
|
||||
if template_path and not os.path.isfile(template_path):
|
||||
print(f"[blender_render] ERROR: template not found: {template_path}")
|
||||
sys.exit(1)
|
||||
@@ -108,4 +113,5 @@ def parse_args() -> SimpleNamespace:
|
||||
use_template=bool(template_path),
|
||||
focal_length_mm=focal_length_mm,
|
||||
sensor_width_mm=sensor_width_mm_override,
|
||||
material_override=material_override,
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user