浏览代码

Merge pull request #400 from Unity-Technologies/new-light-editor

New light editor
/main
GitHub 7 年前
当前提交
180ce393
共有 1 个文件被更改,包括 23 次插入16 次删除
  1. 39
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/Editor/HDLightEditor.cs

39
ScriptableRenderPipeline/HDRenderPipeline/Lighting/Editor/HDLightEditor.cs


SerializedObject additionalDataSerializedObject;
SerializedObject shadowDataSerializedObject;
SerializedProperty m_SpotInnerAngle;
SerializedProperty m_SpotInnerPercent;
SerializedProperty m_LightDimmer;
SerializedProperty m_FadeDistance;
SerializedProperty m_AffectDiffuse;

// kLightBaked = 1 << 1, // light will always be fully baked
// kLightMixed = 1 << 0, // depends on selected LightmapMixedBakeMode
//};
// This mean that m_Lightmapping.enumValueIndex is enum { Stationary=0, Static=1, Dynamic=2 }
// This mean that m_Lightmapping.enumValueIndex is enum { Mixed=0, Baked=1, Realtime=2 }
Stationary = 0,
Static=1,
Dynamic=2
Mixed,
Baked,
Realtime
}
protected class Styles

public static GUIContent SpotLightShape = new GUIContent("SpotLightShape", "The shape use for the spotlight. Have impact on cookie transformation and light angular attenuation.");
public static GUIContent SpotAngle = new GUIContent("Spot Angle", "Controls the angle in degrees at the base of a Spot light's cone.");
public static GUIContent SpotInnerAngle = new GUIContent("Spot Inner Angle", "Controls the inner angle in percent of the base angle of a Spot light's cone.");
public static GUIContent SpotInnerPercent = new GUIContent("Spot Inner Percent", "Controls the inner angle in percent of the base angle of a Spot light's cone.");
public static GUIContent Color = new GUIContent("Color", "Controls the color being emitted by the light.");
public static GUIContent Intensity = new GUIContent("Intensity", "Controls the brightness of the light. Light color is multiplied by this value.");

public static GUIContent ShadowCascadeCount = new GUIContent("ShadowCascadeCount", "");
public static GUIContent[] ShadowCascadeRatios = new GUIContent[6] { new GUIContent("Cascade 1"), new GUIContent("Cascade 2"), new GUIContent("Cascade 3"), new GUIContent("Cascade 4"), new GUIContent("Cascade 5"), new GUIContent("Cascade 6") };
public static GUIContent AffectDiffuse = new GUIContent("AffectDiffuse", "This will disable diffuse lighting for this light. Don't save performance, diffuse lighting is still.");
public static GUIContent AffectSpecular = new GUIContent("AffectSpecular", "This will disable specular lighting for this light. Don't save performance, specular lighting is still.");
public static GUIContent AffectDiffuse = new GUIContent("AffectDiffuse", "This will disable diffuse lighting for this light. Don't save performance, diffuse lighting is still computed.");
public static GUIContent AffectSpecular = new GUIContent("AffectSpecular", "This will disable specular lighting for this light. Don't save performance, specular lighting is still computed.");
public static GUIContent FadeDistance = new GUIContent("FadeDistance", "The light color will fade at distance FadeDistance before being culled to minimize popping.");
public static GUIContent LightDimmer = new GUIContent("LightDimmer", "Aim to be use with script, timeline or animation. It allow to dim one or multiple lights of heterogeneous intensity easily (Else you need to know the intensity of each light)");
public static GUIContent ApplyRangeAttenuation = new GUIContent("ApplyRangeAttenuation", "Allow to disable range attenuation. This aim to be use indoor (like a room) to avoid to have to setup a large range for a light to get correct inverse square attenuation that may leak out of the indoor");

public static string lightShapeText = "LightShape";
public static readonly string[] lightShapeNames = Enum.GetNames(typeof(LightShape));
public static string lightmappingModeText = "Mode";
public static readonly string[] lightmappingModeNames = Enum.GetNames(typeof(LightMappingType));
}
static Styles s_Styles;

private bool lightmappingTypeIsSame { get { return !m_Lightmapping.hasMultipleDifferentValues; } }
private bool isRealtime { get { return m_Lightmapping.enumValueIndex == (int)LightMappingType.Dynamic; } }
private bool isRealtime { get { return m_Lightmapping.enumValueIndex == (int)LightMappingType.Realtime; } }
private bool isBakedOrMixed { get { return !isRealtime; } }

shadowDataSerializedObject = new SerializedObject(shadowDatas);
// Additional data
m_SpotInnerAngle = additionalDataSerializedObject.FindProperty("m_InnerSpotPercent");
m_SpotInnerPercent = additionalDataSerializedObject.FindProperty("m_InnerSpotPercent");
m_LightDimmer = additionalDataSerializedObject.FindProperty("lightDimmer");
m_FadeDistance = additionalDataSerializedObject.FindProperty("fadeDistance");
m_AffectDiffuse = additionalDataSerializedObject.FindProperty("affectDiffuse");

if (m_SpotLightShape.enumValueIndex == (int)SpotLightShape.Cone)
{
EditorGUILayout.Slider(m_SpotAngle, 1f, 179f, Styles.SpotAngle);
EditorGUILayout.Slider(m_SpotInnerAngle, 0f, 100f, Styles.SpotInnerAngle);
EditorGUILayout.Slider(m_SpotInnerPercent, 0f, 100f, Styles.SpotInnerPercent);
}
// TODO : replace with angle and ratio
if (m_SpotLightShape.enumValueIndex == (int)SpotLightShape.Pyramid)

// Fake line with a small rectangle in vanilla unity for GI
m_AreaSizeX.floatValue = m_ShapeLength.floatValue;
m_AreaSizeY.floatValue = 0.01f;
m_ShadowsType.enumValueIndex = (int)LightShadows.None;
break;
case (LightShape)(-1):

EditorGUILayout.HelpBox(Styles.IndirectBounceShadowWarning.text, MessageType.Info);
}
EditorGUILayout.PropertyField(m_Range, Styles.Range);
EditorGUILayout.PropertyField(m_Lightmapping, Styles.LightmappingMode);
// We need to overwrite the name of the default enum that doesn't make any sense
// EditorGUILayout.PropertyField(m_Lightmapping, Styles.LightmappingMode);
m_Lightmapping.enumValueIndex = EditorGUILayout.Popup(Styles.lightmappingModeText, (int)m_Lightmapping.enumValueIndex, Styles.lightmappingModeNames);
// Warning if GI Baking disabled and m_Lightmapping isn't realtime
if (bakingWarningValue)

{
if (m_ShadowsType.enumValueIndex != (int)LightShadows.None)
{
if (m_Lightmapping.enumValueIndex == (int)LightMappingType.Static)
if (m_Lightmapping.enumValueIndex == (int)LightMappingType.Baked)
{
switch ((LightType)m_Type.enumValueIndex)
{

EditorGUILayout.PropertyField(m_LightDimmer, Styles.LightDimmer);
EditorGUILayout.PropertyField(m_ApplyRangeAttenuation, Styles.ApplyRangeAttenuation);
if (m_ShadowsType.enumValueIndex != (int)LightShadows.None && m_Lightmapping.enumValueIndex != (int)LightMappingType.Static)
if (m_ShadowsType.enumValueIndex != (int)LightShadows.None && m_Lightmapping.enumValueIndex != (int)LightMappingType.Baked)
{
EditorGUILayout.LabelField(new GUIContent("Shadows"), EditorStyles.boldLabel);
EditorGUILayout.PropertyField(m_ShadowFadeDistance, Styles.ShadowFadeDistance);

EditorGUILayout.LabelField(new GUIContent("Light features"), EditorStyles.boldLabel);
// Do not display option for shadow if we are fully bake
if (m_Lightmapping.enumValueIndex != (int)LightMappingType.Static)
if (m_Lightmapping.enumValueIndex != (int)LightMappingType.Baked)
{
if (EditorGUILayout.Toggle(new GUIContent("Enable Shadow"), m_ShadowsType.enumValueIndex != 0))
m_ShadowsType.enumValueIndex = (int)LightShadows.Hard;

}
// shadow cascade
if (m_Type.enumValueIndex == (int)LightType.Directional && m_Lightmapping.enumValueIndex != (int)LightMappingType.Static)
if (m_Type.enumValueIndex == (int)LightType.Directional && m_Lightmapping.enumValueIndex != (int)LightMappingType.Baked)
{
EditorGUI.indentLevel--;
EditorLightUtilities.DrawSplitter();

正在加载...
取消
保存