Ray Tracer / Physics Based Renderer (PBR)

Random Scene Rendered with 1000 rays per pixel

Visit the Ray Tracer Repository

What is a Ray Tracer?

A Ray Tracer simulates a world/scene, particular the physics of the light rays that bounce around the scene, hitting any object that populate that world. This considers how light bounces/transmits/scatters off of these objects, and how it gets focused onto a camera/sensor to eventually be turned into an image.

Key Features:

  • Positionable Camera
  • Defocus Blur (Depth of Field): notice how objects very close/far away are out of focus (that's intentional)
  • Anti-aliasing: Helps objects look more realistic (avoiding that jagged pixelated images.
  • Materials: Determing how light behaves when hitting the surface
    • Diffuse Materials: Any non-reflective material, that scatters light in all directions
    • Metals (Reflective): Bounces in a particular direction, like it would off of a mirror
    • Dielectric (Transparent, like glass): Goes through material, based on ratio of indexes of refraction.

What was the purpose of this project?

The project itself is exciting for me. I've build simple 2D game engines before, but 3D graphics is very new territory. It opens up a new world of tools, and it's very compelling visually. My Fiancee is a 3D artist as well, so I'm always hearing about these concepts, and now I finally understand them.

This project also immersed me in C++, building experience with the language, and particularly with a mindset of writing highly efficient/optimized code. This project does not use any external libraries. All the math behind the rays is handling within this repo.

Acknowledgements

  • Peter Shirley who wrote a great beginner book on ray tracing, which was the foundation for this!
  • The Cherno: Great C++ resources and optimization tips

View full source code on githubGitHub