Post

Coding a Ray Tracer

Coding a Ray Tracer
1
Ray Tracer, Ray Tracing, Image Modeling, Phong Model, Image Rendering

Subject

For this course project, the goal was to do something with a personal implementation of a ray tracer.

My base implementation was able to render objects in space like those spheres:

Project

I decided to implement the support of height maps, by creating them randomly with a diamond-square algorithm and discretizing their complex form into smaller ones (triangles) to ease the ray tracing process.

This pipeline can give this kind of output:

Performances Enhancement

The problem for creating visualy attractive maps, is that a lot of triangles are required, and therefore the computation time increases a lot. To counter this, I found a trick to ignore most of the triangles during the ray tracing process.

I decided to consider maps as a cuboids:

Then, the cuboid could act as a hitbox and give interesting informations on the ray that was launched during calculations, esentially where it was entering and exiting the cuboid:

In the end, it reduces the number of triangles to check when searching which objects in the scene get intersected by the launched ray of light.

I did some benchmarks, which showed that this method was indeed speeding up the computation process:

Final Results

Finally, I was able to have those results, with maps containing millions of triangles:

This post is licensed under CC BY 4.0 by the author.

Trending Tags