Ray-tracer


SMFL framework which can ray trace models on the CPU

 
 
  • Date: 08/03/2020

    Languages: C++

    Keywords: Ray-tracing, Graphics, SFML

 

Overview

CPU based ray-tracer. It uses SFML to create a window to render onto. This entails firing rays out of a camera, through a pixel, and into a virtual scene. These rays are tested for intersections against objects within the scene. This is done by the ray traversing through the objects bounding volume hierarchy (BVH) to greatly increase the ray-tracer’s performance. The respective pixel’s colour is then set to the colour of the object at the intersection position. This colour is also affected by lighting and shadows that are computed.

Colours

The colour of an object at an intersection position is determined when a ray intersects with an object’s triangle. The intersection calculation produces the barrycentric coordinates of the intersection which can be used to determine texture coordiantes to find the colour of the object’s texture at that point.

Shadows and Lighting

To compute shadows secondary rays known as shadow rays would be fired out from the intersection position of normal rays. These shadow rays would be aimed towards the light source in the scene and would be checked for intersections with other objects. If an intersection occurs then the light source is occluded from the original object at the point of intersection and therefore should be in shadow.

The ray-tracer also uses these shadow rays as part of its two different types of lighting: point lighting and area lighting. Point lighting is a light source at a specific point in the scene and changes the colour of objects based upon its colour and intensity as well as its distance away from the object in question. Area lighting is a light source covering a defined area. It uses multiple point lights within the area to determine average lighting values. Point lighting provides hard, distinct shadows whereas area lighting produces softer shadows.

Threading

The ray-tracer uses threads to further increase its performance. The pixels in the camera’s screen are split into blocks. Each thread in a pool of threads is then provided with a block of pixels to render. Once a thread has fully rendered a block they are provided with another until all the pixel blocks have been rendered.

 

Demo video

Video demonstrating the ray-tracer, as well as the plant generator and face autoencoder, also made alongside this project.

 
 
Previous
Previous

Firestar - Internship Project

Next
Next

DirectX11 Plant Editor