// 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 = Mathf . PI ; // In Lux
public float directionalIntensity = k_DefaultDirectionalLightIntensity ;
public float punctualIntensity = 6 0 0.0f ; // Light default to 600 lumen, i.e ~48 candela
public float punctualIntensity = k_DefaultPunctualLightIntensity ;
public float areaIntensity = 2 0 0.0f ; // Light default to 200 lumen to better match point light
public float areaIntensity = k_DefaultAreaLightIntensity ;
public const float k_DefaultPunctualLightIntensity = 6 0 0.0f ; // In lumens
public const float k_DefaultAreaLightIntensity = 2 0 0.0f ; // In lumens
public const float k_DefaultPunctualLightIntensity = 6 0 0.0f ; // Light default to 600 lumen, i.e ~48 candela
public const float k_DefaultAreaLightIntensity = 2 0 0.0f ; // Light default to 200 lumen to better match point light
public float intensity
{
public bool enableSpotReflector = false ;
[Range(0.0f, 100.0f)]
public float m_InnerSpotPercent = 0.0f ; // To display this field in the UI this need to be public
public float m_InnerSpotPercent ; // To display this field in the UI this need to be public
public float GetInnerSpotPercent01 ( )
{
public float volumetricDimmer = 1.0f ;
// Used internally to convert any light unit input into light intensity
public LightUnit lightUnit ;
public LightUnit lightUnit = LightUnit . Lumen ;
// Not used for directional lights.
public float fadeDistance = 1 0 0 0 0.0f ;
public float aspectRatio = 1.0f ;
// Only for Sphere/Disc
public float shapeRadius = 0.0f ;
public float shapeRadius ;
// Only for Spot/Point - use to cheaply fake specular spherical area light
[Range(0.0f, 1.0f)]
#if UNITY_EDITOR
// We need these old states to make timeline and the animator record the intensity value and the emissive mesh changes (editor-only)
[System.NonSerialized]
TimelineWorkaround timelineWorkaround ;
TimelineWorkaround timelineWorkaround = new TimelineWorkaround ( ) ;
#endif
// For light that used the old intensity system we update them
// Runtime datas used to compute light intensity
Light _light ;
Light m_Light
Light _light ;
Light m_Light
{
get
{
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
public void CopyTo ( HDAdditionalLightData data )
{
#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 ;
#if UNITY_EDITOR
data . timelineWorkaround = timelineWorkaround ;
#endif
}
// As we have our own default value, we need to initialize the light intensity correctly
public static void InitDefaultHDAdditionalLightData ( HDAdditionalLightData lightData )
{
light . lightShadowCasterMode = LightShadowCasterMode . Everything ;
}
public void OnBeforeSerialize ( ) { }
public void OnBeforeSerialize ( ) { }
public void OnAfterDeserialize ( )
{