Ray Tracer Using C++

Ray tracing is a rendering technique used in the field of computer graphics that has recently gained media attention due to consumer-grade technology like the Nvidia GeForce RTX series graphics cards. Ray tracing works by tracing the path of light through a computerized 3D environment to figure out what colors pixels on a screen should be. This project includes code for a C++ ray tracer that has support for various ray tracing features.

Sample Images

Basic Render Perspective & Anti-Aliasing Soft Shadows 3D Objects & Materials

Getting Started

Download the project by running git clone https://github.com/Greenninja4/RayTracer. You can view sample .ppm images generated by the ray tracer in the Images folder.

Running the Code

Run make in the project directory to generate the default ray tracer. The compiler used in the makefile is Clang++6.0. Then run ./Build/tracer to run the ray tracer. It will ouput a ray-traced image of the computerized world named image.ppm in the main project directory! In the terminal, the program will also show how long it took to render the image in seconds as well as how many rays were traced. Since this ray tracer is a CPU ray tracer, it will not be very fast compared to modern technology that uses parallelization and dedicated ray tracing hardware in GPUs.

Changing the World

To generate a different image, go into World.cpp. Find the build() function and uncomment one of the other lines, re-compile, and re-run for a different world. If you want to create your own scene, create a new build function in the Source/Build directory and then update the World.cpp and World.h files accordingly.

Authors

  • John Born

Acknowledgments

  • Kevin Suffern - Most of this project is based off of his "Ray Tracing from the Ground Up" textbook.
  • Eric Shaffer - Eric was my professor for the Fall 2018 course CS419: Production Computer Graphics at the University of Illinois at Urbana-Champaign. In that course, I implemented the base of this project and learned fundamental computer graphics concepts.

Included Features

This ray tracer implementes the following features which are common in various ray tracing applications

  • BRDFS: Glossy Specular, Lambertian, Perfect Specular, SV Lambertian
  • BTDFS: Perfect Transmitter
  • Cameras: Orthographic, Pinhole
  • Geometric Objects: BBox, BVH, Compound, CSG, Deformed, FastTriMesh, Instance, Plane, Rectangle, SmoothMesh, Smooth Triangle, Sphere, Triangle, Triangle Mesh
  • Lights: Ambient, Area Light, Directional, Point
  • Mappings: Rectangular Map, Spherical Map
  • Materials: Emmissive, Matte, Phong, Reflective, SV Matte, Transparent
  • Samplers: Jittered
  • Textures: Checker, Constant Color, Image Texture, Noise
  • Tracers: Area Lighting, Ray Cast, Whitted
  • Utilities: Constants, Image, Maths, Matrix, Ray, ShadeRec, Vector3D
  • World: ViewPlane