Lumen Reflections

Changed Test Scene

image

In order to better demonstrate the working process of Lumen Reflection, I adjusted the material of the floor in this step, changing its roughness to 0 and its metallicness to 1, creating a surface similar to a mirror.

Process

Tile Classification and Compact

Please note that Lumen Reflection is only used to handle the area of mirror reflection.

If we directly trace the pixels on the screen, many areas are not mirror reflections, so the threads corresponding to those pixels will skip all calculations. This causes a lot of thread waste.

Therefore, Lumen first organizes the pixels in the GBuffer that really need reflection calculations, and then parallel traces only these areas as much as possible.

This needs to be divided into two sub-steps: recognizing the pixels on the screen and merging the recognized tiles.

image

Tile Classification

ℹ️
Engine\Shaders\Private\Lumen\LumenReflections.usf : ReflectionTileClassificationMarkCS

In this step, Lumen splits the screen into tiles of 8x8 and analyzes the GBuffer for each tile. If the pixels in the tile meet the conditions for reflection calculation, the tile is marked as valid.

Conditions for enabling Reflection calculation

ℹ️
Engine\Shaders\Private\Lumen\LumenReflections.usf : NeedRayTracedReflections
  • Based on roughness calculation, the function is determined as: LumenCombineReflectionsAlpha
  • Alternatively, the material is ClearCoat.

Compact

ℹ️
Engine\Shaders\Private\Lumen\LumenReflections.usf :ReflectionTileClassificationBuildListsCS

During this step, the information obtained from the Tile in the previous step will be merged, and the output will be a one-dimensional RWReflectionTileData array.

Generate Rays

ℹ️
Engine\Shaders\Private\Lumen\LumenReflections.usf : ReflectionGenerateRaysCS

During the Lumen Reflection stage, the task of generating rays becomes much simpler. We no longer need to calculate the distribution of PDF based on LightPDF in order to generate rays. Instead, we can directly calculate the direction of the final Trace Ray based on the Camera Vector and surface normal.

RayDirection = reflect(CameraVector, Material.WorldNormal);
ℹ️
For the Strata material, Lumen has a special treatment here. If readers are interested in this, please read the source code of the ReflectionGenerateRaysCS function.

Trace

The following Trace process is actually a simplified version of Screen, Mesh, Voxel Trace. Therefore, we will not repeat the details. Here we directly provide the process and comparison with the ScreenProbeGather phase.

image