|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Define macro for a better understanding of the loop |
|
|
|
#define EVALUATE_BSDF_ENV(envLightData, TYPE, type) \ |
|
|
|
if (IsMatchingLightLayer(envLightData.lightLayers, builtinData.renderingLayers)) \ |
|
|
|
{ \ |
|
|
|
#define EVALUATE_BSDF_ENV_SKY(envLightData, TYPE, type) \ |
|
|
|
AccumulateIndirectLighting(lighting, aggregateLighting); \ |
|
|
|
} |
|
|
|
AccumulateIndirectLighting(lighting, aggregateLighting); |
|
|
|
|
|
|
|
// Environment cubemap test lightlayers, sky don't test it |
|
|
|
#define EVALUATE_BSDF_ENV(envLightData, TYPE, type) if (IsMatchingLightLayer(envLightData.lightLayers, builtinData.renderingLayers)) { EVALUATE_BSDF_ENV_SKY(envLightData, TYPE, type) } |
|
|
|
|
|
|
|
// First loop iteration |
|
|
|
if (featureFlags & (LIGHTFEATUREFLAGS_ENV | LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_SSREFRACTION | LIGHTFEATUREFLAGS_SSREFLECTION)) |
|
|
|
|
|
|
// Only apply the sky if we haven't yet accumulated enough IBL lighting. |
|
|
|
if (reflectionHierarchyWeight < 1.0) |
|
|
|
{ |
|
|
|
EVALUATE_BSDF_ENV(envLightSky, REFLECTION, reflection); |
|
|
|
EVALUATE_BSDF_ENV_SKY(envLightSky, REFLECTION, reflection); |
|
|
|
} |
|
|
|
|
|
|
|
if (featureFlags & LIGHTFEATUREFLAGS_SSREFRACTION) |
|
|
|
|
|
|
EVALUATE_BSDF_ENV(envLightSky, REFRACTION, refraction); |
|
|
|
EVALUATE_BSDF_ENV_SKY(envLightSky, REFRACTION, refraction); |
|
|
|
#undef EVALUATE_BSDF_ENV_SKY |
|
|
|
|
|
|
|
// Also Apply indiret diffuse (GI) |
|
|
|
// PostEvaluateBSDF will perform any operation wanted by the material and sum everything into diffuseLighting and specularLighting |
|
|
|