If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

3. Light rays

Let's look more closely at how light bounces when it strikes an object. We'll cover reflected and refracted rays, direct and indirect illumination, and shadow rays. Refracted rays follow the path light takes when it passes through a transparent object, like a glass of water. Reflected rays follow the path light takes when it bounces off a shiny surface. Click here for more detail on refraction!

Want to join the conversation?

Video transcript

(introductory sound) In the previous video, we've talked about what color a point on a surface is by considering three factors: One, how much light falls on the point. Two, how the surface reflects light, and three, where the camera is. For the first factor, the ray tracer needs to determine if the point being considered is visible to the light source. This is actually pretty easy to answer. The ray tracer constructs a ray that starts at the point being shaded and launches off in the direction of the light source. These rays to light sources are called, naturally enough, shadow rays. Here's an example of an point that is visible to the light source, because the shadow ray doesn't hit anything but the light source. It's important to notice that only some of the light falling on a point comes directly from the light sources. This is called direct illumination. In the real world, some of the light comes from other objects in the scene as well. Notice that I can bounce light off this card, which you can see adds to the light hitting my face. This is an example of indirect illumination. As another example of indirect illumination, you can see a reflection of the tennis ball in the pool ball. A ray tracer can account for such reflections by sending another ray in the reflection direction. The direction of this reflective ray is determined by how a light ray would bounce naturally in the same way a pool ball bounces. This technique was used, for instance, in Cars 2 because reflections off shiny cars were super important to the look of the film. If the object is partially transparent, like this glass cup, the ray tracer can do a similar thing and launch a ray in the refracted direction. Refracted rays pass through an object while reflected rays bounce off of them. When the rays pass through an object, such as this glass, the rays bend in different directions instead of in straight lines, which explains why the image you see of me through this glass looks warped. (ding) The ray tracer can keep doing this, casting rays, sending out reflective and refractive rays to account for reflections, the refractions, and so on. Then, it uses all of these rays to determine the final pixel color. In this next exercise, you can test your understanding of these concepts.