/vr-dev:blender-cli-vr-assetsfrom vr-dev
Builds VR-ready 3D assets via headless Blender CLI stages, bakes Cycles lighting into atlases, and exports deterministic FBX for Unity/Meta Quest. Includes stage runner, bpy helpers, fidelity gate with SSIM/CIEDE2000.
Ships in vr-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
An agent cannot click through Blender, and a Quest cannot afford real-time lighting of a detailed room. Both problems have the same answer: a pipeline of headless Blender stages that builds the asset from code, bakes the full Cycles light into atlases that Unity draws unlit, proves the result with gates and numbers, and exports bytes that only change when the asset changes.
The method was proven on a radiotherapy treatment room for a Quest app (a TrueBeam-class linear accelerator in a 6.2 m vault: a jointed gantry, imaging arms and a couch), built entirely by headless stages: 61 validate checks, 73,744 machine triangles at LOD0, 4096^2 atlases at ASTC 4x4, a deterministic FBX, and Unity frames matching the Cycles previews at machine-region mean SSIM 0.898 and mean CIEDE2000 3.72 (all 6 shots inside the >= 0.85 / <= 6 target).
Use for: generating rooms, props, jointed machines or environments from scripts; fixing an FBX that lands rotated,
scaled or with joints in the wrong place; baking light / AO into atlases; making Unity match a Blender render;
making an asset pipeline reproducible and reviewable; any blender -b ... -P script.py work.
Not for: interactive sculpting / artist workflows (no gates to automate), skinned characters and animation clips
(the joint contract here is rigid-body joints driven by code), or Unity-side runtime work after import (see the
Quest simulator / build skills).
| Path | What |
|---|---|
scripts/run_stages.py | CPython runner: pipeline.json -> one Blender process per stage, --from/--to/--only/--quick, stops at the first non-zero exit |
scripts/bpy_stage.py | imported by stage scripts: args after --, absolute OUT, open_stage / save_stage, sha256, check_version, write_json |
scripts/fbx_deterministic.py | deterministic_fbx() patch, UNITY_EXPORT_KW, read_fbx() read-back, assert_no_host_paths() |
scripts/fidelity.py (+ requirements.txt) | CPython SSIM + CIEDE2000 gate over masks, JSON + montages |
examples/hello-room/ | a runnable 6-stage pipeline using all of the above (~12 s with --quick on a GPU, ~26 s on CPU) |
references/unity-handoff.md | axes, the rotation-sign rule, units, joint contract template, Unity import checklist |
references/baking-and-fidelity.md | view transform, display-referred bake, bake sets, gloss, env map, contact shadows, metrics, expected gaps |
references/determinism.md | inputs vs non-inputs, the FBX patch points, bake device noise, the validate binding |
references/pitfalls.md | every headless trap hit so far, symptom -> cause -> fix |
Start a new pipeline by copying examples/hello-room/ and replacing contract.py, lookdev.py and the geometry;
copy scripts/bpy_stage.py and scripts/fbx_deterministic.py beside the stages (or fix their sys.path line, which
expects the skill's scripts/ two folders up).
export BLENDER=/path/to/blender # Windows PowerShell: $env:BLENDER = "C:\path\to\blender.exe"
export PIPELINE_PY=/path/to/venv/python # CPython with numpy, scikit-image, Pillow (only for fidelity.py)
python scripts/run_stages.py examples/hello-room/pipeline.json --quick
BLENDER at it, and record bpy.app.version and build_hash in
every manifest - the FBX writer, the UV packer and Cycles change between versions, so the build is an input.pipeline.json ("blender": {"min_version": "4.2", "pin": "5.2.2", "policy": "warn"}); the runner checks blender --version before any stage and passes the rule to bpy_stage.check_version()
as env BLENDER_MIN_VERSION / BLENDER_PIN / BLENDER_VERSION_POLICY (set them when running a stage by hand).
Use "refuse" for release builds.--factory-startup on every stage.blender -b --factory-startup --python-exit-code 2 -P 02_bake.py -- --out /abs/out [--quick]
.blend in <OUT>/work/ (open_stage("01_build")
... save_stage("02_bake")): a crash cannot leave half-modified state for the next step, a stage can be re-run
alone, and memory never accumulates across a long pipeline.--python-exit-code 2: without it an uncaught exception exits 0 and the next stage runs on garbage. Gate
failures raise SystemExit(1); so 1 = "a gate refused", 2 = "the script broke".run_stages.py prints
=== bake: exit 0 in 5.6 s). The exit code IS the result: block on the process, never on a log line.bpy_stage.resolve): a relative output path in an unsaved file lands at the drive root.--quick (small atlases, low samples) for iteration; the export refuses a quick stage unless --allow-quick, so
an iteration build cannot ship by accident."python": true) run tools that need packages Blender lacks (fidelity.py: scikit-image).Write contract.py before any geometry; every stage imports it and nothing else defines these numbers.
unity (x, y, z) = (X, Z, Y), det -1. The
conversion happens in the export stage only, so bake, preview, validate and clearance all work in one frame.+t about a == Unity Quaternion.AngleAxis(-t, M a). Write it next to
every joint in the manifest and gate it numerically..001 suffix
is a build failure.localRotation assignment.references/unity-handoff.md.o.location = world - parent_world): positions are readable in the source
and exact in the file.lookdev.py that build, bake and preview share, so the bake sees
exactly what the reference renders.Atlas RGB = encode(view)(albedo x (direct + indirect diffuse) + emission), 8-bit sRGB; A = gloss. Drawn with an
unlit shader in a linear project it reproduces the reference pixel at no lighting cost. Details in
references/baking-and-fidelity.md; the rules:
image.save_render), not a hand-written curve.DIFFUSE {DIRECT, INDIRECT, COLOR} + EMIT, not COMBINED (its glossy term is seen from the wrong
direction). Glossy goes to a cheap runtime reflection scaled by the gloss alpha.margin=0 (a bake's margin overwrites other islands it thinks are empty), then dilate
the gutters in numpy and fill unused texels with the mean colour.correct_aspect=False and
rotate=False headless (otherwise islands stretch 4-16x), texel-density weights for what users look at.alpha_mode = "CHANNEL_PACKED"; a float image is
premultiplied and saving it wipes the colour of every matte (alpha 0) texel.Per shot, from the final stage file (never saved): previews/ = the Cycles REFERENCE (authoring materials, the look
definition, denoised except emission closures), previews_unlit/ = every surface the emission of its atlas (what the
Quest draws), previews_mask/ = flat group colours rendered with the Raw view (R room, G static, B moving; overlays
black), and cameras.json = every shot in UNITY coordinates (position, target, up, vertical FOV, aspect, resolution,
near clip, pose) plus the stage sha256, so Unity can render the same frames.
python scripts/fidelity.py --ref out/previews --test out/previews_unlit --mask out/previews_mask \
--cameras out/cameras.json --regions machine=gb,scene=rgb --gate machine --min-ssim 0.85 --max-de 6 \
--json out/fidelity.json --montage out/previews_compare
SSIM (Gaussian sigma 1.5, data range 255) catches noise, blur and misalignment; mean CIEDE2000 catches colour,
exposure and view-transform errors. Gate the region the bake is responsible for, report the rest, and name the
expected gaps (glossy coat, moving-part shadows, poses away from rest, noise, edge AA) instead of chasing them. Run the
same script on Unity captures (--resize-test if sizes differ): one metric for both hops.
04_validate.py fails loudly (exit 1) and writes validate.json with the sha256 of the exact stage it checked. Gate
at least: contract names / parents / kinds and nothing extra; identity rest everywhere and det > 0; every node at its
contract position; each joint turning about its contract axis through its pivot (and the Unity sign rule reproducing
it); outward / inward normals; tris and atlas budgets; one UV map, inside [0, 1], no overlaps, stretch p95; the atlas
format (8-bit RGBA, size, straight alpha, gloss values); cameras.json, the previews and a PASSING fidelity.json
all bound to this stage's sha256. Domain checks (a part on the correct side, a clearance, a floor height) are worth more
than generic ones - they catch the sign error a self-consistent pipeline reproduces.
The export refuses unless validate.json passed (fail == 0, pass > 0) on exactly the file it is about to
export:
[05_export] FAILED: REFUSED:
validate.json is for stage sha256 ebe8ce8d5384, the file being exported is c3fe5f9336cd (stale: re-run validate)
(that was a no-op re-save of the stage: .blend files are not byte-reproducible, so any touch re-derives the chain).
(-X, Z, Y) (det +1), the root set to the inverse of
the exporter's axis matrix, axis_forward="-Z", axis_up="Y", bake_space_transform=False - "Apply Transform"
converts meshes and roots but leaves child joint offsets in Blender axes. Units: apply_scale_options="FBX_SCALE_ALL"
-> metres with UnitScaleFactor 100 -> Unity useFileScale = 1 unit per metre. All in F.UNITY_EXPORT_KW.fbx_deterministic.deterministic_fbx(): it pins the creation time, ApplicationNativeFile, the
texture paths and the UIDs (Python's salted hash(); Blender ignores PYTHONHASHSEED), and raises if io_scene_fbx
changed instead of silently writing non-deterministic files. Then assert_no_host_paths().manifest.json with joints in Unity coordinates
(local + world rest position, axis, range, sign rule), tris, texture import settings, the validate block, the
fidelity summary, the bake device and the sha256 of every file.read_fbx) and re-check in Unity coordinates: axis system Y-up, UnitScaleFactor 100, no
rotation / scale / pre / post / geometric transforms, exact names, every node at M . contract position, a few
domain facts. Exit 1 on any miss.run_stages.py --from export --to export twice -> same sha256, also into another --out. In the example,
unpatched exports of the same stage differ in 342 bytes; patched ones are identical across runs, folders and drives.Details and the code: references/determinism.md, references/unity-handoff.md.
Set budgets from measured GPU time on the device, then gate them. Reference point from the treatment room (Quest 3S, 72 Hz = 13.9 ms frame): an earlier build drew 1.5 - 3.6 ms App GPU, so the detail pass spent that headroom on geometry and texels - machine 73,744 tris (LOD0 only) + room 5,430, five 4096^2 atlases at ASTC 4x4.
| Item | Rule | Why |
|---|---|---|
| Triangles | gate a per-group budget (TRIS_MAX), LOD0 counts | the budget is GPU ms; tris are the knob you control |
| Atlases | <= 4096^2, power of two, <= 2 per group | memory, import max size, mip chain; more texels rarely show at VR pixel density |
| ASTC 4x4 | 8 bpp: a 4096^2 atlas = 16 MiB, ~21 MiB with mips | hero surfaces: text, sharp colour edges, the machine |
| ASTC 6x6 | 3.56 bpp: ~7 MiB, ~9.5 MiB with mips | large smooth walls / floors |
| RGBA8 | 32 bpp: 64 MiB, ~85 MiB with mips | never ship uncompressed atlases |
| Anisotropy | 8x on floors, walls, long surfaces | grazing angles blur in a room without it |
| Materials | one per atlas group | each extra material is another draw call per mesh |
| LOD | only when measured to help | decimate AFTER the unwrap so LODs share the atlas; LOD siblings add mesh memory and pop; the room dropped them once GPU headroom was measured |
When parts move (gantries, arms, doors, couches), still renders cannot show collisions. Pose the rig exactly like the runtime kinematics (same signs and interpolation as the Unity code), and measure every moving pair on the triangles:
from mathutils.bvhtree import BVHTree
bvh_b = BVHTree.FromPolygons(verts_b_local, tris_b) # once per part, in its local frame
M_ab = np.linalg.inv(world(B)) @ world(A) # float64, per pose
for q in samples_a @ M_ab[:3, :3].T + M_ab[:3, 3]: # A's vertices + edge samples every ~4 mm
loc, nrm, idx, dist = bvh_b.find_nearest(Vector(q), cut) # min distance (both ways)
hit = bool(bvh_a.overlap(BVHTree.FromPolygons(verts_b_in_a, tris_b))) # surfaces intersect
# containment: ray parity against B's closed components; depth = deepest sample inside
Skip pairs whose transformed boxes are farther apart than the cut; classify each contact (A = modelling error, B = a limit the real device has too, U = a runtime pose / kinematics number) and gate "no A in the working poses". Keep the JSON deterministic (timings to a sidecar) and bind it to the stage sha256 like the previews. The treatment-room sweep found an imaging panel whose deploy path crossed the machine's own shell 149 mm deep - invisible in every still.
AssetPostprocessor or the scene builder, never by hand): globalScale 1, useFileScale
on, bakeAxisConversion off, normals Import, tangents None for unlit, materialImportMode None (assign the unlit
atlas material in code), no cameras / lights / animation, Read/Write off (copy triangles at edit time if CPU code
needs them), preserveHierarchy on.manifest.json (names, local positions, identity rotations, tris), render the
cameras.json shots and run fidelity.py on them.
Full checklist: references/unity-handoff.md.End every pipeline run with a short report that separates the three kinds of evidence:
validate.json n / n pass on stage sha256 ...; FBX read-back OK in Unity coordinates;
fidelity per shot (gate region SSIM / mean dE vs target); determinism (two export sha256s equal); the bake device.--quick.
Never present an iteration (--quick) build or a GPU-baked atlas hash as the reproducible release artefact.Full list with fixes: references/pitfalls.md. The ones that bite first:
--python-exit-code -> crashes exit 0. 2. Relative output paths -> written to the drive root.correct_aspect / rotate headless -> stretched islands.bake_space_transform -> child joints in the wrong place. 8. hash()-based FBX UIDs -> new bytes every run.examples/hello-room/01_build.py (opens in a new tab)examples/hello-room/02_bake.py (opens in a new tab)examples/hello-room/03_preview.py (opens in a new tab)examples/hello-room/04_validate.py (opens in a new tab)examples/hello-room/05_export.py (opens in a new tab)examples/hello-room/README.md (opens in a new tab)examples/hello-room/contract.py (opens in a new tab)examples/hello-room/lookdev.py (opens in a new tab)examples/hello-room/pipeline.json (opens in a new tab)references/baking-and-fidelity.md (opens in a new tab)references/determinism.md (opens in a new tab)references/pitfalls.md (opens in a new tab)references/unity-handoff.md (opens in a new tab)scripts/bpy_stage.py (opens in a new tab)scripts/fbx_deterministic.py (opens in a new tab)scripts/fidelity.py (opens in a new tab)scripts/requirements.txt (opens in a new tab)scripts/run_stages.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
blender, vr-assets, fbx, light-baking, asset-pipeline, quest
npx claudepluginhub gomesgustavoo/vr-dev-skills --plugin vr-dev4 skills in this plugin
/horizon-os-mcpConnect and use Meta's Horizon OS developer MCP server (metavr via npx, or hzos-dev-mcp bundled with Meta Quest Developer Hub) for Quest work - authoritative Meta docs and exact Unity/Unreal API signatures, device control (list, apps, files, logcat, screenshots, UI automation), and Perfetto performance traces with baseline comparison. Use it before relying on memory about any Meta XR SDK name, setting, manifest entry or Store/VRC rule; when a Quest app crashes, stutters or runs hot; when the user asks to install, launch, inspect or capture something on the headset; or when setting up, checking or repairing the MCP connection itself./quest-build-deployBuild a Unity Meta Quest app into an APK headlessly (release, development, or development without the XR Operator layer), refuse the build when a build gate fails, sideload it with adb, launch it, confirm it stays up with no crash in logcat, and turn a worn-headset session into a scripted readout (self-report lines, distinct problems, VrApi fps/GPU/stale summary). Use it when the user says build, build the apk, deploy, sideload, install or push to the Quest/headset, test on the device, or asks why a build or install failed - and when a change needs real hardware after the simulator loop./unity-quest-sim-loopTest and debug a Unity Meta Quest app without the headset. Runs it in editor Play Mode on the Meta XR Simulator and drives it through the Meta XR Operator (port 8720) plus the app's own agent tools - inject controller and head poses and buttons, press UI for hand-tracking apps, query app state, capture the eye view, pixel-diff one object's colour, run JSON scenario suites that assert on app state, then stop, refresh and replay after each edit and pin findings with a headless gate. Works on Meta XR SDK 205 and on older SDKs such as 203, and covers passthrough apps. Also the headset follow-up (dev APK, adb, logcat, VrApi numbers). Use it whenever the user wants to verify, test, reproduce or look at a Quest/Unity XR feature; mentions the XR Simulator, XR Operator, xrsim or openxr_* tools; reports something wrong in the headset (invisible or untextured objects, dead buttons, overlapping UI); or wants this loop in a new project.Other plugins' skills for the same job