Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No that's wrong. You do start tracing paths at the camera. The lens usually is extremely small and the rays that do contribute are highly directional, the probability of hitting the lens is extremely low and the probability of the hitting the lens in a direction that actually contributes to the final image is even lower. On the other hand there usually are many lights in a scene with a total area that's much larger than the area of lens and most lights don't have a directional profile. So you're much more likely to hit a light than you are to hit the lens, hence we start at the camera and not at a light.

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).



One more thing that makes this possible: you actually have some room for "choice" in which way the ray goes, and so at the 'last step' you can just choose that it goes towards the sun. What do I mean? Well, most objects are largely diffuse, meaning that light is reflected in a random direction. When you hit a diffuse object, you can choose to sample light that 'randomly' bounces off in the direction of the sun. Since if it bounces off away from the sun, then it doesn't contribute light.

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.


What you describe is next event estimation.


Thanks for giving the name; I wanted to describe why connecting two paths works. Other answers seemed to skirt around that without spelt it out.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: