Ray Tracing Part I

This is the first part of Ray tracing. In this part we have basic ray tracing which includes basic phong shading and it supports ray-triangle, ray-sphere and ray-mesh intersections. It uses threading to speed up. You can see the different between threading and without trading results.

First example is simple.xml file. It contains 3 basic objects
 It took 0.76 seconds with 8 threads.
 It took 0.86 seconds withoud threading. We can see difference even in simple scenes.


It took 0.89 seconds with 8 threads.
It took 1.25 seconds without threading.
In this example we have only two sphere but we have shading and shadows. It has impact on performance. First scene took 0.76 seconds but this took 0.89 seconds.

It took 16.08 seconds with 8 threads.
It took 85.21 seconds without threading.
Science tree example took much more time than first two example because this example has too many vertices and triangles. In this part, to understand whether a ray intersect with object, we look every object's triangle and check that whether ray passes inside this triangle or not. Thus, if we increase triangle count, we do one more calculation for each ray. For example if we work on 1920 * 1080 resolution, If we add one more triangle we do  around 2 million extra calculations.
Spheres result

It took 7.89 seconds with 8 threads.
It took 38.31 seconds without threading.
In science tree example we have less vertices and triangle than bunny example. However, science tree example took more time. Actually, bunny example has much more intersection calculations than science tree example. However, there is another factors that have impact on speed. In science tree we have 1440*720 resolution. On the other hand  bunny has 512*512 resolution.In the bunny we do  42839 times shading calculations and in science tree, we do 582168 times shading calculations. Thus, science tree example took much more time.

In the first part of the ray tracing, we see that threading has a great impact on speed and if we increase resolution or triangle count it decreases speed. In the second part we will find a way to speed up our algorithm.

Yorumlar