Ray Tracing, Ray Casting, Ray Marching
July 2018 - December 2017

Ray tracing and ray casting are terms often confused. Ray casting is simply a ray intersecting geometry to get a color or some data at the hit point. Whereas ray tracing is using rays to simulate light by reflecting, refracting, absorbing etc. Rays are typically represented by parametric equations typically expressed in equation below.
Where position is the vector position in 3D space where the ray hits, Ray Origin is the ray’s origin, ray direction is the direction the ray is traveling (usually normalized), and t is the parameter where you are on the line.
The t value is periodically advanced through the scene till a hit with geometry has occurred. The t value can either be moved a constant distance or some variable distance determined by the structure which it resides in. For voxel structures a typical way to advance the t value is the DDA line algorithm.
Constant step algorithm
DDA line algorithm
Ray Marching algorithm
To more efficiently move the ray, it is also possible to advance the t value through hierarchical structures like octrees, quadtrees, or BVH trees. Nvidia’s RTX cards build a BVH tree in real-time from a triangle mesh, this is one of the reasons why they can have Gigarays(billions of rays per second)!
Here is one of my programs that ray marches a signed distance field. The hotter(Red) the value the more steps a ray takes. It can be noted that it is significantly hotter by the edges as the steps will converge to infinity as it reaches the surface. Thus, a minimum step is used to prevent this.