new in 2020.06
Ray TracingSimple iterative CPU ray tracing.
Implementation of a simple CPU 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.
Controls
- mouse drag rotates the camera
- Shift mouse drag pans the camera
- mouse wheel zooms in/out
- R resets the camera to its original transformation
- D toggles Depth-of-Field
- M toggles marking the next rendered block by a different color
- N generate a new random scene
- Space pauses/resumes 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)
Credits
This example was originally contributed by Nghia Truong.
Source
Full source code is linked below and also available in the magnum-examples GitHub repository.
- Camera.h
- CMakeLists.txt
- Materials.h
- Materials.cpp
- Objects.h
- Objects.cpp
- RayTracer.h
- RayTracer.cpp
- RayTracingExample.cpp
- RndGenerators.h
The ports branch contains additional patches for Emscripten support that aren't present in master
in order to keep the example code as simple as possible.