Sai Coumar
visender is a codegen tool that lets you snapshot a live viser scene and rebuild it in Blender to create beautiful demonstration renderings with Cycles instead of three.js. It saves a viser scene to an intermediate bundle representation which is then routed into blenderpy for automatic environment regeneration.
A runnable end-to-end example rendering a Gundam rx78 can be found in
examples/.
This quickstart will download the tool and run the example
git clone https://github.com/saiccoumar/visender.git
cd visender
uv sync
source .venv/bin/activate
uv pip install -e '.[cli]'
uv pip install viser
python examples/gundam.py
time visender render examples/gundam.yaml --profile final
As a prerequisite, blender must be installed. Blender 5.2's tar.gz can be downloadeed here: Blender 5.2 Linux Download
The path to the blender executable must be set to the $BLENDER variable for visender to run.
uv sync
source .venv/bin/activate
uv pip install -e '.[cli]'
uv pip install viserThe cli extra pulls in pyyaml, which the visender wrapper needs to read config
files. A plain pip install -e . is enough for the export half and the raw
blender --python path. Nothing is installed on the Blender side.
Add a button to any viser script:
import visender
server = viser.ViserServer()
... # build the scene as usual
visender.add_export_button(server, out_dir="renders/pen_grip",
environment_map="city")Pose the scene in the browser, then click Export to Blender. Each click
writes a fresh timestamped bundle (renders/pen_grip_142530/), so you can
export several takes and pick the best one later.
There is a plain function too, if you want to export without a GUI:
visender.export_scene(server, "renders/take1")Both entry points take the same options:
| option | default | what it does |
|---|---|---|
include_gizmos |
False |
Emit transform controls, labels, grids, frames. Off by default — they are alignment aids, not subjects. |
include_hidden |
False |
Emit nodes hidden in the browser. |
node_filter |
None |
lambda name: ... — return False to drop a node by path. |
environment_map |
None |
The preset you passed to configure_environment_map. viser does not retain it, so repeat it here. |
A light parented
to a transform control (/ctrl/key/light) keeps the pose you dragged it to —
world transforms are composed down the full /a/b/c path regardless of which
nodes get emitted. This is the intended way to art-direct a shot.
The visender command quickly automates the blenderpy environment generation.
visender can be run with the following commands:
visender render renders/pen_grip.yaml --profile final
visender render renders/pen_grip.yaml --profile draft --output preview.png
visender export renders/pen_grip.yaml # build a .blend, render nothing
visender list-nodes renders/pen_grip_142530 # node paths + vertex/point counts
visender inspect renders/pen_grip_142530 # nodes, camera, recording
visender init renders/pen_grip_142530 > pen_grip.yaml # scaffold a starter configA minimal config:
bundle: renders/pen_grip_142530
output: renders/out/pen_grip_{profile}.png
profiles:
draft: {engine: EEVEE, samples: 64, resolution: [1280, 720]}
final: {engine: CYCLES, samples: 8192, resolution: [3840, 2160], gpu: true}
world: {studio: true, strength: 0.9}
backdrop: {enabled: true, color: [205, 205, 210]}
lighting: {dim_authored: 0.15, key: {az: -40, el: 35}}
save_blend: truePrecedence is config file < profile < explicit CLI flag — any raw
blender_import.py flag passed after the config is forwarded straight through
and wins over the file. Every successful render also writes a <output>.yaml
provenance sidecar: the effective settings after overrides, the config file's
own values, bundle path, visender/Blender versions and render time.
Before a config exists, --quality draft|preview|final is a shorthand (mutually
exclusive with --profile):
visender render pen_grip.yaml --quality draftThe full schema — profiles, aliases, per-polygon material splits, camera
framing, lighting rig — is in docs/config.md.
visender is a convenience layer over blender_import.py, which you can drive
directly:
blender -b --python visender/blender_import.py \
-- --bundle renders/pen_grip_142530 --render cover.png --samples 512Drop the -b to open the scene in the Blender GUI instead, already built and
framed. Every flag is documented in
docs/blender-flags.md.
Sometimes the point is not a PNG but the Blender scene itself — to art-direct by
hand, hand it to someone else, or keep the shot around for later.
visender export builds the scene exactly as a render would and saves a
.blend instead of rendering:
visender export renders/pen_grip.yaml # -> renders/out/pen_grip_default.blend
visender export renders/pen_grip.yaml --profile final -o hero.blend
visender export renders/pen_grip_142530 # a bare bundle -> ./pen_grip_142530.blend| flag | what it does |
|---|---|
-o, --output PATH |
Where to write the .blend. Default: the config's output: with a .blend suffix, or <bundle>.blend in the CWD. |
--profile NAME |
Same profiles a render uses, for the settings that shape the scene (materials, lighting, camera). Sample counts and resolution ride along harmlessly. |
--animation / --still |
Key the recording onto the timeline, or ignore it. Defaults to keying it when the bundle holds one. |
--blender PATH |
Which Blender binary to use. |
The argument is either a config file — so the .blend opens with the
materials, lighting rig, backdrop and camera framing that config describes — or
a bundle directory, for the raw scene as exported from viser. Any extra
blender_import.py flag is forwarded through, same as with render.
A still — examples/gundam.py exports a bundle from
the browser; examples/gundam.yaml describes the shot:
python examples/gundam.py # pose it, click Export to Blender
visender export examples/gundam.yaml --profile final -o out/gundam.blendOpen out/gundam.blend and the RX-78 is there in its posed, gold-shaded,
key-lit state on the camera you framed in the browser — no render was run.
A video — examples/gundam_video.py is a
keyframe editor; the recorded take becomes a bundle with a timeline:
python examples/gundam_video.py # keyframe it, click Record shot
visender inspect examples/bundle_gundam_video # frames, fps, what moved
visender export examples/gundam_video.yaml -o out/gundam_video.blendThe whole take is keyed onto the objects at build time, so the saved scene holds
the entire animation, not frame 1 — scrub it, retime it, or hit render from
the GUI. Pass --still if you only want the opening pose.
Alongside a render. If you want both in one go, keep using render and set
save_blend in the config — it is written before the first frame, so it
survives an interrupted or crashed render.
examples/gundam_video.yaml ends with it:
save_blend: true # -> beside the output, out/gundam_video_draft.blend
# save_blend: out/hero.blend # or an explicit path, relative to the config fileThe lowest-level route is blender_import.py with --save-blend and no
--render; every flag is in
docs/blender-flags.md.
| viser | Blender |
|---|---|
add_mesh_trimesh, add_glb |
imported GLB under a posed empty |
add_mesh_simple, add_box, add_icosphere |
mesh + Principled BSDF |
add_spline_catmull_rom, add_spline_cubic_bezier, add_line_segments |
beveled curve (a real tube), per-segment colours preserved via a Col attribute |
add_light_directional / point / spot / rect_area |
sun / point / spot / area |
add_light_ambient / hemisphere |
folded into the world shader |
add_point_cloud |
geometry-nodes instanced spheres, coloured from the exported per-point Col |
| browser camera | camera with matching position, aim and vertical FOV |
Anything else is named on stdout and skipped rather than silently dropped.
A bundle is normally one instant. visender.Recorder samples the same world
matrices over time, so Blender keys every object instead of just placing it —
assets are still written once, so a 500-frame take costs about what a still
does on disk.
rec = visender.Recorder(server, fps=24)
for cfg in trajectory:
viser_urdf.update_cfg(cfg) # or drag things in the browser
rec.capture()
rec.save("renders/take1")visender inspect renders/take1 # frames, fps, what moved
visender render take.yaml --profile draft # animation: {enabled: true}The output suffix picks the container: .mp4 encode a movie,
anything else writes a numbered PNG sequence. visender.add_record_button
records live from the browser instead, camera moves included.
examples/gundam_video.py is a keyframe editor in the browser: click a body
part to pose the joint that drives it, capture that pose at a time, and the
script interpolates between your keyframes onto a chosen fps. Scrub or play the
result before committing to a render, and save the take to YAML.
Details in docs/animation.md.
- The camera comes from a connected browser. Export with the tab open and Blender opens on the view you framed. With no client attached the bundle has no camera, and Blender falls back to its default view.
- Light intensity is not physically portable. three.js and Cycles disagree
about units, so
--sun-scale/--point-scaleare knobs to taste. Poses transfer exactly; brightness is a starting point. - Line widths are pixels in viser, metres in Blender. Splines get a tube
radius of
line_width * 0.00025, which reads about right at cover-image scale. Adjustbevel_depthin Blender if not. - Environment maps do not transfer. viser's presets are three.js built-ins;
pass
--hdriwith your own file to match. - Colours are converted sRGB → linear (
^2.2), so Blender matches what the browser showed. - Axes are corrected on import. Blender's glTF importer bakes a
(x, y, z) → (x, -z, y)rotation (+90° about X) into imported vertex data; the import undoes it so meshes match viser's Z-up frame. Measured against Blender 5.2 by comparing world-space vertex bounds to trimesh ground truth. Relatedly,matrix_worldis cached, so the depsgraph is updated after re-parenting — without it the transforms silently do not apply.
pip install pytest # plus the [cli] extra for pyyaml
pytest # everything, ~20 s
pytest -m "not slow" # skip the tests that launch Blender
BLENDER=/path/to/blender pytest # pick a specific BlenderThree tiers, in tests/:
- Solver side (
test_config.py,test_cli.py,test_export.py) — config resolution, thevisenderwrapper (Blender stubbed out) and the bundle format the exporter writes, driven by fakes shaped like viser handles. - Contracts (
test_contracts.py) — the invariants that keep the two interpreters in step:blender_importimports nothing pip-only,config.SETTINGS_FIELDSmatches theSettingsdataclass (checked by parsing the source, not importing it), every CLI flag lands on a field, pyyaml stays out of the base dependencies. - Blender side (
test_blender_import_logic.py,test_blender_integration.py) — pure logic runs under a stubbpy; scene building, materials, lighting, camera and a real EEVEE render run inside Blender viatests/_scene_probe.py, which reports the built scene as JSON. Skipped automatically when no Blender binary is found.
