Abstract
We present several formulas and methods for generating samples distributed according to a desired probability density function on a specific domain. Sampling is a fundamental operation in modern rendering, both at runtime and in preprocessing. It is becoming ever more prevalent with the introduction of ray tracing in standard APIs, as many ray tracing algorithms are based on sampling by nature. This chapter provides a concise list of some useful tricks and methods.
Introduction
In modern physically based rendering, "randomness" is rarely truly random. To produce clean, noise-free images, ray tracers must carefully distribute samples according to specific mathematical rules—a process known as importance sampling. This work serves as a practical "zoo" or catalog of the most essential transformation formulas used by graphics engineers today, bridging the gap between abstract probability theory and high-performance implementation.
Ray tracing is inherently a statistical process. To simulate light transport, we cast millions of rays. Purely random sampling often leads to significant variance, manifested as "noise" or graininess in the final image. Importance sampling addresses this by concentrating rays where they contribute most to the final pixel value, such as toward bright light sources or along the specular lobes of materials.
Methodology: The Inversion Method
The primary technique for generating these distributions is the Inversion Method. This workflow transforms a uniform random variable $u \in [0, 1]$ into a target sample $x$ following a desired Probability Density Function (PDF). The process involves defining the PDF, integrating it to find the Cumulative Distribution Function (CDF), and finally inverting that CDF to create a mapping function.
The "Zoo" categorizes these transformations into several domains:
- 1D and Discrete Distributions: Handling linear, tent, and Gaussian distributions, as well as picking from discrete sets (e.g., light source selection) using optimized search structures.
- 2D and Geometric Surfaces: Uniformly sampling disks, triangles, and complex meshes.
- Directional and Volumetric Sampling: Generating rays for diffuse (cosine-weighted) and specular (GGX, Phong) reflections, as well as scattering within participating media like fog.
Key Insights and Implementation Best Practices
Beyond basic formulas, the paper highlights several critical practical considerations for high-quality rendering.
Advanced Mapping Techniques
For disk sampling, the authors advocate for Concentric Mapping over standard polar coordinates. Polar mapping creates a "seam" and distorts samples near the center, whereas concentric mapping preserves the adjacency of samples. This preservation is vital when using sophisticated quasi-random sequences or "blue noise," which rely on spatial relationships to reduce aliasing. Similarly, for spherical domains, Octahedral Concentric Mapping is preferred due to its low "stretch" factor, ensuring a more uniform distribution of samples across the sphere.
Directional Sampling of Specular Lobes
Sampling specular highlights, particularly using the GGX distribution, is a cornerstone of modern material modeling. The paper provides optimized "recipes" for these lobes, which are essential for simulating realistic metals and plastics.
The Precision Trap
A subtle but vital insight involves floating-point precision. When "reusing" a random number by remapping it (e.g., $u' = u / P$), bits of precision are effectively discarded. In deep hierarchical sampling structures, such as large texture atlases or complex light hierarchies, a 32-bit float can "run out of bits," leading to visible sampling artifacts. In such cases, drawing a fresh random number is often necessary despite the performance cost.
Conclusion
This "Zoo" provides a collection of best-practice algorithms and optimized C++ snippets rather than a quantitative study. It emphasizes that while rejection sampling is simple to implement, its efficiency drops significantly for sparse distributions. For modern production rendering, inversion and hierarchical methods are far superior. Future work continues to explore transforms that perfectly preserve the stratification properties of advanced sampling sequences like Blue Noise across complex geometric mappings.
Summary updated