Blender product render
Turn a CAD/EDA export into a studio product image or film that looks photographed, using
tested bpy modules in scripts/ driven through the Blender MCP (or any Python access to Blender).
The default look is Alex's reference style (see references/visual-language.md): bright seamless
studio, monochrome/tone-on-tone backdrops, large soft sources, long lenses, macro detail crops,
floating and exploded compositions.
Execution model — read first
Where the scripts run. All modules are plain bpy and import each other, so put the
scripts/ folder on sys.path inside Blender and call functions:
import sys, importlib; sys.path.insert(0, r"<scripts dir on the Blender machine>")
import bpr_inspect; importlib.reload(bpr_inspect); result = bpr_inspect.run()
- Alex's workstation (redribbon): the full skill folder is installed at
C:\Users\alex_\OneDrive\Renders\BLENDER\Referencias para Skill\blender-product-render\— put itsscriptssubfolder onsys.pathfrom execute_blender_code; read the reference docs there (stage them in Cowork, or Read them directly in Claude Code). If this copy of SKILL.md is the only file you have, that folder is where everything else lives. - The canonical, always-current copy is the GitHub repo
https://github.com/alexbatista/blender-product-render (the folder above is its clone). If the
scripts bundled with this skill lack a module this file mentions (e.g.
bpr_mesh,bpr_normals,bpr_reference,bpr_zfight,bpr_parts,bpr_scene), use the workstation folder or the repo. - Skill folder on the same machine as Blender (Claude Code locally): use the skill's own path.
- Skill in a cloud session, Blender on the user's computer (Cowork): zip
scripts/andassets/, send it with SendUserFile, write it to a folder on the device with device_commit_files, extract it there withzipfilefrom execute_blender_code, then use that folder (the material library installs from itsassets/). Do this once per session and again after you edit a script. Never extract over a folder someone else may be editing: compare first, write only the files you changed. - No Blender reachable (or for evals):
pip install bpy==<user's version>in a venv and run the same modules headless (CPU only, keep previews small).
Protect the user's session. Inspect first (read-only). Before the first destructive step
(normalise/classify/join) check bpy.data.is_dirty/filepath: if the work is unsaved, ask to save or
work on a copy. For long jobs (renders, joins of thousands of objects) use the background pattern:
bpr_render.background() saves a copy and renders with bpy.app.binary_path --background in a
separate process, so the MCP call returns at once and the UI never freezes. Poll with
bpr_render.job_status(). The same subprocess trick works for any test you want to run on a copy.
Previews are not finals. bpr_camera.create() keeps the current resolution %, so set a low
percentage for look-dev and raise it only for finals. Micro textures (VDI grain, FDM layers)
only resolve at full resolution in macro shots — judge them there, not in small previews.
MCP limits. One call ≈ 45 s max. Return small JSON (result = {...}); every bpr function
already returns a compact report. Read images by rendering to a file in a connected folder,
staging it, and viewing it — do look at your previews, numbers don't show glare or z-fighting.
Pipeline
Work stage by stage; after each visual stage render a small preview and check it against the checklist at the end. Ask the user only what the scene can't tell you (marked ASK).
| # | Stage | Call | Details |
|---|---|---|---|
| 0 | Inspect | bpr_inspect.run() + bpr_library.status() | source exporter guess, units, thin axis, layer heights, materials; material library installed and up to date (ensure_installed() if not) |
| 1 | Import (if needed) | bpr_import.import_file(path, split="loose") | OBJ/FBX/GLB/STL/STEP/pcb3d; splits merged CAD bodies |
| 2 | Normalise | bpr_normalize.run(kind="pcb"|"product", front="-Y") | metres, Z-up, grounded, origins centred, PRODUCT_ROOT |
| 2b | Mesh check | bpr_mesh.analyze(target) | read-only: slivers, unwelded seams, degenerate/loose geometry, non-manifold, ngons + a per-object smoothing plan; tell the user what was found; references/mesh.md |
| 2c | Mesh repair | bpr_mesh.repair(target) | weld 1 µm seams, remove degenerate faces and loose bits |
| 2d | Fix normals | bpr_normals.fix_normals(target) (dry run: report_normals()) | after repair; PCBs: after bpr_pcb.classify(). Ray-parity orientation on a welded copy (works on unwelded Altium/STEP bodies), plates by side tag; built-in audit (audit_normals(), 6-direction ray grid) re-runs bad objects — report audit.share (expect < 0.5 %) |
| 2e | Surface smoothing | bpr_mesh.smooth(target, plan=…) → fix_shading(r["audit"]["failing"]) → shading_diagnostic(path) | modifier stack per object (all BPR_*); CAD-triangulated meshes are dissolved (0.5°) before any Bevel and every Bevel is extent-guarded; then measure, don't assume: shading_audit finds flat faces bent by interpolated normals (> 8°) and exploding modifiers, fix_shading escalates only the failing objects (Weighted Normal → sharp borders → dissolve → Bevel; never Remesh); look at the MatCap diagnostic of anything still failing |
| 3 | Identify front | bpr_camera.orientation_sheet(path) → look → bpr_camera.set_front("+Y") | ASK if ambiguous |
| 4a | PCB | bpr_pcb.classify() → bpr_mesh.repair() → bpr_normals.fix_normals() → 4a′ → bpr_mesh.smooth() → assign_materials() → fix_layer_stack() → add_solder() → organize() → 4c → 4d | add_solder() makes smooth mounds with a Subdivision modifier (look at one joint in a macro preview); references/pcb.md |
| 4a′ | Merged parts | bpr_parts.find_merged() → preview(obj, path) per candidate → split_metal(obj, hint=…, finish=…) / split_all(exclude=[…]) | connectors exported as one mesh/one colour (pins, SMD feet, hold-down tabs, shells fused into the housing): split by shape into <name>_METAL (contacts, finish) and <name>_TABS (stamped sheet: hold-down tabs, side brackets, tin); run after repair + normals; the halves are re-audited for normals after the split; look at the red/grey previews from both sides (preview(..., view=…): pins usually exit on one side), use the user's context ("H2 é pin header", "contatos estanhados") for hint/finish, ASK when a part is ambiguous; references/pcb.md |
| 4b | Enclosure | bpr_import.name_parts() → 4b′ → separate_coplanar() → bpr_materials.assign_from_source_names(objs, process=…) → 4c → 4d | references/materials.md; ASK moulded vs printed, colours/finishes; show the part-name table and rename what the heuristics got wrong |
| 4b′ | Inlays | bpr_inlay.find_inlays() → fix_inlays() → inlay_report() | glyph bodies (logo, text) seated in a host pocket — multi-colour prints, INLAY_* parts: after repair/normals, before any coplanar fix; seats every glyph front 10 µm in front of the host face, grows it over the pocket's chords, rebuilds its walls, strips its bevel and keeps the host's bevel off the pocket rims; tagged glyphs are skipped by separate_coplanar/bpr_zfight; report inlay_report()["ok"] and look at a macro render; references/pcb.md (Inlays) |
| 4c | Coplanar validation | loop r = bpr_zfight.resolve() until r["clean"] or not r["more"], then bpr_zfight.scan() | mandatory after any layer/coplanar fix: exact scan for visible overlaps that remain (silk corners, shared outline edges, pad vs pour, sub-bodies) + automatic stagger/shrink + targeted pass; report the final scan; survivors → check_camera(at_mm) + macro preview + manual fix; references/pcb.md |
| 4d | Shade Smooth pass | bpr_mesh.ensure_smooth() | mandatory after 4c and again after any later geometry edit (split_metal, re-add_solder, imported parts): every mesh body gets smooth shading with sharp edges by angle (40°), Subdivision cages fully smooth, CAD parts a BPR_WeightedNormal, then the same audit + fix loop as 2e (report smoothed and shading.failing_after); skips STUDIO_*/CAM_* and objects tagged bpr_keep_flat; references/mesh.md |
| 5 | Camera | bpr_camera.create("hero_34", aspect="4:5", projection="perspective") | main scene's shot; perspective is the default (it is what real cameras do); ASK/offer projection="orthographic" for technical, spec-sheet or exploded-diagram output ("iso" shot = true isometric); references/camera.md |
| 6 | Studio | bpr_studio.build("soft_highkey") | after the camera (lights are placed camera-relative; size-aware glare guard); every rim gets an ortho and a perspective variant switched by drivers on scene.camera.data.type (the perspective one skips the solder-mask plates; refine_persp_rim gives parts that still clip their own orbited rim); "make it perspective/ortho" = change cam.data.type only; references/lighting.md |
| 6b | More shots | bpr_scene.new_shot(name, source=…) | every additional view — preset, reference image, the user's current viewport, an existing camera, a screenshot — becomes its own scene SHOT_<name> with the full standard setup (shared product, own camera/rig/backdrop/world, preview render settings); never re-aim an existing shot; see Shot scenes below |
| 7 | Look-dev loop | bpr_render.exposure_check(path, scene=sc) + bpr_studio.veil_check(r["view"], scene=sc) | per scene (any scene, not just the window one): bands are read from the False Color image Blender wrote, per region (product silhouette from a mask render, its left/centre/right thirds, background); red/white on the product = glare, black/blue = crushed; on glossy PCBs in perspective also compare veil_check before/after a lighting change (the veil stays lime/yellow); tweak with scale_lights(f, role), exposure, materials; references/lighting.md |
| 8 | Animation | bpr_anim.* | references/animation.md |
| 9 | Final | ASK first → bpr_render.render_shots(dir, confirmed=True) / background(out, confirmed=True) | the final render never starts on its own: when the setup is done, summarise the scenes and ask whether to render now (all shots / some / not now). Without a yes, save the .blend and stop; background()/render_shots() refuse to run without confirmed=True; references/render.md |
Order inside 4a matters: materials are assigned per object before joining (joins keep per-face
materials) and solder is built from individual pads. Re-running a stage on an already processed
scene is not supported for normalize/organize — re-import instead.
Material library (PCB Materials) — primary source for shading
The skill ships a Blender asset library (assets/PCB Materials/, 158 materials: masks,
finishes, silk, substrates, component bodies/metals, enclosure plastics, FDM/SLA, clear and
frosted, elastomers, metals, inks). It is the first source of every material, so all
renders share one look; a material is built from scratch only when no library material is
adequate.
- Install / first run:
bpr_library.ensure_installed()copies it to<Documents>/Blender/Asset Libraries/PCB Materials/and registers it in Preferences > File Paths > Asset Libraries (Preferences saved). It also runs by itself the first time a material is requested in a session, and updates an older installed copy (backup inAsset Library Backups/, outside the library so the Asset Browser never lists a material twice). Runbpr_library.status()in stage 0 and tell the user if it was installed or updated. - PCB and components:
bpr_pcb.*_material()andbpr_materials.component_material()fetch the library material with the same key (pcb_mask:green:glossy,cmp:metal_tin, ...). - Enclosures and colour-dependent parts:
assign_from_source_names/material_for_sourcedecide the kind (injection + VDI, FDM, SLA, translucent, clear, rubber, metal + finish) and take the closest library material of that kind whose colour is within ΔE 6 (CIE76; whites and blacks compared on hue first) and whose VDI is within ±6; otherwise they build one. The returned table sayslibrary <key> (ΔE …)orbuiltper material — show it to the user. - FDM layers along an axis other than Z, unusual colours and custom finishes are built.
- Pick by hand:
bpr_library.get("enc:abs_white_vdi30"), browsebpr_library.list_keys("enc:"). - No duplicates:
get()reuses an existing copy (tagged, same name, project original, or linked) instead of appending again; identical library materials are one material with alias keys. Local copies never update themselves: after a library update runbpr_library.consolidate(refresh=True, keys=[changed keys])on the scene — it also merges repeated copies and repeated links to the library file. - Keys, catalogues, adequacy rules, rebuilding and re-bundling:
references/material-library.md.
Shot scenes (every new view = a new scene)
Whenever the user asks for another view — "faz uma vista isométrica", a reference image, a
screenshot of their viewport, "usa a posição atual da câmera" — create it with
bpr_scene.new_shot(name, source=...); do not move the camera of an existing scene:
| Input | Call |
|---|---|
| a preset angle | new_shot("iso", shot="iso", projection="orthographic") |
| a reference image | new_shot("ref1", source="reference", reference=path) (camera + studio from the picture) |
| "this view" / current viewport (Blender UI open) | new_shot("view1", source="view") (position, rotation, lens/ortho scale) |
| an existing camera | new_shot("cam2", source="camera", camera="CAM_hero_34") |
| a viewport screenshot only | source="reference" with the screenshot (no numbers in a picture), or ask the user to keep that view open and use "view" |
The new scene links the product collections only (camera, rig, backdrop and parked-light
collections of the source are recognised by bpr_role tag, name or content and left out), copies
the source's view-layer states (an excluded back cover stays excluded), refuses an implausible
product size before placing anything, and measures the source in its own depsgraph (the window
scene does not matter). It gets its own camera, light rig (STUDIO_RIG_<name>), backdrop and
world, copies units, resolution and frame range, uses the source scene's studio preset unless told otherwise, and is
set to preview quality. Then run exposure_check(path, scene=sc) on it. bpr_scene.list_shots() /
activate(name) list and switch scenes. Presets with float move the shared PRODUCT_ROOT.
Choosing the look
Map the user's words (or their reference images) to a preset + shot; bpr_studio.list_presets()
and bpr_camera.list_shots() print them. Defaults when the user gives no direction:
enclosure → soft_highkey + hero_34; PCB → pcb_hero + high_34 (and offer pcb_clean).
If the user supplies new references, analyse them the way references/visual-language.md does
(background tone, source size/direction, contrast, lens, angle, crop) and pick or extend a preset.
Reference-image mode (the user hands you a picture)
When the user gives a reference image ("quero algo assim", a Pinterest pin, a competitor photo), treat it as the spec:
- Look at it and write down what the numbers can't give: camera angle and height, lens feel (perspective, compression), crop, material and finish, mood, props.
- Measure it:
bpr_reference.analyze(path)→ backdrop colour/gradient/vignette, how much of the frame the product fills and where it sits, tonal contrast inside the product, which side the key is on, contact shadow vs floating, plus arecipe(preset, bg, aspect, margin, lens shift, mirror_lights, look, fill_scale). - Apply:
bpr_reference.apply_recipe(rec, shot=..., az=..., el=..., lens=...)— pass the angle/lens you judged by eye as camera overrides. Uselevitateiffloatingis true, a macro shot if the product bleeds off the frame. - Iterate: render a preview, then
bpr_reference.compare(ref, render, sheet)→ side-by-side sheet + deltas + hints (flatter/harsher, backdrop brighter/darker, product too small, key on the wrong side). Look at the sheet; stop when both read alike as thumbnails. - Say which aspects you matched and which you deliberately didn't (e.g. a lifestyle prop).
Several references → find what they share (that is the brief) and note where they disagree. Never copy a reference's logo, text or a recognisable branded product into the render.
Alex's taste (review feedback)
High-key must not look washed out: keep a clear light/shadow side and a backdrop that falls off
toward the corners — reduce fill before raising exposure. Plastic texture should read. Logo
letters/icons (INLAY_*) get dark ink by default (inlay="source" keeps the CAD metal).
Florence enclosures default to injection-moulded VDI 30; use FDM when asked.
Things that silently ruin product renders (and the fix built into the scripts)
- Wrong scale → DOF, SSS, texture grain and light falloff all wrong. Normalise to metres.
- Bad tessellation (CAD sliver triangles, split seams, degenerate faces) → streaks and pinched
highlights under smooth shading.
bpr_mesh.repair+smooth(Weighted Normal, Bevel modifier, Subdivision/Remesh where appropriate) — verify with the MatCapshading_diagnostic. - Smooth shading on CAD triangulation → dark gradients and streaks on flat faces (the
corner normals of a big face lean toward the slivers and fillet strips around it), and a Bevel
modifier whose arc miters solve sliver pairs can throw vertices ~1e15 m away (seen on Blender
5.2 for Windows; off-screen, so previews look fine while every bbox breaks).
smooth()dissolves first and guards the extent;shading_audit/fix_shadingmeasure and repair per object;bpr_utilbounding boxes ignore non-finite or > 1 km corners. - Flat-shaded bodies (imports and every
separate/split come in flat) → cylinders, pins, bends and fillets show bands of flat facets.bpr_mesh.ensure_smooth()(stage 4d) shades every body smooth with sharp edges by angle (40°: 12-segment curves at 30° blend, 45° chamfers and 90° edges stay crisp). Polygonal silhouettes (a 12-gon hole outline) are geometry and stay visible. - Inverted / mixed normals (whole bodies inside-out, random triangle winding — Altium OBJ
flips about half of each body's faces —, mirrored parts) → Cycles still draws them, but
Fresnel, coat, transmission, SSS, bevel and bump all invert: white plastic goes grey, glass and
the translucent mask misbehave.
bpr_normals.fix_normalsorients every body by ray parity on a welded copy (unwelded faces are the norm in EDA exports; signed volume alone leaves them inverted), falls back to the side tag for single-sided plates, clears stale custom normals and audits the result;bpr_normalizealready re-winds objects baked with a mirroring transform. - Coplanar faces (EDA mask plane vs component bottoms/silk; logo letters, icons, LED
diffusers flush with a housing face) → black stripes that change per sample.
bpr_pcb.fix_layer_stackandbpr_import.separate_coplanarlift by µm along the face normal; overlaps inside a layer (silk segments crossing at outline corners, two outlines sharing an edge, pad vs pour) survive that and show as black dots/lines —bpr_zfightfinds them exactly, fixes them and re-validates. Never declare the model clean without a cleanscan(). - Inlays treated as coplanar conflicts (logo/text bodies filling a host pocket) → black
wedges, a dark ragged outline, glyphs at different heights. A host-sized bevel folds a 0.2 mm
glyph (
smooth()now caps every bevel at 25 % of the part's thinnest wall), the two outlines are tessellated independently, the host bevel rounds the pocket rim, and depth translations separate the glyphs.bpr_inlay.fix_inlayshandles all four;bpr_zfightleaves seated glyphs alone. - Merged component bodies (pins, feet and tabs fused into a connector housing with one
colour) → black or white "plastic" pins.
bpr_partsfinds them by shape (bars incl. bent L-leads, bent sheet, repeated blades, loose pin shells), previews the split, moves contacts into<name>_METAL(gold/tin) and tabs into<name>_TABS(tin), and re-checks normals. - Blocky solder → pointed tents on every lead.
add_solder()builds tangent mounds with elliptical contours and a Subdivision modifier; fillet height follows the pad width. - Light in the camera's mirror direction → white sheet of glare over glossy flat tops.
build(glare_guard=True)swings such lights away (keeping the light's edge, not just its centre, outside the reflection; lifting it if swinging is not enough) and reports it. High iso/top views of PCBs are the typical case: confirm withexposure_check()— red/white on the board in False Color means a reflection still hits the camera. - A rim that is safe in ortho glares in perspective → perspective rays fan out (±10° at
100 mm) and, near a frame corner, the glossy mask's mirror cone reaches the strip's edge: a
washed, desaturated veil that never turns red in False Color. The perspective rim variant
excludes the mask plates;
veil_checkmeasures it. - Light linking with collection instances → an instancer inside any receiver set overrides
per-object membership of what it instances; product-only lights use an EXCLUDE{backdrop} set,
never INCLUDE{instancer} (
bpr_studio.link_set). - Judging exposure by eye on a preview → glare and crushed shadows hide in small PNGs.
bpr_render.exposure_check()renders the False Color view (Color Management → View → False Color) and measures the bands per region; use it on every scene during look-dev, never for finals (it restores the view transform). - Area-light Spread concentrates power in Cycles (75° ≈ 4×, 45° ≈ 6.6× on-axis). The rig
compensates (
SPREAD_GAIN); remember it when adding lights by hand. - Lights left over from the import at the old scale swamp the rig;
build()parks them. - Razor CAD edges → render looks like CAD. Library shaders include a Bevel node (0.2–0.5 mm).
matrix_worldis stale after Python edits → wrong bboxes. Callbpr_util.refresh().- Blender 5.x API changes (slotted actions,
use_nodes, AgX look names): seereferences/blender5-notes.md.
Verification checklist (look at every preview)
- Exposure (
exposure_check()per scene): no red/white on the product except tiny specular points, no black/blue shadow areas; white parts just below clipping with visible shading; backdrop separates from the product (high-key backdrop yellow/orange in False Color, ~#E0–E8; dark presets ≤ #1A). - No glare sheets on flat glossy surfaces; no black/stripy lines or corner dots (z-fighting —
bpr_zfight.scan()reportsclean: True); no fireflies. - Materials come from the library where one is adequate (the assignment table says so) and read correctly at delivery size: mask green (not white), traces faintly lighter, gold pads, solder bright and smooth (no ridges or points), no flat facet bands on curved bodies, connector pins/feet/tabs metallic (not housing-coloured), plastic texture visible only up close.
- Framing: product fills ~60–75 % of the frame (hero) with breathing room; focus where intended.
- Matches the chosen reference category (compare side by side if the user gave references).
Report what you changed and show the preview. At the end, list the scenes and ask whether to
render now — never start the final render without that answer. Keep the user's scene organised: everything the
skill creates is prefixed (STUDIO_, CAM_, PCB_, CMP_, SRC_) and grouped in collections.
Tests
tests/run_tests.py — synthetic regression tests (bevel guard, shading audit/fix, False Color
bands vs pixels, product mask/region, new_shot copy, rim variants and instance light linking,
inlay seating and the bevel thickness guard, library duplicates).
Run blender -b --factory-startup --python tests/run_tests.py after changing a module.
Reference files
scripts/bpr_reference.py— reference-image analysis, recipe and compare sheet (see above).scripts/bpr_zfight.py— coplanar-overlap scan, automatic repair loop, conflict camera.scripts/bpr_parts.py— split merged component bodies into plastic and metal parts.scripts/bpr_inlay.py— inlay detection, seating and verification (alsobpr_parts.find_inlays/fix_inlays).scripts/bpr_scene.py— shot scenes: one scene per view with the standard setup.references/visual-language.md— Alex's 200-image reference library distilled: categories, lighting/camera/CMF patterns, which preset reproduces which images (IDs).references/mesh.md— mesh-quality checks, repair, modifier toolbox (Bevel, Weighted Normal, Subdivision, Remesh, Corrective Smooth) with pros/cons and tuning.references/pcb.md— board layer model, exporter quirks (Altium OBJ, KiCad/pcb2blender), mask physics, finishes, solder, z-fight rules, troubleshooting.references/materials.md— enclosure/component material library, VDI table, FDM, metals, CAD-appearance mapping, CMF tips.references/lighting.md— product lighting principles, preset anatomy, tuning recipes.references/camera.md— lenses, shot list, DOF, composition, aspect ratios.references/animation.md— shot grammar, timing/easing, recipes for every bpr_anim function, video references.references/render.md— Cycles settings, AgX looks, denoise, output formats, background jobs.references/blender5-notes.md— API gotchas verified on 5.2 LTS.references/material-library.md— the bundled PCB Materials library: install, keys, catalogues, adequacy rules, rebuild and re-bundle