Posts from the “Ray Tracing” Category

Russian Roulette for Photon Scattering

On a surface, Russian Roulette determines whether a photon is absorbed or reflected.

The photon power is not scaled.

Reflection or Absorption:

a: [0, 1] is a random variable

p: probability of reflection

phi: the power of incoming photon

if( a < p ) reflect photon at power phi

else photon is absorbed

Specular or Diffuse Reflection:

a: [0, 1] is a random variable

p_d: probability of diffuse reflection

p_s: probability of specular reflection

where ( p_d + p_s < 1 )

Diffuse Reflection: a: [0, p_d]

Specular Reflection: a: [p_d, p_d + p_s]

Absorption: a: [p_d + p_s, 1]

In participating media, Russian Roulette determines whether a photon is absorbed or scattered.

The probability of a photon being scattered is given by the scattering albedo ( rho / (rho + alpha) ) [Jensen 1998], where rho and alpha are the scatter and absorption coefficients.

Scattering or Absorption:

a: [0, 1] is a random variable

p: probability of scattering

phi: the power of incoming photon

if( a < p ) scatter photon at power phi

else photon is absorbed 

New direction of a photon being scattered from diffuse reflection or participating media:

Sampling techniques. Importance sampling is usually applied.

Build Photon Maps of Surface and Volume for Indirect Illumination

As described in Volume Photon Map[Jensen 1998], three types of photon maps are presented to compute indirect illumination in scenes with participating media: global, caustic and volume. Volume photon map contains photons interacting with particles in the participating media, regular photon map stores photons bounced by diffuse surface, and caustic photon maps stores photons bounced specular and transmissive surfaces.

This scratch describes steps to build these photon maps. But global and caustic photon maps are not separately built, while combined together, i.e. photons bounced by any kind of surfaces are stored in the same photon map.

When tracing photons, photons are stored from the 2nd bounce, because the first bounce is the direct illumination on surfaces or volumes.

The photon’s power does not need be scaled when using Russian Roulette.

Photon Map:

For each photon, when it’s not traced to the maximum bounce (user defined number):

Store: only when it hits a diffuse surface.

Scatter: use Russian Roulette to determine whether the photon is absorbed or scattered.

Increase the bounce: every time it hits a surface.

Volume Photon Map:

For each photon, when it’s not traced to the maximum bounce:

Store: when it hits somewhere within the participating media.

Scatter: use Russian Roulette to determine whether the photon is absorbed or scattered.

Increase the bounce: every time it hits a surface or somewhere within the participating media.

Direct Illumination in Scenes with Participating Media

Assume that the participating media volume is finite. Besides of attenuation and emission, direct illumination of participating media accounts for the single scattering, while indirect illumination is for multiple scattering. This scratch only consider single scattering.

The color along a camera, reflect or refract ray:

(1) If the ray does not go through the participating media volume, and it hits:

(a) nothing: background color

(b) diffuse, specular, transparent surface: direct illumination of the surface. Consider the light ray being affected by participating media. For reflect and refract rays, consider the radiance attenuation if they go through the media.

(2) Otherwise, if the ray intersects with the volume, compute the color with two steps:

Step 1: compute the color as described in (1).

Step 2: apply attenuation, emission and scattering to the color computed from step 1.

If the ray hits a surface, attenuate the color from the hit point in the surface to the first intersect point with the volume, or to the origin of the ray if the origin is inside the volume.

If the ray hits nothing, attenuate the background color from the second intersect point with the volume to the first intersect point, or to the origin of the ray if the origin is inside the volume.

 The color of a point X being illuminated by the light ray:

If the light ray hits a surface closer than X, it’s not illuminated, i.e the color is zero. Otherwise, apply attenuation and emission for the light ray.