浏览代码

couple additional data for ReflectionProbe

/main
RSlysz 6 年前
当前提交
9508e09b
共有 4 个文件被更改,包括 69 次插入11 次删除
  1. 25
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs
  2. 11
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs
  3. 4
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs
  4. 40
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs

25
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs


[CanEditMultipleObjects]
partial class HDReflectionProbeEditor : Editor
{
[MenuItem("CONTEXT/ReflectionProbe/Remove HD Reflection Probe", false, 0)]
static void RemoveLight(MenuCommand menuCommand)
[MenuItem("CONTEXT/ReflectionProbe/Remove Component", false, 0)]
static void RemoveReflectionProbe(MenuCommand menuCommand)
{
GameObject go = ((ReflectionProbe)menuCommand.context).gameObject;

Undo.DestroyObjectImmediate(go.GetComponent<ReflectionProbe>());
Undo.DestroyObjectImmediate(go.GetComponent<HDAdditionalReflectionData>());
}
[MenuItem("CONTEXT/ReflectionProbe/Reset", false, 0)]
static void ResetReflectionProbe(MenuCommand menuCommand)
{
GameObject go = ((ReflectionProbe)menuCommand.context).gameObject;
Assert.IsNotNull(go);
ReflectionProbe reflectionProbe = go.GetComponent<ReflectionProbe>();
HDAdditionalReflectionData reflectionProbeAdditionalData = go.GetComponent<HDAdditionalReflectionData>();
Assert.IsNotNull(reflectionProbe);
Assert.IsNotNull(reflectionProbeAdditionalData);
Undo.SetCurrentGroupName("Reset HD Reflection Probe");
Undo.RecordObjects(new UnityEngine.Object[] { reflectionProbe, reflectionProbeAdditionalData }, "Reset HD Reflection Probe");
reflectionProbe.Reset();
// To avoid duplicating init code we copy default settings to Reset additional data
// Note: we can't call this code inside the HDAdditionalReflectionData, thus why we don't wrap it in Reset() function
HDUtils.s_DefaultHDAdditionalReflectionData.CopyTo(reflectionProbeAdditionalData);
}
static Dictionary<ReflectionProbe, HDReflectionProbeEditor> s_ReflectionProbeEditors = new Dictionary<ReflectionProbe, HDReflectionProbeEditor>();

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


bool needMigrateToHDProbeChild = false;
bool needMigrateToUseInfluenceVolume = false;
public void CopyTo(HDAdditionalReflectionData data)
{
influenceVolume.CopyTo(data.influenceVolume);
data.influenceVolume.shape = influenceVolume.shape; //force the legacy probe to refresh its size
data.mode = mode;
data.refreshMode = refreshMode;
data.multiplier = multiplier;
data.weight = weight;
}
public void OnBeforeSerialize()
{
}

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


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; } }
public float multiplier { get { return m_Multiplier; } protected set { m_Multiplier = value; } }
public float weight { get { return m_Weight; } }
public float weight { get { return m_Weight; } protected set { m_Weight = value; } }
/// <summary>The capture mode.</summary>
public virtual ReflectionProbeMode mode

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


[Serializable]
public class InfluenceVolume
{
HDProbe probe;
HDProbe m_Probe;
[SerializeField, FormerlySerializedAs("m_ShapeType")]
InfluenceShape m_Shape = InfluenceShape.Box;

[SerializeField, FormerlySerializedAs("m_SphereInfluenceNormalFade")]
float m_SphereBlendNormalDistance;
internal void CopyTo(InfluenceVolume data)
{
//keep the m_Probe as it is used to reset the probe
data.m_Shape = m_Shape;
data.m_Offset = m_Offset;
data.m_BoxSize = m_BoxSize;
data.m_BoxBlendDistancePositive = m_BoxBlendDistancePositive;
data.m_BoxBlendDistanceNegative = m_BoxBlendDistanceNegative;
data.m_BoxBlendNormalDistancePositive = m_BoxBlendNormalDistancePositive;
data.m_BoxBlendNormalDistanceNegative = m_BoxBlendNormalDistanceNegative;
data.m_BoxSideFadePositive = m_BoxSideFadePositive;
data.m_BoxSideFadeNegative = m_BoxSideFadeNegative;
data.m_SphereRadius = m_SphereRadius;
data.m_SphereBlendDistance = m_SphereBlendDistance;
data.m_SphereBlendNormalDistance = m_SphereBlendNormalDistance;
data.m_EditorAdvancedModeBlendDistancePositive = m_EditorAdvancedModeBlendDistancePositive;
data.m_EditorAdvancedModeBlendDistanceNegative = m_EditorAdvancedModeBlendDistanceNegative;
data.m_EditorSimplifiedModeBlendDistance = m_EditorSimplifiedModeBlendDistance;
data.m_EditorAdvancedModeBlendNormalDistancePositive = m_EditorAdvancedModeBlendNormalDistancePositive;
data.m_EditorAdvancedModeBlendNormalDistanceNegative = m_EditorAdvancedModeBlendNormalDistanceNegative;
data.m_EditorSimplifiedModeBlendNormalDistance = m_EditorSimplifiedModeBlendNormalDistance;
data.m_EditorAdvancedModeEnabled = m_EditorAdvancedModeEnabled;
}
/// <summary>Shape of this InfluenceVolume.</summary>
public InfluenceShape shape
{

switch (m_Shape)
{
case InfluenceShape.Box:
probe.UpdatedInfluenceVolumeShape(m_BoxSize, offset);
m_Probe.UpdatedInfluenceVolumeShape(m_BoxSize, offset);
probe.UpdatedInfluenceVolumeShape(Vector3.one * (2 * m_SphereRadius), offset);
m_Probe.UpdatedInfluenceVolumeShape(Vector3.one * (2 * m_SphereRadius), offset);
break;
}
}

set
{
m_BoxSize = value;
probe.UpdatedInfluenceVolumeShape(m_BoxSize, offset);
m_Probe.UpdatedInfluenceVolumeShape(m_BoxSize, offset);
}
}

set
{
m_SphereRadius = value;
probe.UpdatedInfluenceVolumeShape(Vector3.one * (2 * m_SphereRadius), offset);
m_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; } }
this.probe = probe;
this.m_Probe = probe;
}
internal BoundingSphere GetBoundingSphereAt(Transform probeTransform)

正在加载...
取消
保存