// User can chose if they use This is use in case we want to force infinite projection distance (i.e no projection);
public float minProjectionDistance;
public Vector3 innerDistance; // extents of the env light
public Vector3 influenceExtents; // extents of the env light
public float unused0;
public Vector3 offsetLS;
float dimmer;
float3 right;
float minProjectionDistance;
float3 innerDistance;
float3 influenceExtents;
float unused0;
float3 offsetLS;
float unused1;
{
return value.minProjectionDistance;
}
float3 GetInnerDistance(EnvLightData value)
float3 GetInfluenceExtents(EnvLightData value)
return value.innerDistance;
return value.influenceExtents;
float GetUnused0(EnvLightData value)
// probe.bounds.extents is BoxSize / 2
var blendDistancePositive = Vector3.Min(probe.bounds.extents, influenceBlendDistancePositive);
var blendDistanceNegative = Vector3.Min(probe.bounds.extents, influenceBlendDistanceNegative);
envLightData.innerDistance = extents;
envLightData.influenceExtents = extents;
envLightData.envIndex = envIndex;
envLightData.offsetLS = probe.center; // center is misnamed, it is the offset (in local space) from center of the bounding box to the cubemap capture point
envLightData.blendDistancePositive = blendDistancePositive;
output.right = float3(1.0, 0.0, 0.0);
output.positionWS = float3(0.0, 0.0, 0.0);
output.offsetLS = float3(0.0, 0.0, 0.0);
output.innerDistance = float3(0.0, 0.0, 0.0);
output.influenceExtents = float3(0.0, 0.0, 0.0);
output.blendDistancePositive = float3(0.0, 0.0, 0.0);
output.blendDistanceNegative = float3(0.0, 0.0, 0.0);
output.blendNormalDistancePositive = float3(0.0, 0.0, 0.0);
// 1. First process the projection
float3 dirLS = mul(R, worldToLocal);
float sphereOuterDistance = lightData.innerDistance.x;
float sphereOuterDistance = lightData.influenceExtents.x;
float projectionDistance = SphereRayIntersectSimple(positionLS, dirLS, sphereOuterDistance);
projectionDistance = max(projectionDistance, lightData.minProjectionDistance); // Setup projection to infinite if requested (mean no projection shape)
// 2. Process the position influence
float lengthPositionLS = length(positionLS);
float sphereInfluenceDistance = lightData.innerDistance.x - lightData.blendDistancePositive.x;
float sphereInfluenceDistance = lightData.influenceExtents.x - lightData.blendDistancePositive.x;
float insideInfluenceNormalVolume = lengthPositionLS <= (lightData.innerDistance.x - lightData.blendNormalDistancePositive.x) ? 1.0 : 0.0;
float insideInfluenceNormalVolume = lengthPositionLS <= (lightData.influenceExtents.x - lightData.blendNormalDistancePositive.x) ? 1.0 : 0.0;
float insideWeight = InfluenceFadeNormalWeight(bsdfData.normalWS, normalize(positionWS - lightData.positionWS));
alpha *= insideInfluenceNormalVolume ? 1.0 : insideWeight;
#endif
float3 boxOuterDistance = lightData.innerDistance;
float3 boxOuterDistance = lightData.influenceExtents;
float projectionDistance = BoxRayIntersectSimple(positionLS, dirLS, -boxOuterDistance, boxOuterDistance);
float alpha = saturate(influenceFalloff);
#else
float distFace = DistancePointBox(positionLS, -lightData.innerDistance + lightData.blendDistancePositive.x, lightData.innerDistance - lightData.blendDistancePositive.x);
float distFace = DistancePointBox(positionLS, -lightData.influenceExtents + lightData.blendDistancePositive.x, lightData.influenceExtents - lightData.blendDistancePositive.x);
float alpha = saturate(1.0 - distFace / max(lightData.blendDistancePositive.x, 0.0001));