Reader's Guide
How To
Links (References)
About The Graphics Codex
New in this Version
Bibliography
Preface
Prerequisites — Educational Goals — Topics Covered — Structure — Projects and Code — Primary Sources — Feedback
Introduction
Images and Light — Physically Based Rendering — The Rendering EquationRadiometry Photometry light ray primary ray Rendering Equation
C++
An Example — Header and Source Files — Memory Model — Types — Plain Old Data — Pointer Types — Stack and Heap Allocation — References — const References — Reference-Counted Pointers — Copying and Assignment — Pre- and Post-Increment — Conclusion: The C++ Programmer Mindsetheader source translation units linker variable value address type pointer dereference dangling pointers memory leak reference reference-counted pointer shared pointer
Surface Geometry
What is a Surface? — The Speeds of Light — Surfaces are Interfaces — Modeling a 1D Surface in 2D Space — A Surface is a Set of Points — Implicit Form — Explicit Form — Triangle Meshes — A Triangle — Triangle List — Indexed Triangle Listobject implicit explicit homogeneous optical interface boundary oriented implicit explicit simplex front mesh triangle list tetrahedron indexed triangle list vertex array index array
A Model of Light
Digital Images are Measurements — Rays of Light — Transport Paths — Vectors — Unit Vectors — Geometric Rays — The Light Field — Light is Conserved Along a Ray — Assumptions and Simplificationslight field crepuscular rays ray line segment line segment path emitter luminaire light source vector magnitude length unit vector normalizing unit sphere light field plenoptic function 4D light field light slab Lumigraph time phase Polarization frequencies
The Rendering Equation
Radiometric Units — Photon Energy — Power — Irradiance and Radiosity — The Measure of a Set — Radiance — Measurements in Different Frames — Lambert's Projected Area — Vector Dot Product — The Rendering Equation — Rendering is Very Hardradiometry energy photons power flux Irradiance radiosity measure angle solid angle steradians Radiance Lambert's cosine law dot product inner product integral equation
Version Control Basics
Systems — Advantages — Repository Model — An Example — Concurrent Changes — Typical Workflow — Starting a Project — Pull into the Workspace — Merge Conflicts — Adding and Removing Files — Push to the Remote Repository — Leveraging Versions — Checking the Log — Inspecting Old Versions — Workspace Undo — Local Repository Undo — Remote Repository Undo — Best PracticesSubversion git Perforce server client bridges remote repository workspace revision history distributed version control systems local repository local snapshot pulls commits pushes conflict resolved log message log git perforce p4 svn subversion mercurial hg cvs rcs source control source management revision control
A Camera Model
Images — Images are Everywhere — An Aperture Selects an Image — A 16ᵗʰ Century Mechanical Renderer — A Modern Computational Renderer — Primary Rays from a Pinhole Camera — Dynamic Range — Gamma Encoding — Bloom — Desaturationpinhole aperture virtual image real image data driven ray casting surface element (surfel) direct illumination dynamic range tone mapping gamma encoding Bloom
Ray Casting
Ray Casting Algorithm — Ray-Sphere Intersection — Ray-Plane Intersection — Ray-Triangle Intersection — Unit Triangle — Barycentric Coordinates — Arbitrary Triangle — Vector Cross Product — Triangle Mesh — Some Performance Considerations — Visualization for Debugging — Texture Coordinates — Stepping Into One Pixelray casting surface element surfel unit triangle barycentric coordinate barycenter signed area cross product cross product procedural early out spatial data structure Visualization texture coordinate texture map ray trace
Direct Illumination
Radiance is Conserved Along a Ray — Direct Illumination — Scattered Radiance — Biradiance — Implementing Point Lights — Shadows — The Visibility Function — Ambient Illuminationdirect illumination ambient term direct illumination point light biradiance shadow visibility function ambient environment mapping irradiance mapping
Materials
Probability Density — The BSDF — Lambert's Law — Scattering Functions — Common Terms — Mirror Reflection — Implementing Impulses — Transmission and Refraction — Microfacets — Subsurface Scattering — Lambertian Reflection — The Fresnel Effect — Partial Coverage — Compositing — Alpha Cutout — Perceived Colorbidirectional scattering distribution function material scattering function bump partial coverage probability mass probability density differential probability probability mass bidirectional scattering distribution function reflective bidirectional reflectance distribution function transmission non-negative energy conserving reciprocal passive Lambert's Law scattering distribution photon distribution impulse transmits refraction microfacets diffuse half vector Lambertian reflectivity normal incidence partial coverage over composite brdf btdf shading
Rendering Algorithms
The Transport Graph — Path Notation — Node Types — Operators — Notable Phenomena — Direct and Ambient Illumination — Whitted Ray Tracing — Path Tracing — Bidirectional Path Tracing — Photon Mapping — Radiositytransport graph Path notation Luminaire Specular Diffuse Eye Caustics Mirror reflections perfect refraction Diffuse interreflection color bleeding shadow Highlights ambient Whitted ray tracing backwards ray tracing ray tracing path tracing Bidirectional path tracing photon mapping consistent biased radiosity algorithm form factor metropolis radiosity
Numerical Calculus
Definition of a Derivative — Numerical Differentiation — Definition of an Integral — Analytic Integration — Numerical Integration — A Tale of Two Cities — Las Vegas — Monte Carlo — Monte Carlo Integration — An Energy Examplederivative differentiable analytically power rule antiderivative symbolic analytic Numerical (definite) integration samples randomized algorithms nondeterministic stochastic deterministic algorithms Las Vegas Monte Carlo Monte Carlo (definite) Integral estimator probability density function converged
Path Tracing
A Simple Implementation — Algorithmic Complexity — The Transport Graph — Elements of Path Tracing — Applying Monte Carlo Integration — The Camera Integrals — Distributed Sampling — The Transport Integral — Terminal Cases — Importance SamplingReverse, recursive ray tracing Distributed sampling Markov chain Monte Carlo Importance sampling spatial data structures SIMD SPMD stream processing Fixed-function hardware distributed sampling Russian roulette shadow rays material importance sampling bidirectional scattering distribution function (BSDF) importance sampling direct resampling
Ray Marching
Intersection Algorithms — Marching — Distance Estimators — Sphere Tracing — Some Distance Estimators — Sphere — Plane — Box — Rounded Box — Torus — Wheel — Cylinder — Computing Normals — A Simple GLSL Ray Caster — C++ Shader Launch — GLSL Ray Setup — GLSL Intersection — Operations on Distance Estimators — Some Useful Operators — Union — Intersection — Subtraction — Repetition — Transformation — Blending — Increasing Performance — Over-Relaxation — Bounding Spheres — Reintroducing Analytic Roots — Other Optimization Strategies — Some Online Examples in GLSL — Educational — Aspirational — Further Readingimplicit surface Analytic ray-surface intersection explicit equation Ray marching Rasterization depth buffer signed distance estimators isosurface level set sphere tracing gradient surface normal point-based graphics GPU implicit signed distance
Parallel Architectures
SIMD — Coherence — Memory Coalescing — Cores — Thread Pools and Megakernels — Occupancy — Synchronization — Pipelines — Physics Revisited — Super-Linear Speedups — Intra-core Utilization — Memory — Physics Revisited — Structures and ArraysSIMD SIMT lane masked coherent divergent coalesce virtual cores physical cores Stream Processor CUDA Core thread pooling Megakernel occupancy concurrent strict parallel race condition deadlock atomic operations mutexes spinlocks semaphores lockless datastructures barrier pipelining bubble array of structures (AOS) structure of arrays (SOA) GPU CPU SIMT AVX SSE warp CUDA
The Eye
Photoreceptors — Photoreceptor Response — Photopic Vision — Scotopic Visioncones rods punctum caecum
3D Model File Formats
A* Search
ASCII
Character Table
Diacritics and Ligatures
Greek Letters
Math Symbol Table
αAbsorption Coefficient
Adams, Ansel
Tetons and the Snake River
Angle
Arg Max
Array
Fast Remove
Filter
Shuffle
αAttenuation Coefficient
ψAzimuth Angle Measure
Bacon, Francis
Study for a Self-Portrait-Triptych
Three Studies of Lucian Freud
Ball
-Ray Intersection
Surface Area
Volume
to Ball Distance
Barycentric Coordinates
Bayes' Rule
Beer-Lambert Law
βBiradiance
Blinn Microfacet BSDF
Blinn-Phong Microfacet
DXDistribution
GXGeometry Term
Botticelli, Sandro
Nascita di Venere (The Birth of Venus)
Bouguereau, William-Adolphe
La Naissance de Vénus (The Birth of Venus)
C/C++
Function Pointer
Integers
Lambda
Method Pointer
Syntax Example
printf Specification
std::function
std::shared_ptr
Cabanel, Alexandre
La Naissance de Vénus (The Birth of Venus)
Church, Frederic Edwin
Heart of the Andes
Niagara
clamp(⋅)Clamp
Compressed Texture Formats
Conditional Expression
Cone
Random Direction Inside
Convolution
cosCosine
Hardy's Approximation
coshHyperbolic
Taylor Polynomial
Cosine-Weighted Hemisphere
Crepuscular Ray Image
×Cross Product
Cross-Correlation
Cylinder
Surface Area
Volume
det(A)Determinant
det(A)2×2 Matrix
det(A)3×3 Matrix
det(A)4×4 Matrix
Differential Solid Angle
Directions
Distance
Euclidean
Line-Line
Manhattan
Point-Line
Point-Plane
Point-Point
Sphere-Sphere
Table of Useful Lengths
Dot Product
Duchamp, Marcel
Nu descendant un escalier no2
Dürer, Albrecht
Man Drawing a Lute (annotated)
Man Drawing a Lute
Perspective Nude
Perspective Woodcut
Electromagnetic Spectrum
Euler
χCharacteristic
eConstant
Formula
Expected Value
E(X)of a Random Variable
of a Series
κExtinction Coefficient
File Format
3D Models
Raster Images
Floating Point Formats
Fog, Simple Models
Frame Rate Table
Frequency
Display Refresh
fof Light
νof Light, Spatial
F(⋅)Fresnel Coefficient
F0F0 for Selected Materials
FS(⋅)Schlick's Approximation
F0at Normal Incidence
Fc(⋅)for a Conductor
Fd(⋅)for a Dielectric
GGX/TR/GTR2
GGeometry Term
DMicrofacet Distribution
GLSL
Functions
Matrix Notation
DGTR1/Berry Microfacet Distribution
Gamma Compression
DGeneralized Trowbridge-Reitz (GTR)
Geometric Series
Git
Quick Reference
ϕGolden Ratio
Greek Alphabet
HLSL Matrix Notation
HTML
CSS Box Model
CSS3 Custom Font
CSS3 Selectors
Diacritics and Ligatures
Greek Letter Table
HTML5 Example
Math Symbol Table
Half Vector
||⋅||Hausdorff Measure
Heap Sort
ℋ()Heaviside Step Function
S+2Hemisphere
Cosine-weighted
ρ(ωo)Hemispherical-Directional Reflectance
Holbein, Hans
The Ambassadors
Hue-Saturation-Value to/from sRGB
Hull Speed
Human Retina
Photoreceptor Density
Spectral Response
Hyperbolic
coshCosine
θInclination Angle Measure
Incoming
Li(⋅)Light Field
Light Vector
Reflection Vector
Refraction Vector
Increment Mod 3
Index of Refraction
Complex
ηReal
for Selected Materials
Insertion Sort
EIrradiance
JavaScript
Operators
Types
LaTeX
Greek Letter Table
Math Symbol Table
Size Command Table
Space Command Table
includegraphics
Lambertian Surface
Latin Square Sampling
Law of Cosines
L(⋅)Light Field
Li(⋅)Incoming
Lo(⋅)Outgoing
Line
to Line Distance
to Point Distance and Closest Point
lerp(⋅)Linear Interpolation
Luminance
Magritte, René
Empire of Lights
Treachery of Images
Matrix
det(A)2×2 Determinant
A-12×2 Inverse
det(A)3×3 Determinant
A-13×3 Inverse
det(A)4×4 Determinant
:Frobenius Inner Product
Hadamard Product
Multiplication
RRotation (Roll, Yaw, Pitch)
RRotation from Axis and Angle
RRotation from Unit Quaternion
SScale
XSkew-Symmetric
TTranslation
det(A)n×n Determinant
Pzf = -∞ Perspective Projection
Pzf > -∞ Perspective Projection
Mean
Arithmetic
E(X)Expected Value
Geometric
||⋅||Measure (Hausdorff)
Merge Sort
Metric Prefixes
DXMicrofacet Distribution
crMicrofacet Reflection Angle Cosine
αXMicrofacet Roughness
Microfacet Scattering Function
Microfacet Smoothness
mirror(⋅)Mirror Reflection Operator
Monte Carlo Integration
S(⋅)Normalize a Vector
Normalized Fixed-Point
OOrigin
Outgoing
Lo(⋅)Light Field
Light Vector
Refraction Vector
Specular Reflection Vector
PICO-8
Controllers
Palette
PPerspective Projection Matrix
PInfinite
Inverting
Phong-like Scattering Functions
1973 Original
1977 Blinn Half-vector version
1986 Normalized Phong
2008 Normalized Blinn-Phong
Photon
QEnergy
fFrequency
νSpatial Frequency
λWavelength
Photoreceptor
Density, Human
Spectral Response, Human
Picasso, Pablo
Guernica
Les Damoiselles d'Avignon
hPlanck Constant
L(⋅)Plenoptic Function
Point
to Line Distance
to Plane Distance
to Point Distance
Point Lights
ΦPower
Pythagorean Theorem
Python
Lambda
Quadratic Formula
Quaternion, Unit
Basis
slerp(⋅)Interpolation
Inverse
Multiplication
from Axis and Angle
to Matrix
Quick Sort
RGB to Grayscale
RGB to/from sRGB
LRadiance
L(⋅)Radiance Function
MRadiant Emittance
MRadiant Exitance
ΦRadiant Flux
IRadiant Intensity
Radiometric Unit Table
Depicted
BRadiosity
Random Number Generator
Box-Muller Gaussian
Integer
clamp(⋅)Range Clamp
Raphael (Raffaello Sanzio da Urbino)
School of Athens
Ray
-Plane Intersection
-Sphere Intersection
-Triangle Intersection
Reciprocity
Reflectance (Albedo)
Reflection
crAngle, Microfacet Cosine of
mirror(⋅)Operator
Vector (Incoming)
Vector (Outgoing)
Refraction
ctAngle, Microfacet Cosine of
Index of (Complex)
ηIndex of (Real)
refract(⋅)Operator
Vector (Incoming)
Vector (Outgoing)
Rendering Equation, The
Area Domain (Kajiya)
Sphere Domain (Immel et al.)
Rodrigues' Formula
Scalar Triple Product
Scattering Function (BSDF)
Scattering Variables
FS(⋅)Schlick's Fresnel Approximation
Screen Resolution Table
Screenshot Keys
Shadow Map
Shader Pseudocode
Shallow Water Equation
sinSine
Taylor Polynomial
slerp(⋅)Slerp
Snell's Law
Solid Angle
Differential
Measure of a Lat-Long Patch
Measure of a Triangle
Sort
Heap
Insertion
Merge
Quick
Spectrum
Electromagnetic
Visible Light
c0Speed of Light (in Vacuum)
Sphere
-Ray Intersection
3D Random Direction
Surface Area
Unit
Volume Inside
to Sphere Distance
Spherical Coordinates
Right-handed with y=up
Right-handed with z=up
Subversion
Quick Reference
Sun
Spectrum
Table of Useful Speeds
Tetrahedron
Surface Area
Volume
Toksvig Normal Distribution
Transformation Matrix
RRotation (Roll, Yaw, Pitch)
RRotation from Axis and Angle
RRotation from Unit Quaternion
SScale
XSkew-Symmetric
TTranslation
Triangle
-Ray Intersection
Area
Solid Angle
Trigonometric Identities
Type Notation
Semantic
Structural
Unicode
Diacritics and Ligatures
Greek Letter Table
Math Symbol Table
Unit Sphere
Unproject from depth
Variance
Var,σof a Random Variable
Vector
×Cross Product
Dot Product
||⋅||Magnitude
Versor (Unit Quaternion)
Basis
slerp(⋅)Interpolation
Inverse
Multiplication
from Axis and Angle
from Rotation Matrix
to Matrix
Web Servers, Simple
XML
Escape Code Table
Greek Letter Table
Math Symbol Table
da Vinci, Leonardo
Mona Lisa
The Last Supper
πpi
printf Specification
smootherstep
smoothstep