Пример #1
0
        public static GBlurParams Create()
        {
            GBlurParams param = new GBlurParams();

            param.radius = 10;
            return(param);
        }
Пример #2
0
        public void Apply(RenderTexture targetRt, GTextureFilterParams param)
        {
            GBlurParams   blurParam = param.Blur;
            RenderTexture bg        = CloneBg(targetRt);

            Mat.SetTexture("_MainTex", bg);
            GCommon.DrawQuad(targetRt, GCommon.FullRectUvPoints, Mat, blurParam.Radius);
        }
        private void DrawFilterLayer(GTextureFilterLayer layer, int index)
        {
            string label = string.Format("{0} {1}", ObjectNames.NicifyVariableName(layer.Type.ToString()), layer.Enabled ? "" : "[-]");
            string id    = "texture-creator-filter" + index;

            string prefKey  = GEditorCommon.GetProjectRelatedEditorPrefsKey("foldout", id);
            bool   expanded = EditorPrefs.GetBool(prefKey, true);

            int indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            Rect headerRect = EditorGUILayout.BeginHorizontal();

            expanded = EditorGUILayout.Foldout(expanded, label);
            EditorPrefs.SetBool(prefKey, expanded);
            GUILayout.FlexibleSpace();
            Rect deleteButtonRect = EditorGUILayout.GetControlRect(GUILayout.Width(15));

            if (headerRect.Contains(Event.current.mousePosition))
            {
                if (GUI.Button(deleteButtonRect, "X", EditorStyles.label))
                {
                    ConfirmAndRemoveFilterAt(index);
                }
            }
            EditorGUILayout.EndHorizontal();

            if (expanded)
            {
                EditorGUI.indentLevel += 1;
                layer.Enabled          = EditorGUILayout.Toggle("Enable", layer.Enabled);
                GTextureFilterParams param = layer.Param;
                if (layer.Type == GTextureFilterType.Blur)
                {
                    GBlurParams blur = param.Blur;
                    blur.Radius = EditorGUILayout.DelayedIntField("Radius", blur.Radius);
                    EditorGUILayout.LabelField("This filter is expensive!", GEditorCommon.WordWrapItalicLabel);
                    param.Blur = blur;
                }
                else if (layer.Type == GTextureFilterType.Curve)
                {
                    GCurveParams curve = param.Curve;
                    curve.MasterCurve = EditorGUILayout.CurveField("Master", curve.MasterCurve, Color.white, GCommon.UnitRect);
                    curve.RedCurve    = EditorGUILayout.CurveField("Red", curve.RedCurve, Color.red, GCommon.UnitRect);
                    curve.GreenCurve  = EditorGUILayout.CurveField("Green", curve.GreenCurve, Color.green, GCommon.UnitRect);
                    curve.BlueCurve   = EditorGUILayout.CurveField("Blue", curve.BlueCurve, Color.blue, GCommon.UnitRect);
                    curve.AlphaCurve  = EditorGUILayout.CurveField("Alpha", curve.AlphaCurve, Color.gray, GCommon.UnitRect);
                    param.Curve       = curve;
                }
                else if (layer.Type == GTextureFilterType.Invert)
                {
                    GInvertParams invert = param.Invert;
                    invert.InvertRed   = EditorGUILayout.Toggle("Red", invert.InvertRed);
                    invert.InvertGreen = EditorGUILayout.Toggle("Green", invert.InvertGreen);
                    invert.InvertBlue  = EditorGUILayout.Toggle("Blue", invert.InvertBlue);
                    invert.InvertAlpha = EditorGUILayout.Toggle("Alpha", invert.InvertAlpha);
                    param.Invert       = invert;
                }
                else if (layer.Type == GTextureFilterType.Step)
                {
                    GStepParams step = param.Step;
                    step.Count = EditorGUILayout.IntSlider("Count", step.Count, 1, 256);
                    param.Step = step;
                }
                else if (layer.Type == GTextureFilterType.Warp)
                {
                    GWarpParams warp = param.Warp;
                    warp.MaskIsNormalMap = EditorGUILayout.Toggle("Is Normal Map", warp.MaskIsNormalMap);
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Mask");
                    using (EditorGUI.IndentLevelScope level = new EditorGUI.IndentLevelScope(-1))
                    {
                        warp.Mask = EditorGUILayout.ObjectField(warp.Mask, typeof(Texture2D), false) as Texture2D;
                    }
                    EditorGUILayout.EndHorizontal();
                    warp.Strength = EditorGUILayout.FloatField("Strength", warp.Strength);
                    param.Warp    = warp;
                }


                /*
                 * else if (layer.Type == GTextureFilterType.HydraulicErosion)
                 * {
                 *  GHydraulicErosionParams erosion = param.HydraulicErosion;
                 *
                 *  erosion.Iteration = EditorGUILayout.IntField("Iteration", erosion.Iteration);
                 *
                 *  Vector3 dim = erosion.Dimension;
                 *  dim = GEditorCommon.InlineVector3Field("Dimension", dim);
                 *  dim.Set(Mathf.Max(1, dim.x), Mathf.Max(1, dim.y), Mathf.Max(1, dim.z));
                 *  erosion.Dimension = dim;
                 *
                 *  erosion.Rain = EditorGUILayout.Slider("Rain", erosion.Rain, 0f, 1f);
                 *  erosion.Transportation = EditorGUILayout.Slider("Transportation", erosion.Transportation, 0f, 1f);
                 *  erosion.AngleMin = EditorGUILayout.Slider("Min Angle", erosion.AngleMin, 1f, 45f);
                 *  erosion.Evaporation = EditorGUILayout.Slider("Evaporation", erosion.Evaporation, 0f, 1f);
                 *
                 *  EditorGUILayout.BeginHorizontal();
                 *  EditorGUILayout.PrefixLabel("Water Source");
                 *  using (EditorGUI.IndentLevelScope level = new EditorGUI.IndentLevelScope(-1))
                 *  {
                 *      erosion.WaterSourceMap = EditorGUILayout.ObjectField(erosion.WaterSourceMap, typeof(Texture2D), false) as Texture2D;
                 *  }
                 *  EditorGUILayout.EndHorizontal();
                 *
                 *  EditorGUILayout.BeginHorizontal();
                 *  EditorGUILayout.PrefixLabel("Hardness");
                 *  using (EditorGUI.IndentLevelScope level = new EditorGUI.IndentLevelScope(-1))
                 *  {
                 *      erosion.HardnessMap = EditorGUILayout.ObjectField(erosion.HardnessMap, typeof(Texture2D), false) as Texture2D;
                 *  }
                 *  EditorGUILayout.EndHorizontal();
                 *
                 *  param.HydraulicErosion = erosion;
                 * }
                 */

                layer.Param            = param;
                EditorGUI.indentLevel -= 1;
            }

            EditorGUI.indentLevel = indent;
        }