What they are saying here is wrong or rather extremely simplified for a younger audience.
What they are saying here is wrong or rather extremely simplified for a younger audience.
They do simplify things a bit though. Normally we don't trace one path at a time, but we trace multiple of them. Each time we intersect with an object we do not only create another ray to continue to path, but we also sample a point on a light and we connect the two points by a ray to finish the path. This process is called Next Event Estimation and we can combine both 'accidental' paths and 'connected' paths by using a technique called Multiple Importance Sampling (MIS).
Lots of caveats here, of course. You do need to also sample light going in other directions, since the sun isn't the only light source (other objects reflect). You can only do this on diffuse surfaces, so you need to keep going until you hit a diffuse surfaces. Most surfaces are partly diffuse partly specular, etc. so you'll actually want to sample both straight towards the light source and off in other angles.
But what does the most simple path tracer look like? You shoot rays from the camera. If it hits a diffuse surface, bounce a ray toward each light, adding that light if that ray isn't obstructed from the light. If it hits a specular surface, bounce off based on the surface and ray orientations, and recurse when you hit another surface. You see how we cheat? If everything is diffuse, then we only ever make one bounce, straight from us to the sun. But that's a great first order approximation, since sunlight is so much brighter than reflected light. Same approach works for more bounces; just end with it trying to hit the sun.
For instance: a beam hits some material and needs to reflect or worse, pass through via transparency. Another issue: If we are calculating on a per pixel basis, that means bundling multiple paths together to figure out what the weighted return will look like. How can this all be computed with any kind of efficiency without cheating?
- Trace random paths from light sources until they terminate (usually decided with Russian roulette).
- Trace random paths from the camera (usually N per pixel, or you can use more paths in noisy areas) until they terminate.
- Try to connect each point in a camera path with each point in a light path, using a simple line test. If it succeeds, that color is added to the pixel from which the camera path originated.
At least that's my understanding; I've only implemented simpler algorithms and read a bit about bidirectional path tracing.
> If we are calculating on a per pixel basis, that means bundling multiple paths together to figure out what the weighted return will look like. How can this all be computed with any kind of efficiency without cheating?
Right, we still need to consider many paths per pixel to get a high quality image. But it converges faster than most other Monte Carlo techniques.
If the surface is refractive/reflective, recursively shoot one more ray calculating the right direction, with correctly diminished intensity and follow the same process.
Keep in mind that there is a very mathematical foundation to all this, we're not just tracing paths for the fun of it. Basically what we want to solve is a path integral (an integral over all paths), we do this using a technique called Monte Carlo integration (which basically means we use randomness). We first sample a path (using path tracing) and then we calculate the contribution of that path (which basically is the amount of radiance is carries divided by the probability of sampling the path) and then we add that contribution to the right pixel.