Shadows anchor objects to the world, and ray tracing is reshaping real-time lighting. Learn shadow mapping — the standard real-time shadow technique — and how rasterization compares to ray tracing.
The standard real-time shadow technique is shadow mapping: render the scene’s depth from the light’s point of view into a texture, then when shading each pixel, check whether it is farther from the light than that stored depth — if so, something is blocking the light and the pixel is in shadow. It is a clever reuse of the depth buffer and the workhorse of real-time shadows despite its well-known aliasing quirks.
Shadow mapping — two passes:
PASS 1: render the scene's DEPTH from the LIGHT's viewpoint -> a "shadow map"
(each texel = distance from the light to the nearest surface)
PASS 2: render normally. For each fragment, look up its position in the shadow
map. If the fragment is FARTHER from the light than the stored depth,
something is BETWEEN it and the light -> it's in SHADOW.
in shadow? fragmentDepthFromLight > shadowMap[projectedCoord] + bias
Cheap + widely used. Downsides: aliasing/"shadow acne" (needs a bias),
resolution limits -> techniques like cascaded shadow maps + PCF soften it.The pipeline you have learned is rasterization: project triangles to the screen and shade the pixels they cover — extremely fast, but effects like accurate reflections, shadows, and global lighting need clever tricks. Ray tracing instead simulates light by casting rays from the camera into the scene and following bounces, producing those effects naturally at a higher cost. Modern games increasingly blend both.
Two ways to make a picture:
RASTERIZATION (this course's pipeline)
project triangles -> shade covered pixels. VERY fast.
reflections/shadows/GI need approximations (shadow maps, cubemaps, SSR...).
RAY TRACING
cast a ray per pixel from the camera INTO the scene; find what it hits;
spawn more rays for reflection/shadow/bounce light.
accurate reflections, shadows, global illumination — but far costlier.
Rasterization draws geometry to the screen; ray tracing simulates light paths.
Modern games use rasterization + selective ray tracing (hybrid rendering).At its core a ray tracer, for each pixel, shoots a ray, finds the nearest surface it intersects, and computes lighting there — then may recurse: a shadow ray toward each light checks for blockers, a reflection ray follows the mirror direction, and so on. Acceleration structures (BVHs, from the physics course) make the intersection search fast. This recursive "follow the light" model is why ray tracing captures effects rasterization must fake.
def trace(ray, depth=0):
hit = nearest_intersection(ray, scene) # accelerated by a BVH
if hit is None or depth > MAX_DEPTH:
return sky_color(ray)
color = ambient(hit)
for light in scene.lights:
shadow_ray = ray_to(light, hit.point)
if not blocked(shadow_ray, scene): # shadow ray -> is the light visible?
color += shade(hit, light)
if hit.material.reflective:
refl = reflect(ray.dir, hit.normal)
color += 0.5 * trace(Ray(hit.point, refl), depth + 1) # recurse
return color
# per pixel: hit -> light -> maybe reflect/recurse. Naturally gives shadows +
# reflections. BVH acceleration (physics course) makes the hit test fast.Dedicated GPU hardware (RT cores) and APIs — DirectX Raytracing, Vulkan Ray Tracing, NVIDIA OptiX — now make limited ray tracing viable in real time. Games use it selectively for reflections, shadows, and global illumination on top of a rasterized base, and pair it with AI denoising and upscaling to hit frame rates. It is the current frontier: not replacing rasterization, but augmenting it where physically-accurate light matters most.
Real-time ray tracing is now practical (selectively):
hardware GPU "RT cores" accelerate ray-vs-BVH intersection
APIs DirectX Raytracing (DXR), Vulkan Ray Tracing, NVIDIA OptiX
usage HYBRID: rasterize the frame, then ray-trace specific effects —
reflections, soft shadows, global illumination, ambient occlusion
budget trace few rays/pixel + AI DENOISING + upscaling (DLSS/FSR) to
reach playable frame rates
Not a replacement for rasterization — an augmentation where accurate light
(mirror reflections, bounce lighting) matters most. The current frontier.