First Journey Into Ray Tracing
Well this is my first post in this blog. Normally I was planning to be more poetic but since I could not figured out the bug in my ray tracer and since my mind is thinking in terms of triangles rather than words, I will keep it as simple as possible.
I’ve built my ray tracer on a Macbook Pro with following CPU specifications:
2.2GHz quad-core Intel Core i7 processor (I7-4980HQ)
(Turbo Boost up to 3.4GHz) with 6MB shared L3 cache
Render times are as follows:
Rendered model simple.png in 0.148414 seconds
Rendered model simple_shading.png in 0.191162 seconds
Rendered model bunny.png in 69.194954 seconds
Here are my initial results from my ray tracer:
![Simple rendering of basic shapes](https://istemi-bahceci.github.io/blog/assets/1/simple.png)
Figure-1: Simple rendering of basic shapes
![Simple shading](https://istemi-bahceci.github.io/blog/assets/1/simple_shading.png)
Figure-2: Simple shading of sphere
![Rendered bunny model](https://istemi-bahceci.github.io/blog/assets/1/bunny.png)
Figure-3: Rendered bunny model with shading
As it can be seen from the last image, there are some problems in terms of triangle normals in rendered bunny mesh. I suspected that it might be because of normals of some triangles in the mesh are not properly calculated so I rendered normals as below, but still could not figured out the problem yet. I will update this post whenever I find the bug :)
![Rendered normals of simple shapes](https://istemi-bahceci.github.io/blog/assets/1/simple_normal.png)
Figure-4: Rendered normals of simple shapes
![Simple sphere shading](https://istemi-bahceci.github.io/blog/assets/1/simple_shading_normal.png)
Figure-5: Rendered normals of sphere model
![Rendered normals of bunny model](https://istemi-bahceci.github.io/blog/assets/1/bunny.png)
Figure-6: Rendered normals of bunny model
Update on 2017-03-15 ~ 2:15 AM
I finally fixed the problem in my ray tracer, YAY !!! I was trying to be smart in the mesh intersection function of my ray tracer where I return the function as soon as I find first triangle in mesh that intersects with the incoming ray.
Since I was discarding back-facing triangles in my triangle intersection method I was sure that I will end up seeing only the front facing triangles in scene and rays would intersect in one of them so first intersection would be enough. This was a silly mistake that I learned much from it, thanks to the rendered normals :)
![Rendered normals of simple shapes](https://istemi-bahceci.github.io/blog/assets/1/simple_final.png)
Figure-7: Final rendering of simple shapes
![Simple sphere shading](https://istemi-bahceci.github.io/blog/assets/1/simple_shading_final.png)
Figure-8: Final rendering of sphere model with shading
![Final rendering of bunny model](https://istemi-bahceci.github.io/blog/assets/1/bunny_final.png)
Figure-9: Final rendering of bunny model with shading