Ray tracing is a family of computational methods that follow rays through a mathematical representation of a scene to determine intersections, visibility, and the propagation of light or other signals. In computer graphics, it is used to generate images by tracing rays associated with image samples and evaluating how surfaces and volumes emit, reflect, transmit, or scatter light. Outside graphics, related methods support optical design, radio propagation, acoustics, and seismic modeling.
Its central advantage is a unified treatment of spatial relationships that are difficult to reproduce with purely image-based techniques. A ray can find a surface outside the current camera view, test whether a light is occluded, or continue through successive reflections and refractions. These capabilities make ray tracing particularly useful for realistic shadows, mirrors, transparent materials, and indirect illumination. However, tracing rays does not by itself guarantee physical accuracy: the result also depends on the geometry, material models, light-transport algorithm, and sampling strategy.
The term has both broad and narrow meanings. Broadly, it covers algorithms built around ray–scene intersection queries. More narrowly, it sometimes denotes recursive rendering of direct illumination, ideal reflections, and refractions, in contrast to path tracing, which statistically samples more general light transport. Modern rendering systems often combine ray tracing with other methods rather than treating it as a complete, exclusive rendering pipeline.
Historical development
Ray tracing grew from geometric optics and early attempts to determine which surfaces are visible in a computer-generated picture. In optical engineering, tracing rays through lenses and mirrors long predates electronic computers. The graphics problem introduced a different emphasis: instead of checking the behavior of a limited optical system, an algorithm had to identify visible objects and assign colors to potentially millions of image samples. Arthur Appel’s 1968 work on shaded rendering is an important early contribution, using ray-based tests to establish visibility and shadows.
Turner Whitted’s 1980 paper, “An Improved Illumination Model for Shaded Display,” established the influential recursive formulation now called Whitted-style ray tracing. After a viewing ray struck a surface, further rays could test visibility toward lights or follow ideal reflection and refraction directions. This produced convincing combinations of hard shadows, mirrors, and transparent objects within a single framework. The method did not generally account for diffuse interreflection, but it demonstrated that recursively following rays could reproduce effects that were awkward for contemporary scanline renderers.
In 1984, Robert Cook, Thomas Porter, and Loren Carpenter introduced distributed ray tracing, in which rays sampled different positions, directions, lens locations, and times. Here “distributed” means distributed over sampling domains, not necessarily distributed across networked computers. The approach supported soft shadows, glossy reflection, depth of field, and motion blur. James Kajiya’s 1986 rendering equation and path-tracing work subsequently supplied a general framework for describing and estimating surface light transport. David Immel, Michael Cohen, and Donald Greenberg independently developed a closely related rendering-equation formulation in the same period.
Later research addressed both transport and efficiency. Bidirectional path tracing and photon mapping expanded the range of difficult lighting configurations that could be rendered effectively. Improved acceleration structures, multicore processors, and programmable graphics hardware reduced intersection costs. In 2018, Microsoft introduced DirectX Raytracing, and NVIDIA introduced Turing graphics processors with dedicated ray-tracing hardware; Khronos finalized Vulkan ray-tracing extensions in 2020. These developments made ray queries a more widely available component of interactive graphics, although production rendering had already used software ray tracing for decades. The historical progression was therefore not a replacement of one algorithm by another, but an accumulation of transport methods, sampling techniques, and execution platforms.
Geometric foundations and camera rays
A ray is usually represented by an origin , a direction , and a parameter interval:
The direction need not be normalized, although normalization makes correspond to distance in the coordinate system being used. The interval is essential: a shadow query may concern only the segment between a surface and a light, while a camera ray may extend to an effectively unbounded distance. The fundamental operation asks which geometric object, if any, intersects this ray within the permitted interval.
For image synthesis, rays are typically generated from a mathematical camera model. In a pinhole camera, a sample on the image plane determines a direction through a single camera center. An orthographic camera instead launches parallel rays from different origins. A thin-lens model samples points on an aperture and aims rays toward a focal surface, allowing defocused objects to form blurred images. More detailed camera models can trace rays through multiple lens elements, incorporating lens geometry, aperture shape, and wavelength-dependent refraction.
An image pixel is an area measurement, not an infinitesimal line of sight. Consequently, a renderer generally traces multiple rays at different subpixel positions and combines their contributions using a reconstruction filter. Additional sample coordinates can represent lens position, shutter time, or wavelength. Motion blur, for example, can be estimated by assigning rays different times and evaluating moving geometry at those times. A rolling shutter requires a time interval that varies with image position rather than one common exposure interval for the whole image.
Coordinate transformations make complex scenes manageable. An object can retain geometry in its own local coordinates while a transformation places it in the scene. Rays are transformed into that local coordinate system for intersection testing, and the resulting hit data are transformed back. Under nonuniform scaling, surface normals require an inverse-transpose transformation rather than the ordinary direction transformation. Care is also needed if a transformed ray is renormalized, because its parameterization then changes. Instancing exploits this arrangement: many scene objects can share one geometric model while using different transforms and material assignments, reducing storage without changing the basic intersection problem.
Intersection tests and visibility
Most rendering systems represent visible surfaces with triangles because triangles are planar, compact, and supported efficiently by graphics hardware. A ray–triangle intersection can be expressed as
where , , and are the vertices. A valid hit requires , , , and a permitted value of . The barycentric coordinates and also interpolate texture coordinates, vertex colors, and shading normals. Algorithms differ in arithmetic cost, numerical behavior, and how consistently they treat shared triangle edges.
Other geometric representations require different tests. Substituting a ray into a sphere equation gives a quadratic equation; cylinders and several other analytic surfaces admit similar solutions. Curved surfaces may be intersected directly or tessellated into triangles. Implicit surfaces can require iterative root finding. Sphere tracing advances along a ray using conservative distance estimates to avoid stepping across a surface, but its safety and convergence depend on the properties of the distance function. Hair and fur commonly use specialized curve primitives rather than extremely fine triangle meshes.
Different visibility questions require different query semantics. A closest-hit query returns the nearest acceptable intersection, as needed to identify the surface visible to a camera ray. An occlusion query only needs to establish whether any blocking object lies within a segment, so it can terminate early. Multi-hit queries may be needed for ordered transparency, layered media, or specialized scientific calculations. These distinctions affect performance: collecting every intersection is usually unnecessary when the renderer only needs a yes-or-no shadow result.
Opacity complicates the idea that a geometric hit is automatically a visible surface. Foliage is often modeled with textured polygons whose opacity masks represent leaves and gaps. A ray that hits such a polygon may need to inspect the texture and continue if the sampled location is transparent. Refractive glass, by contrast, usually represents a genuine optical boundary whose transmission direction must be calculated. Surface orientation matters as well: back-face removal appropriate for an opaque closed mesh may be inappropriate for a thin sheet or an interior view. Robust implementations therefore separate geometric intersection from the material and visibility rules that determine whether a hit is accepted.
Surface scattering and light transport
An intersection locates a possible interaction, but a material model determines what happens there. The bidirectional reflectance distribution function (BRDF) describes how reflected radiance in an outgoing direction depends on illumination from an incoming direction. A bidirectional scattering distribution function extends the description to transmission. Physically based models generally respect energy conservation and, under the relevant assumptions, reciprocity. They distinguish idealized delta interactions, such as a perfect mirror, from distributions that scatter light over a finite range of directions.
For a surface without participating media at the interaction point, the rendering equation can be written as
Here is outgoing radiance, is emitted radiance, is incident radiance, is the BRDF, and is the surface normal. For reflection, integration is over the relevant hemisphere. Incident radiance itself depends on other surfaces and lights, making this an interconnected transport problem rather than an isolated local shading calculation.
Reflection and refraction supply important special cases. For an incident direction directed toward a surface with unit normal , the ideal reflected direction is
Refraction follows Snell’s law,
where the values are refractive indices. The Fresnel equations determine the reflected and transmitted fractions at an interface. They explain why ordinary glass becomes more reflective at grazing angles and why some internal rays undergo total internal reflection. Roughness spreads these ideal interactions over a distribution, often modeled through unresolved microscopic surface facets.
Not all important scattering occurs at an infinitely thin boundary. Skin, wax, and marble can transport light beneath the surface; fog and smoke scatter it throughout a volume. Such effects require subsurface or volumetric transport models. Nor does standard geometric ray tracing reproduce every optical phenomenon. RGB transport approximates spectral behavior, while interference and diffraction generally require wave-optical treatment or specialized models. Polarization also requires additional state beyond an ordinary three-component color. A physically plausible image therefore depends on selecting a transport model appropriate to the phenomenon, not merely on tracing more rays.
Recursive rendering and transport algorithms
Whitted-style rendering evaluates a restricted but useful set of light paths. A camera ray finds a surface, shadow rays test direct illumination, and recursive rays follow ideal reflection or transmission. A mirror reflecting another mirror naturally produces further levels of recursion. A depth limit or contribution threshold prevents unbounded computation. This method handles sharp reflective and refractive effects well, but ordinary diffuse surfaces do not exchange indirect illumination unless the renderer adds another technique.
Path tracing estimates more general transport by sampling a sequence of scattering events. At each interaction, a direction is selected from a probability distribution, the path’s contribution is weighted to compensate for that selection, and tracing continues. Direct-light sampling often supplements the continuation ray: the renderer explicitly selects a point on an emitter and tests whether it is visible. Without this step, a path leaving a diffuse surface may have a very small chance of encountering a small light. Multiple sampled paths then contribute estimates of the radiance associated with an image sample.
Choosing how to generate paths is crucial. Importance sampling concentrates samples in directions or regions likely to contribute strongly, such as the bright part of an environment map or the narrow reflection lobe of a smooth material. Multiple importance sampling combines strategies, commonly light sampling and material sampling, while controlling the large weights that can arise when one strategy is poorly matched to the integrand. Russian roulette probabilistically terminates paths and rescales the surviving contributions, avoiding the systematic energy loss caused by simply discarding all sufficiently long paths. A fixed maximum path length, by contrast, omits longer-path contributions.
Some light paths remain difficult for ordinary camera-based path tracing. A small light shining through a curved glass object can produce a concentrated caustic on a diffuse surface; finding the relevant sequence by chance may be rare. Bidirectional methods construct paths from both the camera and the lights, then connect suitable vertices. Photon mapping traces light-originating particles and estimates illumination from their spatial distribution, exchanging controlled estimation bias for useful handling of concentrated transport. Metropolis methods explore path space by mutating existing paths. These approaches demonstrate the distinction between ray tracing as a geometric operation and a light-transport integrator as the algorithm that decides which rays to trace and how to combine their results.
Acceleration structures and computational cost
Testing every ray against every primitive would be prohibitively expensive for large scenes. With rays and primitives, a direct implementation performs on the order of intersection tests. Acceleration structures reduce this work by ruling out groups of primitives using inexpensive spatial tests. Their design is closely tied to data structures, memory layout, and the computational complexity of both construction and traversal. No structure guarantees that every possible ray distribution or scene will be inexpensive.
A bounding volume hierarchy (BVH) encloses groups of primitives within nested bounds, usually axis-aligned boxes. Traversal first tests a parent bound; if the ray misses it, all enclosed primitives can be skipped. If the ray enters it, traversal examines its children and eventually tests leaf primitives. Closest-hit traversal can reduce the ray’s maximum distance whenever a nearer hit is found. Visiting promising nodes first can therefore allow later nodes to be rejected. BVHs are widely used because they support diverse geometry, instancing, and practical updates to changing scenes.
Construction quality affects the number of tests needed later. The surface-area heuristic estimates traversal cost using child bounding-box areas as proxies for the probability that rays enter those children. Builders seek partitions that balance traversal overhead against primitive testing. Faster builders may instead sort primitives using spatial keys such as Morton codes, or combine a fast initial hierarchy with subsequent optimization. A high-quality structure can justify a substantial build cost for a static scene rendered many times, while an interactive application may need a cheaper structure every frame.
Spatial subdivision provides alternatives. A uniform grid divides space into regularly sized cells; a k-d tree recursively splits it with planes. Such methods can work well for suitable scenes, but uneven geometry density and primitives crossing many cells or partitions create difficulties. Dynamic scenes introduce another trade-off: refitting a BVH updates existing bounds cheaply, yet substantial deformation can make those bounds overlap excessively and degrade traversal. Rebuilding restores organization at greater cost. Performance also depends on cache locality, hierarchy width, compressed node representations, and ray coherence. Consequently, a claim of logarithmic intersection cost is at best a useful intuition for favorable cases, not a universal bound on real ray-tracing workloads.
Sampling, noise, and numerical robustness
Image formation involves integration over several domains: pixel area, lens aperture, time, wavelength, light sources, and scattering directions. Monte Carlo integration estimates such integrals from samples. If a quantity is expressed as , samples drawn from a probability density yield
The density must cover the regions that contribute to the integral. For independent samples with finite variance, standard error decreases proportionally to . Thus, reducing error by a factor of two generally requires about four times as many samples under those assumptions.
Finite sampling produces several different artifacts. Regularly spaced samples can turn fine geometry or textures into structured aliasing, while randomized samples tend to replace coherent patterns with noise. Stratification and low-discrepancy sequences spread samples more evenly and often improve practical convergence. Adaptive sampling assigns additional work to pixels or regions estimated to be noisy, although estimating error from a small sample set can itself be unreliable. Rare high-contribution paths can produce isolated bright pixels, commonly called fireflies; these are not necessarily evidence of an intersection bug.
Denoising reduces visible noise by using relationships across neighboring pixels, frames, and auxiliary buffers such as depth, normals, and material color. Methods based on machine learning can infer a cleaner image from a small number of path samples, but the reconstructed result may erase detail, introduce bias, or leave temporal trails. Temporal accumulation reuses previous frames after estimating where surfaces moved. It is especially effective when the scene changes slowly, but newly exposed surfaces, changing reflections, and animated lighting can invalidate old samples. A clean-looking denoised frame is therefore not equivalent to a converged transport estimate.
Floating-point error creates a separate class of problems. A secondary ray launched exactly at a computed surface point may immediately hit the same surface because the intersection position is not exact. A fixed offset can hide this self-intersection but may skip nearby geometry or cause light leaks at another scene scale. More robust approaches use error bounds and carefully directed offsets. Consistent triangle-edge tests prevent cracks between adjacent faces, while correctly handled geometric and shading normals avoid implausible scattering or self-shadowing. Robustness must extend across transforms, extreme coordinate ranges, and thin surfaces; increasing the number of samples does not correct a systematic geometric error.
Parallel hardware and real-time rendering
Ray tracing exposes substantial parallelism because many rays or paths can be processed independently. Yet it is not automatically an ideal workload for a graphics processing unit. Primary camera rays often travel in similar directions and access related geometry, but diffuse scattering rapidly sends paths toward different objects and materials. Threads may then take different branches, fetch unrelated data, and finish at different times. Traversal stacks, long material programs, and irregular memory access can limit throughput even when the arithmetic workload appears modest.
Renderers organize this work in different ways. A “megakernel” may carry a path through many stages inside one large program, reducing scheduling overhead but increasing register pressure and divergence. A wavefront design places work into queues for stages such as intersection, material evaluation, light sampling, and continuation. Sorting or grouping rays can improve coherence, although queue management also has a cost. Dedicated hardware commonly accelerates bounding-box traversal and triangle intersection; shading, scene management, sampling, and denoising still require substantial programmable computation.
An application programming interface such as DirectX Raytracing or the Vulkan ray-tracing extensions exposes acceleration structures and ray-query operations to applications. Implementations commonly distinguish structures containing individual meshes from higher-level structures containing transformed instances. Programmable stages or inline queries let applications respond to intersections and invoke visibility tests within broader graphics or compute workloads. The availability of these operations does not prescribe a particular renderer: the same hardware can support a single shadow test, selected reflection effects, or a multi-bounce path tracer.
Interactive rendering operates under strict time budgets: 60 frames per second allows about 16.7 milliseconds per frame, while 30 frames per second allows about 33.3 milliseconds. Many systems therefore use rasterization for primary visibility and ray tracing only for selected effects, including shadows, ambient occlusion, reflections, or indirect illumination. Screen-space and precomputed methods may supply additional approximations. Full real-time path tracing generally combines low per-frame sample counts with temporal reuse, denoising, and image reconstruction. Performance depends strongly on image resolution, scene complexity, material cost, ray depth, and hardware, so the description “ray traced” alone says little about either physical completeness or visual accuracy.
Applications and limits of the ray model
In film and animation, ray tracing supports consistent lighting across complex scenes containing reflective surfaces, hair, transparent objects, and participating media. Offline production can spend much longer on each frame than an interactive renderer, making sophisticated transport and many samples practical. Even then, production rendering is not simply a numerical optics experiment: artists control materials, lighting, visibility, and exposure to obtain a desired image. A physically motivated transport engine provides predictable interactions, but scenes can deliberately depart from physical measurements.
Architecture and product visualization use ray tracing to assess appearance under specified lighting and material conditions. For quantitative daylighting or optical analysis, however, convincing appearance is insufficient. Geometry, source distributions, material measurements, spectral sensitivity, and calibration must correspond to the physical problem. Optical design traces rays through lens systems to study focus, aberrations, and throughput; wave-optical calculations are added when diffraction or interference matters. Ray-based simulation can also generate labeled imagery for computer vision, though synthetic data may differ from real sensor observations in ways that affect model performance.
Other disciplines use related geometric ideas without adopting the graphics interpretation of pixel color. High-frequency radio propagation models may follow direct, reflected, transmitted, and diffracted paths through buildings or terrain. Geometrical acoustics traces sound paths to estimate arrivals and reverberation characteristics when the wavelength is sufficiently small relative to relevant structures. Seismic ray tracing follows travel paths through media whose propagation speed varies spatially. In smoothly varying media, those paths can curve rather than consist solely of straight segments. Each field supplies its own propagation equations, boundary conditions, and criteria for when a ray approximation is valid.
The principal physical limitation is that rays suppress much of the wave structure of the underlying field. Diffraction around small obstacles, interference between coherent paths, and resonant behavior cannot generally be recovered by ordinary intensity-only ray tracing. The principal computational limitation is the difficulty of discovering important contributions efficiently in complex path spaces. Numerous bounces, strongly concentrated caustics, dense volumes, and fine geometry can each increase cost substantially. Methods such as path guiding, which learns useful directional sampling distributions, and differentiable rendering, which estimates how images change with scene parameters, extend the role of ray tracing while introducing additional estimation and numerical challenges.