CPU Ray Tracer

CPU Ray Tracer C++


Features

  • Ray Tracer
  • C++
  • Area Lighting
  • BVH
An area light being used to illuminate a dog.

This project was to create a CPU ray tracer that uses a BVH to illuminate a scene with models. Materials were also implemented to make the surface more realistic.

The rays were fired out from the camera origin through the image plane and returns all the hits on objects. When the ray hits an object it fires off multiple rays (shadow rays) in the direction of the light (only 1 if it is a point light) and returns the sum of these divided by the number of shadow rays. The pixel is then set to the colour that is returned.

A BVH (bounding volume hierarchy) is used in the to make it for efficient for collisions between the ray and objects. It generates bounding boxes around groups of triangles based of the cost of checking collisions (traversal cost). Then smaller bounding boxes are created around smaller groups of triangles within the larger groups. This continues until the traversal cost is lower than just looping through the triangle. The BVH is then traversed using nodes which connect to each other.

A BVH example thats shows the multiple levels of bounding boxes and nodes. (Source - NVidia: https://developer.nvidia.com/blog/thinking-parallel-part-ii-tree-traversal-gpu/)

What I Learned

  • Consolidated my understanding of C++
  • Introduced me to Ray Tracing
  • Improved my understanding of 3D maths
  • Introduced me to spatial data structures

Project Details

Date: Apr 15, 2020

Author: Lewis Bond

Categories: project

Tagged: Ray Tracer, AT, UWEGames, C++, University

Client:

Website: https://github.com/lbondi7

Related Works.

About

Those who can do and those who can't teach games design.

Our Bunker



United Kingdom.