Ray Tracing in Media
Ray Tracing and Path Tracing
🎯 Introduction to Ray Tracing
Ray tracing is a computational rendering technique that simulates how rays of light interact with virtual 3D objects. It is the industry standard for generating photorealistic images in TV shows, movies, and increasingly in video games.
Rendering is the process of transforming a 3D scene—composed of models, textures, lights, and a virtual camera—into a 2D image by simulating light behavior.
Path tracing is the specific ray tracing algorithm used as the current industry standard in film and television. It requires an enormous number of calculations: for example, rendering a single scene using path tracing would take the entire world population (each performing one calculation per second) 12 days of nonstop work.
Path tracing was first conceptualized in 1986, but it took 30 years before films like Zootopia, Moana, Finding Dory, and Coco could be rendered with it, requiring server farms with thousands of computers working for months.
🧩 Building a 3D Scene
Triangles as the Foundation
All 3D models in GPU-rendered scenes are ultimately broken down into triangles. Even models that appear smooth or composed of squares/polygons are subdivided into triangles. A complex scene might contain millions of triangles (e.g., 3.2 million for an island kingdom scene, 8 million for a barbershop scene).
Textures and Materials
After modeling, each triangle is assigned a texture that defines:
Color (RGB values)
Material properties: whether the surface is rough, smooth, metallic, glass-like, water-like, or other materials
Scene Setup
Models are positioned in the scene
Lights are added (sky, sun, artificial lights) with adjustable intensity and direction to simulate time of day
A virtual camera is placed
The scene is rendered
🔦 How Path Tracing Works
The Core Idea: Reversing Light
In reality, light rays travel from the sun/sky to surfaces, where some light is absorbed and some is reflected, eventually reaching the camera. Since only a tiny fraction of all light rays from a source reach the camera, simulating rays from the light source is computationally wasteful.
Path tracing reverses this: it sends rays from the virtual camera into the scene, finding which surfaces they hit, and then calculating how those surfaces are illuminated by the light sources.
Primary Rays and the View Plane
The final 2D image is represented by a view plane in front of the virtual camera. The view plane has the same pixel count as the final image – for 4K, that is 8.3 million pixels.
Primary rays are sent from the camera through random points in each pixel of the view plane into the scene.
For each pixel, thousands of primary rays (e.g., 1000 rays per pixel) are used.
Each primary ray travels straight until it hits a triangle.
The color of the hit object becomes associated with that ray and pixel.
All rays through a single pixel are averaged to determine the pixel's basic color.
Ray tracing is massively parallel because each pixel's calculations are independent of all other pixels.
From Flat Color to Realistic Shading
The image produced by primary rays alone is flat-colored (just the object's base color). To achieve realism, the next step is to determine how each intersection point is illuminated – that is, how bright or dark that point should be.
This illumination has two components:
🌞 Direct Illumination
Shadow rays are generated from the intersection point toward each light source in the scene.
If no objects block the ray, the point is directly illuminated by that light source.
The light's brightness, size, color, distance, and the surface direction (normal) at the intersection point are all factored in.
These factors multiply the RGB color of the object at that point, changing the pixel's shading.
If all shadow rays are blocked, the point receives no direct illumination and would be black—but in reality, it still receives light bounced from other surfaces.
🌍 Indirect Illumination (Global Illumination)
To calculate indirect illumination:
From the primary ray's intersection point, a secondary ray is generated that bounces off the surface.
This secondary ray hits a new surface (e.g., a wall).
From this new point, another set of shadow rays is sent to each light source to determine if that point is directly illuminated.
The result (color and brightness) from that secondary point is combined with the wall's surface color, effectively turning that point into a light source that illuminates the original point.
If needed, additional bounces continue – each bounce generates a new secondary ray and more shadow rays.
This process is called path tracing because it finds billions of paths from the camera, through different points in the scene, and to the light sources (via direct and indirect illumination).
The combination of direct and indirect illumination is called global illumination and is what creates realistic lighting effects like gradients, soft shadows, and color bleeding.
Color Bleeding
One important effect of indirect illumination is color bleeding: color from one object can tint nearby surfaces. For example, a red balloon placed next to a wall will cause a reddish tint on the wall as secondary rays bounce off the balloon and then onto the wall.
Material Properties: Roughness and Refraction
The direction of secondary rays depends on the material's roughness:
0% roughness (perfectly smooth): The surface behaves as a mirror – all secondary rays bounce in the same perfect reflection direction. Whatever those rays hit becomes visible in the mirror-like surface.
100% roughness (fully diffuse): Rays bounce in entirely random directions, producing a flat, matte appearance (uniform scattering of light).
Intermediate roughness values produce a blend between mirror and diffuse behavior (e.g., brushed metal, satin finishes).
For glass materials, additional refraction rays are generated that pass through the surface. The color and brightness of pixels in the glass depend on the direction of those refraction rays and what they hit beyond the glass.
⚙️ Computational Challenges
The Scale of the Problem
A single frame of animation may require:
8.3 million pixels (4K image)
1,000 rays per pixel
4 secondary bounces per ray
Multiple light sources
Multiplying these together yields over a hundred billion rays per frame. At 24 frames per second, a 20-minute animation requires over a quadrillion rays.
The two core computational problems are:
Figuring out which triangle (out of millions) each ray hits first
Processing the enormous number of rays required for a single image
Solving Problem 1: Ray-Triangle Intersection and Bounding Volume Hierarchies (BVH)
Basic Ray-Triangle Intersection
For a single ray and a single triangle:
Extend the plane containing the triangle
Calculate the intersection point of the ray with that plane (using plane equation and ray equation)
Check whether that point lies inside the triangle (using barycentric coordinates or similar tests)
If it does, the ray hits the triangle; if not, it misses
With 10 triangles, this is repeated 10 times. With millions of triangles, this becomes computationally prohibitive.
Bounding Volume Hierarchy (BVH)
A bounding volume hierarchy dramatically reduces the number of ray-triangle intersection tests.
Construction:
All triangles in the scene are enclosed in a large box (bounding volume) aligned with the coordinate axes.
The box is divided into two smaller boxes, each containing half the triangles.
This process repeats recursively – each box is further subdivided into two smaller boxes.
After 19 divisions for 3 million triangles, the hierarchy ends with about 525,000 very small boxes, each containing roughly 6 triangles.
Traversal:
At each level of the hierarchy, a simple ray-box intersection test is performed to determine which box the ray enters.
Because all boxes are axis-aligned, these tests are computationally cheap (just checking coordinate boundaries).
The ray travels down the binary tree, following the boxes it hits.
At the bottom, only 6 ray-triangle intersections need to be calculated for the smallest box.
BVH traversal reduces millions of potential ray-triangle tests to a handful of box intersection tests followed by 6 triangle tests.
Solving Problem 2: GPU Hardware Acceleration
Modern GPUs contain thousands of cores specifically designed for parallel processing. For example, an NVIDIA 3090 GPU has:
10,496 CUDA (shading) cores – handle general arithmetic operations
82 Ray Tracing (RT) cores – specialized hardware for ray tracing operations
Inside each RT core:
BVH traversal section: Takes coordinates of bounding boxes and ray direction, executes BVH traversal in nanoseconds.
Ray-triangle intersection section: Uses coordinates of the 6 triangles in the smallest bounding volume to quickly find the first triangle hit.
RT cores operate in parallel and pipeline operations, allowing billions of rays to be processed per second. A complex scene that once required months on a supercomputer can now be rendered in 4 minutes on a desktop GPU.
Historical Perspective: Supercomputers vs. Modern GPUs
Supercomputer (2000) | Modern GPU (2022) |
|---|---|
ASCI White | NVIDIA RTX 3090 |
$110 million cost | ~$1,500 (initial MSRP) |
12.3 trillion operations/second (CUDA cores) | 36 trillion operations/second (CUDA cores) |
This massive increase in accessible computing power has made CGI and special effects, once exclusive to high-budget films, possible on a desktop computer.
🎮 Ray Tracing in Video Games
Video games use ray tracing with shortcuts and approximations to achieve real-time performance. Two common techniques are:
Light Maps (with Low-Resolution Duplicates)
A low-resolution duplicate of all models in the scene is created.
Path tracing is used to calculate direct and indirect lighting on these low-resolution objects.
The results are saved into a light map applied to the low-resolution duplicate.
The light map is then applied to the high-resolution version of the objects, creating realistic lighting and shadows.
This method is used in Unreal Engine's Lumen renderer to approximate indirect lighting efficiently.
Screen Space Ray Tracing
Screen space ray tracing does not use the scene's original 3D geometry. Instead, it uses data generated from the standard graphics rendering pipeline:
Depth map: Shows how far each pixel is from the camera.
Normal map: Shows the direction each surface pixel is facing.
The viewscreen image combined with depth and normal maps provides a simplified 3D representation in screen space.
Process:
For a reflective surface (e.g., a lake), rays are bounced from the lake's pixels using the normal map.
These rays travel through the simplified screen-space geometry and hit other objects (e.g., trees), producing reflections.
Limitations:
Can only use data visible on the current screen. If an object moves off screen, its reflection disappears.
Cannot reflect objects behind the camera.
Not as physically accurate as full path tracing.
Screen space ray tracing is used in games like Cyberpunk 2077 alongside other rendering algorithms.
📐 Mathematical Foundations
Ray tracing is a fusion of multiple disciplines:
Physics of light – understanding how light interacts with surfaces (reflection, refraction, absorption)
Trigonometry, vectors, and matrices – calculating intersections, reflections, transformations
Computer science – algorithms (BVH, path tracing) and data structures
Hardware architecture – GPU design optimized for parallel ray operations
📝 Key Takeaways
Ray tracing simulates light paths from the camera to the scene to determine what each pixel sees.
Path tracing is the standard algorithm used in film, combining primary rays, secondary rays, and shadow rays to achieve global illumination.
Global illumination (direct + indirect lighting) creates realistic shading, shadows, and color bleeding.
Bounding Volume Hierarchies (BVH) solve the problem of finding which triangle a ray hits first, reducing millions of tests to a handful.
Specialized RT cores in modern GPUs execute BVH traversal and ray-triangle intersections in hardware, enabling real-time or near-real-time rendering.
Video games use approximations like light maps and screen space ray tracing to achieve real-time performance with reduced computational cost.

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