|
|
|
|
|
|
if (lightData.lightType != LightType.Directional) |
|
|
|
{ |
|
|
|
// Light attenuation in lightweight matches the unity vanilla one.
|
|
|
|
// attenuation = 1.0 / 1.0 + distanceToLightSqr * quadraticAttenuation
|
|
|
|
// then a smooth factor is applied to linearly fade attenuation to light range
|
|
|
|
// the attenuation smooth factor starts having effect at 80% of light range
|
|
|
|
// attenuation = 1.0 / distanceToLightSqr
|
|
|
|
// We offer two different smoothing factors.
|
|
|
|
// The smoothing factors make sure that the light intensity is zero at the light range limit.
|
|
|
|
// The first smoothing factor is a linear fade starting at 80 % of the light range.
|
|
|
|
|
|
|
|
// The other smoothing factor matches the one used in the Unity lightmapper but is slower than the linear one.
|
|
|
|
// smoothFactor = (1.0 - saturate((distanceSqr * 1.0 / lightrangeSqr)^2))^2
|
|
|
|
lightAttenuation.x = oneOverFadeRangeSqr; |
|
|
|
float oneOverLightRangeSqr = 1.0f / Mathf.Max(0.0001f, lightData.range * lightData.range); |
|
|
|
lightAttenuation.x = SystemInfo.deviceType == DeviceType.Handheld ? oneOverFadeRangeSqr : oneOverLightRangeSqr; |
|
|
|
lightAttenuation.y = lightRangeSqrOverFadeRangeSqr; |
|
|
|
subtractiveMixedLighting = 1.0f; |
|
|
|
} |
|
|
|