void DoDetailArea()
 {
     MGUI.BoldLabel("Detail Textures");
     MGUI.PropertyGroup(() => {
         me.TexturePropertySingleLine(Tips.detailAlbedoText, detailAlbedoMap, detailAlbedoMap.textureValue ? detailAlbedoBlend : null);
         me.TexturePropertySingleLine(Tips.detailNormalMapText, detailNormalMap, detailNormalMap.textureValue ? detailNormalMapScale : null);
         me.TexturePropertySingleLine(Tips.detailRoughnessMapText, detailRoughnessMap, detailRoughnessMap.textureValue ? detailRoughBlend : null);
         MGUI.sRGBWarning(detailRoughnessMap);
         me.TexturePropertySingleLine(Tips.detailAOMapText, detailAOMap, detailAOMap.textureValue ? detailAOBlend : null);
         MGUI.sRGBWarning(detailAOMap);
         MGUI.SpaceN2();
     });
 }
 void DoFilteringArea()
 {
     MGUI.PropertyGroup(() => {
         me.ShaderProperty(filtering, "Enable");
         MGUI.ToggleGroup(filtering.floatValue == 0);
         MGUI.BoldLabel("Base Color");
         MGUI.PropertyGroupLayer(() => {
             MGUI.SpaceN1();
             me.ShaderProperty(hue, "Hue");
             me.ShaderProperty(saturation, "Saturation");
             me.ShaderProperty(brightness, "Brightness");
             me.ShaderProperty(contrast, "Contrast");
             MGUI.SpaceN2();
         });
         MGUI.Space4();
         MGUI.BoldLabel("Detail Color");
         MGUI.PropertyGroupLayer(() => {
             MGUI.SpaceN1();
             me.ShaderProperty(hueDet, "Hue");
             me.ShaderProperty(saturationDet, "Saturation");
             me.ShaderProperty(brightnessDet, "Brightness");
             me.ShaderProperty(contrastDet, "Contrast");
             MGUI.SpaceN2();
         });
         if (emissionEnabled)
         {
             MGUI.Space4();
             MGUI.BoldLabel("Emission Color");
             MGUI.PropertyGroupLayer(() => {
                 MGUI.SpaceN1();
                 me.ShaderProperty(hueEmiss, "Hue");
                 me.ShaderProperty(saturationEmiss, "Saturation");
                 me.ShaderProperty(brightnessEmiss, "Brightness");
                 me.ShaderProperty(contrastEmiss, "Contrast");
                 MGUI.SpaceN2();
             });
         }
         MGUI.Space4();
         MGUI.BoldLabel("Global Color");
         MGUI.PropertyGroupLayer(() => {
             MGUI.SpaceN1();
             me.ShaderProperty(huePost, "Hue");
             me.ShaderProperty(saturationPost, "Saturation");
             me.ShaderProperty(brightnessPost, "Brightness");
             me.ShaderProperty(contrastPost, "Contrast");
             MGUI.SpaceN2();
         });
         MGUI.ToggleGroupEnd();
     });
 }
示例#3
0
    public override void OnGUI(MaterialEditor me, MaterialProperty[] props)
    {
        Material material = (Material)me.target;

        isTransparent = material.shader.name.Contains("(Transparent)");
        foreach (var property in GetType().GetFields(bindingFlags))
        {
            if (property.FieldType == typeof(MaterialProperty))
            {
                property.SetValue(this, FindProperty(property.Name, props));
            }
        }

        EditorGUI.BeginChangeCheck(); {
            MGUI.BoldLabel("Image");
            MGUI.Space2();
            if (_FlipbookMode.floatValue == 0)
            {
                me.TexturePropertySingleLine(mainTex, _MainTex, _FlipbookMode);
                MGUI.TexPropLabel("Flipbook", 105);
                me.ShaderProperty(_Color, "Color");
                if (_MainTex.textureValue)
                {
                    MGUI.TextureSOScroll(me, _MainTex, _UVScroll);
                    MGUI.Space6();
                }
            }
            else
            {
                me.TexturePropertySingleLine(flipbookTex, _Flipbook, _FlipbookMode);
                MGUI.TexPropLabel("Flipbook", 105);
                if (_Flipbook.textureValue)
                {
                    MGUI.TextureSO(me, _MainTex);
                    MGUI.SpaceN2();
                    me.ShaderProperty(_FPS, "FPS");
                    MGUI.Space6();
                }
            }
            MGUI.SetKeyword(material, "_FLIPBOOK_MODE", material.GetInt("_FlipbookMode") == 1);
            me.TexturePropertySingleLine(smoothTex, _SpecGlossMap, _Glossiness);
            MGUI.TextureSO(me, _SpecGlossMap, _SpecGlossMap.textureValue);
            MGUI.SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
            MGUI.Space4();

            MGUI.SetKeyword(material, "_EMISSION", true);
            me.ShaderProperty(_EmissionIntensity, "Emission Strength");
            me.ShaderProperty(_LightmapEmissionScale, "Lightmap Emission Strength");
            me.ShaderProperty(_BoostAmount, "Boost Multiplier");
            me.ShaderProperty(_BoostThreshold, "Boost Threshold");
            material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;
            MGUI.Space4();

            MGUI.BoldLabel("Panel");
            MGUI.Space2();
            me.TexturePropertySingleLine(RGBMatrixTex, _RGBSubPixelTex);
            MGUI.TextureSO(me, _RGBSubPixelTex, _RGBSubPixelTex.textureValue);
            me.ShaderProperty(_Backlight, "Backlit");
            MGUI.Space4();
            MGUI.BoldLabel("Render Settings");
            if (isTransparent)
            {
                me.ShaderProperty(_ZWrite, "ZWrite");
            }
            me.RenderQueueField();
            MGUI.Space8();
        }

        MGUI.Space20();
        float buttonSize = 35f;
        Rect  footerRect = EditorGUILayout.GetControlRect();

        footerRect.x     += (MGUI.GetInspectorWidth() / 2f) - buttonSize - 5f;
        footerRect.width  = buttonSize;
        footerRect.height = buttonSize;
        if (GUI.Button(footerRect, MGUI.patIconTex))
        {
            Application.OpenURL("https://www.patreon.com/mochieshaders");
        }
        footerRect.x += buttonSize + 5f;
        footerRect.y += 17f;
        GUIStyle formatting = new GUIStyle();

        formatting.fontSize  = 15;
        formatting.fontStyle = FontStyle.Bold;
        if (EditorGUIUtility.isProSkin)
        {
            formatting.normal.textColor = new Color(0.8f, 0.8f, 0.8f, 1);
            formatting.hover.textColor  = new Color(0.8f, 0.8f, 0.8f, 1);
            GUI.Label(footerRect, versionLabel, formatting);
            footerRect.y     += 20f;
            footerRect.x     -= 35f;
            footerRect.width  = 70f;
            footerRect.height = 70f;
            GUI.Label(footerRect, MGUI.mochieLogoPro);
            GUILayout.Space(90);
        }
        else
        {
            GUI.Label(footerRect, versionLabel, formatting);
            footerRect.y     += 20f;
            footerRect.x     -= 35f;
            footerRect.width  = 70f;
            footerRect.height = 70f;
            GUI.Label(footerRect, MGUI.mochieLogo);
            GUILayout.Space(90);
        }
    }
    public override void OnGUI(MaterialEditor me, MaterialProperty[] props)
    {
        if (!me.isVisible)
        {
            return;
        }

        ClearDictionaries();

        foreach (var property in GetType().GetFields(bindingFlags))
        {
            if (property.FieldType == typeof(MaterialProperty))
            {
                property.SetValue(this, FindProperty(property.Name, props));
            }
        }
        Material mat = (Material)me.target;

        if (m_FirstTimeApply)
        {
            m_FirstTimeApply = false;
        }

        header = "WaterHeader_Pro";
        if (!EditorGUIUtility.isProSkin)
        {
            header = "WaterHeader";
        }

        Texture2D headerTex    = (Texture2D)Resources.Load(header, typeof(Texture2D));
        Texture2D collapseIcon = (Texture2D)Resources.Load("CollapseIcon", typeof(Texture2D));

        GUILayout.Label(headerTex);
        MGUI.Space4();

        if (!foldouts.ContainsKey(mat))
        {
            foldouts.Add(mat, toggles);
        }

        EditorGUI.BeginChangeCheck(); {
            // Surface
            baseTabButtons.Add(() => { Toggles.CollapseFoldouts(mat, foldouts, 1); }, MGUI.collapseLabel);
            baseTabButtons.Add(() => { ResetSurface(); }, MGUI.resetLabel);
            Action surfaceTabAction = () => {
                MGUI.PropertyGroup(() => {
                    me.RenderQueueField();
                    me.ShaderProperty(_CullMode, "Culling Mode");
                    me.ShaderProperty(_ZWrite, "ZWrite");
                    me.ShaderProperty(_Opacity, "Opacity");
                    me.ShaderProperty(_DistortionStrength, "Distortion Strength");
                    MGUI.Space2();
                });
                MGUI.PropertyGroup(() => {
                    me.TexturePropertySingleLine(texLabel, _MainTex, _Color, _BaseColorStochasticToggle);
                    MGUI.TexPropLabel(Tips.stochasticLabel, 172);
                    MGUI.TextureSOScroll(me, _MainTex, _MainTexScroll);
                    me.ShaderProperty(_BaseColorOffset, Tips.parallaxOffsetLabel);
                    me.ShaderProperty(_BaseColorDistortionStrength, "Distortion Strength");
                });
                MGUI.DisplayInfo("   This shader requires a \"Depth Light\" prefab be present in the scene.\n   (Found in: Assets/Mochie/Unity/Prefabs)");
            };
            Foldouts.Foldout("BASE", foldouts, baseTabButtons, mat, me, surfaceTabAction);

            // Primary Normal
            norm0TabButtons.Add(() => { ResetPrimaryNormal(); }, MGUI.resetLabel);
            Action norm0TabAction = () => {
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    me.TexturePropertySingleLine(Tips.waterNormalMap, _NormalMap0, _Normal0StochasticToggle);
                    MGUI.TexPropLabel(Tips.stochasticLabel, 172);
                    me.ShaderProperty(_NormalStr0, "Strength");
                    MGUI.Vector2Field(_NormalMapScale0, "Scale");
                    MGUI.Vector2Field(_NormalMapScroll0, "Scrolling");
                    me.ShaderProperty(_Rotation0, "Rotation");
                    me.ShaderProperty(_NormalMapOffset0, Tips.parallaxOffsetLabel);
                });
            };
            Foldouts.Foldout("PRIMARY NORMAL", foldouts, norm0TabButtons, mat, me, norm0TabAction);

            // Secondary Normal
            norm1TabButtons.Add(() => { ResetSecondaryNormal(); }, MGUI.resetLabel);
            Action norm1TabAction = () => {
                me.ShaderProperty(_Normal1Toggle, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_Normal1Toggle.floatValue == 0);
                    me.TexturePropertySingleLine(Tips.waterNormalMap, _NormalMap1, _Normal1StochasticToggle);
                    MGUI.TexPropLabel(Tips.stochasticLabel, 172);
                    me.ShaderProperty(_NormalStr1, "Strength");
                    MGUI.Vector2Field(_NormalMapScale1, "Scale");
                    MGUI.Vector2Field(_NormalMapScroll1, "Scrolling");
                    me.ShaderProperty(_Rotation1, "Rotation");
                    me.ShaderProperty(_NormalMapOffset1, Tips.parallaxOffsetLabel);
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("SECONDARY NORMAL", foldouts, norm1TabButtons, mat, me, norm1TabAction);

            // Reflections & Specular
            reflSpecTabButtons.Add(() => { ResetReflSpec(); }, MGUI.resetLabel);
            Action reflSpecTabAction = () => {
                MGUI.Space4();
                me.ShaderProperty(_Roughness, Tips.waterRoughness);
                me.ShaderProperty(_Metallic, Tips.waterMetallic);
                MGUI.Space8();
                me.ShaderProperty(_Reflections, "Reflections");
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_Reflections.floatValue == 0);
                    if (_Reflections.floatValue == 2)
                    {
                        me.TexturePropertySingleLine(cubeLabel, _ReflCube);
                        MGUI.Vector3Field(_ReflCubeRotation, "Rotation", false);
                    }
                    me.ShaderProperty(_ReflStrength, "Strength");

                    MGUI.ToggleFloat(me, "Screenspace Reflections", _SSR, _SSRStrength);
                    if (_SSR.floatValue > 0)
                    {
                        me.ShaderProperty(_EdgeFadeSSR, "Edge Fade");
                    }
                    me.ShaderProperty(_ReflTint, "Tint");
                    MGUI.ToggleGroupEnd();
                });
                MGUI.Space8();
                me.ShaderProperty(_Specular, "Specular");
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_Specular.floatValue == 0);
                    if (_Specular.floatValue == 2)
                    {
                        MGUI.Vector3Field(_LightDir, "Light Direction", false);
                    }
                    me.ShaderProperty(_SpecStrength, "Strength");
                    me.ShaderProperty(_SpecTint, "Tint");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("REFLECTIONS & SPECULAR", foldouts, reflSpecTabButtons, mat, me, reflSpecTabAction);

            // Flow Mapping
            flowTabButtons.Add(() => { ResetFlowMapping(); }, MGUI.resetLabel);
            Action flowTabAction = () => {
                me.ShaderProperty(_FlowToggle, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_FlowToggle.floatValue == 0);
                    me.TexturePropertySingleLine(flowLabel, _FlowMap);
                    MGUI.Vector2Field(_FlowMapScale, "Scale");
                    me.ShaderProperty(_FlowSpeed, "Speed");
                    me.ShaderProperty(_FlowStrength, "Strength");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("FLOW MAPPING", foldouts, flowTabButtons, mat, me, flowTabAction);

            // Vertex Offset
            vertTabButtons.Add(() => { ResetVertOffset(); }, MGUI.resetLabel);
            Action vertTabAction = () => {
                me.ShaderProperty(_VertOffsetMode, "Mode");
                MGUI.Space4();
                MGUI.ToggleGroup(_VertOffsetMode.floatValue == 0);
                if (_VertOffsetMode.floatValue == 1)
                {
                    MGUI.PropertyGroup(() => {
                        me.TexturePropertySingleLine(noiseLabel, _NoiseTex);
                        me.ShaderProperty(_NoiseTexBlur, "Blur");
                        MGUI.Vector2Field(_NoiseTexScale, "Scale");
                        MGUI.Vector2Field(_NoiseTexScroll, "Scrolling");
                    });
                    MGUI.PropertyGroup(() => {
                        MGUI.Vector3Field(_Offset, "Strength", false);
                        me.ShaderProperty(_WaveHeight, "Strength Multiplier");
                        MGUI.SliderMinMax(_VertRemapMin, _VertRemapMax, -1f, 1f, "Remap", 1);
                    });
                }
                else if (_VertOffsetMode.floatValue == 2)
                {
                    MGUI.BoldLabel("Global");
                    MGUI.PropertyGroup(() => {
                        me.ShaderProperty(_WaveStrengthGlobal, "Strength");
                        me.ShaderProperty(_WaveScaleGlobal, "Scale");
                        me.ShaderProperty(_WaveSpeedGlobal, "Speed");
                    });
                    MGUI.BoldLabel("Wave 1");
                    MGUI.PropertyGroup(() => {
                        me.ShaderProperty(_WaveStrength0, "Strength");
                        me.ShaderProperty(_WaveScale0, "Scale");
                        me.ShaderProperty(_WaveSpeed0, "Speed");
                        me.ShaderProperty(_WaveDirection0, "Direction");
                    });
                    MGUI.BoldLabel("Wave 2");
                    MGUI.PropertyGroup(() => {
                        me.ShaderProperty(_WaveStrength1, "Strength");
                        me.ShaderProperty(_WaveScale1, "Scale");
                        me.ShaderProperty(_WaveSpeed1, "Speed");
                        me.ShaderProperty(_WaveDirection1, "Direction");
                    });
                    MGUI.BoldLabel("Wave 3");
                    MGUI.PropertyGroup(() => {
                        me.ShaderProperty(_WaveStrength2, "Strength");
                        me.ShaderProperty(_WaveScale2, "Scale");
                        me.ShaderProperty(_WaveSpeed2, "Speed");
                        me.ShaderProperty(_WaveDirection2, "Direction");
                    });
                    MGUI.BoldLabel("Turbulence");
                    MGUI.PropertyGroup(() => {
                        me.ShaderProperty(_Turbulence, Tips.turbulence);
                        me.ShaderProperty(_TurbulenceSpeed, "Speed");
                        me.ShaderProperty(_TurbulenceScale, "Scale");
                    });
                }
                MGUI.ToggleGroupEnd();
            };
            Foldouts.Foldout("VERTEX OFFSET", foldouts, vertTabButtons, mat, me, vertTabAction);

            // Caustics
            causticsTabButtons.Add(() => { ResetCaustics(); }, MGUI.resetLabel);
            Action causticsTabAction = () => {
                me.ShaderProperty(_CausticsToggle, "Enable");
                MGUI.ToggleGroup(_CausticsToggle.floatValue == 0);
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    me.ShaderProperty(_CausticsOpacity, "Strength");
                    me.ShaderProperty(_CausticsDisp, "Phase");
                    me.ShaderProperty(_CausticsSpeed, "Speed");
                    me.ShaderProperty(_CausticsScale, "Scale");
                    me.ShaderProperty(_CausticsFade, Tips.causticsFade);
                    MGUI.Vector3Field(_CausticsRotation, "Rotation", false);
                });
                MGUI.PropertyGroup(() => {
                    me.ShaderProperty(_CausticsDistortion, "Distortion Strength");
                    me.ShaderProperty(_CausticsDistortionScale, "Distortion Scale");
                    MGUI.Vector2Field(_CausticsDistortionSpeed, "Distortion Speed");
                });
                MGUI.ToggleGroupEnd();
            };
            Foldouts.Foldout("CAUSTICS", foldouts, causticsTabButtons, mat, me, causticsTabAction);

            // Foam
            foamTabButtons.Add(() => { ResetFoam(); }, MGUI.resetLabel);
            Action foamTabAction = () => {
                me.ShaderProperty(_FoamToggle, "Enable");
                MGUI.Space4();
                MGUI.ToggleGroup(_FoamToggle.floatValue == 0);
                MGUI.PropertyGroup(() => {
                    me.TexturePropertySingleLine(foamLabel, _FoamTex, _FoamColor, _FoamStochasticToggle);
                    MGUI.TexPropLabel(Tips.stochasticLabel, 172);
                    MGUI.Space2();
                    MGUI.Vector2Field(_FoamTexScale, "Scale");
                    MGUI.Vector2Field(_FoamTexScroll, "Scrolling");
                    me.ShaderProperty(_FoamOffset, Tips.parallaxOffsetLabel);
                    me.ShaderProperty(_FoamDistortionStrength, "Distortion Strength");
                    MGUI.ToggleFloat(me, Tips.foamNormal, _FoamNormalToggle, _FoamNormalStrength);
                });
                MGUI.PropertyGroup(() => {
                    me.TexturePropertySingleLine(noiseLabel, _FoamNoiseTex);
                    MGUI.Vector2Field(_FoamNoiseTexScale, "Scale");
                    MGUI.Vector2Field(_FoamNoiseTexScroll, "Scrolling");
                    me.ShaderProperty(_FoamNoiseTexStrength, Tips.foamNoiseTexStrength);
                    me.ShaderProperty(_FoamNoiseTexCrestStrength, Tips.foamNoiseTexCrestStrength);
                });
                MGUI.PropertyGroup(() => {
                    me.ShaderProperty(_FoamRoughness, Tips.foamRoughness);
                    me.ShaderProperty(_FoamPower, Tips.foamPower);
                    me.ShaderProperty(_FoamOpacity, Tips.foamOpacity);
                    me.ShaderProperty(_FoamCrestStrength, Tips.foamCrestStrength);
                    me.ShaderProperty(_FoamCrestThreshold, Tips.foamCrestThreshold);
                });
                MGUI.ToggleGroupEnd();
            };
            Foldouts.Foldout("FOAM", foldouts, foamTabButtons, mat, me, foamTabAction);

            // Depth Fog
            fogTabButtons.Add(() => { ResetFog(); }, MGUI.resetLabel);
            Action fogTabAction = () => {
                me.ShaderProperty(_FogToggle, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_FogToggle.floatValue == 0);
                    me.ShaderProperty(_FogTint, "Color");
                    me.ShaderProperty(_FogPower, "Power");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("DEPTH FOG", foldouts, fogTabButtons, mat, me, fogTabAction);

            // Edge Fade
            edgeFadeTabButtons.Add(() => { ResetEdgeFade(); }, MGUI.resetLabel);
            Action edgeFadeTabAction = () => {
                me.ShaderProperty(_EdgeFadeToggle, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_EdgeFadeToggle.floatValue == 0);
                    me.ShaderProperty(_EdgeFadePower, "Power");
                    me.ShaderProperty(_EdgeFadeOffset, "Offset");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("EDGE FADE", foldouts, edgeFadeTabButtons, mat, me, edgeFadeTabAction);

            // Rain
            rainTabButtons.Add(() => { ResetRain(); }, MGUI.resetLabel);
            Action rainTabAction = () => {
                me.ShaderProperty(_RainToggle, "Enable");
                MGUI.Space4();
                MGUI.PropertyGroup(() => {
                    MGUI.ToggleGroup(_RainToggle.floatValue == 0);
                    me.ShaderProperty(_RippleStr, "Strength");
                    me.ShaderProperty(_RippleSpeed, "Speed");
                    me.ShaderProperty(_RippleScale, "Scale");
                    MGUI.ToggleGroupEnd();
                });
            };
            Foldouts.Foldout("RAIN", foldouts, rainTabButtons, mat, me, rainTabAction);
        }
        ApplyMaterialSettings(mat);

        GUILayout.Space(20);
        float buttonSize = 35f;
        Rect  footerRect = EditorGUILayout.GetControlRect();

        footerRect.x     += (MGUI.GetInspectorWidth() / 2f) - buttonSize - 5f;
        footerRect.width  = buttonSize;
        footerRect.height = buttonSize;
        if (GUI.Button(footerRect, MGUI.patIconTex))
        {
            Application.OpenURL("https://www.patreon.com/mochieshaders");
        }
        footerRect.x += buttonSize + 5f;
        footerRect.y += 17f;
        GUIStyle formatting = new GUIStyle();

        formatting.fontSize  = 15;
        formatting.fontStyle = FontStyle.Bold;
        if (EditorGUIUtility.isProSkin)
        {
            formatting.normal.textColor = new Color(0.8f, 0.8f, 0.8f, 1);
            formatting.hover.textColor  = new Color(0.8f, 0.8f, 0.8f, 1);
            GUI.Label(footerRect, versionLabel, formatting);
            footerRect.y     += 20f;
            footerRect.x     -= 35f;
            footerRect.width  = 70f;
            footerRect.height = 70f;
            GUI.Label(footerRect, MGUI.mochieLogoPro);
            GUILayout.Space(90);
        }
        else
        {
            GUI.Label(footerRect, versionLabel, formatting);
            footerRect.y     += 20f;
            footerRect.x     -= 35f;
            footerRect.width  = 70f;
            footerRect.height = 70f;
            GUI.Label(footerRect, MGUI.mochieLogo);
            GUILayout.Space(90);
        }
    }
    void DoUVArea()
    {
        bool needsHeightMaskUV = (((workflow.floatValue > 0 && useHeight.floatValue == 1) || (workflow.floatValue == 0 && heightMap.textureValue)) && parallaxMask.textureValue) && samplingMode.floatValue < 3;
        bool needsEmissMaskUV  = emissionEnabled && emissionMask.textureValue;
        bool needsAlphaMaskUV  = blendMode.floatValue > 0 && useAlphaMask.floatValue > 0;

        MGUI.PropertyGroup(() => {
            MGUI.BoldLabel("Primary");
            EditorGUI.BeginChangeCheck();
            MGUI.PropertyGroupLayer(() => {
                MGUI.SpaceN2();
                if (samplingMode.floatValue < 3)
                {
                    me.ShaderProperty(uvPri, Tips.uvSetLabel.text);
                    MGUI.TextureSOScroll(me, albedoMap, uv0Scroll);
                }
                else
                {
                    MGUI.TextureSO(me, albedoMap);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset;
                }
                me.ShaderProperty(uv0Rot, "Rotation");
                MGUI.SpaceN2();
            });
            MGUI.Space4();
            MGUI.BoldLabel("Detail");
            MGUI.PropertyGroupLayer(() => {
                MGUI.SpaceN2();
                if (samplingMode.floatValue < 3)
                {
                    me.ShaderProperty(uvSetSecondary, Tips.uvSetLabel.text);
                    MGUI.TextureSOScroll(me, detailAlbedoMap, uv1Scroll);
                }
                else
                {
                    MGUI.TextureSO(me, detailAlbedoMap);
                }
                me.ShaderProperty(uv1Rot, "Rotation");
                me.ShaderProperty(detailSamplingMode, Tips.detailSamplingMode);
                MGUI.SpaceN4();
            });
            if (needsHeightMaskUV)
            {
                MGUI.Space4();
                MGUI.BoldLabel("Height Mask");
                MGUI.PropertyGroupLayer(() => {
                    MGUI.SpaceN2();
                    me.ShaderProperty(uvHeightMask, Tips.uvSetLabel.text);
                    MGUI.TextureSOScroll(me, parallaxMask, uv2Scroll);
                    MGUI.SpaceN2();
                });
            }
            if (needsEmissMaskUV)
            {
                MGUI.Space4();
                MGUI.BoldLabel("Emission Mask");
                MGUI.PropertyGroupLayer(() => {
                    MGUI.SpaceN2();
                    me.ShaderProperty(uvEmissMask, Tips.uvSetLabel.text);
                    MGUI.TextureSOScroll(me, emissionMask, uv3Scroll);
                    me.ShaderProperty(uv3Rot, "Rotation");
                    MGUI.SpaceN2();
                });
            }
            if (needsAlphaMaskUV)
            {
                MGUI.Space4();
                MGUI.BoldLabel("Alpha Mask");
                MGUI.PropertyGroupLayer(() => {
                    MGUI.SpaceN2();
                    me.ShaderProperty(uvAlphaMask, Tips.uvSetLabel.text);
                    MGUI.TextureSOScroll(me, alphaMask, uv4Scroll);
                    me.ShaderProperty(uv4Rot, "Rotation");
                    MGUI.SpaceN2();
                });
            }
        });
    }
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
    {
        me = materialEditor;
        Material material = materialEditor.target as Material;

        FindProperties(props, material);

        // Make sure that needed setup (ie keywords/renderqueue) are set up if we're switching some existing
        // material to a standard shader.
        // Do this before any GUI code has been issued to prevent layout issues in subsequent GUILayout statements (case 780071)
        if (m_FirstTimeApply)
        {
            MaterialChanged(material);
            m_FirstTimeApply = false;
        }

        // Add mat to foldout dictionary if it isn't in there yet
        if (!foldouts.ContainsKey(material))
        {
            foldouts.Add(material, toggles);
        }

        // Use default labelWidth
        EditorGUIUtility.labelWidth = 0f;

        // Detect any changes to the material
        EditorGUI.BeginChangeCheck(); {
            // Core Shader Variant
            MGUI.BoldLabel("Shader Variant");
            DoVariantArea();
            MGUI.Space2();

            // Primary properties
            MGUI.BoldLabel("Primary Textures");
            DoPrimaryArea(material);
            MGUI.Space2();

            // Detail properties
            DoDetailArea();
            MGUI.Space4();

            // Emission
            // bool emissFoldout = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "Emission");
            // if (emissFoldout){
            //  DoEmissionArea(material);
            // }

            // Rim
            bool rimFoldout = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "Rim");
            if (rimFoldout)
            {
                DoRimArea();
            }

            // Subsurface
            bool subsurfaceArea = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "Subsurface Scattering");
            if (subsurfaceArea)
            {
                DoSubsurfaceArea();
            }

            // Filtering
            bool filteringFoldout = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "Filtering");
            if (filteringFoldout)
            {
                DoFilteringArea();
            }

            // UVs
            bool uvFoldout = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "UVs");
            if (uvFoldout)
            {
                DoUVArea();
            }

            // Rendering options
            bool renderFoldout = Foldouts.DoSmallFoldoutBold(foldouts, material, me, "Render Settings");
            if (renderFoldout)
            {
                DoRenderingArea(material);
            }

            // Watermark and version display
            DoFooter();

            // Setup stuff for decal mode
            SetDecalRendering(material);
        }

        // Ensure settings are applied correctly if anything changed
        if (EditorGUI.EndChangeCheck())
        {
            foreach (var obj in blendMode.targets)
            {
                MaterialChanged((Material)obj);
            }
        }

        MGUI.Space8();
    }