Raytracing With C++
- Adrian Aquino-Neary
- Apr 16, 2023
- 2 min read
This is a Raytracing side project that created using the Raytracing In One Weekend series of tutorials. The ray-tracer is not real time however and saves the result into an image using the C++ stb image library. However, despite not being real time, some attempts were made to optimise it.
The public GitHub repo is found here. There are many versions, of which I rewrote the ray-tracer from scratch using the things I learned while making the other versions, either from mistakes I made or from researching later.

After fully following the tutorial I also added features not included in the tutorials.
Fresnel: The ray-tracer implements fresnel to simulate real world behaviour of light. This simulates that the greater the angle that the light has bounce off the less likely it is absorbed by the material
Sampling with Noise: Using sampling, the raytracer hopefully generates a better quality scene by sending multiple rays per pixel up to a maximum amount of sample.
A noise function is used to scatter the rays instead of sampling from the same point.
A rudimentary version of adaptive sampling is also used - which was inspired by Blender's Adaptive Sampling feature
It stops sending out rays as soon as the pixel becomes too similar to previous samples by using a certain threshold difference between them.
Textures & Normals: The first ever version (stored in the v1 branch) is able to support three textures - albedo, normal and the material properties (which stores roughness, metalness & emission).

Future Plans
Real time rendering using an engine which utilises the GPU, as currently, every calculation is done on the CPU
Potentially use CUDA
Denoising using a denoising library to clean up noise on the generated image from using low samples
Adding more objects and read an obj file.
Implement an HDRI as the background for scenes.






Comments