3
$\begingroup$

In ray tracing if we are tracing a ray from camera to the object, then why there is need for light source as in this image and also rays are going towards the light source instead of outgoing from the light source?

Ray Tracing
Recursive ray tracing associates an entire tree of rays with each image location.
Image from: Physically Based Rendering: From Theory to Implementation by Matt Pharr, ‎Greg Humphreys, 2010

$\endgroup$
14
$\begingroup$

There are two questions that you're asking here.

The first is why there is a light source. That's the easy part. Think what happens in the real world: if there's no light source, everything is dark and you can't see anything. That's an uninteresting case in computer graphics, so we usually don't consider it.

The second question is why rays are pointing to the light source instead of away from it. Physically, photons are emitted by light sources, and scatter around the physical environment, before hitting the imaging device (e.g. eye, camera).

It's possible to produce an image this way, like this for example:

Photon Soup

Richard Keene produced this image in 1991. It was produced by tracing almost 30 billion photons from the light sources, which scattered around the scene until they hit the virtual camera lens. This took a month of compute time on 100 SPARCstations, each with 10MHz CPUs, and it's still quite noisy.

Keene repeated the experiment in 2004, this time using volunteers around the Internet donating computer time. I can't recall how long this one took, but 382 billion photons were traced in total:

Photon Soup 2

The important thing here is that this technique is highly impractical. If you need to render an 85 minute movie at 24 frames per second, and allow a year of compute time, this turns out to be less than 5 minutes per frame. Clearly you can't spend 100 CPU-months on each image.

The problem is that if you trace photons from light sources, most photons don't hit the camera lens most of the time. If you continue scattering until they do hit the camera lens, they're usually so attenuated by that point that they contribute very little to the final image.

Ray tracing fixes this problem by tracing from the camera lens instead. Mathematically, a ray is the adjoint of a photon. This ensures that every trace contributes to the final image. However, you do then have the opposite problem. If you trace a photon from a light source, there's no guarantee that it will end up in the camera lens, but if you trace a ray from the camera, there's no guarantee that it will end up at a light source.

For this reason, most modern rendering algorithms (well, the ones that attempt to solve Kajiya's rendering equation) actually work in both directions. Photon mapping, bidirectional path tracing, and the Metropolis light transport algorithm (to pick but three) use information both from the camera and the light sources to try to spend most of the computer time on light paths which contribute to the final image.

If you're reading the book that I think you're reading, you'll get to all this in time.

EDIT Richard Keene himself chimed in, but unfortunately doesn't have enough rep yet to post comments on questions. So here's the link to his Photon Soup paper.

Richard, welcome to cs.se!

$\endgroup$
  • $\begingroup$ What about real time rendering? Ray tracing is used in non real time rendering such as films, Which technique is used in real time rendering such as games? $\endgroup$ – Mr.Grey Mar 7 '15 at 0:54
  • $\begingroup$ Your favourite search engine can help you out with the latest thinking in real-time rendering. Here's a start: realtimerendering.com $\endgroup$ – Pseudonym Mar 7 '15 at 10:35
  • $\begingroup$ Hi I have one more question - I want to learn methods and ideas for rendering - more specifically physics and mathematics required for rendering. Is pbrt is good choice for methods and ideas - pbrt.org and I'm not interested in implementing pbrt. How about this book - sites.edm.uhasselt.be/agibook Should I read this book instead of PBRT for methods and ideas? $\endgroup$ – Mr.Grey Mar 9 '15 at 8:18
  • $\begingroup$ I have found an another great source for methods and ideas - graphicscodex.com Should I prefer this over everything? $\endgroup$ – Mr.Grey Mar 9 '15 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.