Skip to content

Latest commit

 

History

History
81 lines (57 loc) · 7.05 KB

Math.md

File metadata and controls

81 lines (57 loc) · 7.05 KB

RTXGI Math Guide

Irradiance

To find the illumination of a point on a surface in space, we compute the irradiance () at the point. Radiometry defines irradiance as the flux of radiant energy per unit area arriving at a surface. The complement of irradiance is radiant exitance (), the flux of radiant energy per unit area leaving a surface. Irradiance and radiant exitance; however, do not capture the directional distribution of energy. Radiance (), the flux of radiant energy per unit projected area, per unit solid angle (e.g. along a single ray), provides the directional information needed to compute irradiance and radiant exitance.

To compute irradiance, we evaluate the incoming radiance () over the set of all directions () in the hemisphere above the surface point. Mathematically, this is expressed by the integral of cosine-radiance over the hemisphere.

For a point with normal , irradiance is written as:

Equation 1: Irradiance

where:

  • is the equation for incoming radiance at point from direction .
  • is the angle between the incoming radiance direction and the surface normal .

Since the dot product represents the cosine of the angle between two vectors, Equation 1 can also be written as:

Equation 2: Irradiance reformulated with a dot product

Note that the and terms do not need to be clamped since we restrict the set of directions to the hemisphere above the surface. This is illustrated in the figure below from Physically Based Rendering, 3rd Edition:

Figure 1: Irradiance at a point p is given by the integral of incoming radiance times the cosine of the incident direction over the entire upper hemisphere above the point.

Dynamic Diffuse Global Illumination (DDGI)

Irradiance Integral Estimator

As is the case with all renderers, DDGI approximates since it can't be evaluated directly. We approximate the irradiance integral using a Monte Carlo Estimator and a uniformly distributed set of sample directions.

The estimator transforms Equation 2 into:

Equation 3

where is the number of incoming radiance directions (or samples). The summation represents the average value of the incoming radiance over the unit hemisphere multiplied by a constant term representing the integration domain (i.e. the area of the unit hemisphere). The approximate equality sign is used here to denote that the expected value of the quantity on the right is equal to the integral on the left, even though each individual average of samples will have some variance.

Probe Storage and Lookup

In our implementation of DDGI, each probe irradiance texel stores the Monte Carlo Estimator defined in Equation 4 for a point and direction defined by an octahedral parameterization of a sphere:

Equation 4

To decrease variance in the estimate stored in the probes, we divide the sum of incoming radiance by the sum of the cosine weights (instead of the number of radiance samples). This gives the quantity:

Equation 5

But, we don't write this quantity exactly to the probe texels. To see why, consider that the term is a sum of cosine values uniformly distributed on the hemisphere. The expected value of this quantity is:

Equation 6

Recalling Equation 4, we get an average by dividing by . If we were to divide by above, the result would be off by a factor of 2. Therefore, we multiply the sum of the cosine weights by 2 before dividing by it to obtain the correct average. This final value is written to the probe texel:

To estimate the irradiance integral, this quantity is read from probes and then multiplied by .

See DDGIGetVolumeIrradiance() in Irradiance.hlsl:

irradiance *= (2.f * RTXGI_PI); // Factored out of the probes

This yields the final estimate of the irradiance integral as described in Equation 3.