浏览代码

coupling HDLight-Light reset workflow

/main
RSlysz 7 年前
当前提交
8eb9fc52
共有 3 个文件被更改,包括 139 次插入47 次删除
  1. 71
      com.unity.render-pipelines.core/CoreRP/Shadow/AdditionalShadowData.cs
  2. 23
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs
  3. 92
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs

71
com.unity.render-pipelines.core/CoreRP/Shadow/AdditionalShadowData.cs


}
[Range(0.0f, 1.0f)]
public float shadowDimmer = 1.0f;
public float shadowFadeDistance = 10000.0f;
public bool contactShadows = false;
public float shadowDimmer;
public float shadowFadeDistance;
public bool contactShadows;
public float viewBiasMin = 0.5f;
public float viewBiasMax = 10.0f;
public float viewBiasMin;
public float viewBiasMax;
public float viewBiasScale = 1.0f;
public float normalBiasMin = 0.2f;
public float normalBiasMax = 4.0f;
public float viewBiasScale;
public float normalBiasMin;
public float normalBiasMax;
public float normalBiasScale = 1.0f;
public bool sampleBiasScale = true;
public bool edgeLeakFixup = false; // Causes large banding artifacts
public bool edgeToleranceNormal = true;
public float normalBiasScale;
public bool sampleBiasScale;
public bool edgeLeakFixup;
public bool edgeToleranceNormal;
public float edgeTolerance = 1.0f;
public float edgeTolerance;
// shadow related parameters

};
[HideInInspector, SerializeField]
private int shadowCascadeCount = 4;
private int shadowCascadeCount;
private float[] shadowCascadeRatios = new float[3] { 0.05f, 0.2f, 0.3f };
private float[] shadowCascadeRatios;
private float[] shadowCascadeBorders = new float[4] { 0.2f, 0.2f, 0.2f, 0.2f };
private float[] shadowCascadeBorders;
[HideInInspector, SerializeField]
private int shadowAlgorithm;
[HideInInspector, SerializeField]

}
return -1;
}
private void Awake()
{
Reset(); //Init
}
public void Reset()
{
shadowResolution = DefaultShadowResolution;
shadowDimmer = 1.0f;
shadowFadeDistance = 10000.0f;
contactShadows = false;
viewBiasMin = 0.5f;
viewBiasMax = 10.0f;
viewBiasScale = 1.0f;
normalBiasMin = 0.2f;
normalBiasMax = 4.0f;
normalBiasScale = 1.0f;
sampleBiasScale = true;
edgeLeakFixup = false; // Causes large banding artifacts
edgeToleranceNormal = true;
edgeTolerance = 1.0f;
shadowCascadeCount = 4;
shadowCascadeRatios = new float[3] { 0.05f, 0.2f, 0.3f };
shadowCascadeBorders = new float[4] { 0.2f, 0.2f, 0.2f, 0.2f };
shadowAlgorithm = 0;
shadowVariant = 0;
shadowPrecision = 0;
shadowData = new ShadowData();
shadowDatas = new ShadowData[0];
}
}
#if UNITY_EDITOR

void OnEnable()
{
m_ShadowAlgorithm = serializedObject.FindProperty("shadowAlgorithm");
m_ShadowVariant = serializedObject.FindProperty("shadowVariant");
m_ShadowData = serializedObject.FindProperty("shadowData");
m_ShadowDatas = serializedObject.FindProperty("shadowDatas");
m_ShadowCascadeCount = serializedObject.FindProperty("shadowCascadeCount");
m_ShadowVariant = serializedObject.FindProperty("shadowVariant");
m_ShadowData = serializedObject.FindProperty("shadowData");
m_ShadowDatas = serializedObject.FindProperty("shadowDatas");
m_ShadowCascadeCount = serializedObject.FindProperty("shadowCascadeCount");
m_ShadowCascadeRatios = serializedObject.FindProperty("shadowCascadeRatios");
m_ShadowCascadeBorders = serializedObject.FindProperty("shadowCascadeBorders");
}

23
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs


[CustomEditorForRenderPipeline(typeof(Light), typeof(HDRenderPipelineAsset))]
sealed partial class HDLightEditor : LightEditor
{
[MenuItem("CONTEXT/Light/Remove HD Light", false, 0)]
[MenuItem("CONTEXT/Light/Remove Component", false, 0)]
static void RemoveLight(MenuCommand menuCommand)
{
GameObject go = ((Light)menuCommand.context).gameObject;

Undo.DestroyObjectImmediate(go.GetComponent<Light>());
Undo.DestroyObjectImmediate(go.GetComponent<HDAdditionalLightData>());
Undo.DestroyObjectImmediate(go.GetComponent<AdditionalShadowData>());
}
[MenuItem("CONTEXT/Light/Reset", false, 0)]
static void ResetLight(MenuCommand menuCommand)
{
GameObject go = ((Light)menuCommand.context).gameObject;
Assert.IsNotNull(go);
Light light = go.GetComponent<Light>();
HDAdditionalLightData lightAdditionalData = go.GetComponent<HDAdditionalLightData>();
AdditionalShadowData shadowAdditionalData = go.GetComponent<AdditionalShadowData>();
Assert.IsNotNull(light);
Assert.IsNotNull(lightAdditionalData);
Assert.IsNotNull(shadowAdditionalData);
Undo.RecordObjects(new UnityEngine.Object[] { light, lightAdditionalData, shadowAdditionalData }, "Reset HD Light");
light.Reset();
lightAdditionalData.Reset();
shadowAdditionalData.Reset();
}
sealed class SerializedLightData

92
com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs


// 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;
public float punctualIntensity = 600.0f; // Light default to 600 lumen, i.e ~48 candela
public float punctualIntensity;
public float areaIntensity = 200.0f; // Light default to 200 lumen to better match point light
public float areaIntensity;
public const float k_DefaultPunctualLightIntensity = 600.0f; // In lumens
public const float k_DefaultAreaLightIntensity = 200.0f; // In lumens
public const float k_DefaultPunctualLightIntensity = 600.0f; // Light default to 600 lumen, i.e ~48 candela
public const float k_DefaultAreaLightIntensity = 200.0f; // Light default to 200 lumen to better match point light
public float intensity
{

// Only for Spotlight, should be hide for other light
public bool enableSpotReflector = false;
public bool enableSpotReflector;
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()
{

[Range(0.0f, 1.0f)]
public float lightDimmer = 1.0f;
public float lightDimmer;
public float volumetricDimmer = 1.0f;
public float volumetricDimmer;
public float fadeDistance = 10000.0f;
public float fadeDistance;
public bool affectDiffuse = true;
public bool affectSpecular = true;
public bool affectDiffuse;
public bool affectSpecular;
public bool nonLightmappedOnly = false;
public bool nonLightmappedOnly;
public LightTypeExtent lightTypeExtent = LightTypeExtent.Punctual;
public LightTypeExtent lightTypeExtent;
public SpotLightShape spotLightShape = SpotLightShape.Cone;
public SpotLightShape spotLightShape;
public float shapeWidth = 0.5f;
public float shapeWidth;
public float shapeHeight = 0.5f;
public float shapeHeight;
public float aspectRatio = 1.0f;
public float aspectRatio;
public float shapeRadius = 0.0f;
public float shapeRadius;
public float maxSmoothness = 1.0f;
public float maxSmoothness;
public bool applyRangeAttenuation = true;
public bool applyRangeAttenuation;
public bool useOldInspector = false;
public bool featuresFoldout = true;
public bool showAdditionalSettings = false;
public bool useOldInspector;
public bool featuresFoldout;
public bool showAdditionalSettings;
public bool displayAreaLightEmissiveMesh = false;
public bool displayAreaLightEmissiveMesh;
// 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

// For light that used the old intensity system we update them
[System.NonSerialized]
bool needsIntensityUpdate_1_0 = false;
bool needsIntensityUpdate_1_0;
// Runtime datas used to compute light intensity
Light _light;

}
#endif
private void Awake()
{
Reset(); //init
}
public void Reset()
{
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 = 10000.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;
#if UNITY_EDITOR
timelineWorkaround = new TimelineWorkaround();
#endif
InitDefaultHDAdditionalLightData(this);
}
// As we have our own default value, we need to initialize the light intensity correctly
public static void InitDefaultHDAdditionalLightData(HDAdditionalLightData lightData)

正在加载...
取消
保存