Tuesday, December 2, 2014

More on lazy ray tracing tricks

I got some questions on yesterday's post.  First, you will need a bunch of samples per pixel (like hundreds).   You can reduce that by jittering, but again, you bought that fancy computer-- watch movies while your sampling progresses.

Second, don't branch.  Once you go to random, you may as well "path" trace so there is no ray tree.  Instead of

color(ray) = R*color(reflected_ray) + (1-R)*color(refracted_ray)

instead do:
    if (drand48() < R)
          return color(reflected_ray)
          return  color(refracted_ray)

If you want motion blur, you can add a time to the ray ray.t = t0 + drand48*(t1-t0) and add some moving primitives or a moving camera.  For a translating sphere, it would be  center = p0 + time*(p1-p0)

No comments: