In our current implementation of a path tracer, we’ve assumed our geometry lives in a vaccuum. There’s nothing between surfaces, and nothing in the air would modify the irradiance as it travels through the vaccuum.

In reality this is not true: light passes through many mediums on Earth (water, smoke, the air itself) which affects its properties after passing through.

Example

God rays occur when the edges of clouds are thin/have low opacity, and the rays of light that shine through pick up particles in the air and bounce off of them and between them

Explosion clouds and fog are both considered volumes. One is simply more

turbulentthan the other. If we wanted to render the explosion accurately, we would need fluid sims

## Scattering process

When interacting with a medium, four things can occur:

**Absorption:**particles block light traveling towards the viewer.**Emission:**particles increase radiance when energy is converted into light.**Out-scattering:**particles cause the light to be deflected into different directions.**In-scattering:**radiance from other light rays is scattered into the current light path, increasing its radiance.

### Coefficients

The phenomenon above are described by an *absorption coefficient* $σ_{a}$, which is the probability density that light will be absorbed per unit distance (1 meter), and a *scattering coefficient* $σ_{s}$, the probability that light is scattered per unit distance.

The *extinction coefficient* $σ_{t}$ is simply the sum of the two. It’s the total loss in radiance per unit distance. Also called the attenuation coefficient.

If $σ_{a}$ and $σ_{s}$ vary throughout the space, then this is considered a heterogenous media (e.g. smoke). If both stay constant throughout a volume, then this is homogenous media (e.g. fog).

In practice we keep the coefficients constant depending on the medium properties, but

scaleit depending on the density of the given volume, which can vary for the same medium.

## Beer-Lambert Law

Describes the ratio of incoming and outgoing light after it passes through a certain volume of medium. We have

$L_{i}L_{o} =exp(−σρ(z))$where $ρ(z)$ is the density of the given medium.

## Determining the ray color after it passes through a medium

### Integrating along the volume

Let $C(p,ω_{o})$ be the final color of the ray. We want to take infinitesimal steps $dt$ along the ray, e.g. raymarching. We have

$C(p,ω_{o})=∫_{0}c(p+ω_{o}t)⋅ρ(p+ω_{o}t)⋅T(p,ω_{o},t)dt$where $c$ and $ρ$ are the color and density function at the current point described by $p+ω_{o}t$, and $T$ is the accumulated transmittance over the ray march.

- Begin with $T=1$ and $C=(0,0,0)$.
- Incrementally update $T$ and $C$ during the ray march, using the previous value and modifying it. See slides for exact formula.

In practice we convert the integral to a finite summation, with discrete values of $Δt$ instead of infinitesimal $dt$.

#### Accounting for light

This current formula doesn’t account for light sources in the scene. All it does is account for the medium the ray is traveling though.

To account for light, we perform *nested ray marches*. In particular, in addition to the ray march above, for each point $p+ω_{o}t$, we ray march to a light source.

### Phase functions

The previous method relies on a “color function” $c$ that doesn’t fully capture the possible mediums e.g. smoke, mist, cloud.

**Phase functions** are the “volumetric version” of BSDFs. They describe the fraction of light traveling along $ω_{i}$ that is scattered along $ω_{o}$.

- Specified by the angle between $ω_{i}$ and $ω_{o}$ at a given point $p$ along $ω_{o}$.
- They are normalized and integrate to 1. Otherwise, radiance would not be conserved (not physically accurate). In a sense, phase functions describe the
*probability*of scattering occurring in a particular direction. - Just like BSDFs, phase functions are bidirectional: $ω_{i}$ and $ω_{o}$ can be swapped
- Can be
*isotropic*or*anisotropic*, controlled by an asymmetry factor $g$

#### Isotropic phase function

This is when $g=0$, and is analogous to the Lambertian BRDF model. It is simply $f(p,θ)=4π1 $, because the surface area of a sphere is $4πr_{2}$ (and we begin with a unit sphere).

#### Henyey-Greenstein phase function

Actually uses the $g$ term. Commonly used in production rendering because it’s relatively inexpensive to calculate.