1. Ray tracing intuition
About this video
This video lists the maths questions a ray tracer must answer and focuses on the first one: where a ray intersects a scene object. To simplify, it takes a 2D cross-section of the 3D scene, so the image plane becomes an image line, and the object becomes a line segment AB. A ray from the camera C through a pixel P on the image line hits the segment at an intersection point I.
You'll be able to
- name the questions a ray tracer needs to answer, starting with ray-object intersection.
- describe how a 3D scene is reduced to a 2D cross-section for ray tracing.
- identify the camera C, pixel P, image line and intersection point I in a 2D ray tracing picture.
Key words
- Ray object intersection
- Finding where a ray from the camera first hits an object in the scene.
- Cross-section
- A slice through a 3D scene that shows a flat, 2D picture.
- Image plane
- In 3D, the flat surface where the image is formed, made of pixels.
- Image line
- The 2D version of the image plane: the line where the image is formed.
- Line segment
- A straight piece of line joining two points, such as A and B.
Transcript
(introductory sound) We saw in the previous lesson that to write a ray tracer, you need a mathematical way to answer a bunch of questions. Where does a ray intersect a scene object? Does a shadow ray reach the light source before it intersects another object? How does the surface reflect light?
How far away is the light source? Finally, where is the camera? In the remainder of this lesson, we're going to focus on the first sub-problem, that of ray object intersection. We're going to start our study by first looking at the simpler problem of how to do ray object intersection in two dimensions.
What does ray tracing look like in two dimensions? Let's start with our three-dimensional situation and take a cross-section through this white plane that contains the camera and the viewing direction. Notice too that the white plane intersects the image plane on the line, which we'll call the image line.
That means if we draw just what's in the white plane, we get a picture like this. To make the problem even easier, we'll try first intersecting with the simplest object possible, the line segment. Here's our scene: Just a line segment connecting two points, A and B.
To render the scene, just as in three dimensions, we need to pick a location for our camera. Call the camera point, C. Next, we pick a viewing direction, shown here in red. In three dimensions, the camera location and viewing direction defines an image plane. but in two dimensions, it gives us an image line.
That's the line in which our image will be formed. Now, let's pick a point, P, on the image line to denote the pixel we want to determine the color of. Recall that the ray tracer builds a ray from C through P off into the scene. We need a mathematical way to compute intersection points.
Like this one, called 'I'. To develop the math, we first introduce a coordinate system. The math we need comes from looking at the Algebra of intersecting a ray with a line segment. We've introduced quite a few ideas in this video. So, use the next exercise to make sure you're comfortable with two-dimensional ray tracing.
Video © Khan Academy, used under CC BY-NC-SA. Watch on Khan Academy. Puzzicle is not affiliated with Khan Academy.