return alpha;
}
float InfluenceBoxWeight(EnvLightData lightData, BSDFData bsdfData, float3 positionWS, float3 positionLS, float3 dirL S)
float InfluenceBoxWeight(EnvLightData lightData, BSDFData bsdfData, float3 positionWS, float3 positionIS, float3 dirI S)
{
float3 boxOuterDistance = lightData.influenceExtents;
// 2. Process the position influence
float3 negativeDistance = boxOuterDistance + positionL S;
float3 positiveDistance = boxOuterDistance - positionL S;
float3 negativeDistance = boxOuterDistance + positionI S;
float3 positiveDistance = boxOuterDistance - positionI S;
#endif
#if defined(ENVMAP_FEATURE_PERFACEINFLUENCE)
float alpha = saturate(influenceFalloff);
#else
float distFace = DistancePointBox(positionL S, -lightData.influenceExtents + lightData.blendDistancePositive.x, lightData.influenceExtents - lightData.blendDistancePositive.x);
float distFace = DistancePointBox(positionI S, -lightData.influenceExtents + lightData.blendDistancePositive.x, lightData.influenceExtents - lightData.blendDistancePositive.x);
float alpha = saturate(1.0 - distFace / max(lightData.blendDistancePositive.x, 0.0001));
#endif
// We consider R.x as cos(X) and then fade as angle from 60°(=acos(1/2)) to 75°(=acos(1/4))
// For positive axes: axisFade = (R - 1/4) / (1/2 - 1/4)
// <=> axisFace = 4 * R - 1;
float3 faceFade = saturate((4 * dirLS - 1) * lightData.boxSideFadePositive) + saturate((-4 * dirL S - 1) * lightData.boxSideFadeNegative);
float3 faceFade = saturate((4 * dirIS - 1) * lightData.boxSideFadePositive) + saturate((-4 * dirI S - 1) * lightData.boxSideFadeNegative);
alpha *= saturate(faceFade.x + faceFade.y + faceFade.z);
#endif
float3x3 WorldToLight Space(EnvLightData lightData)
float3x3 WorldToInfluence Space(EnvLightData lightData)
float3 WorldToLightPosition(EnvLightData lightData, float3x3 worldToL S, float3 positionWS)
float3 WorldToInfluencePosition(EnvLightData lightData, float3x3 worldToI S, float3 positionWS)
float3 positionL S = positionWS - lightData.positionWS;
positionLS = mul(positionLS, worldToL S).xyz;
return positionL S;
float3 positionI S = positionWS - lightData.positionWS;
positionIS = mul(positionIS, worldToI S).xyz;
return positionI S;
}
#endif // UNITY_VOLUMEPROJECTION_INCLUDED