See on Gitlab
A Physics based Renderer using Ray Tracing in C++.
Scroll ↓
The goal of this project was to allow us to build a Ray Rracing rendering engine from scratch. The only part given to us was a function to export the final image.
I started by implementing a simple Sphere using Phong shading.
I implemented proper shadow using bouncing rays.
The next step was to implement refraction. The first sphere has a different refraction index. The leftmost one is very low, akin to a plastic ball. The middle one is medium, closer to water or glass. The right one is super high and would give result like diamond.
Then we test reflection using a mirror in the background. This is also when the number of ray start to get rather important. So rendering time start to ramp up significantly.
Sphere material using a physical based absorption formula. Here we can see that the closer to the center of the sphere we are the darker the result is.
More complex objects are being rendered via a ray-marching method using formula from Inigo Quilez’s site. The advantage of this method compared to using polygon based models is that they are infinitely scalable while retaining perfect curvature.
This is the final render. It is 900x670px, using anti-aliasing techniques and it took me 8 hours to render on an Intel Core i7 3770K.