Examples » Ray Tracing new in Git master

Simple iterative ray tracing.

This is an implementation of a simple ray tracer adapted from Peter Shirley's book Ray Tracing in One Weekend. The current implementation runs on single thread and performs iterative rendering to refine the result. Typically, a high quality image can be achieved after around 100 iterations.



  • mouse drag rotates the camera
  • Shift mouse drag pans the camera
  • mouse wheel zooms in/out
  • R reset the camera to its original transformation
  • D toggle Depth-of-Field
  • M toggle marking the next render block by a different color
  • N generate a new random scene
  • Space pause/resume rendering

Additionally, various options can be set via command line:

  • --block-size PIXELS — size of a block to render at a time (default: 64)
  • --max-samples COUNT — max samples per pixel (default: 100)
  • --max-ray-depth DEPTH — max ray depth (default: 16)


This example was originally contributed by Nghia Truong.


Full source code is linked below and also available in the magnum-examples GitHub repository.