Ray Tracing

Subscribe Send me a message home page tags


In this post, we will present a brief review of ray tracing.

Intersection of a light beam and a surface

As defined in the book Mathematics for 3D Game Programming and Computer Graphics, the term ray tracing refers to any algorithm that follows beams of light to determine with which objects they interact in the world. Ray tracing has many applications, such as

From the math perspective, the problem can be translated into a root-finding problem. A beam of light is defined as

$$ P(t) = \mathbf{S} + t \mathbf{V} $$

Suppose a surface is defined as an equation \( f(\mathbf{P}) = 0 \), then the problem becomes finding the root of the equation of \( f(\mathbf{P}(t)) = 0 \).

There are two types of solutions to a root-finding problem

Newton's method is an iterative process that constructs a series that converges to the actual root of the equation. It has a quadratic convergence rate. The basic formula is:

$$ x_{n+1} = x_{n} - \frac{f(x_n)}{f'(x_n)} $$

For more details, please check the wiki page of Newton's method.

Note that Newton's method is not guaranted to converge to a solution. In practice, we need to make sure our initial guess of the root is close enough to the actual value. It's straightforward to make a reasonable guess. For example, when we try to determine the intersection of a light beam and a complex object, we can first calculate the intersection of the light beam and a simple bounding volume of the object.

Oftentimes, we find ourself calculate the intersection of a beam and a plane. But what we really want to know is the intersection of the beam and the face of the object. So we need to check if the intersection point lies inside a face. For example, after we determine the intersection of the beam emitted from the point \(\mathbf{P}\) and the plane of the triangle ABC, we need to check if the intersection point lies inside the triangle ABC.

barrycenter.jpeg

A point in a convex area can be represented as barrycenter. In this case, it can be represented as

$$ w_1 A + w_2 B + w_3 C $$

where \( w_i \gt 0 \) and \( w_1 + w_2 + w_3 = 1 \).

Reflection and Refraction

reflection_and_refraction.jpeg

----- END -----

Welcome to join reddit self-learning community.
Send me a message Subscribe to blog updates

Want some fun stuff?

/static/shopping_demo.png