float3x3 ltcTransformCoat; // Inverse transformation for GGX (4x VGPRs)
float ltcMagnitudeCoatFresnel;
#if HAS_REFRACTION
#endif
ZERO_INITIALIZE(PreLightData, preLightData);
// Don't init to zero to allow to track warning about uninitialized data
float3 N = bsdfData.normalWS;
preLightData.NdotV = dot(N, V);
ltcGGXFresnelMagnitude = ltcMagnitude.g;
preLightData.ltcMagnitudeCoatFresnel = (CLEAR_COAT_F0 * ltcGGXFresnelMagnitudeDiff + ltcGGXFresnelMagnitude) * bsdfData.coatMask;
}
else
{
preLightData.ltcTransformCoat = 0.0;
preLightData.ltcMagnitudeCoatFresnel = 0.0;
}
#ifdef REFRACTION_MODEL
#if HAS_REFRACTION
RefractionModelResult refraction = REFRACTION_MODEL(V, posInput, bsdfData);
preLightData.transparentRefractV = refraction.rayWS;
preLightData.transparentPositionWS = refraction.positionWS;
float3 R = preLightData.iblR;
#if HAS_REFRACTION
#endif
// Note: using influenceShapeType and projectionShapeType instead of (lightData|proxyData).shapeType allow to make compiler optimization in case the type is know (like for sky)
EvaluateLight_EnvIntersection(positionWS, bsdfData.normalWS, lightData, influenceShapeType, R, weight);
// Can't attenuate diffuse lighting here, may try to apply something on bakeLighting in PostEvaluateBSDF
}
}
#if HAS_REFRACTION
else
{
// No clear coat support with refraction
envLighting = (1.0 - F) * preLD.rgb * preLightData.transparentTransmittance;
}
#endif
#endif // LIT_DISPLAY_REFERENCE_IBL
if (GPUImageBasedLightingType == GPUIMAGEBASEDLIGHTINGTYPE_REFLECTION)
lighting.specularReflected = envLighting;
#if HAS_REFRACTION
#endif
return lighting;
}