Skip to main content

tinyraytracer

v1.0

Ultra-minimal educational ray tracer in approximately 250 lines of C++ demonstrating core rendering concepts without external dependencies

Ray Tracing
C++
MIT
Archived
CPU
Stars
5.2k
Latest Release1.0
Release DateFeb 2019
Contributors8
Forks500
At a Glance
Technique
Ray Tracing
Language
C++
License
MIT
Platforms
Linux
macOS
Windows
GPU Support
No
CPU Support
Yes
Scene Formats
Hardcoded
Output Formats
TGA
First Release
Jan 2019
Latest Release
1.0 — Feb 2019
Best For
Absolute beginners seeking the quickest possible introduction to ray tracing concepts, and students who want to understand ray-sphere intersection and basic lighting before tackling more comprehensive resources

Development Activity

Commit activity data is not available for this renderer.

5.2k
Stars
1.0
7 years ago
8
Contributors
View on GitHub

Overview

Best for

Absolute beginners seeking the quickest possible introduction to ray tracing concepts, and students who want to understand ray-sphere intersection and basic lighting before tackling more comprehensive resources

Not ideal for

Learning physically based rendering, any practical rendering task, benchmarking, or anyone who already understands basic ray casting

Strengths

  • Extreme minimalism — the entire ray tracer fits in approximately 250 lines of readable C++ with zero external dependencies, making it the quickest possible entry point for understanding ray tracing
  • Commit-by-commit tutorial structure isolates each concept (spheres, lighting, shadows, reflections, refractions) so learners can understand each feature independently
  • Part of a coherent educational ecosystem: tinyrenderer (rasterization), tinyraytracer (ray tracing), and tinykaboom (ray marching) together cover the three fundamental rendering approaches
  • No build system complexity — a single g++ command compiles the complete program, eliminating all tooling barriers for beginners
  • The code is deliberately straightforward with no templates, abstractions, or cleverness — pure instructional clarity prioritized over elegance

Limitations

  • Covers only Whitted-style recursive ray tracing — does not teach path tracing, Monte Carlo methods, or physically based rendering, limiting its depth as a learning resource
  • No anti-aliasing, importance sampling, or noise handling means output images have visible aliasing artifacts that production renderers solve
  • Extremely limited scene complexity — hardcoded spheres and planes only, with no scene description format or ability to load external models
  • Not maintained or updated — it is a finished tutorial artifact, so no new features, fixes, or community engagement should be expected
  • Outputs only TGA format, requiring conversion for modern use

Background

tinyraytracer is an educational ray tracing tutorial by Dmitry V. Sokolov (ssloy) that builds a complete Whitted-style ray tracer in approximately 250 lines of C++ with zero external dependencies. Created in 2019 as part of a series of "tiny" educational graphics projects (alongside tinyrenderer for software rasterization and tinykaboom for ray marching), it teaches ray-sphere intersection, Phong lighting, shadow rays, reflections, refractions via Snell's law, procedural checkerboard textures, and environment mapping through a commit-by-commit tutorial structure.

The tutorial is structured so that each git commit adds exactly one new feature, allowing learners to follow the progression from a blank canvas to a complete scene with reflective and refractive spheres on a checkerboard floor. The output is a TGA image file, and the entire program compiles with a single `g++` invocation. The code deliberately avoids templates, abstractions, and clever optimizations — every line is straightforward and instructional. Unlike Shirley's books which teach path tracing and Monte Carlo methods, tinyraytracer covers only Whitted-style recursive ray tracing with deterministic shading.

tinyraytracer occupies the niche of "absolute minimum viable ray tracer" — even more minimal than Ray Tracing in One Weekend. It is designed for complete beginners who want to understand the very basics of ray tracing (ray generation, intersection, reflection, refraction) before progressing to more sophisticated resources. The companion project tinyrenderer teaches software rasterization using the same minimalist philosophy, and together they provide a comprehensive introduction to the two fundamental rendering paradigms.

Quick Start

git clone https://github.com/ssloy/tinyraytracer && cd tinyraytracer && g++ -O3 tinyraytracer.cpp -o tinyraytracer

Community & Resources

Tutorials & Resources

Performance Benchmarks

No benchmark data available for tinyraytracer yet.

Benchmarks will be added as more renderers are tested across our standard scene suite.

Learn about our methodology