Lighting Equation
- Last UpdatedAug 22, 2023
- 2 minute read
FGI is based on dynamic lighting. Some parts are pre-computed (Probes) and some parts are realtime (Lights, Sun, Shadows).
In order to simulate reflected light, the Shader requires a diffuse and specular component.
Scenario example
This example would produce the following equation.
Equation [1]
result = (probesAmbient*diffuse) + (lights*diffuse) + (lights.specular*specularColor) + (sun*diffuse*sunShadows)
Note: To skip the specular calculations, do not connect anything to the specularColor input.
Realistic shadows
Equation [1] produces realistic shadows. In this equation, the sun is treated differently from the other lights because it is combined with the cascaded shadow maps output.
result = (probesAmbient*diffuse) + (lights*diffuse) + (lights.specular*specularColor) + (sun*diffuse*sunShadows)
This gives a realistic look to the image, because a pixel in shadow is treated like a pixel that does not receive that sunlight's color.
This effect is enabled by the FGI parameter realisticShadows. In this situation, the shadow color parameter is not considered because a pixel in shadow is just a pixel that is "missing" the contribution of the light that is casting the shadow.
Non-realistic shadows
When realisticShadows is turned off, the shadows are applied at the end of the lighting equation. So, the final pixel is colored by the shadow's color and intensity. The Equation [1] then becomes:
// Non-Realistic Shadows equation
result = shadowColor * ((probesAmbient*diffuse) + (lights*diffuse) + (lights.specular*specularColor) + (sun*diffuse))
Note: Realtime reflections may work only if the reflectionDetail is set to low.
