smallpt
v1.099-line educational global illumination renderer demonstrating Monte Carlo path tracing in minimal C++
Development Activity
Commit activity data is not available for this renderer.
Sample Renders
Overview
Best for
First introduction to path tracing for students and self-learners, demonstrating the core Monte Carlo rendering algorithm in absolute minimum code, and as a starting point for building educational renderers
Not ideal for
Any practical rendering — not for production, research benchmarking, or any task beyond education and algorithmic demonstration
Strengths
- Demonstrates that a complete, physically correct Monte Carlo path tracer with global illumination, specular reflection, and refraction fits in just 99 lines of C++ — an unmatched demonstration of algorithmic elegance
- Zero external dependencies and no build system complexity — compiles with a single g++ command on any platform with a C++ compiler, making it the most accessible possible introduction to rendering
- Has spawned an entire ecosystem of educational extensions (GPU versions, volumetric variants, annotated expansions) that collectively form one of the best introductory resources for understanding path tracing
- The underlying algorithm is physically correct — an unbiased Monte Carlo estimator with Russian roulette termination — not a toy approximation, but a real solution to the rendering equation
- Universally cited in university computer graphics courses, conference talks, and textbooks as the canonical example of the minimum viable path tracer
Limitations
- Supports only sphere primitives with no triangle meshes or arbitrary geometry, making it unsuitable for any rendering task beyond its single hardcoded Cornell Box scene
- The 99-line version uses deliberately compressed code formatting that is nearly unreadable — educational value comes primarily from community-created annotated and expanded versions
- No scene file format, no configuration, and no material system — every change requires modifying and recompiling the source code
- No features beyond basic path tracing — no textures, no volumetrics, no depth of field, no motion blur, no denoiser, no acceleration structure, and brute-force O(n) intersection testing
- Exists purely as a teaching tool and demonstration — attempting to extend it into a practical renderer defeats its purpose and is better served by starting with PBRT or Tungsten
Background
smallpt is a global illumination renderer written in just 99 lines of C++ by Kevin Beason in 2007. It implements a fully functional, physically correct unbiased Monte Carlo path tracer with Russian roulette path termination, tent filter anti-aliasing, and support for diffuse, perfectly specular, and ideal refractive (glass) surfaces. The entire scene — a modified Cornell Box with two spheres — is hardcoded in the source. Despite its extreme brevity, the algorithm is not an approximation: it produces a mathematically correct solution to the rendering equation.
The renderer uses only spheres as geometric primitives, performs brute-force ray-sphere intersection testing without any acceleration structure, and outputs a single PPM image file. It has no external dependencies beyond the C++ standard library and OpenMP pragmas for optional parallelism. The 99-line version is deliberately compressed and nearly unreadable; the educational value comes primarily from annotated and expanded versions created by the community, which typically span 200-300 lines. Configuration is limited to resolution and sample count via command-line arguments or source code modification.
smallpt is arguably the most famous minimal renderer in existence and occupies a unique niche in the rendering ecosystem. It has spawned an entire family of educational extensions — smallptGPU, smallpaint, smallvol, and numerous annotated versions — that collectively form one of the best introductory resources for understanding path tracing. It is universally cited in university computer graphics courses, conference talks, blog posts, and textbooks as the canonical example of how simple a physically correct global illumination renderer can be. It is the "hello world" of path tracing.
Quick Start
Visit the repository for installation instructions for smallpt.
View RepositoryRelated Renderers
Community & Resources
Tutorials & Resources
Performance Benchmarks
No benchmark data available for smallpt yet.
Benchmarks will be added as more renderers are tested across our standard scene suite.
Learn about our methodology