# A Shader-Based Ray Tracing Engine
## 4 Implementation Results  
Our ray-tracing engine runs on Windows 10 and is based on the C++ programming language with Visual Studio 2019 development environment. The _OpenGL_ graphics library [44; 45] has opted for more elegant codes. The rendering environment is Nvidia GeForce GTX 1070 graphics card and Intel Core i7-6700K 4.00 GHz CPU. To analyze our implementation, we used three different animation scenes for the test cases: tavern, radio, and spaceship, as shown in Figure 12. As presented in Figure 5 and Section 3.1, our implementation starts from constructing BVH trees, for overall speed-ups. The heat map in Figure 13 proves that the binned BVH tree structure is consistent to the original tree, which was constructed without accelerated binning techniques. Table 1 is the performance result of the tree construction with and without _primitive binning_. Results are evaluated by averaging 100 tests per model. Table 1 shows that the binned construction is 6.631 to 16.391 times accelerated. Note that this result is only for the BVH tree construction. We should include the reflection calculation steps. Figure 12: Three different scenes for test cases. Figure 13: BVH tree structures, compared with respect to the heat map. We were able to achieve modest interactive ray traced illumination with the _OpenGL compute shader_, as shown in Figure 14. The _roped BVH acceleration_ structure and the _upsampling technique_ enabled us to boost rendering performance. All scenes were rendered with 2 ray bounce limit and 100 sampling in its resolution. Note that the _ray bounce count_ and the _ray sampling count_ are the important control factors for the speed of the overall ray-tracing process. With our current hardware configuration, 2 ray bounces and 100 samplings per pixel are the limits for real-time processing. Figure 14 and Table 2 shows the rendering result and performance of our experimental scenes. Figure 14a shows the normal ray-traced images, without roped BVH acceleration and upsampling techniques. Figure 14b represents our ray-traced results with all acceleration techniques are applied. Figure 14c represents the pixel-by-pixel differences between Figure 14a,b. The rendering performances are shown in Table 2. The final acceleration ratio shows that our final results are accelerated at least 2.478 to 13.618 times (maximum). The pixel-by-pixel error measures are shown in Table 3. We denoted the errors as percent values with respect to the pixel value ranges. Since we use 256-levels for each color channels, the 50% error means 128 level differences in its absolute pixel values. As shown in Table 2, the error values show the mean values (\(\mu\)) from 0.215% to 0.854%, and standard deviations (\(\sigma\)) from 0.680% to 0.990%, as their statistical values. Assuming the normal distributions, we can expect that more than 95% of the pixel-by-pixel errors are less than the value of \(\mu+2\sigma\), or 1.977%-2.767%. Finally, we can expect that almost pixel-by-pixel errors are bound less than 3% of the actual pixel values. In the case of minimum and maximum error values, we have some outliers, unfortunately. Table 2 shows that at most 77% error was found, as one of the worst cases. Fortunately, they are very restricted cases to the sharp edge areas, due to the limitations of the joint bilateral upsampling. At the edge boundaries, the joint bilateral upsampling cannot avoid to fail the accurate ray-object intersections and also ray-reflection calculations. These artifacts are drawbacks of our acceleration scheme, and will be investigated in the future. \begin{table}
\begin{tabular}{c c c c} \hline  & **(a) Naive** & **(b) Binned** & **Acceleration** \\  & **Construction** & **Construction** & **Ratio** \\  & **(Prev Method)** & **(Our Method)** & **(a)/(b)** \\ \hline tavern & 137,847 & 20,787 & 6.631 \\ radio & 281,897 & 20,172 & 13.974 \\ spaceship & 262,211 & 15,996 & 16.391 \\ \hline \end{tabular}
\end{table} 
Table 1: The BVH tree construction performance for three different models (unit: usec).