Slightly altered version of Whitted Ray Tracing implemented entirely in the fragment shader. Runs in real-time.
Source Code: GitHub
The main difference is that classical Whitted ray tracing uses recursive function calls for reflection and refraction (depth-first approach), whereas this shader flattens the recursion into a fixed-size array of rays (breadth-first approach) and processes them in a loop - there’s no true recursion in GLSL.
Classical Whitted ray tracing has a fixed recursion depth (tree depth), while this approach has a fixed ray budged: As long as there is space in the array, new rays can be added. Consequently, some rays can bounce more times than others (for example on objects that are only reflective, as opposed to reflective and refractive).