Repository navigation
Examples
github-actions[bot] edited this page Sep 24, 2026
·
15 revisions
examples/. Each example is one program that renders one image or animation into out/. make animation renders them all.
Run one by hand:
mkdir -p out
.venv/bin/mojo run -I . examples/cubes.mojo out/cubes.png| Example | Output | Page |
|---|---|---|
triangle.mojo |
triangle.png |
The smallest program that draws. |
spin.mojo |
spin.png |
Image files |
cube.mojo |
cube.png |
Why a software rasterizer |
cubes.mojo |
cubes.png |
Scene graph |
uv.mojo |
uv.png |
Why interpolation is perspective-correct |
textured.mojo |
textured.png |
Textures |
glass.mojo |
glass.png |
Why transparency is sorted |
floor.mojo |
floor.png |
Why mipmaps |
photo.mojo |
photo.png |
A decoded PNG on a cube. The README figure. |
lamps.mojo |
lamps.png |
Lights |
first_scene.mojo |
first_scene.png |
Render your first scene |
lit_scene.mojo |
lit_scene.png |
Light, texture and animate |
rotations.mojo |
rotations.png |
Rotations |
ortho.mojo |
cameras.png |
Cameras |
stereo.mojo |
stereo.png |
Cameras |
geometry.mojo |
geometry.png |
Geometry |
instances.mojo |
instances.png |
Meshes and assets |
raycast.mojo |
raycast.png |
Raycasting |
curves.mojo |
curves.png |
Curves and paths |
lines.mojo |
lines.png |
Lines |
sprites.mojo |
sprites.png |
Points and sprites |
television.mojo |
television.png |
Textures |
mirror.mojo |
mirror.png |
Textures |
outlines.mojo |
helpers.png |
Helpers |
keyframes.mojo |
keyframes.png |
Animation |
skinning.mojo |
skinning.png |
Skinning |
phong.mojo |
phong.png |
Materials |
physical.mojo |
physical.png |
Materials |
fog.mojo |
fog.png |
Fog |
culling.mojo |
culling.png |
Renderer |
split.mojo |
split.png |
Renderer |
clipping.mojo |
clipping.png |
Rasterization |
gpu_backend.mojo |
gpu_backend.png |
GPU backend |
exposure.mojo |
exposure.png |
Render target and framebuffer |
model.mojo |
model.png |
Model files |
orbit.mojo |
math.png |
Math |
clock.mojo |
units.png |
Units |
chain.mojo |
chain.png |
Why the scene graph is an array |
additive.mojo |
additive.png |
Why color is linear |
normals.mojo |
normals.png |
Why a normal is not a color |
fragments.mojo |
fragments.png |
Why shading is per fragment |
edges.mojo |
coverage.png |
Why coverage uses fixed point |
shadows.mojo |
shadows.png |
Lights |
wide.mojo |
wide.png |
Lines |
bloom.mojo |
postprocessing.png |
Post-processing |
gizmo.mojo |
controls.png |
Windowing and controls |
json_scene.mojo |
scenejson.png |
Scene JSON |
reloaded.mojo |
exporters.png |
Exporters |
gem.mojo |
transmission.png |
Materials |
distance.mojo |
distance.png |
Materials |
unfogged.mojo |
unfogged.png |
Materials |
targets.mojo |
targets.png |
Render target and framebuffer |
layers.mojo |
layers.png |
Materials |
graph.mojo |
nodes.png |
Node materials |
basis.mojo |
ktx2.png |
Textures |
coats.mojo |
coats.png |
Materials |
skyjson.mojo |
environment.png |
Scene JSON |
daylight.mojo |
sky.png |
Scene objects |
faces.mojo |
faces.png |
Meshes and assets |
utah.mojo |
teapot.png |
Geometry addons |
blobs.mojo |
blobs.png |
Scene objects |
photo.mojo takes the image path first: examples/photo.mojo assets/brick.png out/photo.png.
viewer.mojo writes no file. It opens a window in the terminal, and make viewer runs it. See Windowing and controls.
Animated outputs are APNG files. A browser or VS Code plays them. A viewer that does not know APNG shows the first frame.
| Program | Shows |
|---|---|
bench/raster_bench.mojo |
CPU against GPU rasterization across image sizes. |
bench/scene_bench.mojo |
Each stage of the CPU renderer, one worker and every core. |
tools/bench_examples.py |
Every example against three.js, and the Mojo 1.0 probe. |
The recorded tables live on Benchmarks. The refresh command is in How to measure examples.
| Program | Shows |
|---|---|
tools/gpu_status.mojo |
Whether an accelerator is present. |
tools/doc_lint.mojo |
Whether the documentation follows the writing rules. |
Tutorials
How-to
Reference
- Scene graph
- Rotations
- Cameras
- Geometry
- Geometry addons
- Lofts and clipping groups
- Sculptor
- Procedural generators
- Meshes and assets
- Lines
- Points and sprites
- Helpers
- Scene objects
- Animated objects
- Raycasting
- Curves and paths
- Animation
- Skinning
- Materials
- Node materials
- TSL functions
- Lights
- Lighting addons
- Fog
- Textures
- Renderer
- Renderer hooks and material flags
- Rasterization
- GPU backend
- Render target
- Post-processing
- GPU computation
- Compute nodes
- Progressive light map
- Gaussian splats
- Voxel global illumination
- SVG renderer
- Image files
- Image decode queue
- Model files
- More model files
- Exporters
- Scene JSON
- Windowing and controls
- Math
- Norm consumers
- Math addons
- Units
- Coverage tool
- Commands
- Examples
- Benchmarks
- Extensions
- Shared physics
- Physics query snapshots
- Continuous collision
- Tick force restoration
- Water
- Streamline
- Animals
- Buildings
- CARLA
- Femur
- Tibia
- Fibula
- Patella
- Knee
- Muscles
- Vessels
- Lymph
- Nerves
- Integument
- Leg
- Foot
- Pelvis
- Torso
- Arm
- Hand
- Head
- Genome
- Game humanoid
- Humanoid fidelity
- Audio-aligned game faces
- Converted assets
- Mesh quality
- Segment inertia
Explanation
- Software rasterizer
- Scene graph as an array
- Linear color
- Normals are not colors
- Perspective correction
- Fixed-point coverage
- Per-fragment shading
- Mipmaps
- Sorted transparency
- Types and checks
- Render hooks as a trait
- Shared CPU and GPU code
- Bands and threads
- PNG structure
- Extensions beside the port
- CUDA teardown hang
- Mojo compiler hang