Just a repost of one of my first shaders on Shadertoy. This is a simple realtime path tracer, implemented in a webgl fragment shader. The shader shows motion blur, depth of field and importance sampling.

The path tracer is based on this excellent article about path tracing by Iñigo Quílez.

To speed up rendering I cast a ray through a 2d grid. For all grid cells in the line of sight a intersection tests is done with two spheres in each cell, until a sphere is hit. The (pseudo random) offset of the two spheres in each cell is based on the time, and the hash of the id of the cell.

You can find (the full source of) the fragment shader on Shadertoy: https://www.shadertoy.com/view/lsX3DH.

I have also rendered a movie of this shader. You can find this movie on YouTube.

Realtime webgl path tracer