Esempio n. 1
0
        static void Drawer_BakeToolBar(SerializedProbeVolume serialized, Editor owner)
        {
            var asset = serialized.probeVolumeAsset.objectReferenceValue as ProbeVolumeAsset;

            if (ShaderConfig.s_ProbeVolumesBilateralFilteringMode == ProbeVolumesBilateralFilteringModes.OctahedralDepth &&
                asset != null && asset.payload.dataOctahedralDepth == null)
            {
                EditorGUILayout.HelpBox(Styles.k_FeatureOctahedralDepthEnabledNoData, MessageType.Error);
            }

            if (ShaderConfig.s_ProbeVolumesBilateralFilteringMode != ProbeVolumesBilateralFilteringModes.OctahedralDepth &&
                asset != null && asset.payload.dataOctahedralDepth != null)
            {
                EditorGUILayout.HelpBox(Styles.k_FeatureOctahedralDepthDisableYesData, MessageType.Error);
            }

            EditorGUILayout.PropertyField(serialized.probeVolumeAsset, Styles.s_DataAssetLabel);

            EditorGUILayout.Slider(serialized.backfaceTolerance, 0.0f, 1.0f, Styles.s_BackfaceToleranceLabel);
            EditorGUILayout.PropertyField(serialized.dilationIterations, Styles.s_DilationIterationLabel);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(Styles.k_BakeSelectedText))
            {
                ProbeVolumeManager.BakeSelected();
            }
            GUILayout.EndHorizontal();
        }
Esempio n. 2
0
        protected void OnEnable()
        {
            m_SerializedProbeVolume = new SerializedProbeVolume(serializedObject);

            shapeBoxes.Clear();
            for (int i = 0; i < targets.Length; ++i)
            {
                var shapeBox = shapeBoxes[targets[i] as ProbeVolume] = new HierarchicalBox(ProbeVolumeUI.Styles.k_GizmoColorBase, ProbeVolumeUI.Styles.k_BaseHandlesColor);
                shapeBox.monoHandle = false;
            }
        }
 static void Drawer_VolumeContent(SerializedProbeVolume serialized, Editor owner)
 {
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.PropertyField(serialized.size, Styles.s_Size);
     if (EditorGUI.EndChangeCheck())
     {
         Vector3 tmpClamp = serialized.size.vector3Value;
         tmpClamp.x = Mathf.Max(0f, tmpClamp.x);
         tmpClamp.y = Mathf.Max(0f, tmpClamp.y);
         tmpClamp.z = Mathf.Max(0f, tmpClamp.z);
         serialized.size.vector3Value = tmpClamp;
     }
 }
Esempio n. 4
0
        static void Drawer_BakeToolBar(SerializedProbeVolume serialized, Editor owner)
        {
            EditorGUILayout.PropertyField(serialized.probeVolumeAsset, Styles.s_DataAssetLabel);

            EditorGUILayout.Slider(serialized.backfaceTolerance, 0.0f, 1.0f, Styles.s_BackfaceToleranceLabel);
            EditorGUILayout.PropertyField(serialized.dilationIterations, Styles.s_DilationIterationLabel);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Bake Selected"))
            {
                ProbeVolumeManager.BakeSelected();
            }
            GUILayout.EndHorizontal();
        }
Esempio n. 5
0
        static void Drawer_AdvancedSwitch(SerializedProbeVolume serialized, Editor owner)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                bool advanced = serialized.advancedFade.boolValue;
                advanced = GUILayout.Toggle(advanced, Styles.s_AdvancedModeContent, EditorStyles.miniButton, GUILayout.Width(70f), GUILayout.ExpandWidth(false));
                foreach (var containedBox in ProbeVolumeEditor.blendBoxes.Values)
                {
                    containedBox.monoHandle = !advanced;
                }
                if (serialized.advancedFade.boolValue ^ advanced)
                {
                    serialized.advancedFade.boolValue = advanced;
                }
            }
        }
Esempio n. 6
0
        static void Drawer_ToolBar(SerializedProbeVolume serialized, Editor owner)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            EditMode.DoInspectorToolbar(new[] { ProbeVolumeEditor.k_EditShape, ProbeVolumeEditor.k_EditBlend }, Styles.s_Toolbar_Contents, () =>
            {
                var bounds = new Bounds();
                foreach (Component targetObject in owner.targets)
                {
                    bounds.Encapsulate(targetObject.transform.position);
                }
                return(bounds);
            },
                                        owner);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
Esempio n. 7
0
        static void Drawer_PrimarySettings(SerializedProbeVolume serialized, Editor owner)
        {
            EditorGUILayout.PropertyField(serialized.drawProbes, Styles.s_DrawProbesLabel);
            EditorGUILayout.PropertyField(serialized.probeSpacingMode, Styles.s_ProbeSpacingModeLabel);
            switch ((ProbeSpacingMode)serialized.probeSpacingMode.enumValueIndex)
            {
            case ProbeSpacingMode.Density:
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.DelayedFloatField(serialized.densityX, Styles.s_DensityXLabel);
                EditorGUILayout.DelayedFloatField(serialized.densityY, Styles.s_DensityYLabel);
                EditorGUILayout.DelayedFloatField(serialized.densityZ, Styles.s_DensityZLabel);
                if (EditorGUI.EndChangeCheck())
                {
                    serialized.resolutionX.intValue = Mathf.Max(1, Mathf.RoundToInt(serialized.densityX.floatValue * serialized.size.vector3Value.x));
                    serialized.resolutionY.intValue = Mathf.Max(1, Mathf.RoundToInt(serialized.densityY.floatValue * serialized.size.vector3Value.y));
                    serialized.resolutionZ.intValue = Mathf.Max(1, Mathf.RoundToInt(serialized.densityZ.floatValue * serialized.size.vector3Value.z));
                }
                break;
            }

            case ProbeSpacingMode.Resolution:
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.DelayedIntField(serialized.resolutionX, Styles.s_ResolutionXLabel);
                EditorGUILayout.DelayedIntField(serialized.resolutionY, Styles.s_ResolutionYLabel);
                EditorGUILayout.DelayedIntField(serialized.resolutionZ, Styles.s_ResolutionZLabel);
                if (EditorGUI.EndChangeCheck())
                {
                    serialized.resolutionX.intValue = Mathf.Max(1, serialized.resolutionX.intValue);
                    serialized.resolutionY.intValue = Mathf.Max(1, serialized.resolutionY.intValue);
                    serialized.resolutionZ.intValue = Mathf.Max(1, serialized.resolutionZ.intValue);

                    serialized.densityX.floatValue = (float)serialized.resolutionX.intValue / Mathf.Max(1e-5f, serialized.size.vector3Value.x);
                    serialized.densityY.floatValue = (float)serialized.resolutionY.intValue / Mathf.Max(1e-5f, serialized.size.vector3Value.y);
                    serialized.densityZ.floatValue = (float)serialized.resolutionZ.intValue / Mathf.Max(1e-5f, serialized.size.vector3Value.z);
                }
                break;
            }

            default: break;
            }
        }
 static void Drawer_ToolBar(SerializedProbeVolume serialized, Editor owner)
 {
 }
 static void Drawer_FeatureEnableInfo(SerializedProbeVolume serialized, Editor owner)
 {
     EditorGUILayout.HelpBox(Styles.k_featureEnableInfo, MessageType.Error);
 }
Esempio n. 10
0
 static void Drawer_FeatureWarningMessage(SerializedProbeVolume serialized, Editor owner)
 {
     EditorGUILayout.HelpBox(Styles.k_featureWarning, MessageType.Warning);
 }
Esempio n. 11
0
 static bool IsFeatureDisabled(SerializedProbeVolume serialized, Editor owner)
 {
     return((int)ShaderOptions.EnableProbeVolumes == 0);
 }
Esempio n. 12
0
        static void Drawer_VolumeContent(SerializedProbeVolume serialized, Editor owner)
        {
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(serialized.size, Styles.s_Size);
            if (EditorGUI.EndChangeCheck())
            {
                Vector3 tmpClamp = serialized.size.vector3Value;
                tmpClamp.x = Mathf.Max(0f, tmpClamp.x);
                tmpClamp.y = Mathf.Max(0f, tmpClamp.y);
                tmpClamp.z = Mathf.Max(0f, tmpClamp.z);
                serialized.size.vector3Value = tmpClamp;
            }

            Vector3 s = serialized.size.vector3Value;

            EditorGUI.BeginChangeCheck();
            if (serialized.advancedFade.boolValue)
            {
                EditorGUI.BeginChangeCheck();
                CoreEditorUtils.DrawVector6(Styles.s_BlendLabel, serialized.positiveFade, serialized.negativeFade, Vector3.zero, s, InfluenceVolumeUI.k_HandlesColor, serialized.size);
                if (EditorGUI.EndChangeCheck())
                {
                    //forbid positive/negative box that doesn't intersect in inspector too
                    Vector3 positive = serialized.positiveFade.vector3Value;
                    Vector3 negative = serialized.negativeFade.vector3Value;
                    for (int axis = 0; axis < 3; ++axis)
                    {
                        if (positive[axis] > 1f - negative[axis])
                        {
                            if (positive == serialized.positiveFade.vector3Value)
                            {
                                negative[axis] = 1f - positive[axis];
                            }
                            else
                            {
                                positive[axis] = 1f - negative[axis];
                            }
                        }
                    }

                    serialized.positiveFade.vector3Value = positive;
                    serialized.negativeFade.vector3Value = negative;
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                float distanceMax         = Mathf.Min(s.x, s.y, s.z);
                float uniformFadeDistance = serialized.uniformFade.floatValue * distanceMax;
                uniformFadeDistance = EditorGUILayout.FloatField(Styles.s_BlendLabel, uniformFadeDistance);
                if (EditorGUI.EndChangeCheck())
                {
                    serialized.uniformFade.floatValue = Mathf.Clamp(uniformFadeDistance / distanceMax, 0f, 0.5f);
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                Vector3 posFade = new Vector3();
                posFade.x = Mathf.Clamp01(serialized.positiveFade.vector3Value.x);
                posFade.y = Mathf.Clamp01(serialized.positiveFade.vector3Value.y);
                posFade.z = Mathf.Clamp01(serialized.positiveFade.vector3Value.z);

                Vector3 negFade = new Vector3();
                negFade.x = Mathf.Clamp01(serialized.negativeFade.vector3Value.x);
                negFade.y = Mathf.Clamp01(serialized.negativeFade.vector3Value.y);
                negFade.z = Mathf.Clamp01(serialized.negativeFade.vector3Value.z);

                serialized.positiveFade.vector3Value = posFade;
                serialized.negativeFade.vector3Value = negFade;
            }

            // Distance fade.
            {
                EditorGUI.BeginChangeCheck();

                float distanceFadeStart = EditorGUILayout.FloatField(Styles.s_DistanceFadeStartLabel, serialized.distanceFadeStart.floatValue);
                float distanceFadeEnd   = EditorGUILayout.FloatField(Styles.s_DistanceFadeEndLabel, serialized.distanceFadeEnd.floatValue);

                if (EditorGUI.EndChangeCheck())
                {
                    distanceFadeStart = Mathf.Max(0, distanceFadeStart);
                    distanceFadeEnd   = Mathf.Max(distanceFadeStart, distanceFadeEnd);

                    serialized.distanceFadeStart.floatValue = distanceFadeStart;
                    serialized.distanceFadeEnd.floatValue   = distanceFadeEnd;
                }
            }

            EditorGUILayout.PropertyField(serialized.lightLayers);
            EditorGUILayout.PropertyField(serialized.volumeBlendMode, Styles.s_VolumeBlendModeLabel);
            EditorGUILayout.Slider(serialized.weight, 0.0f, 1.0f, Styles.s_WeightLabel);
            {
                EditorGUI.BeginChangeCheck();
                float normalBiasWS = EditorGUILayout.FloatField(Styles.s_NormalBiasWSLabel, serialized.normalBiasWS.floatValue);
                if (EditorGUI.EndChangeCheck())
                {
                    serialized.normalBiasWS.floatValue = Mathf.Max(0, normalBiasWS);
                }
            }
            EditorGUILayout.PropertyField(serialized.debugColor, Styles.s_DebugColorLabel);

            if (ShaderConfig.s_ProbeVolumesAdditiveBlending == 0 && serialized.volumeBlendMode.intValue != (int)VolumeBlendMode.Normal)
            {
                EditorGUILayout.HelpBox(Styles.k_FeatureAdditiveBlendingDisabledError, MessageType.Error);
            }
        }
Esempio n. 13
0
 static bool IsFeatureDisabled(SerializedProbeVolume serialized, Editor owner)
 {
     return(ShaderOptions.ProbeVolumesEvaluationMode == (int)ProbeVolumesEvaluationModes.Disabled);
 }