浏览代码

[PlanarReflection] (wip) added capture camera gizmos

/main
Frédéric Vauchelles 7 年前
当前提交
3f5a5830
共有 6 个文件被更改,包括 79 次插入12 次删除
  1. 15
      ScriptableRenderPipeline/Core/CoreRP/Editor/CoreEditorUtils.cs
  2. 14
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraUI.cs
  3. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Drawers.cs
  4. 40
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs
  5. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs
  6. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/PlanarReflectionProbe.cs

15
ScriptableRenderPipeline/Core/CoreRP/Editor/CoreEditorUtils.cs


}
// UI Helpers
public static void DrawMultipleFields(string label, SerializedProperty[] ppts, GUIContent[] lbls)
{
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(GetContent(label));
GUILayout.BeginVertical();
var labelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 45;
for (var i = 0; i < ppts.Length; ++i)
EditorGUILayout.PropertyField(ppts[i], lbls[i]);
GUILayout.EndVertical();
GUILayout.EndHorizontal();
EditorGUIUtility.labelWidth = labelWidth;
}
public static void DrawSplitter()
{
var rect = GUILayoutUtility.GetRect(1f, 1f);

14
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraUI.cs


static void Drawer_FieldClippingPlanes(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(_.GetContent("Clipping Planes"));
GUILayout.BeginVertical();
var labelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 45;
EditorGUILayout.PropertyField(p.nearClippingPlane, _.GetContent("Near|The closest point relative to the camera that drawing will occur."));
EditorGUILayout.PropertyField(p.farClippingPlane, _.GetContent("Far|The furthest point relative to the camera that drawing will occur.\n"));
GUILayout.EndVertical();
GUILayout.EndHorizontal();
EditorGUIUtility.labelWidth = labelWidth;
_.DrawMultipleFields(
"Clipping Planes",
new[] { p.nearClippingPlane, p.farClippingPlane },
new[] { _.GetContent("Near|The closest point relative to the camera that drawing will occur."), _.GetContent("Far|The furthest point relative to the camera that drawing will occur.\n") });
}
static void Drawer_FieldNormalizedViewPort(HDCameraUI s, SerializedHDCamera p, Editor owner)

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


using System;
using System;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Rendering;

static void Drawer_SectionCaptureSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.captureLocalPosition, _.GetContent("Capture Local Position"));
_.DrawMultipleFields(
"Clipping Planes",
new[] { d.captureNearPlane, d.captureFarPlane },
new[] { _.GetContent("Near|The closest point relative to the camera that drawing will occur."), _.GetContent("Far|The furthest point relative to the camera that drawing will occur.\n") });
}
static void Drawer_SectionProbeModeCustomSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)

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


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

static readonly Color k_GizmoCamera = new Color(233f / 255f, 233f / 255f, 233f / 255f, 128f / 255f);
public static void DrawHandles(PlanarReflectionProbeUI s, PlanarReflectionProbe d, Editor o)
{
var mat = d.transform.localToWorldMatrix;

if (d.proxyVolumeReference != null)
ProxyVolumeComponentUI.DrawGizmos_EditNone(s.proxyVolume, d.proxyVolumeReference);
DrawGizmos_CaptureFrustrum(s, d);
}
static void DrawGizmos_CaptureFrustrum(PlanarReflectionProbeUI s, PlanarReflectionProbe d)
{
var farClipPlane = d.captureFarPlane;
var nearClipPlane = d.captureNearPlane;
var mat = Matrix4x4.TRS(d.capturePosition, d.captureRotation, Vector3.one);
var near = new Vector3[4];
var far = new Vector3[4];
far[0] = new Vector3(0, 0, farClipPlane); // leftBottomFar
far[1] = new Vector3(0, 1, farClipPlane); // leftTopFar
far[2] = new Vector3(1, 1, farClipPlane); // rightTopFar
far[3] = new Vector3(1, 0, farClipPlane); // rightBottomFar
for (var i = 0; i < 4; ++i)
far[i] = mat.MultiplyPoint(far[i]);
near[0] = new Vector3(0, 0, nearClipPlane); // leftBottomNear
near[1] = new Vector3(0, 1, nearClipPlane); // leftTopNear
near[2] = new Vector3(1, 1, nearClipPlane); // rightTopNear
near[3] = new Vector3(1, 0, nearClipPlane); // rightBottomNear
for (var i = 0; i < 4; ++i)
near[i] = mat.MultiplyPoint(near[i]);
var c = Gizmos.color;
Gizmos.color = k_GizmoCamera;
for (var i = 0; i < 4; ++i)
{
Gizmos.DrawLine(near[i], near[(i + 1) % 4]);
Gizmos.DrawLine(far[i], far[(i + 1) % 4]);
Gizmos.DrawLine(near[i], far[i]);
}
Gizmos.color = c;
}
}
}

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


public SerializedInfluenceVolume influenceVolume;
public SerializedProperty captureLocalPosition;
public SerializedProperty captureNearPlane;
public SerializedProperty captureFarPlane;
public SerializedProperty dimmer;
public SerializedProperty mode;
public SerializedProperty refreshMode;

influenceVolume = new SerializedInfluenceVolume(serializedObject.Find((PlanarReflectionProbe p) => p.influenceVolume));
captureLocalPosition = serializedObject.Find((PlanarReflectionProbe p) => p.captureLocalPosition);
captureNearPlane = serializedObject.Find((PlanarReflectionProbe p) => p.captureNearPlane);
captureFarPlane = serializedObject.Find((PlanarReflectionProbe p) => p.captureFarPlane);
dimmer = serializedObject.Find((PlanarReflectionProbe p) => p.dimmer);
mode = serializedObject.Find((PlanarReflectionProbe p) => p.mode);
refreshMode = serializedObject.Find((PlanarReflectionProbe p) => p.refreshMode);

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


RenderTexture m_RealtimeTexture;
[SerializeField]
FrameSettings m_FrameSettings;
[SerializeField]
float m_CaptureNearPlane = 1;
[SerializeField]
float m_CaptureFarPlane = 1000;
public ProxyVolumeComponent proxyVolumeReference { get { return m_ProxyVolumeReference; } }
public InfluenceVolume influenceVolume { get { return m_InfluenceVolume; } }

get { return transform.TransformPoint(m_CaptureLocalPosition); }
set { m_CaptureLocalPosition = transform.InverseTransformPoint(value); }
}
public Quaternion captureRotation
{
get { return Quaternion.LookRotation(influencePosition - capturePosition, transform.up); }
}
public Vector3 influencePosition { get { return transform.position; } }
public Texture customTexture { get { return m_CustomTexture; } }
public Texture bakedTexture { get { return m_BakedTexture; } set { m_BakedTexture = value; }}

public float captureNearPlane { get { return m_CaptureNearPlane; } }
public float captureFarPlane { get { return m_CaptureFarPlane; } }
#region Proxy Properties
public Vector3 proxyRight

}
}
public bool infiniteProjection { get { return m_ProxyVolumeReference != null && m_ProxyVolumeReference.proxyVolume.infiniteProjection; } }
#endregion
public void RequestRealtimeRender()

正在加载...
取消
保存