Ray Tracing-Based Rendering: A Generic Overview
Published:
(work in progress…)
In the term of Ray Tracing-Based (in short ray-based rendering), I did not mean the classical Whitted-style ray tracing (see An Improved Illumination Model for Shaded Display Cook-style ray tracing (see Distributed Ray Tracing), but all the similar type of approaches, including Global Illumination algorithms. These genre of algorithm follows more or less the same procedure of shading, ray generation, intersection, close hit, any hit, miss, and exception handling with slight or no change at all in the pipeline.
Ray Tracing-Based Rendering: A Generic Classification
All the ray tracing-based rendering pipeline, including ray casting, ray tracing, global illumination-based advanced algorithms including path tracing, photon mapping could be classified in these two generic categories. This classification is based on the light path direction. Light distribution in a scene is dynamic equilibrium, as much light is absorbed as is emitted.
- Forward ray Tracing (aka. light tracing ); under global illumination category, it is also referred sometimes as the
forward light transport/ particle - Backward Ray Tracing (aka. reverse ray tracing); under global illumination category, it is also referred sometimes as the
backward light transport/ particle - Hybrid Ray Tracing
Forward Ray Tracing/ Light tracing
It follows the path of the light particles (photon) forward from the light source to the camera. It makes technically possible to simulate the right way light travels in nature on a computer. For instance, the sun emits about 1045 photons per second (Reference). The chances of a random photon from the sun hitting the scene is tiny. About 1 in every 2.1x109$ photons from the sun even hit the earth. About 1 in every 4.5x1010 of those will hit the 100 ft (30 m) radius of the scene. The sun emits about 1045 photons per second.
However, this method inefficient and impractical, especially under the finite computational resources. As from the previous approach, we can see, there is a very low probability that the photon from the light would finally hit the virtual camera sensor.
Turner Whitted mentioned, in an obvious approach to ray tracing, that light rays emanating from a source are traced through their paths until they strike the viewer. Since only a few will reach the viewer, this approach is wasteful. However, in Whitted-style ray tracing, surfaces are treated as perfectly shiny and smooth.
Backward Ray Tracing/ Eye Tracing/ Camera Tracing/ Reverse Ray Tracing
Unlike real life, rays traverse the scene in reverse in the virtual world; start at the viewpoint and go towards the scene. Appel also suggested rays are traced in the opposite direction, from the viewer to the objects in the scene. So, we trace a ray from the eye (virtual camera) to a point on the object’s surface and then a ray from that point to the light source. The first ray we shoot from the eye is called the primary ray/ visibility ray/ view ray/ camera ray. If the ray hits an object, then we find out how much light it receives by throwing another ray (called a light/ shadow ray) from the hit point to the scene’s light/s.
Backward ray tracing is an efficient way of computing direct illumination indeed but not always an efficient way of simulating indirect lighting. Nonetheless, due to the efficiency, almost all the time, ray tracing and other global illumination algorithms are based on the backward tracing. The Next Event Estimation could be used both of the forward and backward ray tracing for robust light sampling.
Hybrid Ray Tracing
The forward ray tracing generates better result; however, requires more computational resources. That would be more challenging for the real-time rendering context where the convergence time is too low (10 ms for current, 2026 VR gold standard of 90 FPS) On the other hand, the backward ray tracing is definitely faster approach than the forward. Nevertheless, it is less vivid as many of the insignificant rays are ommitted. A hybrid approach solves this problem, balancing between computational demand and visual fidelity. Noteworthy, by hybrid, in ray tracing-based rendering also could mean the deferred shading approach where visibility calculation and first hit is done in rasterization pipeline, then over the G-buffer further light calculations are performed.
Common Terminologies (Shaders)
Unlike the rasterization pipeline, the ray tracing-based algorithms has five types of shaders (generally). The computational expensive pixel shader in rasterization could be equivalent of closest-hit shader. The ray tracing-based pipeline’s shaders are more or less 3D graphics API agnostic. The five shaders are as follows:
- The
ray generationshader defines how the ray tracing should start. It runs once per algorithm (per pass) - The
Intersectionshader/s define ray-object (aka. geometry) intersection. The shader is reusable - The
miss shader/sdefine the behavior when the ray miss hitting any geometry in the scene - The
closest hitshader/s run once per ray and shade the final hits - The
any-hitshader/s run once per hit and determine the transparency
The miss, closest hit, and any hit define the behavior of ray/s and may behave differently between primary, shadow, and indirect rays.
