lmblender

lmblender logo: a ringed planet rendered with CPU Cycles
A compact scene rendered with lmblender v0.3.6.

lmblender is Blender's Cycles path tracer as one static executable, driven by short lmscript scenes: no Blender install, no Python, no GPU. A program builds a scene through the scene context object and renders PNG, EXR, image sequences or APNG on the CPU.

Install and run

npm install -g @lmctl-ai/lmctl
lmctl https://raw.githubusercontent.com/lmctl-ai/lmblender/main/examples/cornell-box.lms
lmscript hello.lms

The first run fetches the lmblender release for the platform (Linux x64/arm64, macOS x64/arm64, Windows x64) named by install= on the block. The current release is 0.3.6.

Minimal program

mkdir("images");
prog = _lmcode_ cli="lmblender" install="github:lmctl-ai/lmblender@latest";
let ball = scene.uv_sphere(1.0, 48, 32, true);
ball.set_material(scene.material(0.1, 0.3, 0.8, 0.0, 0.25, 0.0, 0.0, 0.0, 0.0, 0.0));
scene.studio_setup();
scene.render_png("images/hello.png", 32, 640, 480);
end _lmcode_
r = run_lmcode(prog);
if (!r.ok) { println("lmblender failed"); exit(1); }
println("wrote images/hello.png");

Output directories must exist before the host runs. For renders that take minutes, save the bytecode and call the host with an explicit timeout in milliseconds, as the repository examples do:

savedsl(prog, "build/scene.dslb");
argv = dsl_cli(prog);
push(argv, "--lmcode");
push(argv, "build/scene.dslb");
r = system(argv, 3600000);
println(trim(r.stdout));
if (r.code != 0) { println(trim(f"lmblender exit {r.code}: {r.stderr}")); exit(1); }

Host protocol and flags

CommandEffect
lmblender --versionPrints lmblender version with the DSL bytecode version, the Cycles version and the OpenImageDenoise version (or that it is disabled). Exit 0.
lmblender --lmcode-schemaPrints a compact summary: context and function signatures, then methods grouped by type.
lmblender --lmcode-schema --jsonPrints the embedded schema JSON byte for byte (same bytes as schema/lmblender.dsl.json merged with the vendored std).
lmblender --schema --jsonOlder spelling of the same embedded schema output.
lmblender --schemaEmbedded schema followed by one newline (kept for compatibility).
lmblender --lmcode-signaturesPrints every registered signature, one per line. Exit 0.
lmblender --lmcode FILE.dslbLoads compiled bytecode, binds the scene context object, runs the program and prints one JSON result line.
lmblender --presetsLists embedded scene presets as name, tab, description.
lmblender --preset-show NAMEPrints one embedded preset as JSON; exit 2 when the name is unknown.
Exit codeMeaning
0Success. The run prints a JSON line with ok true and a result.
2Usage error (wrong arguments) or unknown preset name for --preset-show. Compile failures reported by lmscript also use 2.
3Load or run error: JSON line with ok false, phase load or run, code, message and line/column when available.
4APP_FAIL (phase app, an unexpected host failure), or a failed write of the schema to stdout.

Host objects and main calls

The host binds one context object, scene, of type Scene (69 methods). Mesh (18 methods) and Material (9 methods) are handles. Coordinates are right-handed and Z-up, distances are scene units, colors are linear floats in 0..1, and every call is positional.

AreaSignatures
Primitives (Scene)plane(float) -> Mesh; cube(float) -> Mesh; uv_sphere(float, int, int, bool) -> Mesh; cylinder(float, float, int, bool) -> Mesh; cone(float, float, int, bool) -> Mesh; torus(float, float, int, int, bool) -> Mesh; capsule(float, float, int, int) -> Mesh; tube_between(float, float, float, float, float, float, float) -> Mesh; label(string, float, float, float, float) -> Mesh
Imports and instances (Scene)import_obj(string) -> Mesh; import_stl(string) -> Mesh; import_ply(string) -> Mesh; import_gltf(string) -> Mesh; instance_mesh(Mesh, float, float, float, float, float, float) -> Mesh
Materials (Scene)material(float, float, float, float, float, float, float, float, float, float) -> Material; checker_material(float, float, float, float, float, float, float, float) -> Material; noise_material(float, float, float, float, float, float, float, float) -> Material; ramp_material(float, float, float, float, float, float, float, float) -> Material; image_material(string, float) -> Material; material_from_palette(string) -> Material
Camera (Scene)camera_look_at(float, float, float, float, float, float, float) -> void; camera_orthographic(float, float, float, float, float, float, float) -> void; fit_camera(float) -> void; camera_dof(float, float) -> void; camera_keyframe(int, float, float, float, float, float, float, string) -> void
Lights and world (Scene)studio_setup() -> void; point_light(float, float, float, float, float, float, float) -> void; sun_light(float, float, float, float, float, float, float, float) -> void; spot_light(float, float, float, float, float, float, float, float, float, float, float, float) -> void; area_light(float, float, float, float, float, float, float, float, float, float, float) -> void; world_color(float, float, float, float) -> void; sky_texture(float, float, float) -> void; environment_texture(string, float, float) -> void; ground_plane(float, float, float, float, float) -> void
Render (Scene)render_png(string, int, int, int) -> void; render_exr(string, int, int, int) -> void; render_passes(string, int, int, int) -> void; render_sequence(string, int, int, int, int, int) -> void; render_apng(string, int, int, int, int, int, int) -> void; render_settings(int, int, bool) -> void; render_preset(string) -> void; render_timeout(int) -> void; set_view_transform(string) -> void; set_threads(int) -> void
Checks (Scene)expect_int(int, int) -> void; version() -> string
Meshset_material(Material) -> void; set_smooth(bool) -> void; translate(float, float, float) -> void; scale(float, float, float) -> void; rotate_x(float) -> void; rotate_y(float) -> void; rotate_z(float) -> void; vertex_count() -> int; triangle_count() -> int; material_count() -> int; keyframe_transform(int, float, float, float, string) -> void; keyframe_visible(int, bool, string) -> void
Materialsubsurface(float, float, float, float, float) -> void; volume(string, float, float, float, float) -> void; keyframe_color(int, float, float, float, string) -> void; bump(float, float, float) -> void; texture_maps(string, string, string, string) -> void; mix_with(Material, float) -> void; mix_with_texture(Material, string) -> void; backface_culling(bool) -> void; keyframe_emission_strength(int, float, string) -> void

The standard library vendored by lmblender 0.3.6 is lmcode_std_v3 with 206 signatures (files, strings, math, Json, typed lists, maps, queues, stacks and priority queues). The current catalog has 226 including the REST and CLI interfaces, which lmblender does not ship yet.

Limits

Two white blocks inside a Cornell box with red and green walls
Cornell box: indirect light carries color from the walls onto the white blocks.
Glass spheres focus bright caustic patterns onto a floor
Ball lens: refracted light makes a focused caustic.
A ringed planet against a dark background
Saturn rings: layer a planet, rings, and directional light.

More