Convert to Irradiance

Process

At this step, Lumen converts the results of 64 Ray Traces for each Probe into AmbientRadiance and DirectionalRadiance encoded with spherical harmonics.

image

Detailed Process

image

The entire calculation process is divided into 3 stages, with the last stage consisting of 2 sub-steps.

Stage 1: Each Group thread is responsible for processing the result of one RayTrace.

Calculate the coefficient projected onto the SH based on the direction of the Ray, and load it into the GroupSharedMemory.

Load the Radiance value of the Ray into the GroupSharedMemory.

This can further accelerate the subsequent summation process, without needing to fetch data from the video memory each time.

Stage 2: Summation stage. Each Group thread is responsible for processing one component of the RGBW in one BasisFunction.

Lumen uses 2nd order spherical harmonics, therefore there are a total of 9 BasisFunction coefficients. At the same time, each coefficient has four RGBW components, for a total of 36 threads processing in parallel.

Stage 3: Output stage. Output consists of two parts: Ambient and Directional, each completed by two sub-steps.

In the first sub-step, only one thread is working, outputting the RGB components of Ambient. Note that Ambient is actually the first part of the spherical harmonic coefficients.

In the second sub-step, a total of 3 threads are working, with each thread mapped to one of the R, G, or B components.

Each thread is responsible for counting the current component (i.e. R/G/B) in 8 Directional BasisFunction coefficients, and outputting it to the Directional Texture.