public SerializedProperty affectSpecular ;
public SerializedProperty lightTypeExtent ;
public SerializedProperty spotLightShape ;
public SerializedProperty spotBackReflector ;
public SerializedProperty shapeWidth ;
public SerializedProperty shapeHeight ;
public SerializedProperty aspectRatio ;
affectSpecular = o . Find ( x = > x . affectSpecular ) ,
lightTypeExtent = o . Find ( x = > x . lightTypeExtent ) ,
spotLightShape = o . Find ( x = > x . spotLightShape ) ,
spotBackReflector = o . Find ( x = > x . spotBackReflector ) ,
shapeWidth = o . Find ( x = > x . shapeWidth ) ,
shapeHeight = o . Find ( x = > x . shapeHeight ) ,
aspectRatio = o . Find ( x = > x . aspectRatio ) ,
if ( spotLightShape = = SpotLightShape . Cone )
{
settings . DrawSpotAngle ( ) ;
EditorGUILayout . PropertyField ( m_AdditionalLightData . spotBackReflector , s_Styles . spotBackReflector ) ;
EditorGUILayout . Slider ( m_AdditionalLightData . spotInnerPercent , 0f , 1 0 0f , s_Styles . spotInnerPercent ) ;
}
// TODO : replace with angle and ratio
EditorGUILayout . PropertyField ( m_AdditionalLightData . spotBackReflector , s_Styles . spotBackReflector ) ;
EditorGUILayout . Slider ( m_AdditionalLightData . aspectRatio , 0.05f , 2 0.0f , s_Styles . aspectRatioPyramid ) ;
}
else if ( spotLightShape = = SpotLightShape . Box )
case LightShape . Spot :
// Spot should used conversion which take into account the angle, and thus the intensity vary with angle.
// This is not easy to manipulate for lighter, so we simply consider any spot light as just occluded point light. So reuse the same code.
settings . intensity . floatValue = LightUtils . ConvertPointLightIntensity ( m_AdditionalLightData . punctualIntensity . floatValue ) ;
// TODO: What to do with box shape ?
// var spotLightShape = (SpotLightShape)m_AdditionalLightData.spotLightShape.enumValueIndex;
var spotLightShape = ( SpotLightShape ) m_AdditionalLightData . spotLightShape . enumValueIndex ;
if ( spotLightShape = = SpotLightShape . Cone )
{
settings . intensity . floatValue = LightUtils . ConvertSpotLightIntensity ( m_AdditionalLightData . punctualIntensity . floatValue , settings . spotAngle . floatValue * Mathf . Deg2Rad , m_AdditionalLightData . spotBackReflector . boolValue ) ;
}
else if ( spotLightShape = = SpotLightShape . Pyramid )
{
if ( m_AdditionalLightData . spotBackReflector . boolValue )
{
var aspectRatio = m_AdditionalLightData . aspectRatio . floatValue ;
// Since the smallest angles is = to the fov, and we don't care of the angle order, simply make sure the aspect ratio is > 1
if ( aspectRatio < 1f ) aspectRatio = 1f / aspectRatio ;
var angleA = settings . spotAngle . floatValue * Mathf . Deg2Rad ;
var halfAngle = angleA * 0.5f ;
var length = Mathf . Sin ( halfAngle ) ;
length * = aspectRatio ;
halfAngle = Mathf . Atan ( length ) ;
var angleB = halfAngle * 2f ;
settings . intensity . floatValue = LightUtils . ConvertFrustrumLightIntensity ( m_AdditionalLightData . punctualIntensity . floatValue , angleA , angleB ) ;
}
else
{
settings . intensity . floatValue = LightUtils . ConvertPointLightIntensity ( m_AdditionalLightData . punctualIntensity . floatValue ) ;
}
}
else // box shape, no conversion implemented for the moment. Should use a fresnel light model.
{
settings . intensity . floatValue = LightUtils . ConvertPointLightIntensity ( m_AdditionalLightData . punctualIntensity . floatValue ) ;
}
break ;
case LightShape . Rectangle :