Ray Tracing Part II

In this part I will add reflection and refraction properties. Then I will add bounding volume to accelerate ray tracing.
I started with reflection. In this part, we need recursive ray tracing. We need to trace ray reflected from mirror objects.
Spheres: Before reflection
To get the reflection we need to reflect rays from object hit point. Then, we follow ray until it reaches max recursion depth or it hits a object which is not reflect light.
Spheres: After reflection
After that, I added refraction. There is two types of material types: Conductor, Dielectics. Conductors only reflect lights but not all of them. On the other hand, Dielectics both reflect and refract lights.
Cornellbox: Before refraction

Cornellbox: After refraction

Errors: While being implemented
Another example for dielectic material is scienceTree example. In this example, science tree is dielectic material. It looks like glass.
Errors: While being implemented
Science Tree is normal material
Science Tree is dielectic material
Then I started implementing BVH. In this part I have several iterations. Firstly, I started with just splitting bounding box from middle. This was slow because if you have more object in one side. It was not work well. I corrupts binary tree structure. Then, I sort every object in bounding box and I select the middle object. I split objects that are in the left side of middle object and right side. Thanks to that approach, I have binary bounding volume hierarchy.


Chinese Dragon : First BVH : around 40 minutes
Second BVH : 15 seconds
Third BVH : 13 seconds
Fourth BVH : 11 seconds
Fifth BVH : 9 seconds
Sixth BVH: 4 seconds
Other dragon: First BVH around 40 minutes
last BVH 17 minutes

In this example I have problem. Problem can be about input. I couldn't  find the problem. Everything is okey for other inputs. I will find the problem in this example. Problem is not about the refraction because in science tree it takes less than 2 second. This example should be around 10-20 seconds. 




Yorumlar