浏览代码

Merge pull request #1679 from Unity-Technologies/refactor-reflectionprobe/make-probes-common-ancestor

Refactor reflectionprobe 0 : make probes common ancestor
/main
GitHub 6 年前
当前提交
1dd1fa8a
共有 8 个文件被更改,包括 129 次插入51 次删除
  1. 8
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs
  2. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs
  3. 6
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs
  4. 56
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs
  5. 35
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs
  6. 16
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ProbeWrapper.cs
  7. 46
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs
  8. 11
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs.meta

8
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs


Handles.matrix = m;
}
if (d.proxyVolumeReference != null)
ReflectionProxyVolumeComponentUI.DrawHandles_EditNone(s.reflectionProxyVolume, d.proxyVolumeReference);
if (d.proxyVolume != null)
ReflectionProxyVolumeComponentUI.DrawHandles_EditNone(s.reflectionProxyVolume, d.proxyVolume);
}
[DrawGizmo(GizmoType.Selected)]

}
}
if (d.proxyVolumeReference != null)
ReflectionProxyVolumeComponentUI.DrawGizmos_EditNone(s.reflectionProxyVolume, d.proxyVolumeReference);
if (d.proxyVolume != null)
ReflectionProxyVolumeComponentUI.DrawGizmos_EditNone(s.reflectionProxyVolume, d.proxyVolume);
var showFrustrum = s.showCaptureHandles
|| EditMode.editMode == EditCenter;

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs


Apply();
}
proxyVolumeComponent = addso.Find((HDAdditionalReflectionData d) => d.proxyVolumeComponent);
proxyVolumeComponent = addso.Find((HDAdditionalReflectionData d) => d.proxyVolume);
}
public void Update()

6
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs


{
this.serializedObject = serializedObject;
proxyVolumeReference = serializedObject.Find((PlanarReflectionProbe p) => p.proxyVolumeReference);
proxyVolumeReference = serializedObject.Find((PlanarReflectionProbe p) => p.proxyVolume);
influenceVolume = new SerializedInfluenceVolume(serializedObject.Find((PlanarReflectionProbe p) => p.influenceVolume));
captureLocalPosition = serializedObject.Find((PlanarReflectionProbe p) => p.captureLocalPosition);

var objs = new List<Object>();
for (var i = 0; i < serializedObject.targetObjects.Length; i++)
{
var p = ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolumeReference;
var p = ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolume;
if (p != null)
objs.Add(p);
}

var proxyVolumeTargets = reflectionProxyVolume.serializedObject.targetObjects;
for (var i = 0; i < serializedObject.targetObjects.Length; i++)
{
if (proxyVolumeTargets[i] != ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolumeReference)
if (proxyVolumeTargets[i] != ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolume)
{
updateProxyVolume = true;
break;

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


using UnityEngine.Serialization;
using UnityEngine.Experimental.Rendering.HDPipeline;
using System;
using UnityEngine.Rendering;
public class HDAdditionalReflectionData : MonoBehaviour, ISerializationCallbackReceiver
public class HDAdditionalReflectionData : HDProbe, ISerializationCallbackReceiver
const int currentVersion = 1;
const int currentVersion = 2;
ReflectionProbe m_LegacyProbe;
ReflectionProbe legacyProbe { get { return m_LegacyProbe ?? (m_LegacyProbe = GetComponent<ReflectionProbe>()); } }
[FormerlySerializedAsAttribute("dimmer")]
public float multiplier = 1.0f;
[Range(0.0f, 1.0f)]
public float weight = 1.0f;
public float influenceSphereRadius = 3.0f;
public float sphereReprojectionVolumeRadius = 1.0f;
public bool useSeparateProjectionVolume = false;

[SerializeField] private float editorSimplifiedModeBlendNormalDistance;
[SerializeField] private bool editorAdvancedModeEnabled;
public ReflectionProxyVolumeComponent proxyVolumeComponent;
bool needMigrateToHDProbeChild = false;
public Vector3 boxBlendCenterOffset { get { return (blendDistanceNegative - blendDistancePositive) * 0.5f; } }
public Vector3 boxBlendSizeOffset { get { return -(blendDistancePositive + blendDistanceNegative); } }

if (m_Version != currentVersion)
{
// Add here data migration code
m_Version = currentVersion;
if (m_Version < 2)
{
needMigrateToHDProbeChild = true;
}
else
{
m_Version = currentVersion;
}
}
}
private void OnEnable()
{
if (needMigrateToHDProbeChild)
MigrateToHDProbeChild();
}
void MigrateToHDProbeChild()
{
mode = legacyProbe.mode;
refreshMode = legacyProbe.refreshMode;
m_Version = 2;
OnAfterDeserialize(); //continue migrating if needed
}
public override ReflectionProbeMode mode
{
set
{
base.mode = value;
legacyProbe.mode = value; //ensure compatibility till we capture without the legacy component
}
}
public override ReflectionProbeRefreshMode refreshMode
{
set
{
base.refreshMode = value;
legacyProbe.refreshMode = value; //ensure compatibility till we capture without the legacy component
}
}
}

35
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[ExecuteInEditMode]
public class PlanarReflectionProbe : MonoBehaviour, ISerializationCallbackReceiver
public class PlanarReflectionProbe : HDProbe, ISerializationCallbackReceiver
{
[HideInInspector]
const int currentVersion = 1;

}
[SerializeField]
ReflectionProxyVolumeComponent m_ProxyVolumeReference = null;
[SerializeField]
[FormerlySerializedAsAttribute("m_Dimmer")]
float m_Multiplier = 1.0f;
[SerializeField]
[Range(0.0f, 1.0f)]
float m_Weight = 1.0f;
[SerializeField]
ReflectionProbeMode m_Mode = ReflectionProbeMode.Baked;
[SerializeField]
ReflectionProbeRefreshMode m_RefreshMode = ReflectionProbeRefreshMode.OnAwake;
[SerializeField]
Texture m_CustomTexture;
[SerializeField]
Texture m_BakedTexture;

public bool overrideFieldOfView { get { return m_OverrideFieldOfView; } }
public float fieldOfViewOverride { get { return m_FieldOfViewOverride; } }
public ReflectionProxyVolumeComponent proxyVolumeReference { get { return m_ProxyVolumeReference; } }
public InfluenceVolume influenceVolume { get { return m_InfluenceVolume; } }
public BoundingSphere boundingSphere { get { return m_InfluenceVolume.GetBoundingSphereAt(transform); } }

{
switch (m_Mode)
switch (mode)
{
default:
case ReflectionProbeMode.Baked:

}
public Bounds bounds { get { return m_InfluenceVolume.GetBoundsAt(transform); } }
public Vector3 captureLocalPosition { get { return m_CaptureLocalPosition; } set { m_CaptureLocalPosition = value; } }
public float weight { get { return m_Weight; } }
public float multiplier { get { return m_Multiplier; } }
public ReflectionProbeMode mode { get { return m_Mode; } }
public Matrix4x4 influenceToWorld
{
get

public Texture customTexture { get { return m_CustomTexture; } set { m_CustomTexture = value; } }
public Texture bakedTexture { get { return m_BakedTexture; } set { m_BakedTexture = value; }}
public RenderTexture realtimeTexture { get { return m_RealtimeTexture; } internal set { m_RealtimeTexture = value; } }
public ReflectionProbeRefreshMode refreshMode { get { return m_RefreshMode; } }
public FrameSettings frameSettings { get { return m_FrameSettings; } }
public float captureNearPlane { get { return m_CaptureNearPlane; } }
public float captureFarPlane { get { return m_CaptureFarPlane; } }

{
get
{
return m_ProxyVolumeReference != null
? m_ProxyVolumeReference.transform.localToWorldMatrix
return proxyVolume != null
? proxyVolume.transform.localToWorldMatrix
: influenceToWorld;
}
}

{
return m_ProxyVolumeReference != null
? m_ProxyVolumeReference.proxyVolume.shapeType
return proxyVolume != null
? proxyVolume.proxyVolume.shapeType
: influenceVolume.shapeType;
}
}

{
return m_ProxyVolumeReference != null
? m_ProxyVolumeReference.proxyVolume.extents
return proxyVolume != null
? proxyVolume.proxyVolume.extents
public bool infiniteProjection { get { return m_ProxyVolumeReference != null && m_ProxyVolumeReference.proxyVolume.infiniteProjection; } }
public bool infiniteProjection { get { return proxyVolume != null && proxyVolume.proxyVolume.infiniteProjection; } }
public bool useMirrorPlane
{

16
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ProbeWrapper.cs


{
get
{
return additional.proxyVolumeComponent != null
? ConvertShape(additional.proxyVolumeComponent.proxyVolume.shapeType)
return additional.proxyVolume != null
? ConvertShape(additional.proxyVolume.proxyVolume.shapeType)
: influenceShapeType;
}
}

{
return additional.proxyVolumeComponent != null
? additional.proxyVolumeComponent.proxyVolume.extents
return additional.proxyVolume != null
? additional.proxyVolume.proxyVolume.extents
: influenceExtents;
}
}

get
{
return additional.proxyVolumeComponent != null
? additional.proxyVolumeComponent.proxyVolume.infiniteProjection
return additional.proxyVolume != null
? additional.proxyVolume.proxyVolume.infiniteProjection
: probe.boxProjection == 0;
}
}

get
{
return additional.proxyVolumeComponent != null
? additional.proxyVolumeComponent.transform.localToWorldMatrix
return additional.proxyVolume != null
? additional.proxyVolume.transform.localToWorldMatrix
: influenceToWorld;
}
}

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


using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public abstract class HDProbe : MonoBehaviour
{
[SerializeField, FormerlySerializedAs("proxyVolumeComponent"), FormerlySerializedAs("m_ProxyVolumeReference")]
ReflectionProxyVolumeComponent m_ProxyVolume = null;
[SerializeField, FormerlySerializedAsAttribute("dimmer"), FormerlySerializedAsAttribute("m_Dimmer"), FormerlySerializedAsAttribute("multiplier")]
float m_Multiplier = 1.0f;
[SerializeField, FormerlySerializedAsAttribute("weight")]
[Range(0.0f, 1.0f)]
float m_Weight = 1.0f;
[SerializeField]
ReflectionProbeMode m_Mode = ReflectionProbeMode.Baked;
[SerializeField]
ReflectionProbeRefreshMode m_RefreshMode = ReflectionProbeRefreshMode.OnAwake;
/// <summary>ProxyVolume currently used by this probe.</summary>
public ReflectionProxyVolumeComponent proxyVolume { get { return m_ProxyVolume; } }
/// <summary>Multiplier factor of reflection (non PBR parameter).</summary>
public float multiplier { get { return m_Multiplier; } }
/// <summary>Weight for blending amongst probes (non PBR parameter).</summary>
public float weight { get { return m_Weight; } }
/// <summary>The capture mode.</summary>
public virtual ReflectionProbeMode mode
{
get { return m_Mode; }
set { m_Mode = value; }
}
/// <summary>Refreshing rate of the capture for Realtime capture mode.</summary>
public virtual ReflectionProbeRefreshMode refreshMode
{
get { return m_RefreshMode; }
set { m_RefreshMode = value; }
}
}
}

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


fileFormatVersion: 2
guid: 843017cb1cb3fa441a28e5a674bfea8e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存