__main__


  • I graduated from PhD in Economics at Cardiff University, U.K in July, 2022.

  • Vast interest in software development, currently developing web and API applications using Django and Rest Framework.

  • Contact Email: gabrielwong1991[at]gmail[dot]com

  • Previous academic research interest: Asset Pricing, Corporate Finance, Machine Learning (Natural Language Processing), Econometrics

A pet project in computer graphics

Outside of Economics and Finance, I have always been fascinated by the recent advancement in computer graphics, especially ray tracing.

Turns out there is a book by Peter Shirley's "Ray tracing in one weekend" that teaches you how to build a ray tracing engine from scratch quickly and I had a lot of fun in it.

At first, I thought this must be so complicated but turned out the math was surprisingly easy, it is mostly vector operations. More importantly, I am learning C++ in my spare time and this is a perfect project to learn about data structure, class, constructor, polymorphism, smart-pointers, etc...

The code is available here using C++20 and a precompiled version (1k resolution) is under x64>Release>raytracing.exe. Run in CMD as <your_path_to_file>/raytracing.exe >> picture.ppm and use this to open the file. - It will convert to PNG format.

In this version (1.0) I reformatted the code to my taste and added parallelism with OpenMP which cuts the rendering time to 1/4 with a 5950x CPU, I would also want to try CUDA but that is for later.

I have also added Bounding Volume Hierarchies (YouTube explanation) which makes the engine more efficient in searching for rays hitting the objects. However, from what I see the gain from using BVH is not that significant because the objects in the scene are spheres, for now, which renders from a simple sphere equation. What's beneficial with this algorithm is when generating millions of polygons stick together to form an object, you reduce the time computing when rays are hitting nothing.

Anyways, the picture below is the end result of this exercise. - A beautifully rendered scene with billions of rays bouncing on random spheres to create a picture. :)