// To be able to have correct default values for our lights and to also control the conversion of intensity from the light editor (so it is compatible with GI)
// we add intensity (for each type of light we want to manage).
[System.Obsolete("directionalIntensity is deprecated, use intensity and lightUnit instead")]
public float directionalIntensity ;
public float directionalIntensity = k_DefaultDirectionalLightIntensity ;
public float punctualIntensity ;
public float punctualIntensity = k_DefaultPunctualLightIntensity ;
public float areaIntensity ;
public float areaIntensity = k_DefaultAreaLightIntensity ;
public const float k_DefaultDirectionalLightIntensity = Mathf . PI ; // In lux
public const float k_DefaultPunctualLightIntensity = 6 0 0.0f ; // Light default to 600 lumen, i.e ~48 candela
}
// Only for Spotlight, should be hide for other light
public bool enableSpotReflector ;
public bool enableSpotReflector = false ;
[Range(0.0f, 100.0f)]
public float m_InnerSpotPercent ; // To display this field in the UI this need to be public
}
[Range(0.0f, 1.0f)]
public float lightDimmer ;
public float lightDimmer = 1.0f ;
public float volumetricDimmer ;
public float volumetricDimmer = 1.0f ;
public LightUnit lightUnit ;
public LightUnit lightUnit = LightUnit . Lumen ;
public float fadeDistance ;
public float fadeDistance = 1 0 0 0 0.0f ;
public bool affectDiffuse ;
public bool affectSpecular ;
public bool affectDiffuse = true ;
public bool affectSpecular = true ;
public bool nonLightmappedOnly ;
public bool nonLightmappedOnly = false ;
public LightTypeExtent lightTypeExtent ;
public LightTypeExtent lightTypeExtent = LightTypeExtent . Punctual ;
public SpotLightShape spotLightShape ;
public SpotLightShape spotLightShape = SpotLightShape . Cone ;
public float shapeWidth ;
public float shapeWidth = 0.5f ;
public float shapeHeight ;
public float shapeHeight = 0.5f ;
public float aspectRatio ;
public float aspectRatio = 1.0f ;
// Only for Sphere/Disc
public float shapeRadius ;
public float maxSmoothness ;
public float maxSmoothness = 1.0f ;
public bool applyRangeAttenuation ;
public bool applyRangeAttenuation = true ;
public bool useOldInspector ;
public bool featuresFoldout ;
public bool showAdditionalSettings ;
public bool useOldInspector = false ;
public bool featuresFoldout = true ;
public bool showAdditionalSettings = false ;
public bool displayAreaLightEmissiveMesh ;
public bool displayAreaLightEmissiveMesh = false ;
// Duplication of HDLightEditor.k_MinAreaWidth, maybe do something about that
const float k_MinAreaWidth = 0.01f ; // Provide a small size of 1cm for line light
[System.NonSerialized]
TimelineWorkaround timelineWorkaround ;
TimelineWorkaround timelineWorkaround = new TimelineWorkaround ( ) ;
bool needsIntensityUpdate_1_0 ;
bool needsIntensityUpdate_1_0 = false ;
Light _light ;
Light m_Light
Light _light ;
Light m_Light
{
get
{
SetLightIntensityPunctual ( intensity ) ;
break ;
case LightTypeExtent . Line :
m_Light . intensity = LightUtils . CalculateLineLightLumenToLuminance ( intensity , shapeWidth ) ;
m_Light . intensity = LightUtils . CalculateLineLightLumenToLuminance ( intensity , shapeWidth ) ;
break ;
case LightTypeExtent . Rectangle :
m_Light . intensity = LightUtils . ConvertRectLightLumenToLuminance ( intensity , shapeWidth , shapeHeight ) ;
else
m_Light . intensity = intensity ;
#if UNITY_EDITOR
#if UNITY_EDITOR
#endif
#endif
}
void SetLightIntensityPunctual ( float intensity )
}
if ( m_Light . color ! = timelineWorkaround . oldLightColor
| | transform . localScale ! = timelineWorkaround . oldLocalScale
| | transform . localScale ! = timelineWorkaround . oldLocalScale
| | lightTypeExtent ! = timelineWorkaround . oldLightTypeExtent
| | lightTypeExtent ! = timelineWorkaround . oldLightTypeExtent
| | m_Light . colorTemperature ! = timelineWorkaround . oldLightColorTemperature )
{
UpdateAreaLightEmissiveMesh ( ) ;
public void UpdateAreaLightEmissiveMesh ( )
{
MeshRenderer emissiveMeshRenderer = GetComponent < MeshRenderer > ( ) ;
MeshFilter emissiveMeshFilter = GetComponent < MeshFilter > ( ) ;
MeshRenderer emissiveMeshRenderer = GetComponent < MeshRenderer > ( ) ;
MeshFilter emissiveMeshFilter = GetComponent < MeshFilter > ( ) ;
bool displayEmissiveMesh = IsAreaLight ( lightTypeExtent ) & & lightTypeExtent ! = LightTypeExtent . Line & & displayAreaLightEmissiveMesh ;
DestroyImmediate ( emissiveMeshFilter ) ;
// We don't have anything to do left if the dislay emissive mesh option is disabled
return ;
return ;
}
Vector3 lightSize ;
}
#endif
private void Awake ( )
{
Reset ( ) ; //init
}
public void Reset ( )
public void CopyTo ( HDAdditionalLightData data )
directionalIntensity = k_DefaultDirectionalLightIntensity ;
punctualIntensity = k_DefaultPunctualLightIntensity ;
areaIntensity = k_DefaultAreaLightIntensity ;
enableSpotReflector = false ;
m_InnerSpotPercent = 0.0f ;
lightDimmer = 1.0f ;
volumetricDimmer = 1.0f ;
lightUnit = LightUnit . Lumen ;
fadeDistance = 1 0 0 0 0.0f ;
affectDiffuse = true ;
affectSpecular = true ;
nonLightmappedOnly = false ;
lightTypeExtent = LightTypeExtent . Punctual ;
spotLightShape = SpotLightShape . Cone ;
shapeWidth = 0.5f ;
shapeHeight = 0.5f ;
aspectRatio = 1.0f ;
shapeRadius = 0.0f ;
maxSmoothness = 1.0f ;
applyRangeAttenuation = true ;
useOldInspector = false ;
featuresFoldout = true ;
showAdditionalSettings = false ;
displayLightIntensity = 0f ;
displayAreaLightEmissiveMesh = false ;
needsIntensityUpdate_1_0 = false ;
#pragma warning disable 0618
data . directionalIntensity = directionalIntensity ;
data . punctualIntensity = punctualIntensity ;
data . areaIntensity = areaIntensity ;
#pragma warning restore 0618
data . enableSpotReflector = enableSpotReflector ;
data . m_InnerSpotPercent = m_InnerSpotPercent ;
data . lightDimmer = lightDimmer ;
data . volumetricDimmer = volumetricDimmer ;
data . lightUnit = lightUnit ;
data . fadeDistance = fadeDistance ;
data . affectDiffuse = affectDiffuse ;
data . affectSpecular = affectSpecular ;
data . nonLightmappedOnly = nonLightmappedOnly ;
data . lightTypeExtent = lightTypeExtent ;
data . spotLightShape = spotLightShape ;
data . shapeWidth = shapeWidth ;
data . shapeHeight = shapeHeight ;
data . aspectRatio = aspectRatio ;
data . shapeRadius = shapeRadius ;
data . maxSmoothness = maxSmoothness ;
data . applyRangeAttenuation = applyRangeAttenuation ;
data . useOldInspector = useOldInspector ;
data . featuresFoldout = featuresFoldout ;
data . showAdditionalSettings = showAdditionalSettings ;
data . displayLightIntensity = displayLightIntensity ;
data . displayAreaLightEmissiveMesh = displayAreaLightEmissiveMesh ;
data . needsIntensityUpdate_1_0 = needsIntensityUpdate_1_0 ;
timelineWorkaround = new TimelineWorkaround ( ) ;
data . timelineWorkaround = timelineWorkaround ;
InitDefaultHDAdditionalLightData ( this ) ;
}
// As we have our own default value, we need to initialize the light intensity correctly
light . lightShadowCasterMode = LightShadowCasterMode . Everything ;
}
public void OnBeforeSerialize ( ) { }
public void OnBeforeSerialize ( ) { }
public void OnAfterDeserialize ( )
{
{
if ( needsIntensityUpdate_1_0 )
{
// Pragma to disable the warning got by using deprecated properties (areaIntensity, directionalIntensity, ...)
// Pragma to disable the warning got by using deprecated properties (areaIntensity, directionalIntensity, ...)
#pragma warning disable 0618
switch ( lightTypeExtent )
{