Calculating Global Illumination (GI) in the browser, in a very slow and inefficient manner.
You can select a scene:
Cornell Box | Torus and lights
GI is calculated per vertex, so the mesh is tessellated to have enough detail for the shadows and bounces to be seen.
At each vertex, a camera is placed looking along the normal, and the scene is rendered into a framebuffer with a very wide FOV. The framebuffer is 32x32, and it's then averaged to get an approximation of the incoming light in that vertex. That color is then set as the vertex color.
The process is repeated, now with the scene lit by the direct light (baked into the vertex colors). We get a second bounce, and update the vertex colors. We do that process 4 times, and get an interesting -albeit slow- result.
To not block the main thread, the work is batched, calculating a few vertices every frame.
From the work of Iñigo Quílez in Simple Global Illumination.
Coded using WebGL with three.js.
See other experiments for Codevember 2016