Projects / 06
o3d
3D for Odin in three.js's vocabulary. Every frame is described from scratch and drawn on the GPU through SDL_GPU, or on the CPU by a software renderer that draws the same picture.
- Odin
- MIT
- three.js terms
- SDL_GPU · CPU
- glTF · 3MF · OBJ

By the numbers
- parity cases match, GPU vs CPU
- 49 / 49
- on Vulkan (RADV) and Metal (Apple M4); PSNR 43.8 dB (motion blur) to 71.1 dB (shapes) on RADV
- heap allocations a warm frame
- 0
- the software renderer, run by the benchmark under an allocator that panics
- model formats
- 3
- glTF 2.0 / GLB, 3MF and OBJ with MTL, into the same tables
- shadow-casting lights a frame
- 4
- directional or spot, with PCF
Parity from tools/gpu_check on o3d v0.1.0 with oksl v0.1.0, 2026-11-17, on an AMD Radeon RX 9070 series (Vulkan through RADV) and an Apple M4 (Metal); allocations from bench on v0.0.11, 2026-10-16 on an RX 9070 XT (Vulkan through RADV); formats and the shadow limit from the README.
What's in it
01What three.js knows carries over
Right-handed and Y up, Euler rotations in radians, a vertical field of view in degrees, and MeshStandardMaterial, MeshBasicMaterial, MeshToonMaterial and ShaderMaterial with three.js's parameters and light units.
02Two renderers, one picture
SDL_GPU on Vulkan or Metal, and a software renderer that is the reference the GPU is tested against. On Metal, checked on an Apple Silicon Mac (macOS 27): every tools/gpu_check case matches the software renderer. A CPU frame is the same bytes with or without a thread pool.
03Your own shaders
ShaderMaterial takes GLSL ES (three.js's GLSL 1 style, or GLSL 3) with three.js's built-in uniforms plus instanceColor and instanceId, compiled at run time by oksl for both renderers: no shader toolchain to install.
04Lights and shadows
Ambient, hemisphere, directional, point and spot lights; PCF shadows from directional and spot lights; image-based lighting from equirectangular environments, fog, and Linear, Reinhard, Cineon, ACES Filmic, AgX or Neutral tone mapping.
05Models people make
glTF 2.0 with node hierarchies, skins, morph targets, keyframe animation, punctual lights, texture transforms and quantized meshes; 3MF and OBJ load into the same tables and draw the same way.
06Geometry by parameters
Box, sphere, plane, cylinder and cone, torus and capsule, a lit tube through points each frame, lines, polylines, wireframes and point clouds; any draw can be instanced, with a colour per instance.
07Frames from scratch
A frame is a pure function of whatever drives it: the scene is refilled every frame, while geometry and textures are kept, and the same parameters give the same geometry id.
08Data-oriented
Flat tables, draws as a structure of arrays, interleaved 40-byte vertices, and skins and morphs in arrays of their own so plain meshes pay nothing. The CPU draws in bands of 32 rows, 4x MSAA on both renderers.
Not yet
- Compressed glTF (Draco, meshopt, KTX2 / Basis and WebP textures) fails cleanly when required; transmission, clearcoat, sheen and the other optional PBR extensions are ignored.
- No shadows from point lights.
- No textures that change every frame, and no textures in ShaderMaterials.
Use it
geos: o3d.Geometries // kept: geometry is made once
textures: o3d.Textures // kept: textures and mipmaps are made once
albedo, _ := o3d.texture_load(&textures, "brick.png")
scene: o3d.Scene // filled every frame
o3d.scene_clear(&scene)
scene.camera = {position = {0, 2, 6}, target = {0, 0.5, 0}, fov = 40, near = 0.1, far = 100}
scene.tone_mapping, scene.tone_mapping_exposure = .ACES_Filmic, 1.0
scene.fog = {kind = .Exp2, color = {0.05, 0.06, 0.08}, density = 0.04}
append(&scene.lights, o3d.Light{kind = .Hemisphere, color = {0.8, 0.9, 1}, ground = {0.2, 0.15, 0.2}, intensity = 1.5})
append(&scene.lights, o3d.Light{kind = .Directional, color = {1, 1, 1}, intensity = 2.5, position = {3, 5, 2},
cast_shadow = true, shadow = {map_size = 1024, bias = -0.0005}})
m := o3d.MATERIAL_DEFAULT
m.color, m.roughness, m.color_map = {1, 0.35, 0.3}, 0.4, albedo
m.flags = {.Cast_Shadow, .Receive_Shadow}
append(&scene.draws, o3d.Draw{o3d.box(&geos, 1, 1, 1), o3d.compose({0, 0.5, 0}, {0, t, 0}), m})// glTF 2.0 / GLB, 3MF and OBJ (model_load picks by extension)
duck, err := o3d.gltf_load("duck.glb", &geos, &textures) // err: .None, or why (GLTF_ERROR_TEXT[err])
o3d.gltf_draw(&scene, &duck, o3d.compose({-1.5, 0, 0}), anim = 0, time = t)
// ShaderMaterial: compiled once (same sources, same id), uniforms per frame
shaders: o3d.Shaders
wave, errors := o3d.shader(&shaders, vertex_glsl, fragment_glsl) // errors: "Fragment:3:7: ..."
w := o3d.MATERIAL_DEFAULT
w.shader = wave
w.uniforms = o3d.scene_uniforms(&scene, {"uTime", {t}}, {"uColor", {0.3, 0.8, 0.4}})
append(&scene.draws, o3d.Draw{o3d.sphere(&geos, 1), o3d.compose(), w})// GPU (o3d/sdlgpu): borrows the host's SDL_GPU device, or makes a headless one
g: o3d_sdlgpu.GPU
o3d_sdlgpu.init(&g, device)
out := o3d_sdlgpu.target(&g, 1920, 1080)
o3d_sdlgpu.render(&g, &scene, &geos, &shaders, out, 1920, 1080, cmd, &textures) // or nil cmd: submit and wait
// CPU: the same pixels, rows banded on the caller's thread pool
sw: o3d.Software
pixels := o3d.software_render(&sw, &scene, &geos, &shaders, 1920, 1080, pool, &textures)odin test . -collection:deps=.. # CPU tests (deps: the folder holding o3d and oksl)
odin test sdlgpu -collection:deps=.. # GPU tests
odin run tools/gpu_check -collection:deps=.. # every GPU-vs-software parity case, by PSNR
odin run bench -collection:deps=.. -o:speed # the zero-allocation software benchmark
odin run demo -collection:deps=.. -- out_dir # a test scene both ways, to PNGsThe family
- ocurves
Curve geometry: exact pixel coverage, and booleans that keep their curves
- ovg
2D vector graphics: paths, SVG, Lottie, text, filters
- oglyph
Fonts and OpenType text shaping, checked against HarfBuzz
- oicut
Video, audio and image codecs with no FFmpeg
- oksl
SkSL and Shadertoy shaders to SPIR-V, MSL and CPU
- o3d
3D in three.js terms, on the GPU or the CPU
- ottis
Text to speech with a time for every word
- odawg
Music from songs as data: synths, sampled instruments, an 808, a 909 and a 303, mixed and mastered
- onimite
Videos from Lua scripts, written by you or your coding agent