浏览代码

[PlanarReflection] Added plane mirror data

/main
Frédéric Vauchelles 7 年前
当前提交
68489545
共有 5 个文件被更改,包括 70 次插入10 次删除
  1. 28
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Drawers.cs
  2. 22
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs
  3. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs
  4. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs
  5. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/PlanarReflectionProbe.cs

28
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Drawers.cs


CED.Action(Drawer_SectionInfluenceSettings)
);
public static readonly CED.IDrawer SectionFoldoutCaptureSettings = CED.FoldoutGroup(
"Capture Settings",
(s, d, o) => s.isSectionExpandedCaptureSettings,
true,
CED.Action(Drawer_SectionCaptureSettings)
);
public static readonly CED.IDrawer SectionFoldoutCaptureSettings;
public static readonly CED.IDrawer SectionCaptureMirrorSettings = CED.Action(Drawer_SectionCaptureMirror);
SectionFoldoutCaptureSettings = CED.FoldoutGroup(
"Capture Settings",
(s, d, o) => s.isSectionExpandedCaptureSettings,
true,
CED.Action(Drawer_SectionCaptureSettings),
CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedCaptureMirrorSettings,
false,
SectionCaptureMirrorSettings)
);
SectionProbeModeSettings = CED.Group(
CED.Action(Drawer_FieldCaptureType),
CED.FadeGroup(

const EditMode.SceneViewEditMode EditBaseShape = EditMode.SceneViewEditMode.ReflectionProbeBox;
const EditMode.SceneViewEditMode EditInfluenceShape = EditMode.SceneViewEditMode.GridBox;
const EditMode.SceneViewEditMode EditInfluenceNormalShape = EditMode.SceneViewEditMode.Collider;
const EditMode.SceneViewEditMode EditCenter = EditMode.SceneViewEditMode.ReflectionProbeOrigin;
const EditMode.SceneViewEditMode EditCenter = EditMode.SceneViewEditMode.ReflectionProbeOrigin;
static void Drawer_SectionCaptureMirror(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.captureMirrorPlaneLocalPosition, _.GetContent("Plane Position"));
EditorGUILayout.PropertyField(d.captureMirrorPlaneLocalNormal, _.GetContent("Plane Normal"));
}
static void Drawer_SectionCaptureSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{

22
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs


using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

static readonly Color k_GizmoMirrorPlaneCamera = new Color(128f / 255f, 128f / 255f, 233f / 255f, 128f / 255f);
public static void DrawHandles(PlanarReflectionProbeUI s, PlanarReflectionProbe d, Editor o)
{

ProxyVolumeComponentUI.DrawGizmos_EditNone(s.proxyVolume, d.proxyVolumeReference);
DrawGizmos_CaptureFrustrum(s, d);
if (d.mode == ReflectionProbeMode.Realtime
&& d.refreshMode == ReflectionProbeRefreshMode.EveryFrame)
DrawGizmos_CaptureMirror(s, d);
}
static void DrawGizmos_CaptureMirror(PlanarReflectionProbeUI s, PlanarReflectionProbe d)
{
var c = Gizmos.color;
var m = Gizmos.matrix;
Gizmos.matrix = Matrix4x4.TRS(
d.captureMirrorPlanePosition,
Quaternion.LookRotation(d.captureMirrorPlaneNormal, Vector3.up),
Vector3.one);
Gizmos.color = k_GizmoMirrorPlaneCamera;
Gizmos.DrawCube(Vector3.zero, new Vector3(1, 1, 0));
Gizmos.matrix = m;
Gizmos.color = c;
}
static void DrawGizmos_CaptureFrustrum(PlanarReflectionProbeUI s, PlanarReflectionProbe d)

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs


{
partial class PlanarReflectionProbeUI : BaseUI<SerializedPlanarReflectionProbe>
{
const int k_AnimBoolFields = 2;
const int k_AnimBoolFields = 3;
static readonly int k_ReflectionProbeModeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length;
static readonly int k_AnimBoolTotal = k_AnimBoolFields + k_ReflectionProbeModeModeCount;

public AnimBool isSectionExpandedInfluenceSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 1]; } }
public AnimBool isSectionExpandedCaptureMirrorSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 2]; } }
public PlanarReflectionProbeUI()
: base(k_AnimBoolTotal)

{
for (var i = 0; i < k_ReflectionProbeModeModeCount; i++)
m_AnimBools[i].target = i == data.mode.intValue;
isSectionExpandedCaptureMirrorSettings.target = data.refreshMode.intValue == (int)ReflectionProbeRefreshMode.EveryFrame && data.mode.intValue == (int)ReflectionProbeMode.Realtime;
proxyVolume.Update();
frameSettings.Update();

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs


public SerializedProperty captureNearPlane;
public SerializedProperty captureFarPlane;
public SerializedProperty capturePositionMode;
public SerializedProperty captureMirrorPlaneLocalPosition;
public SerializedProperty captureMirrorPlaneLocalNormal;
public SerializedProperty dimmer;
public SerializedProperty mode;
public SerializedProperty refreshMode;

captureNearPlane = serializedObject.Find((PlanarReflectionProbe p) => p.captureNearPlane);
captureFarPlane = serializedObject.Find((PlanarReflectionProbe p) => p.captureFarPlane);
capturePositionMode = serializedObject.Find((PlanarReflectionProbe p) => p.capturePositionMode);
captureMirrorPlaneLocalPosition = serializedObject.Find((PlanarReflectionProbe p) => p.captureMirrorPlaneLocalPosition);
captureMirrorPlaneLocalNormal = serializedObject.Find((PlanarReflectionProbe p) => p.captureMirrorPlaneLocalNormal);
dimmer = serializedObject.Find((PlanarReflectionProbe p) => p.dimmer);
mode = serializedObject.Find((PlanarReflectionProbe p) => p.mode);
refreshMode = serializedObject.Find((PlanarReflectionProbe p) => p.refreshMode);

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/PlanarReflectionProbe.cs


float m_CaptureFarPlane = 1000;
[SerializeField]
CapturePositionMode m_CapturePositionMode = CapturePositionMode.Static;
[SerializeField]
Vector3 m_CaptureMirrorPlaneLocalPosition;
[SerializeField]
Vector3 m_CaptureMirrorPlaneLocalNormal = Vector3.forward;
public ProxyVolumeComponent proxyVolumeReference { get { return m_ProxyVolumeReference; } }
public InfluenceVolume influenceVolume { get { return m_InfluenceVolume; } }

public float captureNearPlane { get { return m_CaptureNearPlane; } }
public float captureFarPlane { get { return m_CaptureFarPlane; } }
public CapturePositionMode capturePositionMode { get { return m_CapturePositionMode; } }
public Vector3 captureMirrorPlaneLocalPosition
{
get { return m_CaptureMirrorPlaneLocalPosition; }
set { m_CaptureMirrorPlaneLocalPosition = value; }
}
public Vector3 captureMirrorPlanePosition { get { return transform.TransformPoint(m_CaptureMirrorPlaneLocalPosition); } }
public Vector3 captureMirrorPlaneLocalNormal
{
get { return m_CaptureMirrorPlaneLocalNormal; }
set { m_CaptureMirrorPlaneLocalNormal = value; }
}
public Vector3 captureMirrorPlaneNormal { get { return transform.TransformDirection(m_CaptureMirrorPlaneLocalNormal); } }
#region Proxy Properties
public Matrix4x4 proxyToWorld

if (refreshMode == ReflectionProbeRefreshMode.EveryFrame
&& capturePositionMode == CapturePositionMode.MirrorCamera)
{
var planeCenter = (Vector3)influenceToWorld.GetColumn(3);
var planeNormal = ((Vector3)influenceToWorld.GetColumn(2)).normalized;
var planeCenter = influenceToWorld.MultiplyPoint(m_CaptureMirrorPlaneLocalPosition);
var planeNormal = influenceToWorld.MultiplyVector(m_CaptureMirrorPlaneLocalNormal).normalized;
var sourcePosition = viewerCamera.transform.position;
var r = sourcePosition - planeCenter;
var capturePosition = r - 2 * Vector3.Dot(planeNormal, r) * planeNormal;

正在加载...
取消
保存