Ray Tracing Algorithm
Published:
Ray-Based Approaches
All the ray-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
Forward Ray Tracing/ Light tracing
It follows the path of the photon forward from the light source to the camera. It makes it technically possible to simulate the way light travels in nature on a computer. However, this method is not efficient or practical. For instance, the sun emits about $10^{45}$ photons per second$^{Ref}$. The chances of a random photon from the sun hitting the scene is tiny. About 1 in every $2.1X10^9$ photons from the sun even hit the earth. About 1 in every $4.5X10^{10}$ of those will hit the $100 ft (30 m)$ radius of the scene. The sun emits about $10^{45}$ photons per second.
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.