

The idea is to repeat this many times for each pixel, and then average the samples. Now, to find the total light intensity in a given (outgoing) direction, we need to integrate over all possible incoming directions in the hemisphere: By pure geometrical reasoning, we can see that the amount of light that hits this patch of the surface will be proportional to the cosine of the angle between the surface normal and the light ray:īy definition of a Lambertian material this amount of incoming light will then be reflected with the same probability in all directions. Consider the image above, showing some photons hitting a patch of a surface. Imagine that a Lambertian surface is hit by a light source. Diffuse reflectionsĪ Lambertian material is an ideal diffuse material, which has the same radiance when viewed from any angle. Let us start by considering how light behaves when hitting a very simple material: a perfect diffuse material. The examples are built around Fragmentarium (and thus GLSL) snippets, but the discussion should be quite general. This blog post is an attempt to introduce path tracing as an operational tool without going through too many formal definitions.

There are ways around this: one way is to trace rays starting from both the camera and the lights, and connect them (bidirectional path tracing), another is to test for possible direct lighting at each surface intersection (this is sometimes called ‘next event estimation’).Įven though the concept of path tracing might be simple, introductions to path tracing often get very mathematical. like the sun, we have the same problem: the chance that we hit a light source using a path of random reflections is very low, and our image will be very noisy and slowly converging. And, if the light source is large and slowly varying (for instance when using Image Based Lighting), this may provide good results.īut if the light source is small, e.g. So instead, we might start from the camera and trace the ray from here and until we hit a light source. Though this approach works, only a very tiny fraction of paths would terminate at the camera.


Each time a photon hits a surface, we choose a new randomly reflected direction and continue, adjusting the intensity according to how likely the chosen reflection is. Imagine you want to simulate how the photons from one or more light sources bounce around a scene before reaching a camera. In some ways path tracing is one of the simplest and most intuitive ways to do ray tracing.
