A rendering engine on TypeShade
Radiance draws a scene graph written in TypeScript with a progressive path tracer on WebGPU. The GPU code is TypeShade, and the same kernel runs on the CPU oracle, where CI holds the two images within 0.00003 of each other.
const scene = new Scene();
const ground = new PlaneGeometry(6, 6);const grey = new DiffuseMaterial();grey.color.setHex(0xbfbfbf);const floor = new Mesh(ground, grey);floor.rotation.x = -Math.PI / 2;
const panel = new PlaneGeometry(1.2, 1.2);const light = new EmissiveMaterial();light.emissive.multiplyScalar(10);const lamp = new Mesh(panel, light);lamp.position.set(0, 2.2, 0);lamp.rotation.x = Math.PI / 2;
const sphere = new SphereGeometry(0.5);const chrome = new MirrorMaterial();const mirror = new Mesh(sphere, chrome);mirror.position.set(-0.6, 0.5, 0);
const orange = new DiffuseMaterial();orange.color.setHex(0xe8703a);const ball = new Mesh(sphere, orange);ball.position.set(0.6, 0.5, 0.2);
scene.add(floor, lamp, mirror, ball);
A scene graph you already know
Objects, cameras, geometries, materials, meshes and renderers, laid out as three.js lays them out, so a scene reads the same way and a renderer is one call.
One kernel, two machines
The path tracer is one TypeShade file. The GPU runs it through the compiler's program runtime, and the compiler's CPU oracle runs the same file. CI renders the Cornell box both ways at 16 x 16 and 1024 samples a pixel, and holds the two images to each other; two renders of one seed are bit-identical.
| Mean relative difference, over the frame | under 0.00003 |
|---|---|
| Any channel of any pixel | within 0.001, or 5% of the oracle's value |
| Two renders of one seed | bit-identical |
Examples
All examplesEvery example is a file in the repository, run on its page. Open one and read the file that made it.
Install
The engine is @typeshade/radiance, and the camera controls and ready-made scenes are @typeshade/radiance-addons. Both are written on the compiler pinned at commit 596c805.
npm install @typeshade/radiancePre-release: version 0.0.0 of @typeshade/radiance is not on npm yet. Until it is, the repository is the way to run it.









