浏览代码

Replace sync event in InfluenceVolume

/main
RSlysz 6 年前
当前提交
7beb31aa
共有 3 个文件被更改,包括 56 次插入26 次删除
  1. 18
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs
  2. 24
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs
  3. 40
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs

18
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs


{
if (needMigrateToHDProbeChild)
MigrateToHDProbeChild();
influenceVolume.OnSizeChanged += UpdateLegacySize;
}
void OnDisable()
{
influenceVolume.OnSizeChanged -= UpdateLegacySize;
}
void UpdateLegacySize(Vector3 newSize, Vector3 newCenter)
{
legacyProbe.size = newSize;
legacyProbe.center = newCenter;
}
void MigrateToHDProbeChild()

base.refreshMode = value;
legacyProbe.refreshMode = value; //ensure compatibility till we capture without the legacy component
}
}
internal override void UpdatedInfluenceVolumeShape(Vector3 size, Vector3 offset)
{
legacyProbe.size = size;
legacyProbe.center = offset;
}
}
}

24
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs


using UnityEngine;
public abstract class HDProbe : MonoBehaviour
[ExecuteInEditMode]
public abstract class HDProbe : MonoBehaviour, ISerializationCallbackReceiver
InfluenceVolume m_InfluenceVolume = new InfluenceVolume();
InfluenceVolume m_InfluenceVolume;
[SerializeField, FormerlySerializedAsAttribute("dimmer"), FormerlySerializedAsAttribute("m_Dimmer"), FormerlySerializedAsAttribute("multiplier")]
float m_Multiplier = 1.0f;

public ReflectionProxyVolumeComponent proxyVolume { get { return m_ProxyVolume; } }
/// <summary>InfluenceVolume of the probe.</summary>
public InfluenceVolume influenceVolume { get { return m_InfluenceVolume; } }
public InfluenceVolume influenceVolume { get { return m_InfluenceVolume; } private set { m_InfluenceVolume = value; } }
/// <summary>Multiplier factor of reflection (non PBR parameter).</summary>
public float multiplier { get { return m_Multiplier; } }

get { return m_RefreshMode; }
set { m_RefreshMode = value; }
}
void Awake()
{
influenceVolume = new InfluenceVolume(this);
}
void ISerializationCallbackReceiver.OnBeforeSerialize()
{
}
void ISerializationCallbackReceiver.OnAfterDeserialize()
{
influenceVolume.Init(this);
}
internal virtual void UpdatedInfluenceVolumeShape(Vector3 size, Vector3 offset) { }
}
}

40
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs


[Serializable]
public class InfluenceVolume
{
internal event Action<Vector3, Vector3> OnSizeChanged;
HDProbe probe;
[SerializeField, FormerlySerializedAs("m_ShapeType")]
Shape m_Shape = Shape.Box;

float m_SphereBlendNormalDistance;
/// <summary>Shape of this InfluenceVolume.</summary>
public Shape shape { get { return m_Shape; } set { m_Shape = value; } }
public Shape shape
{
get { return m_Shape; }
set
{
m_Shape = value;
switch (m_Shape)
{
case Shape.Box:
probe.UpdatedInfluenceVolumeShape(m_BoxSize, offset);
break;
case Shape.Sphere:
probe.UpdatedInfluenceVolumeShape(Vector3.one * (2 * m_SphereRadius), offset);
break;
}
}
}
/// <summary>Offset of this influence volume to the component handling him.</summary>
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }

set
{
m_BoxSize = value;
if (OnSizeChanged != null)
{
OnSizeChanged.Invoke(m_BoxSize, offset);
}
probe.UpdatedInfluenceVolumeShape(m_BoxSize, offset);
}
}

set
{
m_SphereRadius = value;
if (OnSizeChanged != null)
{
OnSizeChanged.Invoke(Vector3.one * m_SphereRadius, offset);
}
probe.UpdatedInfluenceVolumeShape(Vector3.one * (2 * m_SphereRadius), offset);
}
}
/// <summary>

/// Value between 0 (on InfluenceVolume hull) and sphereRadius (fade sub volume reduced to a point).
/// </summary>
public float sphereBlendNormalDistance { get { return m_SphereBlendNormalDistance; } set { m_SphereBlendNormalDistance = value; } }
internal InfluenceVolume(HDProbe probe)
{
Init(probe);
}
internal void Init(HDProbe probe)
{
this.probe = probe;
}
internal BoundingSphere GetBoundingSphereAt(Transform probeTransform)
{

正在加载...
取消
保存