A single-source GLSL path tracer in 111 lines of code, based on Kevin Beason's smallpt.
Platform: Windows (tested on MinGW 64 and GCC version 8.1.0)
Make: g++ -O3 pocketpt.cpp -o pocketpt -lopengl32 -lgdi32
Run: ./pocketpt <samplesPerPixel=1000> <y-resolution=400>
The following shows the timings and result renderings at 1620x1080 resolution and different number of samples per pixel achieved on a Core i7-8565U CPU with Intel UHD 620 Onboard Graphics (click to enlarge).
16 spp | 80 spp | 400 spp | 2000 spp | 10000 spp |
6 sec | 25 sec | 114 sec | 10 min | 48 min |
The GLSL path tracing code is generally performed in float precision, with the exception the sphere intersection code in lines 59
- 61
, which uses double-precision. This precision is required due to the huge radii of spheres used for the Cornell box construction. When using smaller spheres or other primitives to define the boundary planes, one can change these lines to float precision, which comes with a considerable performance speedup. However, the code was published as is for better comparability and to better comply with Kevin Beason's original scene definition.
Special Thanks go to Peter Houska, and of course Kevin Beason for publishing the original code.