static void Drawer_Toolbar(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
        {
            if (p.so.targetObjects.Length > 1)
            {
                return;
            }

            // Show the master tool selector
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUI.changed = false;
            var oldEditMode = EditMode.editMode;

            EditMode.DoInspectorToolbar(k_Toolbar_SceneViewEditModes, toolbar_Contents, GetBoundsGetter(p), owner);

            //if (GUILayout.Button(EditorGUIUtility.IconContent("Navigation", "|Fit the reflection probe volume to the surrounding colliders.")))
            //    s.AddOperation(Operation.FitVolumeToSurroundings);

            if (oldEditMode != EditMode.editMode)
            {
                switch (EditMode.editMode)
                {
                case EditMode.SceneViewEditMode.ReflectionProbeOrigin:
                    s.UpdateOldLocalSpace(p.target);
                    break;
                }
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        static void Drawer_InfluenceShapeBoxSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(p.boxSize, CoreEditorUtils.GetContent("Box Size|The size of the box in which the reflections will be applied to objects. The value is not affected by the Transform of the Game Object."));
            if (GUILayout.Button(toolbar_Contents[0], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
            {
                EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeBox, GetBoundsGetter(p)(), owner);
            }
            EditorGUILayout.EndHorizontal();


            EditorGUI.BeginChangeCheck();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(p.boxOffset, CoreEditorUtils.GetContent("Box Offset|The center of the box in which the reflections will be applied to objects. The value is relative to the position of the Game Object."));
            if (GUILayout.Button(toolbar_Contents[3], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
            {
                EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeOrigin, GetBoundsGetter(p)(), owner);
            }
            EditorGUILayout.EndHorizontal();
            if (EditorGUI.EndChangeCheck())
            {
                var center = p.boxOffset.vector3Value;
                var size   = p.boxSize.vector3Value;
                if (HDReflectionProbeEditorUtility.ValidateAABB(p.target, ref center, ref size))
                {
                    //clamp to contains object center instead of resizing
                    Vector3 projector = (center - p.boxOffset.vector3Value).normalized;
                    p.boxOffset.vector3Value = center + Mathf.Abs(Vector3.Dot((p.boxSize.vector3Value - size) * .5f, projector)) * projector;
                }
            }
        }
        static void ApplyConstraintsOnTargets(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
        {
            switch ((ShapeType)sp.influenceShape.enumValueIndex)
            {
            case ShapeType.Box:
            {
                var maxBlendDistance = HDReflectionProbeEditorUtility.CalculateBoxMaxBlendDistance(s, sp, o);
                sp.targetData.blendDistancePositive       = Vector3.Min(sp.targetData.blendDistancePositive, maxBlendDistance);
                sp.targetData.blendDistanceNegative       = Vector3.Min(sp.targetData.blendDistanceNegative, maxBlendDistance);
                sp.targetData.blendNormalDistancePositive = Vector3.Min(sp.targetData.blendNormalDistancePositive, maxBlendDistance);
                sp.targetData.blendNormalDistanceNegative = Vector3.Min(sp.targetData.blendNormalDistanceNegative, maxBlendDistance);
                break;
            }

            case ShapeType.Sphere:
            {
                var maxBlendDistance = Vector3.one * HDReflectionProbeEditorUtility.CalculateSphereMaxBlendDistance(s, sp, o);
                sp.targetData.blendDistancePositive       = Vector3.Min(sp.targetData.blendDistancePositive, maxBlendDistance);
                sp.targetData.blendDistanceNegative       = Vector3.Min(sp.targetData.blendDistanceNegative, maxBlendDistance);
                sp.targetData.blendNormalDistancePositive = Vector3.Min(sp.targetData.blendNormalDistancePositive, maxBlendDistance);
                sp.targetData.blendNormalDistanceNegative = Vector3.Min(sp.targetData.blendNormalDistanceNegative, maxBlendDistance);
                break;
            }
            }
        }
        static void ApplyConstraintsOnTargets(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
        {
            switch ((InfluenceShape)sp.influenceVolume.shape.enumValueIndex)
            {
            case InfluenceShape.Box:
            {
                var maxBlendDistance = sp.influenceVolume.boxSize.vector3Value;
                sp.targetData.influenceVolume.boxBlendDistancePositive       = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
                sp.targetData.influenceVolume.boxBlendDistanceNegative       = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
                sp.targetData.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
                sp.targetData.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
                break;
            }

            case InfluenceShape.Sphere:
            {
                var maxBlendDistance = Vector3.one * sp.influenceVolume.sphereRadius.floatValue;
                sp.targetData.influenceVolume.boxBlendDistancePositive       = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
                sp.targetData.influenceVolume.boxBlendDistanceNegative       = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
                sp.targetData.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
                sp.targetData.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
                break;
            }
            }
        }
        static void Drawer_InfluenceAdvancedSwitch(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                bool advanced = p.editorAdvancedModeEnabled.boolValue;
                advanced = !GUILayout.Toggle(!advanced, CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."), EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
                advanced = GUILayout.Toggle(advanced, CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."), EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
                s.alternativeBoxBlendHandle.allHandleControledByOne = s.alternativeBoxBlendNormalHandle.allHandleControledByOne = !advanced;
                if (p.editorAdvancedModeEnabled.boolValue ^ advanced)
                {
                    p.editorAdvancedModeEnabled.boolValue = advanced;
                    if (advanced)
                    {
                        p.blendDistancePositive.vector3Value       = p.editorAdvancedModeBlendDistancePositive.vector3Value;
                        p.blendDistanceNegative.vector3Value       = p.editorAdvancedModeBlendDistanceNegative.vector3Value;
                        p.blendNormalDistancePositive.vector3Value = p.editorAdvancedModeBlendNormalDistancePositive.vector3Value;
                        p.blendNormalDistanceNegative.vector3Value = p.editorAdvancedModeBlendNormalDistanceNegative.vector3Value;
                    }
                    else
                    {
                        p.blendDistanceNegative.vector3Value       = p.blendDistancePositive.vector3Value = Vector3.one * p.editorSimplifiedModeBlendDistance.floatValue;
                        p.blendNormalDistanceNegative.vector3Value = p.blendNormalDistancePositive.vector3Value = Vector3.one * p.editorSimplifiedModeBlendNormalDistance.floatValue;
                    }
                    p.Apply();
                }
            }
        }
        void BakeRealtimeProbeIfPositionChanged(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
        {
            if (Application.isPlaying ||
                ((ReflectionProbeMode)sp.mode.intValue) != ReflectionProbeMode.Realtime)
            {
                m_PositionHash = 0;
                return;
            }

            var hash = 0;

            for (var i = 0; i < sp.so.targetObjects.Length; i++)
            {
                var p  = (ReflectionProbe)sp.so.targetObjects[i];
                var tr = p.GetComponent <Transform>();
                hash ^= tr.position.GetHashCode();
            }

            if (hash != m_PositionHash)
            {
                m_PositionHash = hash;
                for (var i = 0; i < sp.so.targetObjects.Length; i++)
                {
                    var p = (ReflectionProbe)sp.so.targetObjects[i];
                    p.RenderProbe();
                }
            }
        }
Example #7
0
        static void Handle_OriginEditing(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
        {
            var p = (ReflectionProbe)sp.so.targetObject;
            var transformPosition = p.transform.position;
            var size = p.size;

            EditorGUI.BeginChangeCheck();
            var newPostion = Handles.PositionHandle(transformPosition, HDReflectionProbeEditorUtility.GetLocalSpaceRotation(p));

            var changed = EditorGUI.EndChangeCheck();

            if (changed || s.oldLocalSpace != HDReflectionProbeEditorUtility.GetLocalSpace(p))
            {
                var localNewPosition = s.oldLocalSpace.inverse.MultiplyPoint3x4(newPostion);

                var b = new Bounds(p.center, size);
                localNewPosition = b.ClosestPoint(localNewPosition);

                Undo.RecordObject(p.transform, "Modified Reflection Probe Origin");
                p.transform.position = s.oldLocalSpace.MultiplyPoint3x4(localNewPosition);

                Undo.RecordObject(p, "Modified Reflection Probe Origin");
                p.center = HDReflectionProbeEditorUtility.GetLocalSpace(p).inverse.MultiplyPoint3x4(s.oldLocalSpace.MultiplyPoint3x4(p.center));

                EditorUtility.SetDirty(p);

                s.UpdateOldLocalSpace(p);
            }
        }
Example #8
0
        protected override void OnEnable()
        {
            var additionalData = CoreEditorUtils.GetAdditionalData <HDAdditionalReflectionData>(targets);

            m_AdditionalDataSerializedObject = new SerializedObject(additionalData);
            m_SerializedHDProbe = new SerializedHDReflectionProbe(serializedObject, m_AdditionalDataSerializedObject);

            foreach (var t in targets)
            {
                var p = (ReflectionProbe)t;
                s_ReflectionProbeEditors[p] = this;
            }

            base.OnEnable();

            m_UIState.owner = this;
            m_UIState.Reset(m_SerializedHDProbe, Repaint);

            InitializeTargetProbe();

            HDAdditionalReflectionData probe = (HDAdditionalReflectionData)m_AdditionalDataSerializedObject.targetObject;

            probe.influenceVolume.Init(probe);

            //unhide previously hidden components
            probe.hideFlags = HideFlags.None;
        }
 static void Drawer_InfluenceAreas(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
 {
     if (s.IsSectionExpandedShape(ShapeType.Box).value)
     {
         Drawer_InfluenceBoxSettings(s, p, owner);
     }
     if (s.IsSectionExpandedShape(ShapeType.Sphere).value)
     {
         Drawer_InfluenceSphereSettings(s, p, owner);
     }
 }
 static void Drawer_ReflectionProbeMode(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
 {
     EditorGUI.BeginChangeCheck();
     EditorGUI.showMixedValue = p.mode.hasMultipleDifferentValues;
     EditorGUILayout.IntPopup(p.mode, k_Content_ReflectionProbeMode, k_Content_ReflectionProbeModeValues, CoreEditorUtils.GetContent("Type|'Baked Cubemap' uses the 'Auto Baking' mode from the Lighting window. If it is enabled then baking is automatic otherwise manual bake is needed (use the bake button below). \n'Custom' can be used if a custom cubemap is wanted. \n'Realtime' can be used to dynamically re-render the cubemap during runtime (via scripting)."));
     EditorGUI.showMixedValue = false;
     if (EditorGUI.EndChangeCheck())
     {
         s.SetModeTarget(p.mode.intValue);
     }
 }
        static void Drawer_ProxyVolume(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
        {
            EditorGUILayout.PropertyField(p.proxyVolumeComponent, _.GetContent("Proxy Volume"));

            if (p.proxyVolumeComponent.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox(
                    "When no Proxy setted, Influence shape will be used as Proxy shape too.",
                    MessageType.Info,
                    true
                    );
            }
        }
        static void Drawer_CaptureSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
        {
            var renderPipelineAsset = (HDRenderPipelineAsset)GraphicsSettings.renderPipelineAsset;

            p.resolution.intValue = (int)renderPipelineAsset.GetRenderPipelineSettings().lightLoopSettings.reflectionCubemapSize;
            EditorGUILayout.LabelField(CoreEditorUtils.GetContent("Resolution"), CoreEditorUtils.GetContent(p.resolution.intValue.ToString()));

            EditorGUILayout.PropertyField(p.shadowDistance, CoreEditorUtils.GetContent("Shadow Distance"));
            EditorGUILayout.PropertyField(p.cullingMask, CoreEditorUtils.GetContent("Culling Mask"));
            EditorGUILayout.PropertyField(p.useOcclusionCulling, CoreEditorUtils.GetContent("Use Occlusion Culling"));
            EditorGUILayout.PropertyField(p.nearClip, CoreEditorUtils.GetContent("Near Clip"));
            EditorGUILayout.PropertyField(p.farClip, CoreEditorUtils.GetContent("Far Clip"));
        }
 static Func <Bounds> GetBoundsGetter(SerializedHDReflectionProbe p)
 {
     return(() =>
     {
         var bounds = new Bounds();
         foreach (var targetObject in p.so.targetObjects)
         {
             var rp = (ReflectionProbe)targetObject;
             var b = rp.bounds;
             bounds.Encapsulate(b);
         }
         return bounds;
     });
 }
        static void Drawer_ModeSettingsCustom(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
        {
            EditorGUILayout.PropertyField(p.renderDynamicObjects, CoreEditorUtils.GetContent("Dynamic Objects|If enabled dynamic objects are also rendered into the cubemap"));

            EditorGUI.showMixedValue = p.customBakedTexture.hasMultipleDifferentValues;
            EditorGUI.BeginChangeCheck();
            var customBakedTexture = EditorGUILayout.ObjectField(CoreEditorUtils.GetContent("Cubemap"), p.customBakedTexture.objectReferenceValue, typeof(Cubemap), false);

            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                p.customBakedTexture.objectReferenceValue = customBakedTexture;
            }
        }
 static void Drawer_InfluenceProxyMissmatch(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
 {
     if (p.proxyVolumeComponent.objectReferenceValue != null)
     {
         var proxy = (ReflectionProxyVolumeComponent)p.proxyVolumeComponent.objectReferenceValue;
         if ((int)proxy.proxyVolume.shapeType != p.influenceShape.enumValueIndex)
         {
             EditorGUILayout.HelpBox(
                 "Proxy volume and influence volume have different shape types, this is not supported.",
                 MessageType.Error,
                 true
                 );
         }
     }
 }
        static void Drawer_AdvancedBlendDistance(SerializedHDReflectionProbe p, bool isNormal, Vector3 maxBlendDistance, GUIContent content)
        {
            SerializedProperty blendDistancePositive = isNormal ? p.blendNormalDistancePositive : p.blendDistancePositive;
            SerializedProperty blendDistanceNegative = isNormal ? p.blendNormalDistanceNegative : p.blendDistanceNegative;
            SerializedProperty editorAdvancedModeBlendDistancePositive = isNormal ? p.editorAdvancedModeBlendNormalDistancePositive : p.editorAdvancedModeBlendDistancePositive;
            SerializedProperty editorAdvancedModeBlendDistanceNegative = isNormal ? p.editorAdvancedModeBlendNormalDistanceNegative : p.editorAdvancedModeBlendDistanceNegative;
            SerializedProperty editorSimplifiedModeBlendDistance       = isNormal ? p.editorSimplifiedModeBlendNormalDistance : p.editorSimplifiedModeBlendDistance;
            Vector3            bdp = blendDistancePositive.vector3Value;
            Vector3            bdn = blendDistanceNegative.vector3Value;

            EditorGUILayout.BeginVertical();

            if (p.editorAdvancedModeEnabled.boolValue)
            {
                EditorGUI.BeginChangeCheck();
                CoreEditorUtils.DrawVector6(
                    content,
                    editorAdvancedModeBlendDistancePositive, editorAdvancedModeBlendDistanceNegative, Vector3.zero, maxBlendDistance, HDReflectionProbeEditor.k_handlesColor);
                if (EditorGUI.EndChangeCheck())
                {
                    blendDistancePositive.vector3Value = editorAdvancedModeBlendDistancePositive.vector3Value;
                    blendDistanceNegative.vector3Value = editorAdvancedModeBlendDistanceNegative.vector3Value;
                    p.Apply();
                }
            }
            else
            {
                float distance = editorSimplifiedModeBlendDistance.floatValue;
                EditorGUI.BeginChangeCheck();
                distance = EditorGUILayout.FloatField(content, distance);
                if (EditorGUI.EndChangeCheck())
                {
                    Vector3 decal = Vector3.one * distance;
                    bdp.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
                    bdp.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
                    bdp.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
                    bdn.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
                    bdn.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
                    bdn.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
                    blendDistancePositive.vector3Value           = bdp;
                    blendDistanceNegative.vector3Value           = bdn;
                    editorSimplifiedModeBlendDistance.floatValue = distance;
                    p.Apply();
                }
            }

            GUILayout.EndVertical();
        }
 static void Drawer_InfluenceShapeSphereSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.PropertyField(p.influenceSphereRadius, CoreEditorUtils.GetContent("Radius"));
     if (GUILayout.Button(toolbar_Contents[0], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
     {
         EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeBox, GetBoundsGetter(p)(), owner);
     }
     EditorGUILayout.EndHorizontal();
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.PropertyField(p.boxOffset, CoreEditorUtils.GetContent("Sphere Offset|The center of the sphere in which the reflections will be applied to objects. The value is relative to the position of the Game Object."));
     if (GUILayout.Button(toolbar_Contents[3], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
     {
         EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeOrigin, GetBoundsGetter(p)(), owner);
     }
     EditorGUILayout.EndHorizontal();
 }
Example #18
0
        void OnEnable()
        {
            var additionalData = CoreEditorUtils.GetAdditionalData <HDAdditionalReflectionData>(targets);

            m_AdditionalDataSerializedObject = new SerializedObject(additionalData);
            m_SerializedHdReflectionProbe    = new SerializedHDReflectionProbe(serializedObject, m_AdditionalDataSerializedObject);
            m_UIState.owner = this;
            m_UIState.Reset(m_SerializedHdReflectionProbe, Repaint);

            foreach (var t in targets)
            {
                var p = (ReflectionProbe)t;
                s_ReflectionProbeEditors[p] = this;
            }

            InitializeAllTargetProbes();
        }
        static void Drawer_InfluenceSphereSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
        {
            var maxBlendDistance = HDReflectionProbeEditorUtility.CalculateSphereMaxBlendDistance(s, p, owner);

            var blendDistance = p.blendDistancePositive.vector3Value.x;

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = p.blendDistancePositive.hasMultipleDifferentValues;
            blendDistance            = EditorGUILayout.Slider(CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."), blendDistance, 0, maxBlendDistance);
            if (EditorGUI.EndChangeCheck())
            {
                p.blendDistancePositive.vector3Value = Vector3.one * blendDistance;
                p.blendDistanceNegative.vector3Value = Vector3.one * blendDistance;
            }
            if (GUILayout.Button(toolbar_Contents[1], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
            {
                EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[1], GetBoundsGetter(p)(), owner);
            }
            EditorGUILayout.EndHorizontal();

            var blendNormalDistance = p.blendNormalDistancePositive.vector3Value.x;

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = p.blendNormalDistancePositive.hasMultipleDifferentValues;
            blendNormalDistance      = EditorGUILayout.Slider(CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes."), blendNormalDistance, 0, maxBlendDistance);
            if (EditorGUI.EndChangeCheck())
            {
                p.blendNormalDistancePositive.vector3Value = Vector3.one * blendNormalDistance;
                p.blendNormalDistanceNegative.vector3Value = Vector3.one * blendNormalDistance;
            }
            if (GUILayout.Button(toolbar_Contents[2], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
            {
                EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[2], GetBoundsGetter(p)(), owner);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUI.showMixedValue = false;
        }
        static void Drawer_InfluenceShape(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
        {
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = p.influenceShape.hasMultipleDifferentValues;
            EditorGUILayout.PropertyField(p.influenceShape, CoreEditorUtils.GetContent("Shape"));
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                s.SetShapeTarget(p.influenceShape.intValue);
            }

            switch ((ShapeType)p.influenceShape.enumValueIndex)
            {
            case ShapeType.Box:
                Drawer_InfluenceShapeBoxSettings(s, p, owner);
                break;

            case ShapeType.Sphere:
                Drawer_InfluenceShapeSphereSettings(s, p, owner);
                break;
            }
        }
        public static void DoShortcutKey(SerializedHDReflectionProbe p, Editor o)
        {
            var evt = Event.current;

            if (evt.type != EventType.KeyDown || !evt.shift)
            {
                return;
            }

            for (var i = 0; i < k_ShortCutKeys.Length; ++i)
            {
                if (evt.keyCode == k_ShortCutKeys[i])
                {
                    var mode = EditMode.editMode == k_Toolbar_SceneViewEditModes[i]
                        ? EditMode.SceneViewEditMode.None
                        : k_Toolbar_SceneViewEditModes[i];
                    EditMode.ChangeEditMode(mode, GetBoundsGetter(p)(), o);
                    evt.Use();
                    break;
                }
            }
        }
        static void Drawer_InfluenceBoxSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
        {
            bool advanced         = p.editorAdvancedModeEnabled.boolValue;
            var  maxBlendDistance = HDReflectionProbeEditorUtility.CalculateBoxMaxBlendDistance(s, p, owner);

            EditorGUILayout.BeginHorizontal();
            Drawer_AdvancedBlendDistance(
                p,
                false,
                maxBlendDistance,
                CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.")
                );
            if (GUILayout.Button(toolbar_Contents[1], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3))))
            {
                EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[1], GetBoundsGetter(p)(), owner);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            Drawer_AdvancedBlendDistance(
                p,
                true,
                maxBlendDistance,
                CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes.")
                );
            if (GUILayout.Button(toolbar_Contents[2], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3))))
            {
                EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[2], GetBoundsGetter(p)(), owner);
            }
            EditorGUILayout.EndHorizontal();

            if (advanced)
            {
                CoreEditorUtils.DrawVector6(
                    CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."),
                    p.boxSideFadePositive, p.boxSideFadeNegative, Vector3.zero, Vector3.one, HDReflectionProbeEditor.k_handlesColor);
            }
        }
        static void Drawer_AdditionalSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
        {
            EditorGUILayout.PropertyField(p.weight, CoreEditorUtils.GetContent("Influence Volume Weight|Blending weight to use while interpolating between influence volume. (Reminder: Sky is an Influence Volume too)."));

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(p.multiplier, CoreEditorUtils.GetContent("Multiplier|Tweeking option to enhance reflection."));
            if (EditorGUI.EndChangeCheck())
            {
                p.multiplier.floatValue = Mathf.Max(0.0f, p.multiplier.floatValue);
            }

            if (p.so.targetObjects.Length == 1)
            {
                var probe = p.target;
                if (probe.mode == ReflectionProbeMode.Custom && probe.customBakedTexture != null)
                {
                    var cubemap = probe.customBakedTexture as Cubemap;
                    if (cubemap && cubemap.mipmapCount == 1)
                    {
                        EditorGUILayout.HelpBox("No mipmaps in the cubemap, Smoothness value in Standard shader will be ignored.", MessageType.Warning);
                    }
                }
            }
        }
 static void Drawer_ModeSettingsRealtime(HDProbeUI s, SerializedHDProbe p, Editor owner)
 {
     SerializedHDReflectionProbe probe = (SerializedHDReflectionProbe)p;
     //EditorGUILayout.PropertyField(p.refreshMode, CoreEditorUtils.GetContent("Refresh Mode|Controls how this probe refreshes in the Player"));
     //EditorGUILayout.PropertyField(probe.timeSlicingMode, CoreEditorUtils.GetContent("Time Slicing|If enabled this probe will update over several frames, to help reduce the impact on the frame rate"));
 }
Example #25
0
        static void Handle_InfluenceFadeEditing(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o, InfluenceType influenceType)
        {
            Gizmo6FacesBoxContained alternativeBlendBox;
            SphereBoundsHandle      sphereHandle;
            Vector3 probeBlendDistancePositive, probeBlendDistanceNegative;
            Color   color;

            switch (influenceType)
            {
            default:
            case InfluenceType.Standard:
            {
                alternativeBlendBox        = s.alternativeBoxBlendHandle;
                sphereHandle               = s.sphereBlendHandle;
                probeBlendDistancePositive = sp.targetData.blendDistancePositive;
                probeBlendDistanceNegative = sp.targetData.blendDistanceNegative;
                color = k_GizmoThemeColorInfluenceBlend;
                break;
            }

            case InfluenceType.Normal:
            {
                alternativeBlendBox        = s.alternativeBoxBlendNormalHandle;
                sphereHandle               = s.sphereBlendNormalHandle;
                probeBlendDistancePositive = sp.targetData.blendNormalDistancePositive;
                probeBlendDistanceNegative = sp.targetData.blendNormalDistanceNegative;
                color = k_GizmoThemeColorInfluenceNormalBlend;
                break;
            }
            }

            var mat = Handles.matrix;
            var col = Handles.color;

            Handles.matrix = HDReflectionProbeEditorUtility.GetLocalSpace(sp.target);
            switch ((ShapeType)sp.influenceShape.enumValueIndex)
            {
            case ShapeType.Box:
            {
                alternativeBlendBox.center = sp.target.center - (probeBlendDistancePositive - probeBlendDistanceNegative) * 0.5f;
                alternativeBlendBox.size   = sp.target.size - probeBlendDistancePositive - probeBlendDistanceNegative;

                alternativeBlendBox.container.center = sp.target.center;
                alternativeBlendBox.container.size   = sp.target.size;

                EditorGUI.BeginChangeCheck();
                alternativeBlendBox.DrawHandle();
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(sp.target, "Modified Reflection Probe Influence");
                    Undo.RecordObject(sp.targetData, "Modified Reflection Probe Influence");

                    var center        = sp.target.center;
                    var influenceSize = sp.target.size;

                    var diff     = 2 * (alternativeBlendBox.center - center);
                    var sum      = influenceSize - (alternativeBlendBox.size);
                    var positive = (sum - diff) * 0.5f;
                    var negative = (sum + diff) * 0.5f;
                    var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positive, influenceSize));
                    var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negative, influenceSize));

                    probeBlendDistancePositive = blendDistancePositive;
                    probeBlendDistanceNegative = blendDistanceNegative;

                    ApplyConstraintsOnTargets(s, sp, o);

                    EditorUtility.SetDirty(sp.target);
                    EditorUtility.SetDirty(sp.targetData);
                }
                break;
            }

            case ShapeType.Sphere:
            {
                sphereHandle.center = sp.target.center;
                sphereHandle.radius = Mathf.Clamp(sp.targetData.influenceSphereRadius - probeBlendDistancePositive.x, 0, sp.targetData.influenceSphereRadius);

                Handles.color = k_GizmoThemeColorExtent;
                EditorGUI.BeginChangeCheck();
                Handles.color = color;
                sphereHandle.DrawHandle();
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(sp.target, "Modified Reflection influence volume");
                    Undo.RecordObject(sp.targetData, "Modified Reflection influence volume");

                    var influenceRadius = sp.targetData.influenceSphereRadius;
                    var blendRadius     = sphereHandle.radius;

                    var blendDistance = Mathf.Clamp(influenceRadius - blendRadius, 0, influenceRadius);

                    probeBlendDistancePositive = Vector3.one * blendDistance;
                    probeBlendDistanceNegative = probeBlendDistancePositive;

                    ApplyConstraintsOnTargets(s, sp, o);

                    EditorUtility.SetDirty(sp.target);
                    EditorUtility.SetDirty(sp.targetData);
                }
                break;
            }
            }
            Handles.matrix = mat;
            Handles.color  = col;


            switch (influenceType)
            {
            default:
            case InfluenceType.Standard:
            {
                sp.blendDistancePositive.vector3Value = probeBlendDistancePositive;
                sp.blendDistanceNegative.vector3Value = probeBlendDistanceNegative;

                //save advanced/simplified saved data
                if (sp.editorAdvancedModeEnabled.boolValue)
                {
                    sp.editorAdvancedModeBlendDistancePositive.vector3Value = probeBlendDistancePositive;
                    sp.editorAdvancedModeBlendDistanceNegative.vector3Value = probeBlendDistanceNegative;
                }
                else
                {
                    sp.editorSimplifiedModeBlendDistance.floatValue = probeBlendDistancePositive.x;
                }
                break;
            }

            case InfluenceType.Normal:
            {
                sp.blendNormalDistancePositive.vector3Value = probeBlendDistancePositive;
                sp.blendNormalDistanceNegative.vector3Value = probeBlendDistanceNegative;

                //save advanced/simplified saved data
                if (sp.editorAdvancedModeEnabled.boolValue)
                {
                    sp.editorAdvancedModeBlendNormalDistancePositive.vector3Value = probeBlendDistancePositive;
                    sp.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = probeBlendDistanceNegative;
                }
                else
                {
                    sp.editorSimplifiedModeBlendNormalDistance.floatValue = probeBlendDistancePositive.x;
                }
                break;
            }
            }
            sp.Apply();
        }
Example #26
0
        static void Handle_InfluenceEditing(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
        {
            var mat = Handles.matrix;
            var col = Handles.color;

            Handles.matrix = HDReflectionProbeEditorUtility.GetLocalSpace(sp.target);
            switch ((ShapeType)sp.influenceShape.enumValueIndex)
            {
            case ShapeType.Box:
            {
                s.alternativeBoxInfluenceHandle.center = sp.target.center;
                s.alternativeBoxInfluenceHandle.size   = sp.target.size;

                EditorGUI.BeginChangeCheck();
                s.alternativeBoxInfluenceHandle.DrawHandle();
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(sp.target, "Modified Reflection Probe AABB");
                    Undo.RecordObject(sp.targetData, "Modified Reflection Probe AABB");

                    Vector3 center;
                    Vector3 size;
                    center = s.alternativeBoxInfluenceHandle.center;
                    size   = s.alternativeBoxInfluenceHandle.size;

                    HDReflectionProbeEditorUtility.ValidateAABB(sp.target, ref center, ref size);

                    sp.target.center = center;
                    sp.target.size   = size;

                    //ApplyConstraintsOnTargets(s, sp, o);

                    EditorUtility.SetDirty(sp.target);
                    EditorUtility.SetDirty(sp.targetData);
                }
                break;
            }

            case ShapeType.Sphere:
            {
                s.sphereInfluenceHandle.center = sp.target.center;
                s.sphereInfluenceHandle.radius = sp.targetData.influenceSphereRadius;

                Handles.color = k_GizmoThemeColorExtent;
                EditorGUI.BeginChangeCheck();
                s.sphereInfluenceHandle.DrawHandle();
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(sp.target, "Modified Reflection Probe AABB");
                    Undo.RecordObject(sp.targetData, "Modified Reflection Probe AABB");

                    var center          = sp.target.center;
                    var influenceRadius = s.sphereInfluenceHandle.radius;
                    var radius          = Vector3.one * influenceRadius;

                    HDReflectionProbeEditorUtility.ValidateAABB(sp.target, ref center, ref radius);
                    influenceRadius = radius.x;

                    sp.targetData.influenceSphereRadius = influenceRadius;

                    //ApplyConstraintsOnTargets(s, sp, o);

                    EditorUtility.SetDirty(sp.target);
                    EditorUtility.SetDirty(sp.targetData);
                }
                break;
            }
            }
            Handles.matrix = mat;
            Handles.color  = col;
        }
 static void Drawer_IntensityMultiplier(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.intensityMultiplier, CoreEditorUtils.GetContent("Intensity"));
 }
 static void PerformOperations(HDReflectionProbeUI s, SerializedHDReflectionProbe p, HDReflectionProbeEditor o)
 {
 }
Example #29
0
 public static float CalculateSphereMaxBlendDistance(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor o)
 {
     return(p.influenceSphereRadius.floatValue);
 }
Example #30
0
 public static Vector3 CalculateBoxMaxBlendDistance(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor o)
 {
     return(p.boxSize.vector3Value * 0.5f);
 }