Ray Casting Algorithm
Published:
(work-in-progress)
Ray casting was a popular rendering technique in the 1990s. During that time, the ray-casting added more graphics fidelity over the conventional rasterization-based rendering pipeline. This is a ray-based rendering technique. However, ray-casting is non-recursive. After the first bounce, it is possible to check whether the hit point is directly illuminated by a light source or not by generating a shadow ray. Therefore, ray-casting is not considered under the Global Illumination genre. Nonetheless, understanding this algorithm could assist in the learning curve of other ray-based algorithms, e.g., recursive ray tracing, global illumination algorithms (path tracing, photon mapping, ReSTIR etc). The ray casting also referred to the ray shooting in the literature.
Mathematical Details
Ray casting is a simple collision process to find the closest, or sometimes just any, object (any primitives, e.g., triangles) intersection along the ray/s. Generally, the algorithm shoots one or more rays. If a ray passing through a pixel and out into the 3D scene hits a primitive, then the distance along the ray from the origin to the primitive is determined, and the color data from the primitive contributes to the final color of the pixel. The final color, however, depends on the normal vector at the intersection point, and we need the material properties (Seee More). As a part of shading the hit point, a new ray could be cast toward a light source to determine if the object is shadowed$^{[2]}$.
TODO:
Difference Btw. Ray Casting and Ray Tracing
- Ray casting is only limited to the primary rays**, while
ray tracing shoots secondary raysfrom the intersect point. - The ray may also bounce and hit other objects and pick up color and lighting information from them
- Ray tracing** uses the
ray castingmechanism to recursively gather light contributions from reflection and refractive objects.
Resources
- F.Permadi’s Blog
- Ray Tracing Gems, Haines and Moller
