public static void DrawCustomSettings(SerializedHDProbe serialized, Editor owner)
            {
                var provider = new TProvider();

                ProbeSettingsUI.Draw(
                    serialized.probeSettings, owner,
                    serialized.probeSettingsOverride,
                    provider.displayedAdvancedSettings, provider.overrideableAdvancedSettings
                    );
            }
            // Drawers
            public static void DrawPrimarySettings(SerializedHDProbe serialized, Editor owner)
            {
                const string modeTooltip = "'Baked' 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 capture is wanted. \n" +
                                           "'Realtime' can be used to dynamically re-render the capture during runtime (every frame).";

                var provider = new TProvider();

#if !ENABLE_BAKED_PLANAR
                if (serialized is SerializedPlanarReflectionProbe)
                {
                    serialized.probeSettings.mode.intValue = (int)ProbeSettings.Mode.Realtime;
                }
                else
                {
#endif

                // Probe Mode
                EditorGUI.showMixedValue = serialized.probeSettings.mode.hasMultipleDifferentValues;
                EditorGUILayout.IntPopup(serialized.probeSettings.mode, k_ModeContents, k_ModeValues, EditorGUIUtility.TrTextContent("Type", modeTooltip));
                EditorGUI.showMixedValue = false;

#if !ENABLE_BAKED_PLANAR
            }
#endif

                switch ((ProbeSettings.Mode)serialized.probeSettings.mode.intValue)
                {
                case ProbeSettings.Mode.Realtime:
                {
                    EditorGUI.showMixedValue = serialized.probeSettings.realtimeMode.hasMultipleDifferentValues;
                    EditorGUILayout.PropertyField(serialized.probeSettings.realtimeMode);
                    EditorGUI.showMixedValue = false;
                    break;
                }

                case ProbeSettings.Mode.Custom:
                {
                    EditorGUI.showMixedValue = serialized.customTexture.hasMultipleDifferentValues;
                    EditorGUI.BeginChangeCheck();
                    var customTexture = EditorGUILayout.ObjectField(
                        EditorGUIUtility.TrTextContent("Texture"), serialized.customTexture.objectReferenceValue, provider.customTextureType, false
                        );
                    EditorGUI.showMixedValue = false;
                    if (EditorGUI.EndChangeCheck())
                    {
                        serialized.customTexture.objectReferenceValue = customTexture;
                    }
                    break;
                }
                }
            }
Exemplo n.º 3
0
            // Drawers
            public static void DrawPrimarySettings(SerializedHDProbe serialized, Editor owner)
            {
                var provider = new TProvider();

#if !ENABLE_BAKED_PLANAR
                if (serialized is SerializedPlanarReflectionProbe)
                {
                    serialized.probeSettings.mode.intValue = (int)ProbeSettings.Mode.Realtime;
                }
                else
                {
#endif

                // Probe Mode
                EditorGUILayout.IntPopup(serialized.probeSettings.mode, k_ModeContents, k_ModeValues, k_BakeTypeContent);

#if !ENABLE_BAKED_PLANAR
            }
#endif

                switch ((ProbeSettings.Mode)serialized.probeSettings.mode.intValue)
                {
                case ProbeSettings.Mode.Realtime:
                {
                    EditorGUILayout.PropertyField(serialized.probeSettings.realtimeMode);
                    if ((ProbeSettings.ProbeType)serialized.probeSettings.type.intValue == ProbeSettings.ProbeType.ReflectionProbe)
                    {
                        EditorGUILayout.PropertyField(serialized.probeSettings.timeSlicing, k_TimeSlicingContent);
                    }
                    break;
                }

                case ProbeSettings.Mode.Custom:
                {
                    Rect lineRect = EditorGUILayout.GetControlRect(true, 64);
                    EditorGUI.BeginProperty(lineRect, k_CustomTextureContent, serialized.customTexture);
                    {
                        EditorGUI.BeginChangeCheck();
                        var customTexture = EditorGUI.ObjectField(lineRect, k_CustomTextureContent, serialized.customTexture.objectReferenceValue, provider.customTextureType, false);
                        if (EditorGUI.EndChangeCheck())
                        {
                            serialized.customTexture.objectReferenceValue = customTexture;
                        }
                    }
                    EditorGUI.EndProperty();
                    break;
                }
                }
            }
        static internal void Drawer_DifferentShapeError(SerializedHDProbe serialized, Editor owner)
        {
            var proxy = serialized.proxyVolume.objectReferenceValue as ReflectionProxyVolumeComponent;

            if (proxy != null &&
                (int)proxy.proxyVolume.shape != serialized.probeSettings.influence.shape.enumValueIndex &&
                proxy.proxyVolume.shape != ProxyShape.Infinite)
            {
                EditorGUILayout.HelpBox(
                    k_ProxyInfluenceShapeMismatchHelpBoxText,
                    MessageType.Error,
                    true
                    );
            }
        }
            // Tool bars
            public static void DrawToolbars(SerializedHDProbe serialized, Editor owner)
            {
                var provider = new TProvider();

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.changed = false;

                for (int i = 0; i < k_ListModes.Length; ++i)
                {
                    EditMode.DoInspectorToolbar(k_ListModes[i], k_ListContent[i], HDEditorUtils.GetBoundsGetter(owner), owner);
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
Exemplo n.º 6
0
            public static void DrawProjectionSettings(SerializedHDProbe serialized, Editor owner)
            {
                EditorGUILayout.PropertyField(serialized.proxyVolume, k_ProxyVolumeContent);

                if (serialized.target.proxyVolume == null)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(serialized.probeSettings.proxyUseInfluenceVolumeAsProxyVolume);
                    if (EditorGUI.EndChangeCheck())
                    {
                        serialized.Apply();
                    }
                }

                if (serialized.proxyVolume.objectReferenceValue != null)
                {
                    var proxy = (ReflectionProxyVolumeComponent)serialized.proxyVolume.objectReferenceValue;
                    if (proxy.proxyVolume.shape != serialized.probeSettings.influence.shape.GetEnumValue <ProxyShape>() &&
                        proxy.proxyVolume.shape != ProxyShape.Infinite)
                    {
                        EditorGUILayout.HelpBox(
                            k_ProxyInfluenceShapeMismatchHelpBoxText,
                            MessageType.Error,
                            true
                            );
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox(
                        serialized.probeSettings.proxyUseInfluenceVolumeAsProxyVolume.boolValue ? k_NoProxyHelpBoxText : k_NoProxyInfiniteHelpBoxText,
                        MessageType.Info,
                        true
                        );
                }

                // Don't display distanceBasedRoughness if the projection is infinite (as in this case we force distanceBasedRoughness to be 0 in code)
                if (owner is HDReflectionProbeEditor && !(serialized.proxyVolume.objectReferenceValue == null && serialized.probeSettings.proxyUseInfluenceVolumeAsProxyVolume.boolValue == false))
                {
                    EditorGUILayout.PropertyField(serialized.probeSettings.distanceBasedRoughness, EditorGUIUtility.TrTextContent("Distance Based Roughness", "When enabled, HDRP uses the assigned Proxy Volume to calculate distance based roughness for reflections. This produces more physically-accurate results if the Proxy Volume closely matches the environment."));
                }
            }
Exemplo n.º 7
0
            // Tool bars
            public static void DrawToolbars(SerializedHDProbe serialized, Editor owner)
            {
                var provider = new TProvider();

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.changed = false;

                for (int i = 0; i < k_ListModes.Length - 1; ++i)
                {
                    EditMode.DoInspectorToolbar(k_ListModes[i], k_ListContent[i], HDEditorUtils.GetBoundsGetter(owner), owner);
                }

                //Special case: show chrome gizmo should be mouved to overlay tool.
                //meanwhile, display it as an option of toolbar
                EditorGUI.BeginChangeCheck();
                IHDProbeEditor probeEditor = owner as IHDProbeEditor;
                int            selected    = probeEditor.showChromeGizmo ? 0 : -1;
                int            newSelected = GUILayout.Toolbar(selected, new[] { k_ListContent[k_ListModes.Length - 1][0] }, GUILayout.Height(20), GUILayout.Width(30));

                if (EditorGUI.EndChangeCheck())
                {
                    //allow deselection
                    if (selected >= 0 && newSelected == selected)
                    {
                        selected = -1;
                    }
                    else
                    {
                        selected = newSelected;
                    }
                    probeEditor.showChromeGizmo = selected == 0;
                    SceneView.RepaintAll();
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
Exemplo n.º 8
0
            public static void DrawSHNormalizationStatus(SerializedHDProbe serialized, Editor owner)
            {
                const string kResolution    = " Please ensure that probe positions are valid (not inside static geometry) then bake lighting to regenerate data.";
                const string kMixedMode     = "Unable to show normalization data validity when selecting probes with different modes.";
                const string kMixedValidity = "Baked reflection probe normalization data is partially invalid." + kResolution;
                const string kValid         = "Baked reflection probe normalization data is valid.";
                const string kInvalid       = "Baked reflection probe normalization data is invalid." + kResolution;

                var globalSettings = HDRenderPipelineGlobalSettings.instance;

                if (globalSettings == null || !globalSettings.supportProbeVolumes)
                {
                    return;
                }

                var spMode  = serialized.serializedObject.FindProperty("m_ProbeSettings.mode");
                var spValid = serialized.serializedObject.FindProperty("m_HasValidSHForNormalization");

                if (spMode.intValue != (int)ProbeSettings.Mode.Baked)
                {
                    return;
                }

                EditorGUILayout.Space();

                if (spMode.hasMultipleDifferentValues)
                {
                    EditorGUILayout.HelpBox(kMixedMode, MessageType.Info);
                }
                else if (spValid.hasMultipleDifferentValues)
                {
                    EditorGUILayout.HelpBox(kMixedValidity, MessageType.Warning);
                }
                else
                {
                    EditorGUILayout.HelpBox(spValid.boolValue ? kValid : kInvalid, spValid.boolValue ? MessageType.Info : MessageType.Warning);
                }
            }
            public static void DrawProjectionSettings(SerializedHDProbe serialized, Editor owner)
            {
                EditorGUILayout.PropertyField(serialized.proxyVolume, k_ProxyVolumeContent);

                if (serialized.target.proxyVolume == null)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(serialized.probeSettings.proxyUseInfluenceVolumeAsProxyVolume);
                    if (EditorGUI.EndChangeCheck())
                    {
                        serialized.Apply();
                    }
                }

                if (serialized.proxyVolume.objectReferenceValue != null)
                {
                    var proxy = (ReflectionProxyVolumeComponent)serialized.proxyVolume.objectReferenceValue;
                    if ((int)proxy.proxyVolume.shape != serialized.probeSettings.influence.shape.enumValueIndex &&
                        proxy.proxyVolume.shape != ProxyShape.Infinite)
                    {
                        EditorGUILayout.HelpBox(
                            k_ProxyInfluenceShapeMismatchHelpBoxText,
                            MessageType.Error,
                            true
                            );
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox(
                        serialized.probeSettings.proxyUseInfluenceVolumeAsProxyVolume.boolValue ? k_NoProxyHelpBoxText : k_NoProxyInfiniteHelpBoxText,
                        MessageType.Info,
                        true
                        );
                }
            }
            public static void DrawBakeButton(SerializedHDProbe serialized, Editor owner)
            {
                // Disable baking of multiple probes with different modes
                if (serialized.probeSettings.mode.hasMultipleDifferentValues)
                {
                    EditorGUILayout.HelpBox(
                        "Baking is not possible when selecting probe with different modes",
                        MessageType.Info
                        );
                    return;
                }

                // Check if current mode support baking
                var mode = (ProbeSettings.Mode)serialized.probeSettings.mode.intValue;
                var doesModeSupportBaking = mode == ProbeSettings.Mode.Custom || mode == ProbeSettings.Mode.Baked;

                if (!doesModeSupportBaking)
                {
                    return;
                }

                // Check if all scene are saved to a file (requirement to bake probes)
                foreach (var target in serialized.serializedObject.targetObjects)
                {
                    var comp  = (Component)target;
                    var go    = comp.gameObject;
                    var scene = go.scene;
                    if (string.IsNullOrEmpty(scene.path))
                    {
                        EditorGUILayout.HelpBox(
                            "Baking is possible only if all open scenes are saved on disk. " +
                            "Please save the scenes before baking.",
                            MessageType.Info
                            );
                        return;
                    }
                }

                switch (mode)
                {
                case ProbeSettings.Mode.Custom:
                {
                    if (ButtonWithDropdownList(
                            EditorGUIUtility.TrTextContent(
                                "Bake", "Bakes Probe's texture, overwriting the existing texture asset (if any)."
                                ),
                            k_BakeCustomOptionText,
                            data =>
                        {
                            switch ((int)data)
                            {
                            case 0:
                                RenderInCustomAsset(serialized.target, false);
                                break;
                            }
                        }))
                    {
                        RenderInCustomAsset(serialized.target, true);
                    }
                    break;
                }

                case ProbeSettings.Mode.Baked:
                {
                    if (UnityEditor.Lightmapping.giWorkflowMode
                        != UnityEditor.Lightmapping.GIWorkflowMode.OnDemand)
                    {
                        EditorGUILayout.HelpBox("Baking of this probe is automatic because this probe's type is 'Baked' and the Lighting window is using 'Auto Baking'. The texture created is stored in the GI cache.", MessageType.Info);
                        break;
                    }

                    GUI.enabled = serialized.target.enabled;

                    // Bake button in non-continous mode
                    if (ButtonWithDropdownList(
                            EditorGUIUtility.TrTextContent("Bake"),
                            k_BakeButtonsText,
                            data =>
                        {
                            if ((int)data == 0)
                            {
                                var system = ScriptableBakedReflectionSystemSettings.system;
                                system.BakeAllReflectionProbes();
                            }
                        },
                            GUILayout.ExpandWidth(true)))
                    {
                        HDBakedReflectionSystem.BakeProbes(serialized.serializedObject.targetObjects.OfType <HDProbe>().ToArray());
                        GUIUtility.ExitGUI();
                    }

                    GUI.enabled = true;
                    break;
                }

                case ProbeSettings.Mode.Realtime:
                    break;

                default: throw new ArgumentOutOfRangeException();
                }
            }
            public static void DrawInfluenceSettings(SerializedHDProbe serialized, Editor owner)
            {
                var provider = new TProvider();

                InfluenceVolumeUI.Draw <TProvider>(serialized.probeSettings.influence, owner);
            }
Exemplo n.º 12
0
            public static void DrawCustomSettings(SerializedHDProbe serialized, Editor owner)
            {
                var provider = new TProvider();

                ProbeSettingsUI.Draw(serialized.probeSettings, owner, provider.displayedCustomSettings);
            }
Exemplo n.º 13
0
            public static void DrawCaptureSettingsAdditionalProperties(SerializedHDProbe serialized, Editor owner)
            {
                var provider = new TProvider();

                ProbeSettingsUI.Draw(serialized.probeSettings, owner, provider.displayedAdvancedCaptureSettings);
            }
Exemplo n.º 14
0
        internal static void DrawHandles(SerializedHDProbe serialized, Editor owner)
        {
            var probe = serialized.target;

            switch (EditMode.editMode)
            {
            case EditBaseShape:
                InfluenceVolumeUI.DrawHandles_EditBase(serialized.probeSettings.influence, owner, probe.transform);
                break;

            case EditInfluenceShape:
                InfluenceVolumeUI.DrawHandles_EditInfluence(serialized.probeSettings.influence, owner, probe.transform);
                break;

            case EditInfluenceNormalShape:
                InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(serialized.probeSettings.influence, owner, probe.transform);
                break;

            case EditCapturePosition:
            case EditMirrorPosition:
            {
                var proxyToWorldMatrix = probe.proxyToWorld;

                SerializedProperty target;
                switch (EditMode.editMode)
                {
                case EditCapturePosition: target = serialized.probeSettings.proxyCapturePositionProxySpace; break;

                case EditMirrorPosition: target = serialized.probeSettings.proxyMirrorPositionProxySpace; break;

                default: throw new ArgumentOutOfRangeException();
                }

                var position = proxyToWorldMatrix.MultiplyPoint(target.vector3Value);
                EditorGUI.BeginChangeCheck();
                position = Handles.PositionHandle(position, proxyToWorldMatrix.rotation);
                if (EditorGUI.EndChangeCheck())
                {
                    target.vector3Value = proxyToWorldMatrix.inverse.MultiplyPoint(position);
                }
                break;
            }

            case EditMirrorRotation:
            {
                var proxyToWorldMatrix = probe.proxyToWorld;

                var target   = serialized.probeSettings.proxyMirrorRotationProxySpace;
                var position = serialized.probeSettings.proxyMirrorPositionProxySpace.vector3Value;

                using (new Handles.DrawingScope(proxyToWorldMatrix))
                {
                    var rotation = target.quaternionValue;
                    EditorGUI.BeginChangeCheck();
                    rotation = Handles.RotationHandle(rotation, position);
                    if (EditorGUI.EndChangeCheck())
                    {
                        target.quaternionValue = rotation;
                    }
                }
                break;
            }
            }
        }