Ray Tracing in Media


Ray Tracing in Media

Hope
Every time we watch a modern movie or TV show with incredible CGI, we're actually seeing ray tracing in action. It's the technique that makes those fantastical worlds look so real.

Maria
And it all starts with an artist building a 3D scene from millions of tiny triangles. They model everything, assign textures that define color and material properties like roughness or metalness, place lights and a virtual camera, and then the computer renders the whole thing.

Hope
Rendering is where the magic happens. The standard algorithm in movies now is called path tracing, and it simulates how light actually behaves. Instead of sending rays from light sources, we send rays from the camera through each pixel into the scene.

Maria
That's clever because only the light that reaches the camera matters. For a 4K image with 8.3 million pixels, we might send a thousand rays per pixel—that's over 8 billion rays just for one frame. And an animation at 24 frames per second? That's quadrillions of rays.

Hope
Right, and each ray has to find which triangle it hits first. Without some clever optimization, checking every triangle would be impossible. That's where bounding volume hierarchies, or BVHs, come in.

Maria
A BVH organizes triangles into nested boxes aligned with the coordinate axes. The ray first checks which big box it hits, then goes down the tree into smaller and smaller boxes until it reaches a tiny box with just a handful of triangles. That reduces millions of calculations to just a few.

Hope
Once we know what triangle we hit, we calculate its color and then figure out how it's lit. We send shadow rays toward each light source to check direct illumination. If a shadow ray hits something else, that point is in shadow.

Maria
But shadows alone don't make it look real. We also need indirect illumination—light bouncing off other surfaces. For that, we generate secondary rays that bounce off the first hit point, hit another surface, and then we send shadow rays from there. This bouncing continues, and each bounce adds more realism.

Hope
That's why it's called path tracing: we're finding paths from the camera through the scene to the light sources. The direction of these bounces depends on the material properties. A mirror surface reflects perfectly, while a rough surface scatters the rays randomly.

Maria
Now, even with BVHs, the sheer number of rays is staggering. For decades, this was only possible on supercomputers. But modern GPUs have specialized hardware, like NVIDIA's RT cores, that can do BVH traversal and ray-triangle intersections in nanoseconds.

Hope
To put it in perspective, the most powerful supercomputer in 2000, the ASCI White, cost $110 million and did about 12 trillion operations per second. A consumer GPU from 2022, like the RTX 3090, does 36 trillion operations per second and fits in your PC.

Maria
That's why we can now render a complex scene in minutes on a desktop, whereas movies like Moana and Finding Dory needed server farms with thousands of computers running for months.

Hope
And ray tracing isn't just for movies. Video games use it too, but with shortcuts to keep it real-time. One method is to create a low-resolution duplicate of the scene, calculate lighting on that, and then apply the results as a light map to the high-res version. Unreal Engine's Lumen renderer uses something like that.

Maria
Another technique is screen space ray tracing, which uses only the 2D image and depth data from the current frame. It's fast but limited: reflections of objects off-screen disappear. Games like Cyberpunk 2077 use a mix of these methods.

Hope
So ray tracing is a beautiful blend of physics, math, and computer science—trigonometry, vectors, algorithms, and hardware. And if you want to dive deeper into any of these topics, Brilliant offers interactive courses that make learning hands-on.

Maria
Whether you're into math, physics, or programming, Brilliant's modules let you learn by doing. And as Steve Jobs showed, you never know when a seemingly unrelated skill will change your trajectory. Check out the link in the description for a free trial and discount.

Ask anything
We've read this whole study set, so questions about it get the best answers.