Cinematic Ray Tracer
By Alex Yuan→Description
For this showcase, I augmented the standard Ray Tracer to produce a “Cinematic” rendering effect. The goal was to move away from the perfect, sterile look of a pinhole camera and simulate a real-world camera lens.
Features Added:
Depth of Field (Defocus Blur)
- Implementation: In
main.cpp, I modified the ray generation logic. Instead of all rays originating from a single point (pinhole), I simulate a lens aperture. Rays are jittered on a disk around the camera origin (camera.e) and directed towards a focal point on the focal plane. - Effect: Objects at the focal distance remain sharp, while objects closer or further away become realistically blurry.
- Implementation: In
Anti-Aliasing (Super-Sampling)
- Implementation: In
main.cpp, I implemented a loop to cast multiple rays (50 samples) per pixel. Each ray’s screen coordinate is slightly jittered by a random amount. The final pixel color is the average of these samples. - Effect: This eliminates jagged edges (“jaggies”) on geometry and shadows, producing a much smoother, high-quality image.
- Implementation: In
Auto-Focus System
- Implementation: In
main.cpp, before the main render loop, I cast a single probe ray through the center of the screen to determine the distance to the nearest object. - Effect: This automatically sets the focal distance (
t_focus) so the main subject of the scene is always in sharp focus without manual tuning.
- Implementation: In
Acknowledgements
- Base Code: CSC317 Course Material (Ray Tracing Assignment).
- External Libraries:
Eigen: For linear algebra operations.nlohmann/json: For parsing scene files.
- Scene Data:
sphere-packing.jsonfrom the course data folder.
