浏览代码

Merge pull request #1665 from Unity-Technologies/fix/coupling-hdlight-workflow

Fix/coupling Light-HDLight workflow waiting for a C++ PR #70472
/main
GitHub 6 年前
当前提交
d2258e34
共有 5 个文件被更改,包括 130 次插入38 次删除
  1. 65
      com.unity.render-pipelines.core/CoreRP/Shadow/AdditionalShadowData.cs
  2. 3
      com.unity.render-pipelines.core/CoreRP/Utilities/CoreUtils.cs
  3. 1
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  4. 25
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs
  5. 74
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs

65
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 bool contactShadows = false;
public float viewBiasMin = 0.5f;
public float viewBiasMax = 10.0f;
public float viewBiasMin = 0.5f;
public float viewBiasMax = 10f;
public float viewBiasScale = 1.0f;
public float normalBiasMin = 0.2f;
public float normalBiasMax = 4.0f;
public float viewBiasScale = 1.0f;
public float normalBiasMin = 0.2f;
public float normalBiasMax = 4.0f;
public float normalBiasScale = 1.0f;
public bool sampleBiasScale = true;
public bool edgeLeakFixup = false; // Causes large banding artifacts
public float normalBiasScale = 1.0f;
public bool sampleBiasScale = true;
public bool edgeLeakFixup = false; // Causes large banding artifacts
public float edgeTolerance = 1.0f;
public float edgeTolerance = 1.0f;
// shadow related parameters

[HideInInspector, SerializeField]
private float[] shadowCascadeBorders = new float[4] { 0.2f, 0.2f, 0.2f, 0.2f };
[HideInInspector, SerializeField]
private int shadowAlgorithm;
private int shadowAlgorithm = 0;
private int shadowVariant;
private int shadowVariant = 0;
private int shadowPrecision;
private int shadowPrecision = 0;
private ShadowData shadowData;
private ShadowData shadowData = new ShadowData();
[HideInInspector, SerializeField]
private ShadowData[] shadowDatas = new ShadowData[0];

}
return -1;
}
public void CopyTo(AdditionalShadowData data)
{
data.shadowResolution = shadowResolution;
data.shadowDimmer = shadowDimmer;
data.shadowFadeDistance = shadowFadeDistance;
data.contactShadows = contactShadows;
data.viewBiasMin = viewBiasMin;
data.viewBiasMax = viewBiasMax;
data.viewBiasScale = viewBiasScale;
data.normalBiasMin = normalBiasMin;
data.normalBiasMax = normalBiasMax;
data.normalBiasScale = normalBiasScale;
data.sampleBiasScale = sampleBiasScale;
data.edgeLeakFixup = edgeLeakFixup;
data.edgeToleranceNormal = edgeToleranceNormal;
data.edgeTolerance = edgeTolerance;
data.shadowCascadeCount = shadowCascadeCount;
data.shadowCascadeRatios = new float[shadowCascadeRatios.Length];
shadowCascadeRatios.CopyTo(data.shadowCascadeRatios, 0);
data.shadowCascadeBorders = new float[shadowCascadeBorders.Length];
shadowCascadeBorders.CopyTo(data.shadowCascadeBorders, 0);
data.shadowAlgorithm = shadowAlgorithm;
data.shadowVariant = shadowVariant;
data.shadowPrecision = shadowPrecision;
data.shadowData = shadowData;
data.shadowDatas = new ShadowData[shadowDatas.Length];
shadowDatas.CopyTo(data.shadowDatas, 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");
}

3
com.unity.render-pipelines.core/CoreRP/Utilities/CoreUtils.cs


public static class CoreUtils
{
// Keep a reference to default values for Reset purpose
static public AdditionalShadowData s_DefaultAdditionalShadowData { get { return ComponentSingleton<AdditionalShadowData>.instance; } }
// Data useful for various cubemap processes.
// Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/bb204881(v=vs.85).aspx
static public readonly Vector3[] lookAtList =

1
com.unity.render-pipelines.high-definition/CHANGELOG.md


- Fix display correct target platform when showing message to inform user that a platform is not supported
- Remove workaround for metal and vulkan in normal buffer encoding/decoding
- Fixed an issue with color picker not working in forward
- Fixed an issue where reseting HDLight do not reset all of its parameters
### Changed
- Changed default reflection probe to be 256x256x6 and array size to be 64

25
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();
// To avoid duplicating init code we copy default settings to Reset additional data
// Note: we can't call this code inside the HDAdditionalLightData, thus why we don't wrap it in a Reset() function
HDUtils.s_DefaultHDAdditionalLightData.CopyTo(lightAdditionalData);
CoreUtils.s_DefaultAdditionalShadowData.CopyTo(shadowAdditionalData);
}
sealed class SerializedLightData

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

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 = 10000.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()
{

正在加载...
取消
保存