
applied sciences Article A Shader-Based Ray Tracing Engine Sukjun Park 1 and Nakhoon Baek 2,3,4,* 1 KOG Inc., Daegu 41937, Korea; [email protected] 2 School of Computer Science and Engineering, Kyungpook National University, Daegu 41566, Korea 3 Department of Data Convergence Computing, Kyungpook National University, Daegu 41566, Korea 4 Dassomey.com Inc., Daegu 41566, Korea * Correspondence: [email protected]; Tel.: +82-53-950-6379 Abstract: Recently, ray tracing techniques have been highly adopted to produce high quality images and animations. In this paper, we present our design and implementation of a real-time ray-traced rendering engine. We achieved real-time capability for triangle primitives, based on the ray tracing techniques on GPGPU (general-purpose graphics processing unit) compute shaders. To accelerate the ray tracing engine, we used a set of acceleration techniques, including bounding volume hierarchy, its roped representation, joint up-sampling, and bilateral filtering. Our current implementation shows remarkable speed-ups, with acceptable error values. Experimental results shows 2.5–13.6 times acceleration, and less than 3% error values for the 95% confidence range. Our next step will be enhancing bilateral filter behaviors. Keywords: ray tracing; acceleration; bilateral up-sampling 1. Introduction Citation: Park, S.; Baek, N. A The usefulness of computer graphics in various fields has long been emphasized since Shader-Based Ray Tracing Engine. its origin [1,2]. Ray tracing is a graphics method, based on the individual optical path Appl. Sci. 2021, 11, 3264. https:// tracing to get realistic illustrations, as shown in Figure1. More precisely, this method traces doi.org/10.3390/app11073264 millions of rays (or optical paths), which are intersecting, scattering, and reflecting on object surfaces, with a huge amount of computations [3,4]. Mainly due to its computation Academic Editor: Rubén cost, it is considered as nearly impossible to carry it out on run time [5,6]. Usamentiaga With the need for the immediate visualization, graphics processors were demanded to be specialized in the traditional rasterization technique, consuming conspicuously lower Received: 13 February 2021 resources than the ray tracing in the cost of low precision [7,8]. Accepted: 30 March 2021 Published: 6 April 2021 Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affil- iations. Copyright: © 2021 by the authors. Figure 1. Example pictures of the traditional rasterization and the ray-traced rendering. Licensee MDPI, Basel, Switzerland. This article is an open access article In contrast, rasterization cannot compute optical phenomena such as scattering and/or distributed under the terms and reflection, resulting in comparatively unrealistic illumination as a result. Research has been conditions of the Creative Commons made to overcome this drawbacks, introducing novel ideas such as image-based lighting, Attribution (CC BY) license (https:// irradiance probe, pre-processed global illumination, and more [9–11]. More recently, hybrid creativecommons.org/licenses/by/ methods using both rasterization and ray tracing technique have been introduced to qualify 4.0/). Appl. Sci. 2021, 11, 3264. https://doi.org/10.3390/app11073264 https://www.mdpi.com/journal/applsci Appl. Sci. 2021, 11, 3264 2 of 14 the demands for truthful illumination and is still an ongoing topic; screen-space global illumination, voxel-based global illumination, and photon mapping are a few of them [12–16]. In this paper, we present our research and implementation of the real-time ray-traced rendering engine, tackling the previously known to be bound to the pre-rendering domain. We introduce the real-time implementation of a triangle primitive, based the ray tracing method on the top of the GPGPU compute shader, along with optimization and light ap- proximation techniques. We also present the solutions to the detailed issues, which we encountered during its design and implementation. 2. Related Works In computer graphics field, interactive realistic graphics results have long been pur- sued [17,18]. Ray tracing is one of them, but it has only recently been applied and commer- cialized due to its immense computing cost in real-time. Since it considers global illumination environment, rather than the traditional local illumination settings, the ray tracing is one of the global illumination and/or indirect illumination methods [6,19]. It enables the rendering pipeline to achieve more realistic graphics rendering, as shown in Figure1. Ray tracing is actually rendering an image by recursively tracing optical paths from the viewer’s eye to virtual light sources per pixel [5]. It considers reflection, refraction, and scattering to ultimately compose the luminosity upon the ray’s surface contact [20]. From its accelerated implementation point of view, we should consider two different aspects: global object management for the efficient ray-object intersection checks, and accelerated reflection computing at the intersection points. Reflection computing is again macroscopically divided into two parts: specular and diffuse. The specular reflection is a regular reflection on a mirror-like surface, and the diffuse reflection is a light scattering occurred on a rough surface, as shown in Figure2. specular reflection diffuse reflection Figure 2. Differences between the specular and diffuse reflections: specuclar reflections occur on mirror-like surfaces, while diffuse reflections shows light scattering effects. Theoretically, the rays can be traced infinitely, to get the huge number of reflected bounces. In contrast, practical implementations limits the reflection computing to get real- time results. The two major factors of the real-time reflection computing is: ray bouncing count and ray sampling count. These factors are also related to the final quality of the ray traced rendering images [6,20]. Specular reflection is highly associated with the ray bouncing count, which refers to how much will the single ray bounce between the object surfaces. Likewise, diffuse reflection is associated with the ray sampling count referring to how many rays will be fired on the reflection points. The sampling attribute also affects the anti-aliasing quality of the image, since it is actually one of the super-sampling methods. The ray bouncing is known to be significantly cost-effective than the ray sampling since it occurs seldom in the actual rendering environment; five to six bounces is more than enough in most rendering cases. Ray sampling, on the other hand, is the major reason why ray tracing lacks performance in real-time rendering all the time; due to its nature of omni-directional light scattering, not enough ray sampling will produce disturbingly noisy Appl. Sci. 2021, 11, 3264 3 of 14 illumination as a result. Figure3 depicts the performance and precision of the implemented diffuse reflection. 1 spp 3 spp 5 spp 3 ms 8 ms 14 ms 10 spp 50 spp 100 spp 27 ms 148 ms 336 ms Figure 3. Results of different ray sampling counts: High samples per pixel (spp) values give high quality images, with large amount of computing time (in msec). In our implementation, these ray bouncing counts and ray sampling counts can be controlled to compromise the final image quality and also the processing speed. Another aspect of the ray tracing computation is the global object management. Ray casting is the fundamental steps for performing the ray-object interactions. It is actually a procedure of ray collision checking in the virtual space [21,22]. The simplest form of ray casting is to compare all the primitives (or graphics objects) against the ray, taking the time complexity of O(n) against n objects in the scene. This per-ray operation therefore ought to get costly as the scene gets populated with more objects, leading the programmers to import the acceleration structure to reduce the cost down to logarithmic as a necessary step [23]. Two major methods lie for the ray casting acceleration structures: kd-tree and Bounding Volume Hierarchy (BVH) [24–27]. As an example, in Figure4, a set of triangles labeled with alphabets from A to F denotes the primitives in the scene. The kd-tree is one of the axis-aligned space partitioning methods which divides the current space into two separate child spaces recursively, to construct a binary tree, as shown in Figure4b. Bounding Volume Hierarchy (BVH), on the other hand, is also a binary tree, but it constructs a tree based on geometric objects, as shown in Figure4c. The kd-tree recursively divides the space into half, while the BVH tree recursively groups the graphics primitives and spaces. Note that the child volumes of the BVH structure can be partially overlapped. Recently, benchmarks show that BVH implementations are much better than traditional kd-tree structures [27,28], and we also adopt the BVH structure as our major data structure. Recent advancement of graphics hardware has allowed a great leap towards real-time ray-traced rendering [17,18]. Nvidia’s latest graphics processing units RTX series are the first runner of its kind; it supports real-time ray tracing with its specialized architecture [29]. While the RTX shows an astounding accomplishment, its technical features are rigidly bound to its physical hardware support. There are attempts to achieve real-time ray tracing support without utilizing special- ized hardware, better accustomed to welcome much general graphics processor owners. One of its latest and outstanding attempt is by Unreal Engine 4, the commercial game engine serviced since 2014 [30]. Its ray-traced global illumination feature can run without RTX Appl. Sci. 2021, 11, 3264 4 of 14 feature limitation. However, its ray-tracing pipeline is built-in to the engine, leaving us no freedom of customizing the illumination method. C A B D F E (a) target triangles A to F C 2 C 4 3 4 A B A B 1 3 5 D F D F 5 E E 2 1 1 1 2 3 2 3 A 4 5 F 4 5 C F C B D E A B D E (b) kd-tree representation (c) BVH representation Figure 4.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages14 Page
-
File Size-