Wolfenstein: Ray Tracing on Using WebGL1
The shader used to rasterize the geometry not only calculates direct lighting but also casts random rays from the surface of the rendered geometry to collect the indirect light reflection due to non-shiny surfaces (Diffuse GI) using a ray tracer. Whereas in the prototype the ray trace code for the diffuse GI was combined with the forward shader, I decided to decouple both in the final demo. A Wolfenstein level is encoded in a 64×64 grid, so it is pretty simple to encode all data in a single 64×64 texture:
Casting a ray through the scene is done by stepping through this texture, using the following code:
Similar ray trace code through a grid can be found in this Wolfenstein shader on Shadertoy.
Source: reindernijhoff.net