Ejemplo n.º 1
0
 public override void DrawPerTextureGUI(int index, Material mat, MicroSplatPropData propData)
 {
     InitPropData(5, propData, new Color(1.0f, 1.0f, 1.0f, 1.0f)); //geoTexture, global tint, global normal
     if (geoTexture)
     {
         perTexGeoStr = DrawPerTexFloatSlider(index, 5, GetFeatureName(DefineFeature._PERTEXGEO),
                                              mat, propData, Channel.R, CPerTexGeo, 0, 1);
     }
     if (tintBlendMode != BlendMode.Off)
     {
         perTexTintStr = DrawPerTexFloatSlider(index, 5, GetFeatureName(DefineFeature._PERTEXGLOBALTINTSTRENGTH),
                                               mat, propData, Channel.G, CPerTexTint, 0, 1);
     }
     if (normalBlendMode != NormalBlendMode.Off)
     {
         perTexNormalStr = DrawPerTexFloatSlider(index, 5, GetFeatureName(DefineFeature._PERTEXGLOBALNORMALSTRENGTH),
                                                 mat, propData, Channel.B, CPerTexNormal, 0, 2);
     }
     if (SAOMBlend != SAOMBlendMode.Off)
     {
         perTexSAOMStr = DrawPerTexFloatSlider(index, 5, GetFeatureName(DefineFeature._PERTEXGLOBALSOAMSTRENGTH),
                                               mat, propData, Channel.A, CPerTexSAOM, 0, 2);
     }
     if (emisBlend != SAOMBlendMode.Off)
     {
         perTexEmisStr = DrawPerTexFloatSlider(index, 6, GetFeatureName(DefineFeature._PERTEXGLOBALEMISSTRENGTH),
                                               mat, propData, Channel.A, CPerTexEmis, 0, 2);
     }
 }
    // get, load, or create the property texture for this material..
    public static MicroSplatPropData FindOrCreatePropTex(Material targetMat)
    {
        MicroSplatPropData propData = null;
        // look for it next to the material?
        var path = AssetDatabase.GetAssetPath(targetMat);

        path = path.Replace("\\", "/");
        if (!string.IsNullOrEmpty(path))
        {
            path  = path.Substring(0, path.IndexOf("."));
            path += "_propdata.asset";
            // mesh terrains are in a sub directory when lod'd, so seak back and get the shared propData
            if (path.Contains("MeshTerrain/MicroSplatData/") && !System.IO.File.Exists(path))
            {
                path = path.Replace("MeshTerrain/MicroSplatData/", "");
            }
            propData = AssetDatabase.LoadAssetAtPath <MicroSplatPropData>(path);
            if (propData == null)
            {
                propData = MicroSplatPropData.CreateInstance <MicroSplatPropData>();
                AssetDatabase.CreateAsset(propData, path);
                AssetDatabase.SaveAssets();
            }
        }
        targetMat.SetTexture("_PerTexProps", propData.GetTexture());
        return(propData);
    }
Ejemplo n.º 3
0
 public override void DrawPerTextureGUI(int index, Material mat, MicroSplatPropData propData)
 {
     InitPropData(8, propData, new Color(1.0f, 0, 0, 0)); //snow strength
     if (snow)
     {
         perTexSnow = DrawPerTexFloatSlider(index, 8, GetFeatureName(SnowDefineFeature._PERTEXSNOWSTRENGTH),
                                            mat, propData, Channel.R, CPerTexSnow, 0, 1);
     }
 }
Ejemplo n.º 4
0
 public override void DrawPerTextureGUI(int index, Material mat, MicroSplatPropData propData)
 {
     if (windParticulate != ParticulateMode.None)
     {
         perTexParticulate = DrawPerTexFloatSlider(index, 7, GetFeatureName(DefineFeature._PERTEXWINDPARTICULATE), mat, propData, Channel.A, CPTWindParticulateStrength, 0, 1.0f);
     }
     if (glitter)
     {
         DrawPerTexFloatSliderNoToggle(index, 8, GetFeatureName(DefineFeature._GLITTER), mat, propData, Channel.G, CPTGlitterStrength, 0, 1.0f);
     }
 }
Ejemplo n.º 5
0
        public override void DrawPerTextureGUI(int index, Material mat, MicroSplatPropData propData)
        {
            if (clusterMode != ClusterMode.None && clusterMode != ClusterMode.Stochastic)
            {
                perTexClusterContrast = DrawPerTexFloatSlider(index, 10, GetFeatureName(DefineFeature._PERTEXCLUSTERCONTRAST),
                                                              mat, propData, Channel.R, CPerTexClusterContrast, 1.0f, 0.01f);

                perTexClusterBoost = DrawPerTexFloatSlider(index, 10, GetFeatureName(DefineFeature._PERTEXCLUSTERBOOST),
                                                           mat, propData, Channel.G, CPerTextureClusterBoost, 0.5f, 4.0f);
            }
        }
Ejemplo n.º 6
0
        public override void DrawPerTextureGUI(int index, Material mat, MicroSplatPropData propData)
        {
            if (wetness || streams)
            {
                perTexPorosity = DrawPerTexFloatSlider(index, 3, GetFeatureName(DefineFeature._PERTEXPOROSITY),
                                                       mat, propData, Channel.B, CPerTexPorosity, 0.0f, 1.0f);
            }

            if (streams)
            {
                perTexFoam = DrawPerTexFloatSlider(index, 3, GetFeatureName(DefineFeature._PERTEXFOAM),
                                                   mat, propData, Channel.A, CPerTexFoam, 0.0f, 2.0f);
            }
        }
        public override void DrawPerTextureGUI(int index, Material mat, MicroSplatPropData propData)
        {
            InitPropData(0, propData, new Color(1.0f, 1.0f, 0.0f, 0.0f)); // uvscale2, uvOffset
            InitPropData(1, propData, new Color(1.0f, 1.0f, 1.0f, 0.0f)); // tint, interp contrast
            InitPropData(2, propData, new Color(1.0f, 0.0f, 1.0f, 0.0f)); // norm str, smooth str, ao str, metal values
            InitPropData(3, propData, new Color(0.0f, 1.0f, 0.4f, 1.0f)); // brightness, contrast, porosity, foam
            InitPropData(10, propData, new Color(1, 1, 1, 1));

            if (perTexUVScale && samplerMode == SamplerMode.Default)
            {
                EditorGUILayout.HelpBox("On some GPUs, small artifacts can appear with per-texture UV scales. Switching sampler mode to Mip (fast) or Gradient (slow) will fix the issue", MessageType.Info);
            }

            perTexUVScale = DrawPerTexVector2Vector2(index, 0, GetFeatureName(DefineFeature._PERTEXUVSCALEOFFSET),
                                                     mat, propData, CPerTexUV, CPerTexUVOffset);

            if (!disableHeightBlend)
            {
                perTexInterpContrast = DrawPerTexFloatSlider(index, 1, GetFeatureName(DefineFeature._PERTEXINTERPCONTRAST),
                                                             mat, propData, Channel.A, CPerTexInterp, -1.0f, 1.0f);
            }

            perTexTint = DrawPerTexColor(index, 1, GetFeatureName(DefineFeature._PERTEXTINT),
                                         mat, propData, CPerTexTint, false);

            perTexBrightness = DrawPerTexFloatSlider(index, 3, GetFeatureName(DefineFeature._PERTEXBRIGHTNESS),
                                                     mat, propData, Channel.R, CPerTexBrightness, -1.0f, 1.0f);

            perTexContrast = DrawPerTexFloatSlider(index, 3, GetFeatureName(DefineFeature._PERTEXCONTRAST),
                                                   mat, propData, Channel.G, CPerTexContrast, 0.1f, 3.0f);

            perTexNormStr = DrawPerTexFloatSlider(index, 2, GetFeatureName(DefineFeature._PERTEXNORMSTR),
                                                  mat, propData, Channel.R, CPerTexNormStr, 0.0f, 3.0f);

            perTexSmoothStr = DrawPerTexFloatSlider(index, 2, GetFeatureName(DefineFeature._PERTEXSMOOTHSTR),
                                                    mat, propData, Channel.G, CPerTexSmoothStr, -1.0f, 1.0f);

            perTexAOStr = DrawPerTexFloatSlider(index, 2, GetFeatureName(DefineFeature._PERTEXAOSTR),
                                                mat, propData, Channel.B, CPerTexAOStr, 0.5f, 3.0f);

            perTexMetallic = DrawPerTexFloatSlider(index, 2, GetFeatureName(DefineFeature._PERTEXMETALLIC),
                                                   mat, propData, Channel.A, CPerTexMetallic, 0, 1);

            perTexHeightOffset = DrawPerTexFloatSlider(index, 10, GetFeatureName(DefineFeature._PERTEXHEIGHTOFFSET),
                                                       mat, propData, Channel.B, CPerTexHeightOffset, 0, 2);

            perTexHeightContrast = DrawPerTexFloatSlider(index, 10, GetFeatureName(DefineFeature._PERTEXHEIGHTCONTRAST),
                                                         mat, propData, Channel.A, CPerTexHeightContrast, 0.2f, 4);
        }
Ejemplo n.º 8
0
        public override void DrawPerTextureGUI(int index, Material mat, MicroSplatPropData propData)
        {
            if (triplanarMode != TriplanarMode.None)
            {
                InitPropData(9, propData, new Color(0.0f, 0.5f, 0.0f, 0.0f));

                perTexTriplanar = DrawPerTexFloatSlider(index, 9, GetFeatureName(DefineFeature._PERTEXTRIPLANAR),
                                                        mat, propData, Channel.R, CPerTexTriplanar, 0, 1);
                if (triplanarMode == TriplanarMode.HeightBlended)
                {
                    perTexTriplanarContrast = DrawPerTexFloatSlider(index, 9, GetFeatureName(DefineFeature._PERTEXTRIPLANARCONTRAST),
                                                                    mat, propData, Channel.G, CPerTexTriplanarContrast, 0.01f, 1);
                }
            }
        }
Ejemplo n.º 9
0
 static protected void InitPropData(int pixel, MicroSplatPropData propData, Color defaultValues)
 {
     if (propData == null)
     {
         return;
     }
     // we reserve the last row of potential values as an initialization bit.
     if (propData.GetValue(pixel, 15) == new Color(0, 0, 0, 0))
     {
         for (int i = 0; i < 32; ++i)
         {
             propData.SetValue(i, pixel, defaultValues);
         }
         propData.SetValue(pixel, 15, Color.white);
     }
 }
Ejemplo n.º 10
0
        public override void DrawPerTextureGUI(int index, Material mat, MicroSplatPropData propData)
        {
            if (isTessellated)
            {
                InitPropData(6, propData, new Color(1.0f, 0.0f, 0.0f, 0.5f)); // displace, up, offset

                perTexDisplace = DrawPerTexFloatSlider(index, 6, GetFeatureName(DefineFeature._PERTEXTESSDISPLACE),
                                                       mat, propData, Channel.R, CPerTexDisplace, 0, 2);

                perTexUpBias = DrawPerTexFloatSlider(index, 6, GetFeatureName(DefineFeature._PERTEXTESSUPBIAS),
                                                     mat, propData, Channel.G, CPerTexUpBias, 0, 1);

                perTexOffset = DrawPerTexFloatSlider(index, 6, GetFeatureName(DefineFeature._PERTEXTESSOFFSET),
                                                     mat, propData, Channel.B, CPerTexOffset, -1, 1);

                if (perTexOffset)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button(CComputeIdeal))
                    {
                        float h = IdealOffset(mat.GetTexture("_Diffuse") as Texture2DArray, index);
                        propData.SetValue(index, 6, (int)Channel.B, h);
                        AssetDatabase.Refresh();
                    }
                    if (GUILayout.Button(CComputeIdealAll))
                    {
                        var ta = mat.GetTexture("_Diffuse") as Texture2DArray;
                        for (int i = 0; i < 16; ++i)
                        {
                            float h = IdealOffset(ta, i);
                            propData.SetValue(i, 6, (int)Channel.B, h);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }

            if (parallax)
            {
                perTexParallax = DrawPerTexFloatSlider(index, 6, GetFeatureName(DefineFeature._PERTEXPARALLAX),
                                                       mat, propData, Channel.A, CPerTexParallax, 0, 1);
            }
        }
    // get, load, or create the property texture for this material..
    public static MicroSplatPropData FindOrCreatePropTex(Material targetMat)
    {
        MicroSplatPropData propData = null;
        // look for it next to the material?
        var path = AssetDatabase.GetAssetPath(targetMat);

        path = path.Replace("\\", "/");
        if (!string.IsNullOrEmpty(path))
        {
            path     = path.Substring(0, path.IndexOf("."));
            path    += "_propdata.asset";
            propData = AssetDatabase.LoadAssetAtPath <MicroSplatPropData>(path);
            if (propData == null)
            {
                propData = MicroSplatPropData.CreateInstance <MicroSplatPropData>();
                AssetDatabase.CreateAsset(propData, path);
                AssetDatabase.SaveAssets();
            }
        }

        return(propData);
    }
Ejemplo n.º 12
0
        static protected void DrawPerTexColorNoToggle(int curIdx, int pixel, MicroSplatPropData propData, GUIContent label)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.Width(20));
            Color c  = propData.GetValue(curIdx, pixel);
            Color nv = EditorGUILayout.ColorField(label, c);

            if (nv != c)
            {
                propData.SetValue(curIdx, pixel, nv);
            }

            if (GUILayout.Button("All", GUILayout.Width(40)))
            {
                for (int i = 0; i < 32; ++i)
                {
                    propData.SetValue(i, pixel, nv);
                }
            }

            EditorGUILayout.EndHorizontal();
            drawPertexToggle = true;
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Got per texture properties? Draw the GUI for them here..
 /// </summary>
 /// <param name="index">Index.</param>
 /// <param name="shaderGUI">Shader GU.</param>
 /// <param name="mat">Mat.</param>
 /// <param name="materialEditor">Material editor.</param>
 /// <param name="props">Properties.</param>
 public virtual void DrawPerTextureGUI(int index, MicroSplatKeywords keywords, Material mat, MicroSplatPropData propData)
 {
 }
Ejemplo n.º 14
0
 static protected void DrawPerTexPopUpNoToggle(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel,
                                               GUIContent label, GUIContent[] options, float[] values)
 {
     drawPertexToggle = false;
     DrawPerTexPopUp(curIdx, pixel, keyword, keywords, propData, channel, label, options, values);
 }
Ejemplo n.º 15
0
 static protected void DrawPerTexFloatSliderNoToggle(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel,
                                                     GUIContent label, float min = 0, float max = 0)
 {
     drawPertexToggle = false;
     DrawPerTexFloatSlider(curIdx, pixel, keyword, keywords, propData, channel, label, min, max);
 }
Ejemplo n.º 16
0
 static protected void DrawPerTexVector2Vector2NoToggle(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData,
                                                        GUIContent label, GUIContent label2)
 {
     drawPertexToggle = false;
     DrawPerTexVector2Vector2(curIdx, pixel, keyword, keywords, propData, label, label2);
 }
Ejemplo n.º 17
0
        static protected bool DrawPerTexPopUp(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel,
                                              GUIContent label, GUIContent[] options, float[] values)
        {
            EditorGUILayout.BeginHorizontal();
            bool enabled = PerTexToggle(keywords, keyword);

            GUI.enabled = enabled;
            Color c = propData.GetValue(curIdx, pixel);
            float v = c[(int)channel];

            int selected = -1;

            if (values.Length == 0 || options.Length == 0)
            {
                selected = -1;
            }
            else if (options.Length == 1 || values.Length == 1 || values[0] >= v)
            {
                selected = 0;
            }
            else if (values[values.Length - 1] < v)
            {
                selected = values.Length - 1;
            }
            else
            {
                int   length = options.Length < values.Length ? options.Length : values.Length;
                float dist   = -1f;

                for (int i = 0; i < length; i++)
                {
                    if (values[i] == v)
                    {
                        selected = i;
                        break;
                    }
                    else
                    {
                        float diff = Mathf.Abs(values[i] - v);
                        if (dist < 0)
                        {
                            dist     = diff;
                            selected = i;
                        }
                        else if (diff < dist)
                        {
                            dist     = diff;
                            selected = i;
                        }
                    }
                }
            }

            selected        = EditorGUILayout.Popup(label, selected, options);
            v               = selected >= 0 ? values[selected] : 0;
            c[(int)channel] = v;
            propData.SetValue(curIdx, pixel, c);

            if (GUILayout.Button("All", GUILayout.Width(40)))
            {
                for (int i = 0; i < 32; ++i)
                {
                    Color nv = propData.GetValue(i, pixel);
                    nv[(int)channel] = v;
                    propData.SetValue(i, pixel, nv);
                }
            }

            GUI.enabled      = true;
            drawPertexToggle = true;
            EditorGUILayout.EndHorizontal();

            return(enabled);
        }
Ejemplo n.º 18
0
        protected bool DrawPerTexColor(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData,
                                       GUIContent label, bool hasAlpha)
        {
            EditorGUILayout.BeginHorizontal();
            bool enabled = PerTexToggle(keywords, keyword);

            GUI.enabled = enabled;
            Color c  = propData.GetValue(curIdx, pixel);
            Color nv = EditorGUILayout.ColorField(label, c);

            if (nv != c)
            {
                if (!hasAlpha)
                {
                    nv.a = c.a;
                }
                propData.SetValue(curIdx, pixel, nv);
            }

            if (GUILayout.Button("All", GUILayout.Width(40)))
            {
                for (int i = 0; i < 32; ++i)
                {
                    if (!hasAlpha)
                    {
                        nv.a = propData.GetValue(i, pixel).a;
                    }
                    propData.SetValue(i, pixel, nv);
                }
            }

            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();

            return(enabled);
        }
Ejemplo n.º 19
0
        static protected bool DrawPerTexVector2Vector2(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData,
                                                       GUIContent label, GUIContent label2)
        {
            EditorGUILayout.BeginHorizontal();
            bool enabled = PerTexToggle(keywords, keyword);

            GUI.enabled = enabled;

            Color   c   = propData.GetValue(curIdx, pixel);
            Vector2 v1  = new Vector2(c.r, c.g);
            Vector2 v2  = new Vector2(c.b, c.a);
            Vector2 nv1 = v1;
            Vector2 nv2 = v2;

            EditorGUILayout.BeginVertical();
            nv1 = EditorGUILayout.Vector2Field(label, v1);
            nv2 = EditorGUILayout.Vector2Field(label2, v2);
            EditorGUILayout.EndVertical();

            if (nv1 != v1 || nv2 != v2)
            {
                c.r = nv1.x;
                c.g = nv1.y;
                c.b = nv2.x;
                c.a = nv2.y;
                propData.SetValue(curIdx, pixel, c);
            }

            if (GUILayout.Button("All", GUILayout.Width(40)))
            {
                c.r = nv1.x;
                c.g = nv1.y;
                c.b = nv2.x;
                c.a = nv2.y;
                for (int i = 0; i < 32; ++i)
                {
                    propData.SetValue(i, pixel, c);
                }
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();

            return(enabled);
        }
Ejemplo n.º 20
0
        static protected bool DrawPerTexVector3(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData,
                                                GUIContent label)
        {
            EditorGUILayout.BeginHorizontal();
            bool enabled = PerTexToggle(keywords, keyword);

            GUI.enabled = enabled;

            Color   c = propData.GetValue(curIdx, pixel);
            Vector3 v = new Vector3(c.r, c.g, c.b);

            Vector3 nv = EditorGUILayout.Vector2Field(label, v);

            if (nv != v)
            {
                c.r = nv.x;
                c.g = nv.y;
                c.b = nv.z;
                propData.SetValue(curIdx, pixel, c);
            }

            if (GUILayout.Button("All", GUILayout.Width(40)))
            {
                for (int i = 0; i < 32; ++i)
                {
                    // don't erase other pixels..
                    var fv = propData.GetValue(i, pixel);
                    c.r = nv.x;
                    c.g = nv.y;
                    c.b = nv.z;
                    propData.SetValue(i, pixel, fv);
                }
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();

            return(enabled);
        }
Ejemplo n.º 21
0
        static protected bool DrawPerTexPopUp(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel,
                                              GUIContent label, GUIContent[] options)
        {
            EditorGUILayout.BeginHorizontal();
            bool enabled = PerTexToggle(keywords, keyword);

            GUI.enabled = enabled;
            Color c = propData.GetValue(curIdx, pixel);
            float v = c[(int)channel];

            EditorGUI.BeginChangeCheck();
            int selected = EditorGUILayout.Popup(label, (int)v, options);

            if (EditorGUI.EndChangeCheck())
            {
                c [(int)channel] = selected;
                propData.SetValue(curIdx, pixel, c);
            }

            if (GUILayout.Button("All", GUILayout.Width(40)))
            {
                for (int i = 0; i < 32; ++i)
                {
                    Color nv = propData.GetValue(i, pixel);
                    nv[(int)channel] = selected;
                    propData.SetValue(i, pixel, nv);
                }
            }

            GUI.enabled      = true;
            drawPertexToggle = true;
            EditorGUILayout.EndHorizontal();

            return(enabled);
        }
 static protected void DrawPerTexVector2NoToggle(int curIdx, int pixel, string keyword, Material mat, MicroSplatPropData propData, V2Cannel channel,
                                                 GUIContent label)
 {
     drawPertexToggle = false;
     DrawPerTexVector2(curIdx, pixel, keyword, mat, propData, channel, label);
 }
Ejemplo n.º 23
0
 public override void DrawPerTextureGUI(int index, Material mat, MicroSplatPropData propData)
 {
 }
Ejemplo n.º 24
0
        static protected bool DrawPerTexFloatSlider(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel,
                                                    GUIContent label, float min = 0, float max = 0)
        {
            EditorGUILayout.BeginHorizontal();
            bool enabled = PerTexToggle(keywords, keyword);

            GUI.enabled = enabled;

            Color c  = propData.GetValue(curIdx, pixel);
            float v  = c[(int)channel];
            float nv = v;

            if (min != max)
            {
                nv = EditorGUILayout.Slider(label, v, min, max);
            }
            else
            {
                nv = EditorGUILayout.FloatField(label, v);
            }
            if (nv != v)
            {
                c[(int)channel] = nv;
                propData.SetValue(curIdx, pixel, c);
            }

            if (GUILayout.Button("All", GUILayout.Width(40)))
            {
                for (int i = 0; i < 32; ++i)
                {
                    propData.SetValue(i, pixel, (int)channel, nv);
                }
            }

            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();

            return(enabled);
        }
Ejemplo n.º 25
0
        static protected bool DrawPerTexVector2(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, V2Cannel channel,
                                                GUIContent label)
        {
            EditorGUILayout.BeginHorizontal();
            bool enabled = PerTexToggle(keywords, keyword);

            GUI.enabled = enabled;

            Color   c  = propData.GetValue(curIdx, pixel);
            Vector2 v2 = new Vector2(c.r, c.g);

            if (channel == V2Cannel.BA)
            {
                v2.x = c.b;
                v2.y = c.a;
            }
            Vector2 nv = v2;

            nv = EditorGUILayout.Vector2Field(label, v2);

            if (nv != v2)
            {
                if (channel == V2Cannel.RG)
                {
                    c.r = nv.x;
                    c.g = nv.y;
                }
                else
                {
                    c.b = nv.x;
                    c.a = nv.y;
                }
                propData.SetValue(curIdx, pixel, c);
            }

            if (GUILayout.Button("All", GUILayout.Width(40)))
            {
                for (int i = 0; i < 32; ++i)
                {
                    // don't erase other pixels..
                    var fv = propData.GetValue(i, pixel);
                    if (channel == V2Cannel.RG)
                    {
                        c.r = nv.x;
                        c.g = nv.y;
                    }
                    else
                    {
                        c.b = nv.x;
                        c.a = nv.y;
                    }
                    propData.SetValue(i, pixel, fv);
                }
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();

            return(enabled);
        }
Ejemplo n.º 26
0
        public override void DrawPerTextureGUI(int index, Material mat, MicroSplatPropData propData)
        {
            InitPropData(4, propData, new Color(1.0f, 1, 1, 1));
            InitPropData(14, propData, new Color(1, 1, 1, 1));

            if (detailNoise)
            {
                perTexDetailNoiseStrength = DrawPerTexFloatSlider(index, 4, GetFeatureName(DefineFeature._PERTEXDETAILNOISESTRENGTH),
                                                                  mat, propData, Channel.R, CPerTexDetailNoiseStr, 0, 3);
            }
            if (distanceNoise)
            {
                perTexDistanceNoiseStrength = DrawPerTexFloatSlider(index, 4, GetFeatureName(DefineFeature._PERTEXDISTANCENOISESTRENGTH),
                                                                    mat, propData, Channel.G, CPerTexDistanceNoiseStr, 0, 3);
            }
            if (distanceResample != DistanceResampleMode.None)
            {
                perTexDistanceResampleStrength = DrawPerTexFloatSlider(index, 4, GetFeatureName(DefineFeature._PERTEXDISTANCERESAMPLESTRENGTH),
                                                                       mat, propData, Channel.B, CPerTexDistanceResample, 0, 3);
            }
            if (noiseChannelCount != NormalNoiseChannels.Off)
            {
                perTexNormalNoiseStrength = DrawPerTexFloatSlider(index, 7, GetFeatureName(DefineFeature._PERTEXNORMALNOISESTRENGTH), mat, propData, Channel.R, CPerTexNormalNoise, 0, 2);
            }
            if (noiseChannelCount == NormalNoiseChannels.Two || noiseChannelCount == NormalNoiseChannels.Three)
            {
                DrawPerTexFloatSliderNoToggle(index, 7, GetFeatureName(DefineFeature._PERTEXNORMALNOISESTRENGTH), mat, propData, Channel.G, CPerTexNormalNoise2, 0, 2);
            }
            if (noiseChannelCount == NormalNoiseChannels.Three)
            {
                DrawPerTexFloatSliderNoToggle(index, 7, GetFeatureName(DefineFeature._PERTEXNORMALNOISESTRENGTH), mat, propData, Channel.B, CPerTexNormalNoise3, 0, 2);
            }

            if (antiTileOptions != 0)
            {
                bool controlDrawn = false;
                if (((int)antiTileOptions & (int)AntiTileOptions.NoiseNormal) != 0)
                {
                    perTexAntiTile = DrawPerTexFloatSlider(index, 14, GetFeatureName(DefineFeature._ANTITILEPERTEX), mat, propData, Channel.R, CPerTexAntiTileNormal, 0, 2);
                    controlDrawn   = true;
                }
                if (((int)antiTileOptions & (int)AntiTileOptions.DetailNoise) != 0)
                {
                    if (controlDrawn)
                    {
                        DrawPerTexFloatSliderNoToggle(index, 14, GetFeatureName(DefineFeature._ANTITILEPERTEX), mat, propData, Channel.G, CPerTexAntiTileDetail, 0, 2);
                    }
                    else
                    {
                        perTexAntiTile = DrawPerTexFloatSlider(index, 14, GetFeatureName(DefineFeature._ANTITILEPERTEX), mat, propData, Channel.G, CPerTexAntiTileDetail, 0, 2);
                        controlDrawn   = true;
                    }
                }
                if (((int)antiTileOptions & (int)AntiTileOptions.DistanceNoise) != 0)
                {
                    if (controlDrawn)
                    {
                        DrawPerTexFloatSliderNoToggle(index, 14, GetFeatureName(DefineFeature._ANTITILEPERTEX), mat, propData, Channel.B, CPerTexAntiTileDistance, 0, 2);
                    }
                    else
                    {
                        perTexAntiTile = DrawPerTexFloatSlider(index, 14, GetFeatureName(DefineFeature._ANTITILEPERTEX), mat, propData, Channel.B, CPerTexAntiTileDistance, 0, 2);
                    }
                }
            }
        }