static void Drawer_FieldCaptureType(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { GUI.enabled = false; EditorGUILayout.PropertyField(d.mode, _.GetContent("Type")); d.mode.enumValueIndex = (int)ReflectionProbeMode.Realtime; GUI.enabled = true; }
static void Drawer_SectionProbeModeRealtimeSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { GUI.enabled = false; EditorGUILayout.PropertyField(d.refreshMode, _.GetContent("Refresh Mode")); EditorGUILayout.PropertyField(d.capturePositionMode, _.GetContent("Capture Position Mode")); GUI.enabled = true; }
protected override void OnSceneGUI() { base.OnSceneGUI(); PlanarReflectionProbeUI.DrawHandlesOverride(m_UIState as PlanarReflectionProbeUI, m_SerializedHDProbe as SerializedPlanarReflectionProbe, this); SceneViewOverlay_Window(_.GetContent("Planar Probe"), OnOverlayGUI, -100, target); }
static void Drawer_SectionProxySettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { EditorGUILayout.PropertyField(d.proxyVolumeReference, _.GetContent("Reference")); if (d.proxyVolumeReference.objectReferenceValue != null) { var proxy = (ReflectionProxyVolumeComponent)d.proxyVolumeReference.objectReferenceValue; if ((int)proxy.proxyVolume.shapeType != d.influenceVolume.shapeType.enumValueIndex) { EditorGUILayout.HelpBox( "Proxy volume and influence volume have different shape types, this is not supported.", MessageType.Error, true ); } } else { EditorGUILayout.HelpBox( "When no Proxy setted, Influence shape will be used as Proxy shape too.", MessageType.Info, true ); } }
static void Drawer_SectionShapeBox(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o) { bool advanced = d.editorAdvancedModeEnabled.boolValue; var maxFadeDistance = d.boxBaseSize.vector3Value * 0.5f; var minFadeDistance = Vector3.zero; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(d.boxBaseSize, _.GetContent("Box Size")); PlanarReflectionProbeUI.Drawer_ToolBarButton(0, o, GUILayout.Width(28f), GUILayout.MinHeight(22f)); EditorGUILayout.EndHorizontal(); //offset have no meaning for planar reflexion probe //EditorGUILayout.PropertyField(d.boxBaseOffset, _.GetContent("Box Offset")); EditorGUILayout.BeginHorizontal(); Drawer_AdvancedBlendDistance( d, false, maxFadeDistance, CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.") ); PlanarReflectionProbeUI.Drawer_ToolBarButton(1, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3))); EditorGUILayout.EndHorizontal(); if (advanced) { CoreEditorUtils.DrawVector6( CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."), d.boxPositiveFaceFade, d.boxNegativeFaceFade, Vector3.zero, Vector3.one, HDReflectionProbeEditor.k_handlesColor); } }
static void Drawer_SectionProbeModeRealtimeSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { GUI.enabled = false; EditorGUILayout.PropertyField(d.refreshMode, _.GetContent("Refresh Mode")); EditorGUILayout.PropertyField(d.capturePositionMode, _.GetContent("Capture Position Mode")); d.refreshMode.enumValueIndex = (int)ReflectionProbeRefreshMode.EveryFrame; d.capturePositionMode.enumValueIndex = (int)PlanarReflectionProbe.CapturePositionMode.MirrorCamera; GUI.enabled = true; }
static void Drawer_SectionCaptureStatic(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) { d.customTexture.objectReferenceValue = EditorGUILayout.ObjectField(_.GetContent("Capture"), d.customTexture.objectReferenceValue, typeof(Texture), false); var texture = d.customTexture.objectReferenceValue as Texture; if (texture != null && texture.dimension != TextureDimension.Tex2D) { EditorGUILayout.HelpBox("Provided Texture is not a 2D Texture, it will be ignored", MessageType.Warning); } }
void OnSceneGUI() { for (var i = 0; i < m_TypedTargets.Length; i++) { m_UIHandleState[i].Update(); m_UIHandleState[i].influenceVolume.showInfluenceHandles = m_UIState.influenceVolume.isSectionExpandedShape.target; m_UIHandleState[i].showCaptureHandles = m_UIState.isSectionExpandedCaptureSettings.target; PlanarReflectionProbeUI.DrawHandles(m_UIHandleState[i], m_TypedTargets[i], this); } SceneViewOverlay_Window(_.GetContent("Planar Probe"), OnOverlayGUI, -100, target); }
static void Drawer_SectionInfluenceSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { EditorGUILayout.PropertyField(d.weight, _.GetContent("Weight")); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(d.multiplier, _.GetContent("Multiplier")); if (EditorGUI.EndChangeCheck()) { d.multiplier.floatValue = Mathf.Max(0.0f, d.multiplier.floatValue); } }
static void Drawer_DifferentShapeError(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { var proxy = d.proxyVolumeReference.objectReferenceValue as ReflectionProxyVolumeComponent; if (proxy != null && (int)proxy.proxyVolume.shapeType != d.influenceVolume.shapeType.enumValueIndex) { EditorGUILayout.HelpBox( "Proxy volume and influence volume have different shape types, this is not supported.", MessageType.Error, true ); } }
void OnEnable() { m_SerializedAsset = new SerializedPlanarReflectionProbe(serializedObject); m_UIState.Reset(m_SerializedAsset, Repaint); m_TypedTargets = new PlanarReflectionProbe[targets.Length]; m_UIHandleState = new PlanarReflectionProbeUI[m_TypedTargets.Length]; for (var i = 0; i < m_TypedTargets.Length; i++) { m_TypedTargets[i] = (PlanarReflectionProbe)targets[i]; m_UIHandleState[i] = new PlanarReflectionProbeUI(); m_UIHandleState[i].Reset(m_SerializedAsset, null); s_StateMap[m_TypedTargets[i]] = m_UIHandleState[i]; } }
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 Drawer_Toolbar(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.changed = false; EditMode.DoInspectorToolbar(k_Toolbar_SceneViewEditModes, toolbar_Contents, GetBoundsGetter(o), o); if (d.isMirrored) { EditMode.DoInspectorToolbar(k_Toolbar_Mirror_SceneViewEditModes, toolbar_Mirror_Contents, GetBoundsGetter(o), o); } else { EditMode.DoInspectorToolbar(k_Toolbar_Static_SceneViewEditModes, toolbar_Static_Contents, GetBoundsGetter(o), o); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
static void Drawer_SectionShapeSphere(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, bool drawOffset, bool drawNormal) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(d.sphereRadius, _.GetContent("Radius")); PlanarReflectionProbeUI.Drawer_ToolBarButton(0, o, GUILayout.Width(28f), GUILayout.MinHeight(22f)); EditorGUILayout.EndHorizontal(); if (drawOffset) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(d.offset, _.GetContent("Offset")); HDReflectionProbeUI.Drawer_ToolBarButton(3, o, GUILayout.Width(28f), GUILayout.MinHeight(22f)); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); var maxBlendDistance = d.sphereRadius.floatValue; EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(d.sphereBlendDistance, _.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.")); if (EditorGUI.EndChangeCheck()) { d.sphereBlendDistance.floatValue = Mathf.Clamp(d.sphereBlendDistance.floatValue, 0, maxBlendDistance); } PlanarReflectionProbeUI.Drawer_ToolBarButton(1, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3)); EditorGUILayout.EndHorizontal(); if (drawNormal) { EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(d.sphereBlendNormalDistance, _.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.")); if (EditorGUI.EndChangeCheck()) { d.sphereBlendNormalDistance.floatValue = Mathf.Clamp(d.sphereBlendNormalDistance.floatValue, 0, maxBlendDistance); } PlanarReflectionProbeUI.Drawer_ToolBarButton(2, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3)); EditorGUILayout.EndHorizontal(); } }
internal static void DrawHandles(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { PlanarReflectionProbe probe = d.target; HDProbeUI.DrawHandles(s, d, o); if (probe.useMirrorPlane) { var m = Handles.matrix; var mat = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one * 1.5f); using (new Handles.DrawingScope(k_GizmoMirrorPlaneCamera, mat)) { Handles.ArrowHandleCap( 0, probe.captureMirrorPlaneLocalPosition, Quaternion.LookRotation(probe.captureMirrorPlaneLocalNormal), HandleUtility.GetHandleSize(probe.captureMirrorPlaneLocalPosition), Event.current.type ); } } }
static void Drawer_SectionCaptureSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset; GUI.enabled = false; EditorGUILayout.LabelField( _.GetContent("Probe Texture Size (Set By HDRP)"), _.GetContent(hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionTextureSize.ToString()), EditorStyles.label); EditorGUILayout.Toggle( _.GetContent("Probe Compression (Set By HDRP)"), hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionCacheCompressed); GUI.enabled = true; EditorGUILayout.PropertyField(d.overrideFieldOfView, _.GetContent("Override FOV")); if (d.overrideFieldOfView.boolValue) { ++EditorGUI.indentLevel; EditorGUILayout.PropertyField(d.fieldOfViewOverride, _.GetContent("Field Of View")); --EditorGUI.indentLevel; } }
static void DrawGizmos_CaptureFrustrum(PlanarReflectionProbeUI s, PlanarReflectionProbe d) { var viewerCamera = Camera.current; var c = Gizmos.color; var m = Gizmos.matrix; float nearClipPlane, farClipPlane, aspect, fov; Color backgroundColor; CameraClearFlags clearFlags; Vector3 capturePosition; Quaternion captureRotation; Matrix4x4 worldToCameraRHS, projection; ReflectionSystem.CalculateCaptureCameraProperties(d, out nearClipPlane, out farClipPlane, out aspect, out fov, out clearFlags, out backgroundColor, out worldToCameraRHS, out projection, out capturePosition, out captureRotation, viewerCamera); #if false // TODO: fix frustrum drawing var viewProj = projection * worldToCameraRHS; var invViewProj = viewProj.inverse; var near = new[] { new Vector3(-1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1), new Vector3(1, -1, -1), }; var far = new[] { new Vector3(-1, -1, 1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1), new Vector3(1, -1, 1), }; for (var i = 0; i < near.Length; ++i) { var p = invViewProj * new Vector4(near[i].x, near[i].y, near[i].z, 1); var w = Mathf.Abs(p.w); near[i].Set(p.x / w, p.y / w, p.z / w); } for (var i = 0; i < far.Length; ++i) { var p = invViewProj * new Vector4(far[i].x, far[i].y, far[i].z, 1); var w = Mathf.Abs(p.w); far[i].Set(p.x / w, p.y / w, p.z / w); } 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.matrix = m; #endif Gizmos.DrawSphere(capturePosition, HandleUtility.GetHandleSize(capturePosition) * 0.2f); Gizmos.color = c; }
internal static void DrawHandlesOverride(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { //Note: HDProbeUI.DrawHandles is called in parent PlanarReflectionProbe probe = d.target; switch (EditMode.editMode) { case EditBaseShape: if ((InfluenceShape)d.influenceVolume.shape.intValue != InfluenceShape.Box) { return; } //override base handle behavior to also translate object along x and z axis and offset the y axis using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, d.target.transform.rotation, Vector3.one))) { Vector3 origin = Quaternion.Inverse(probe.transform.rotation) * probe.transform.position; s.influenceVolume.boxBaseHandle.center = origin + probe.influenceVolume.offset; s.influenceVolume.boxBaseHandle.size = probe.influenceVolume.boxSize; EditorGUI.BeginChangeCheck(); s.influenceVolume.boxBaseHandle.DrawHandle(); if (EditorGUI.EndChangeCheck()) { Undo.RecordObjects(new Object[] { probe, probe.transform }, "Modified Planar Base Volume AABB"); Vector3 size = s.influenceVolume.boxBaseHandle.size; //clamp offset value float extend = probe.influenceVolume.boxSize.y * 0.5f; float offset = s.influenceVolume.boxBaseHandle.center.y - origin.y; if (offset < -extend) { size.y += 2f * (-offset - extend); offset = -extend; } if (offset > extend) { size.y += 2f * (offset - extend); offset = extend; } if (size.y < 0) { size.y = 0; } probe.influenceVolume.boxSize = size; probe.influenceVolume.offset = new Vector3(0, offset, 0); Vector3 centerXZ = s.influenceVolume.boxBaseHandle.center; centerXZ.y = origin.y; Vector3 deltaXZ = probe.transform.rotation * centerXZ - probe.transform.position; probe.transform.position += deltaXZ; } } break; case EditCenter: { if ((InfluenceShape)d.influenceVolume.shape.intValue != InfluenceShape.Box) { break; } //override base handle behavior to only translate object along y using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one))) { EditorGUI.BeginChangeCheck(); var newCapturePosition = Handles.Slider( probe.transform.position, probe.transform.rotation * Vector3.up, HandleUtility.GetHandleSize(probe.transform.position), Handles.ArrowHandleCap, 0f ); if (EditorGUI.EndChangeCheck()) { Undo.RecordObjects(new Object[] { probe, probe.transform }, "Translate Influence Position"); Vector3 delta = newCapturePosition - probe.transform.position; Matrix4x4 oldLocalToWorld = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one); probe.transform.position = newCapturePosition; Vector3 offset = d.influenceVolume.offset.vector3Value - oldLocalToWorld.inverse.MultiplyVector(delta); //clamp offset value float extend = probe.influenceVolume.boxSize.y * 0.5f; offset.y = Mathf.Clamp(offset.y, -extend, extend); d.influenceVolume.offset.vector3Value = offset; d.influenceVolume.Apply(); } } break; } } }
static void Drawer_FieldProxyVolumeReference(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { EditorGUILayout.PropertyField(d.proxyVolumeReference, _.GetContent("Reference")); }
static void Drawer_FieldCaptureType(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { EditorGUILayout.PropertyField(d.mode, _.GetContent("Type")); }
public static bool TryGetUIStateFor(PlanarReflectionProbe p, out PlanarReflectionProbeUI r) { return(s_StateMap.TryGetValue(p, out r)); }
static void Drawer_SectionBakeButton(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)d.mode.intValue, d.target); }
static void Drawer_SectionInfluenceSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { EditorGUILayout.PropertyField(d.dimmer, _.GetContent("Dimmer")); }
static void Drawer_SectionCaptureMirror(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { EditorGUILayout.PropertyField(d.captureMirrorPlaneLocalPosition, _.GetContent("Plane Position")); EditorGUILayout.PropertyField(d.captureMirrorPlaneLocalNormal, _.GetContent("Plane Normal")); }
public static void DrawHandles(PlanarReflectionProbeUI s, PlanarReflectionProbe d, Editor o) { var mat = d.transform.localToWorldMatrix; switch (EditMode.editMode) { case EditBaseShape: InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, d.influenceVolume, o, mat, d); break; case EditInfluenceShape: InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, d.influenceVolume, o, mat, d); break; case EditInfluenceNormalShape: InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, d.influenceVolume, o, mat, d); break; case EditMirrorPosition: { EditorGUI.BeginChangeCheck(); var m = Handles.matrix; Handles.matrix = mat; var p = Handles.PositionHandle(d.captureMirrorPlaneLocalPosition, d.transform.rotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(d, "Translate Mirror Plane"); d.captureMirrorPlaneLocalPosition = p; EditorUtility.SetDirty(d); } Handles.matrix = m; break; } case EditMirrorRotation: { EditorGUI.BeginChangeCheck(); var m = Handles.matrix; Handles.matrix = mat; var q = Quaternion.LookRotation(d.captureMirrorPlaneLocalNormal, Vector3.up); q = Handles.RotationHandle(q, d.captureMirrorPlaneLocalPosition); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(d, "Rotate Mirror Plane"); d.captureMirrorPlaneLocalNormal = q * Vector3.forward; EditorUtility.SetDirty(d); } Handles.matrix = m; break; } case EditCenter: { EditorGUI.BeginChangeCheck(); var m = Handles.matrix; Handles.matrix = mat; var p = Handles.PositionHandle(d.captureLocalPosition, d.transform.rotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(d, "Translate Capture Position"); d.captureLocalPosition = p; EditorUtility.SetDirty(d); } Handles.matrix = m; break; } } if (d.useMirrorPlane) { var m = Handles.matrix; Handles.matrix = mat; Handles.color = k_GizmoMirrorPlaneCamera; Handles.ArrowHandleCap( 0, d.captureMirrorPlaneLocalPosition, Quaternion.LookRotation(d.captureMirrorPlaneLocalNormal), HandleUtility.GetHandleSize(d.captureMirrorPlaneLocalPosition), Event.current.type ); Handles.matrix = m; } if (d.proxyVolumeReference != null) { ReflectionProxyVolumeComponentUI.DrawHandles_EditNone(s.reflectionProxyVolume, d.proxyVolumeReference); } }