Dynamic Matrix Instancing

Contents Previous Next

Install

npm install -g @lmctl-ai/lmctl

lmvideo 0.1.38 is released. Source examples are pinned to public commit aab2677.

Download lmvideo 0.1.38

900x560 still; procedural 32x32 wave-modulated shared beveled cube mesh (1,024 instances), per-instance colour and phase.

Verified acceptance capture, reproducible with the lmvideo 0.1.38 prerelease runtime.

Run this example

lmctl autorun https://raw.githubusercontent.com/lmctl-ai/lmvideo/aab2677a4b6264ae6afae8ad64a1d7c1dcd3a052/examples/showcase/bench-11-dynamic-matrix-instancing.lms

Source

# B11 / G.1: one shared beveled cube mesh, 32x32 = 1,024 wave instances.
mkdir("build"); program=_lmcode_ cli="lmvideo" install="github:lmctl-ai/lmvideo@v0.1.38";
let scene=scene3d().threads(4).background("#edf3f8").ambient(0.24).threads(4);
scene.camera(camera3d().look_at(31.0,28.0,40.0,0.0,0.0,0.0).perspective(43.0,0.1,120.0));
let cubes=scene.add_instances(mesh_beveled_box(0.62,0.62,0.62,0.06),"#359b9a");
for(i in range(0,1024)) { let x=float(i%32)-15.5; let z=float(i/32)-15.5; let phase=(x+z)*0.18; let y=1.45*sin(x*0.27+phase)*cos(z*0.24-phase); let c="#359b9a"; if(i%32>15){c="#de7656";} cubes.add_instance(x,y,z,0.0,y*12.0,0.0,1.0,1.0,1.0,c); }
image_assert_true(cubes.size()==1024);
scene.directional_light(1.0,3.0,4.0,"#ffffff",0.95);
let image=scene.render_image(900,560,2); image_assert_true(image.stddev(0)>0.05); image.save("build/bench-11-dynamic-matrix-instancing.png");
end _lmcode_
 r=run_lmcode(program); assert(r.ok,(r.ok ? "" : r.message));println(json_stringify(r.result));

Raw LMScript source

A wave-shaped grid of colored beveled cubes.
Shared geometry appears in many positions with different colors and phases.