In lighting, “ray tracing” refers to emitting light beams from the camera or surface to other surfaces or lighting models (especially outside the camera view) to form light. The huge amount of calculation of this technology makes it only widely used in the fields of filmmaking and high-end visualization, but it has been limited by the number of frames in real-time content creation. Over the years, games have used another method to replace ray tracing, namely rasterization. To put it simply, rasterization means rendering screen pixels affected by specific lighting. In fact, it does not involve the concept of ray tracing, and it has certain limitations due to the nature of its screen space.
Fortunately, with the update and iteration of mainstream GPUs, ray tracing supported by hardware is becoming more popular, and ray tracing may soon become the new standard for generating lighting (especially on high-end platforms). The High Definition Rendering Pipeline (HDRP) has introduced a hybrid ray tracing pipeline that combines traditional rasterization and ray tracing technology, and uses ray tracing to reproduce such things as ambient light occlusion (AO), light reflection, global illumination (GI), Common light effects such as surface scattering and shadows.
The above picture and video show BMW’s 2019 8-series coupe, which is the result of the cooperation of Unity, NVIDIA and BMW. In the video, the seamless fusion of real-time shooting and ray tracing rendering produced incredible results, proving that real-time ray tracing technology can produce extremely realistic images under the premise of time-consuming and much lower cost than offline rendering.
Realize ray tracing with the new HDRP template
Unity 2020.2 launched a brand new HDRP template. We have introduced this template before. If you are interested, click here to review it.
I suggest you download Unity 2020.2, create a new project in Unity Hub, select the HDRP template, and click Create.
The new HDRP template uses rasterization technology to render lighting, using functions such as lighting baking, lighting probe groups, reflection probes, and shadow mapping. This article will introduce the 4 main ray tracing effects in HDRP, namely ray tracing ambient occlusion (Ambient Occlusion), light reflection (Reflection), global illumination (Global Illumination) and shadow (Shadow). Finally, the path tracing function of HDRP is introduced. Path tracing is a simpler and more rude light tracing calculation method. By extending the rendering time, in exchange for higher image fidelity.
Ray tracing ambient light occlusion (RTAO)
For more than ten years, screen space ambient light occlusion (SSAO) has been the main content of real-time rendering of games. It is used to simulate the diffuse light occlusion of the environment, improve the visual effect of the object contact area in the scene, and reduce the light intensity of the concave area. However, if the effect is too strong, it will produce a halo around the geometry, or even produce a cartoon appearance. In addition, it also inherits the main shortcomings of screen space technology, that is, it cannot generate masking effects based on off-screen objects, and can only use the depth information that appears in the z-buffer (z-axis buffer). But in terms of advantages, SSAO is still excellent at dealing with small area light occlusion in the camera, and the cost is relatively low.
With the help of ray tracing, the light outside the camera’s frustum can also be shot into the picture, allowing the light to shine on objects outside the picture, thereby allowing large objects in the cameraGenerate excellent macro occlusion effects.Although technically speaking, AO can only barely be counted as an environmental lighting technology, but it can well complement other lighting such as lightmaps, light probes, etc. The lower resolution and effect intensity of the latter are not enough to generate micro-lights. Obscured.
Ray traced light reflection (RTR)
Similar to SSAO, the screen space light reflection (SSR) can only reflect objects in the picture, and the surface outside the camera lens cannot reflect light. For example, when the camera angle of view is facing the ground, SSR technology will not be able to generate any light information. Therefore, the effect of SSR will be somewhat deviated, and it will be interfered by many factors, and even by yourself: In most static scenes, a properly positioned reflection probe can produce pleasing effects and reduce interference factors. However, where SSR is really useful is the specular reflection in the direction parallel to the line of sight (such as floors, walls, and ceilings). The most ideal way to use SSR is to use it in a camera with a fixed viewing angle, such as a racing game.
But with ray tracing, we canGet light information outside the screen, And use this to generate more accurate light reflections in the entire world or within a certain radius around the lens, and generate lighting effects based on the Light Cluster and the light exposure distance.
Ray Traced Global Illumination (RTGI)
One of the most representative features of ray tracing isReal-time global illumination, That is, the emitted light is used to generate indirect lighting. To put it simply, it is to let the light bounce in the environment.
Usually in game engines, indirect lighting is processed using pre-calculation or baking techniques, including light probes and light maps, but the disadvantage of the technology is that it takes time to calculate and increase the iteration time of scene lighting.
HDRP introduced two RTGI technologies: high performance and high quality. The former is suitable for achieving high frame rates under direct light, while the latter can handle multiple reflections and sampling of light, and can generate accurate light effects in complex indoor environments. Of course, the computational cost is also very high.
Ray traced shadows
HDRP comes with exquisite shadow effects. When the quality of shadow filtering is high (PCSS), the texture generated by the pipeline can simulate the natural softness of shadows to ensure the sharpness of shadows around the projected object and imitate real shadows. However, when the filtering quality is medium, the result is not satisfactory. The entire shadow map will be filtered indiscriminately, and the distance between the projected object and the received object will not affect the effect.
Ray tracing shadows can significantly improve the shadow effect. By projecting rays from the surface to the light to calculate the occlusion area between the two, the resulting shadow is very close to reality, and the performance cost is not high. In addition, HDRP also supports shadows on transparent surfaces!
The ray path tracing function can generate beautiful images faster than traditional offline rendering. The light is emitted from the camera, and when it collides with the surface, the light is projected to other surfaces and the light (forming a light cluster “Light Cluster” structure). The path of the light from the camera to the light is called the path, from which the function is named path tracking.
Compared with other ray tracing methods, the advantage of path tracing is that it can be usedUnified calculation process to generate all lighting, Including shadows, reflections, refraction and global illumination. The main disadvantages of this technology are rendering time and image noise. The latter can calculate a clearer image (similar to temporal anti-aliasing) by accumulating and sampling multiple frames of images.
I would like to remind my friends that the ray tracing in HDRP is currently in the preview stage and cannot meet the requirements of commercial production. Please make sure to make a backup when creating. At the same time, we also welcome your valuable suggestions.