private void DrawSpecularSettings(MaterialEditor materialEditor)
    {
        showSpecular = XSStyles.ShurikenFoldout("Specular", showSpecular);
        if (showSpecular)
        {
            materialEditor.ShaderProperty(_SpecMode, new GUIContent("Specular Mode", "Specular Mode."));
            materialEditor.ShaderProperty(_SpecularStyle, new GUIContent("Specular Style", "Specular Style."));

            XSStyles.SeparatorThin();
            materialEditor.TexturePropertySingleLine(new GUIContent("Specular Map(R,G,B)", "Specular Map. Red channel controls Intensity, Green controls how much specular is tinted by Albedo, and Blue controls Smoothness (Only for Blinn-Phong, and GGX)."), _SpecularMap);
            materialEditor.TextureScaleOffsetProperty(_SpecularMap);
            materialEditor.ShaderProperty(_UVSetSpecular, new GUIContent("UV Set", "The UV set to use for the Specular Map"), 2);
            materialEditor.ShaderProperty(_SpecularIntensity, new GUIContent("Specular Intensity", "Specular Intensity."), 2);
            materialEditor.ShaderProperty(_SpecularAlbedoTint, new GUIContent("Specular Albedo Tint", "How much the specular highlight should derive color from the albedo of the object."), 2);
            if (_SpecMode.floatValue == 0 || _SpecMode.floatValue == 2)
            {
                materialEditor.ShaderProperty(_SpecularArea, new GUIContent("Specular Area", "Specular Area."), 2);
            }
            else
            {
                materialEditor.ShaderProperty(_AnisotropicAX, new GUIContent("Anisotropic Width", "Anisotropic Width, makes anistropic relfections more horizontal"), 2);
                materialEditor.ShaderProperty(_AnisotropicAY, new GUIContent("Anisotropic Height", "Anisotropic Height, makes anistropic relfections more vertical"), 2);
            }
        }
    }
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        if (xsFilePath == null)
        {
            xsFilePath = XSStyles.findAssetPath("");
        }
        foreach (string str in importedAssets)
        {
            if (str.StartsWith(xsFilePath + "/Main/CGIncludes"))
            {
                Debug.Log("XS CGInclude updated: " + str.Replace(xsFilePath + "/Main/CGIncludes/", ""));
                string[] files = Directory.GetFiles(xsFilePath + "/Main/Shaders", "*.shader");
                foreach (string file in files)
                {
                    AssetDatabase.ImportAsset(file, ImportAssetOptions.ForceUpdate);
                }
            }

            if (str.StartsWith(xsFilePath + "/Main/Patreon/CGIncludes"))
            {
                Debug.Log("XS CGInclude updated: " + str.Replace(xsFilePath + "/Main/Patreon/CGIncludes/", ""));
                string[] files = Directory.GetFiles(xsFilePath + "/Main/Patreon/Shaders", "*.shader");
                foreach (string file in files)
                {
                    AssetDatabase.ImportAsset(file, ImportAssetOptions.ForceUpdate);
                }
            }
        }
    }
    private void DrawMainSettings(MaterialEditor materialEditor)
    {
        showMainSettings = XSStyles.ShurikenFoldout("Main Settings", showMainSettings);
        if (showMainSettings)
        {
            materialEditor.TexturePropertySingleLine(new GUIContent("Main Texture", "The main Albedo texture."), _MainTex, _Color);
            if (isCutout)
            {
                materialEditor.ShaderProperty(_Cutoff, new GUIContent("Cutoff", "The Cutoff Amount"), 2);
            }
            if (isCutoutMasked)
            {
                materialEditor.TexturePropertySingleLine(new GUIContent("Dissolve Mask", "Black and white cutout mask"), _CutoutMask);
                materialEditor.ShaderProperty(_Cutoff, new GUIContent("Dissolve Progress", "The Cutoff Amount"), 2);
            }
            materialEditor.ShaderProperty(_UVSetAlbedo, new GUIContent("UV Set", "The UV set to use for the Albedo Texture."), 2);
            materialEditor.TextureScaleOffsetProperty(_MainTex);
            materialEditor.ShaderProperty(_Saturation, new GUIContent("Saturation", "Controls saturation of the final output from the shader."));

            if (isDithered)
            {
                //Dither Fading
                materialEditor.TexturePropertySingleLine(new GUIContent("Dissolve Mask", "Black and white mask to control dithering."), _CutoutMask);
                materialEditor.ShaderProperty(_FadeDither, new GUIContent("Use Distance Fading", "Make the shader dither out based on the distance to the camera."), 2);
                materialEditor.ShaderProperty(_FadeDitherDistance, new GUIContent("Fade Distance", "The distance at which the fading starts happening."), 2);
            }
        }
    }
    private void DrawPatreonSettings(MaterialEditor materialEditor)
    {
        //Plugins for Patreon releases
        if (isPatreonShader)
        {
            if (isEyeTracking)
            {
                showEyeTracking = XSStyles.ShurikenFoldout("Eye Tracking Settings", showEyeTracking);
                if (showEyeTracking)
                {
                    materialEditor.ShaderProperty(_LeftRightPan, new GUIContent("Left Right Adj.", "Adjusts the eyes manually left or right."));
                    materialEditor.ShaderProperty(_UpDownPan, new GUIContent("Up Down Adj.", "Adjusts the eyes manually up or down."));

                    XSStyles.SeparatorThin();
                    materialEditor.ShaderProperty(_AttentionSpan, new GUIContent("Attention Span", "How often should the eyes look at the target; 0 = never, 1 = always, 0.5 = half of the time."));
                    materialEditor.ShaderProperty(_FollowPower, new GUIContent("Follow Power", "The influence the target has on the eye"));
                    materialEditor.ShaderProperty(_LookSpeed, new GUIContent("Look Speed", "How fast the eye transitions to looking at the target"));
                    materialEditor.ShaderProperty(_Twitchyness, new GUIContent("Refocus Frequency", "How much should the eyes look around near the target?"));

                    XSStyles.SeparatorThin();
                    materialEditor.ShaderProperty(_IrisSize, new GUIContent("Iris Size", "Size of the iris"));
                    materialEditor.ShaderProperty(_FollowLimit, new GUIContent("Follow Limit", "Limits the angle from the front of the face on how far the eyes can track/rotate."));
                    materialEditor.ShaderProperty(_EyeOffsetLimit, new GUIContent("Offset Limit", "Limit for how far the eyes can turn"));
                }
            }
        }
        //
    }
Exemplo n.º 5
0
 public static void setupIcons()
 {
     if (skin == null)
     {
         uiPath = XSStyles.findAssetPath(uiPath) + "/Editor/Resources/";
         skin   = (GUISkin)AssetDatabase.LoadAssetAtPath <GUISkin>(uiPath + "XSGuiSkin.guiskin");
     }
 }
 void drawHelpText()
 {
     XSStyles.Separator();
     dHelpText = XSStyles.ShurikenFoldout("Information", dHelpText);
     if (dHelpText)
     {
         scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
         XSStyles.HelpBox("You can use this to create a custom shadow ramp in realtime. \nIf you do not save, the ramp will be reverted back to what it was previously. \n\n - Click the Gradient box. \n - Choose resolution of the texture. \n - Save.", MessageType.Info);
         XSStyles.HelpBox("Ramp textures support up to 5 ramps in one texture. That means you can have up to 5 ramps on a single material. You will need to author a ramp mask to choose which ramp to sample from. \n\nA texture that is fully black would sample from the bottom ramp, a texture that is fully white would sample from the top ramp, and a texture that is half gray would sample from the middle ramp. \n\n A quick tip would be that you can sample from each of the 5 ramps with 0, 0.25, 0.5, 0.75, and 1 on the texture. \n\nThe order of the gradients on the UI is the order that they will be on the texture.", MessageType.Info);
         EditorGUILayout.EndScrollView();
     }
 }
Exemplo n.º 7
0
    private static void setupIconsOnReload()
    {
        uiPath = XSStyles.findAssetPath(uiPath) + "/Editor/Resources/";
        //-----

        skin = (GUISkin)AssetDatabase.LoadAssetAtPath <GUISkin>(uiPath + "XSGuiSkin.guiskin");

        if (skin == null)
        {
            skin = (GUISkin)AssetDatabase.LoadAssetAtPath <GUISkin>(uiPath + "XSGuiSkin.guiskin");
        }
    }
Exemplo n.º 8
0
    public static void DoFooter()
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        XSStyles.discordButton(70, 30);
        XSStyles.patreonButton(70, 30);
        XSStyles.githubButton(70, 30);
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        XSStyles.openInfoPanel(200, 20);
    }
    void drawMGInputOutput()
    {
        GUILayout.BeginHorizontal();
        XSMultiGradient old_xsmg = xsmg;

        xsmg = (XSMultiGradient)EditorGUILayout.ObjectField("MultiGradient Preset", xsmg, typeof(XSMultiGradient), false, null);
        if (xsmg != old_xsmg)
        {
            if (xsmg != null)
            {
                this.gradients       = xsmg.gradients;
                this.gradients_index = xsmg.order;
                makeReorderedList();
            }
            else
            {
                List <Gradient> new_Grads = new List <Gradient>();
                for (int i = 0; i < this.gradients.Count; i++)
                {
                    new_Grads.Add(reflessGradient(this.gradients[i]));
                }
                this.gradients       = new_Grads;
                this.gradients_index = reflessIndexes(this.gradients_index);
                makeReorderedList();
            }
            changed = true;
        }

        if (GUILayout.Button("Save New", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
        {
            finalFilePath = XSStyles.findAssetPath(finalFilePath);
            string path = EditorUtility.SaveFilePanel("Save MultiGradient", (finalFilePath + "/Textures/Shadow Ramps/MGPresets"), "MultiGradient", "asset");
            if (path.Length != 0)
            {
                path = path.Substring(Application.dataPath.Length - "Assets".Length);
                XSMultiGradient _xsmg = ScriptableObject.CreateInstance <XSMultiGradient>();
                _xsmg.uniqueName = Path.GetFileNameWithoutExtension(path);
                foreach (Gradient grad in gradients)
                {
                    _xsmg.gradients.Add(reflessGradient(grad));
                }
                _xsmg.order.AddRange(gradients_index.ToArray());
                xsmg = _xsmg;
                AssetDatabase.CreateAsset(_xsmg, path);
                this.gradients       = xsmg.gradients;
                this.gradients_index = xsmg.order;
                makeReorderedList();
                AssetDatabase.SaveAssets();
            }
        }
        GUILayout.EndHorizontal();
    }
Exemplo n.º 10
0
 private void DrawTransmissionSettings(MaterialEditor materialEditor)
 {
     showSubsurface = XSStyles.ShurikenFoldout("Transmission", showSubsurface);
     if (showSubsurface)
     {
         materialEditor.TexturePropertySingleLine(new GUIContent("Thickness Map", "Thickness Map, used to mask areas where transmission can happen"), _ThicknessMap);
         materialEditor.TextureScaleOffsetProperty(_ThicknessMap);
         materialEditor.ShaderProperty(_UVSetThickness, new GUIContent("UV Set", "The UV set to use for the Thickness Map"), 2);
         XSStyles.constrainedShaderProperty(materialEditor, _SSColor, new GUIContent("Transmission Color", "Transmission Color"), 2);
         materialEditor.ShaderProperty(_SSDistortion, new GUIContent("Transmission Distortion", "How much the Transmission should follow the normals of the mesh and/or normal map."), 2);
         materialEditor.ShaderProperty(_SSPower, new GUIContent("Transmission Power", "Subsurface Power"), 2);
         materialEditor.ShaderProperty(_SSScale, new GUIContent("Transmission Scale", "Subsurface Scale"), 2);
     }
 }
Exemplo n.º 11
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
    {
        Material material = materialEditor.target as Material;
        Shader   shader   = material.shader;

        isDithered      = shader.name.Contains("Dithered");
        isCutout        = shader.name.Contains("Cutout") && !shader.name.Contains("A2C");
        isCutoutMasked  = shader.name.Contains("A2C") && shader.name.Contains("Masked");
        isOutlined      = shader.name.Contains("Outline");
        isPatreonShader = shader.name.Contains("Patreon");
        isEyeTracking   = shader.name.Contains("EyeTracking");

        //Find all material properties listed in the script using reflection, and set them using a loop only if they're of type MaterialProperty.
        //This makes things a lot nicer to maintain and cleaner to look at.
        foreach (var property in GetType().GetFields(bindingFlags))
        {
            if (property.FieldType == typeof(MaterialProperty))
            {
                try{ property.SetValue(this, FindProperty(property.Name, props)); } catch { /*Is it really a problem if it doesn't exist?*/ }
            }
        }

        EditorGUI.BeginChangeCheck();
        {
            if (!isCutout && !isCutoutMasked)            // Do this to make sure that if you're using AlphaToCoverage that you fallback to cutout with 0.5 Cutoff if your shaders are blocked.
            {
                material.SetFloat("_Cutoff", 0.5f);
            }

            XSStyles.ShurikenHeaderCentered("XSToon v" + XSStyles.ver);
            materialEditor.ShaderProperty(_AdvMode, new GUIContent("Shader Mode", "Setting this to 'Advanced' will give you access to things such as stenciling, and other expiremental/advanced features."));
            materialEditor.ShaderProperty(_Culling, new GUIContent("Culling Mode", "Changes the culling mode. 'Off' will result in a two sided material, while 'Front' and 'Back' will cull those sides respectively"));
            materialEditor.ShaderProperty(_TilingMode, new GUIContent("Tiling Mode", "Setting this to Merged will tile and offset all textures based on the Main texture's Tiling/Offset."));

            DrawMainSettings(materialEditor);
            DrawShadowSettings(materialEditor, material);
            DrawOutlineSettings(materialEditor);
            DrawNormalSettings(materialEditor);
            DrawSpecularSettings(materialEditor);
            DrawReflectionsSettings(materialEditor, material);
            DrawEmissionSettings(materialEditor);
            DrawRimlightSettings(materialEditor);
            DrawHalfToneSettings(materialEditor);
            DrawTransmissionSettings(materialEditor);
            DrawAdvancedSettings(materialEditor);
            DrawPatreonSettings(materialEditor);
            XSStyles.DoFooter();
        }
    }
Exemplo n.º 12
0
 private void DrawOutlineSettings(MaterialEditor materialEditor)
 {
     if (isOutlined)
     {
         showOutlines = XSStyles.ShurikenFoldout("Outlines", showOutlines);
         if (showOutlines)
         {
             materialEditor.ShaderProperty(_OutlineLighting, new GUIContent("Outline Lighting", "Makes outlines respect the lighting, or be emissive."));
             materialEditor.ShaderProperty(_OutlineAlbedoTint, new GUIContent("Outline Albedo Tint", "Includes the color of the Albedo Texture in the calculation for the color of the outline."));
             materialEditor.TexturePropertySingleLine(new GUIContent("Outline Mask", "Outline width mask, black will make the outline minimum width."), _OutlineMask);
             materialEditor.ShaderProperty(_OutlineWidth, new GUIContent("Outline Width", "Width of the Outlines"));
             XSStyles.constrainedShaderProperty(materialEditor, _OutlineColor, new GUIContent("Outline Color", "Color of the outlines"), 0);
         }
     }
 }
Exemplo n.º 13
0
 private void DrawRimlightSettings(MaterialEditor materialEditor)
 {
     showRimlight = XSStyles.ShurikenFoldout("Rimlight", showRimlight);
     if (showRimlight)
     {
         materialEditor.ShaderProperty(_RimColor, new GUIContent("Rimlight Tint", "The Tint of the Rimlight."));
         materialEditor.ShaderProperty(_RimAlbedoTint, new GUIContent("Rim Albedo Tint", "How much the Albedo texture should effect the rimlight color."));
         materialEditor.ShaderProperty(_RimCubemapTint, new GUIContent("Rim Environment Tint", "How much the Environment cubemap should effect the rimlight color."));
         materialEditor.ShaderProperty(_RimAttenEffect, new GUIContent("Rim Attenuation Effect", "How much should realtime shadows mask out the rimlight?"));
         materialEditor.ShaderProperty(_RimIntensity, new GUIContent("Rimlight Intensity", "Strength of the Rimlight."));
         materialEditor.ShaderProperty(_RimRange, new GUIContent("Range", "Range of the Rim"), 2);
         materialEditor.ShaderProperty(_RimThreshold, new GUIContent("Threshold", "Threshold of the Rim"), 2);
         materialEditor.ShaderProperty(_RimSharpness, new GUIContent("Sharpness", "Sharpness of the Rim"), 2);
     }
 }
Exemplo n.º 14
0
    private void DrawAdvancedSettings(MaterialEditor materialEditor)
    {
        if (_AdvMode.floatValue == 1)
        {
            showAdvanced = XSStyles.ShurikenFoldout("Advanced Settings", showAdvanced);
            if (showAdvanced)
            {
                materialEditor.ShaderProperty(_VertexColorAlbedo, new GUIContent("Vertex Color Albedo", "Multiplies the vertex color of the mesh by the Albedo texture to derive the final Albedo color."));
                materialEditor.ShaderProperty(_Stencil, _Stencil.displayName);
                materialEditor.ShaderProperty(_StencilComp, _StencilComp.displayName);
                materialEditor.ShaderProperty(_StencilOp, _StencilOp.displayName);

                materialEditor.RenderQueueField();
            }
        }
    }
    void DoFooter()
    {
        GUILayout.Label(XSStyles.Styles.version, new GUIStyle(EditorStyles.centeredGreyMiniLabel)
        {
            alignment = TextAnchor.MiddleCenter,
            wordWrap  = true,
            fontSize  = 12
        });

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        XSStyles.discordButton(20, 20);
        GUILayout.Space(2);
        XSStyles.patreonButton(20, 20);
        XSStyles.githubButton(20, 20);
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
    }
Exemplo n.º 16
0
    private void DrawEmissionSettings(MaterialEditor materialEditor)
    {
        showEmission = XSStyles.ShurikenFoldout("Emission", showEmission);
        if (showEmission)
        {
            materialEditor.TexturePropertySingleLine(new GUIContent("Emission Map", "Emissive map. White to black, unless you want multiple colors."), _EmissionMap, _EmissionColor);
            materialEditor.TextureScaleOffsetProperty(_EmissionMap);
            materialEditor.ShaderProperty(_UVSetEmission, new GUIContent("UV Set", "The UV set to use for the Emission Map"), 2);
            materialEditor.ShaderProperty(_EmissionToDiffuse, new GUIContent("Tint To Diffuse", "Tints the emission to the Diffuse Color"), 2);

            XSStyles.SeparatorThin();
            materialEditor.ShaderProperty(_ScaleWithLight, new GUIContent("Scale w/ Light", "Scales the emission intensity based on how dark or bright the environment is."));
            if (_ScaleWithLight.floatValue == 0)
            {
                materialEditor.ShaderProperty(_ScaleWithLightSensitivity, new GUIContent("Scaling Sensitivity", "How agressively the emission should scale with the light."));
            }
        }
    }
Exemplo n.º 17
0
    public static void DoFooter()
    {
        //GUILayout.Label(XSStyles.Styles.version, new GUIStyle(EditorStyles.centeredGreyMiniLabel)
        //{
        //	alignment = TextAnchor.MiddleCenter,
        //	wordWrap = true,
        //	fontSize = 12
        //});

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        XSStyles.discordButton(70, 30);
        GUILayout.Space(2);
        XSStyles.patreonButton(70, 30);
        XSStyles.githubButton(70, 30);
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        XSStyles.openDocumentation(200, 20);
    }
Exemplo n.º 18
0
    private void DrawHalfToneSettings(MaterialEditor materialEditor)
    {
        showHalftones = XSStyles.ShurikenFoldout("Halftones", showHalftones);
        if (showHalftones)
        {
            materialEditor.ShaderProperty(_HalftoneType, new GUIContent("Halftone Style", "Controls where halftone and stippling effects are drawn."));

            if (_HalftoneType.floatValue == 1 || _HalftoneType.floatValue == 2)
            {
                materialEditor.ShaderProperty(_HalftoneDotSize, new GUIContent("Stippling Scale", "How large should the stippling pattern be?"));
                materialEditor.ShaderProperty(_HalftoneDotAmount, new GUIContent("Stippling Density", "How dense is the stippling effect?"));
            }

            if (_HalftoneType.floatValue == 0 || _HalftoneType.floatValue == 2)
            {
                materialEditor.ShaderProperty(_HalftoneLineAmount, new GUIContent("Halftone Line Count", "How many lines should the halftone shadows have?"));
                materialEditor.ShaderProperty(_HalftoneLineIntensity, new GUIContent("Halftone Line Intensity", "How dark should the halftone lines be?"));
            }
        }
    }
Exemplo n.º 19
0
    private void DrawShadowSettings(MaterialEditor materialEditor, Material material)
    {
        showShadows = XSStyles.ShurikenFoldout("Shadows", showShadows);
        if (showShadows)
        {
            materialEditor.TexturePropertySingleLine(new GUIContent("Ramp Selection Mask", "A black to white mask that determins how far up on the multi ramp to sample. 0 for bottom, 1 for top, 0.5 for middle, 0.25, and 0.75 for mid bottom and mid top respectively."), _RampSelectionMask);

            XSStyles.SeparatorThin();
            if (_RampSelectionMask.textureValue != null)
            {
                string          rampMaskPath = AssetDatabase.GetAssetPath(_RampSelectionMask.textureValue);
                TextureImporter ti           = (TextureImporter)TextureImporter.GetAtPath(rampMaskPath);
                if (ti.sRGBTexture)
                {
                    if (XSStyles.HelpBoxWithButton(new GUIContent("This texture is not marked as Linear.", "This is recommended for the mask"), new GUIContent("Fix Now")))
                    {
                        ti.sRGBTexture = false;
                        AssetDatabase.ImportAsset(rampMaskPath, ImportAssetOptions.ForceUpdate);
                        AssetDatabase.Refresh();
                    }
                }
            }

            materialEditor.TexturePropertySingleLine(new GUIContent("Shadow Ramp", "Shadow Ramp, Dark to Light should be Left to Right"), _Ramp);
            materialEditor.ShaderProperty(_ShadowSharpness, new GUIContent("Shadow Sharpness", "Controls the sharpness of recieved shadows, as well as the sharpness of 'shadows' from Vertex Lighting."));

            XSStyles.SeparatorThin();
            materialEditor.TexturePropertySingleLine(new GUIContent("Occlusion Map", "Occlusion Map, used to darken areas on the model artifically."), _OcclusionMap);
            XSStyles.constrainedShaderProperty(materialEditor, _OcclusionColor, new GUIContent("Occlusion Tint", "Occlusion shadow tint."), 2);
            materialEditor.ShaderProperty(_UVSetOcclusion, new GUIContent("UV Set", "The UV set to use for the Occlusion Texture"), 2);
            materialEditor.TextureScaleOffsetProperty(_OcclusionMap);

            XSStyles.SeparatorThin();
            XSStyles.constrainedShaderProperty(materialEditor, _ShadowRim, new GUIContent("Shadow Rim", "Shadow Rim Color. Set to white to disable."), 0);
            materialEditor.ShaderProperty(_ShadowRimAlbedoTint, new GUIContent("Shadow Rim Albedo Tint", "How much the Albedo texture should effect the Shadow Rim color."));
            materialEditor.ShaderProperty(_ShadowRimRange, new GUIContent("Range", "Range of the Shadow Rim"), 2);
            materialEditor.ShaderProperty(_ShadowRimThreshold, new GUIContent("Threshold", "Threshold of the Shadow Rim"), 2);
            materialEditor.ShaderProperty(_ShadowRimSharpness, new GUIContent("Sharpness", "Sharpness of the Shadow Rim"), 2);
            XSStyles.callGradientEditor(material);
        }
    }
Exemplo n.º 20
0
    private void DrawNormalSettings(MaterialEditor materialEditor)
    {
        showNormalMapSettings = XSStyles.ShurikenFoldout("Normal Maps", showNormalMapSettings);
        if (showNormalMapSettings)
        {
            materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map", "Normal Map"), _BumpMap);
            materialEditor.ShaderProperty(_BumpScale, new GUIContent("Normal Strength", "Strength of the main Normal Map"), 2);
            materialEditor.ShaderProperty(_UVSetNormal, new GUIContent("UV Set", "The UV set to use for the Normal Map"), 2);
            materialEditor.TextureScaleOffsetProperty(_BumpMap);

            XSStyles.SeparatorThin();
            materialEditor.TexturePropertySingleLine(new GUIContent("Detail Normal Map", "Detail Normal Map"), _DetailNormalMap);
            materialEditor.ShaderProperty(_DetailNormalMapScale, new GUIContent("Detail Normal Strength", "Strength of the detail Normal Map"), 2);
            materialEditor.ShaderProperty(_UVSetDetNormal, new GUIContent("UV Set", "The UV set to use for the Detail Normal Map"), 2);
            materialEditor.TextureScaleOffsetProperty(_DetailNormalMap);

            XSStyles.SeparatorThin();
            materialEditor.TexturePropertySingleLine(new GUIContent("Detail Mask", "Mask for Detail Maps"), _DetailMask);
            materialEditor.ShaderProperty(_UVSetDetMask, new GUIContent("UV Set", "The UV set to use for the Detail Mask"), 2);
            materialEditor.TextureScaleOffsetProperty(_DetailMask);
        }
    }
    public void OnGUI()
    {
        if (gradient == null)
        {
            gradient = new Gradient();
        }
        if (oldGradient == null)
        {
            oldGradient = new Gradient();
        }

        if (focusedMat != null && gradient != null)
        {
            XSStyles.ShurikenHeader("Current Material: " + focusedMat.name);
        }
        else
        {
            XSStyles.ShurikenHeader("Current Material: None");
        }

        SerializedObject   serializedGradient = new SerializedObject(this);
        SerializedProperty colorGradient      = serializedGradient.FindProperty("gradient");

        EditorGUILayout.PropertyField(colorGradient, true, null);
        serializedGradient.ApplyModifiedProperties();

        bool changed = !CompareGradients(oldGradient, gradient);

        if (oldFocusedMat != focusedMat)
        {
            changed = true;
            if (this.oldTexture != null)
            {
                if (this.oldTexture == EditorGUIUtility.whiteTexture)
                {
                    this.oldTexture = null;
                }
                oldFocusedMat.SetTexture("_Ramp", this.oldTexture);
                this.oldTexture = null;
            }
            oldFocusedMat = focusedMat;
        }

        if (changed)
        {
            oldGradient.SetKeys(gradient.colorKeys, gradient.alphaKeys);
            oldGradient.mode = gradient.mode;
        }

        Resolutions oldRes = res;

        res = (Resolutions)EditorGUILayout.EnumPopup("Resolution: ", res);
        if (oldRes != res)
        {
            changed = true;
        }

        int width  = (int)res;
        int height = 8;

        isLinear = GUILayout.Toggle(isLinear, "Make Linear Texture");

        if (gradient != null)
        {
            Texture2D tex = new Texture2D(width, height, TextureFormat.RGBA32, false);

            for (int y = 0; y < tex.height; y++)
            {
                for (int x = 0; x < tex.width; x++)
                {
                    tex.SetPixel(x, y, gradient.Evaluate((float)x / (float)width));
                }
            }

            if (focusedMat != null)
            {
                if (changed)
                {
                    if (focusedMat.HasProperty("_Ramp"))
                    {
                        if (this.oldTexture == null)
                        {
                            if (focusedMat.GetTexture("_Ramp") == null)
                            {
                                this.oldTexture = EditorGUIUtility.whiteTexture;
                            }
                            else
                            {
                                this.oldTexture = focusedMat.GetTexture("_Ramp");
                            }
                        }
                        tex.wrapMode = TextureWrapMode.Clamp;
                        tex.Apply(false);
                        focusedMat.SetTexture("_Ramp", tex);
                    }
                }
            }

            XSStyles.Separator();
            if (GUILayout.Button("Save Ramp"))
            {
                finalFilePath = XSStyles.findAssetPath(finalFilePath);
                string path = EditorUtility.SaveFilePanel("Save Ramp as PNG", finalFilePath + "/Textures/Shadow Ramps/Generated", "gradient.png", "png");
                if (path.Length != 0)
                {
                    bool success = GenTexture(tex, path);
                    if (success)
                    {
                        if (focusedMat != null)
                        {
                            string  s    = path.Substring(path.IndexOf("Assets"));
                            Texture ramp = AssetDatabase.LoadAssetAtPath <Texture>(s);
                            if (ramp != null)
                            {
                                focusedMat.SetTexture("_Ramp", ramp);
                                this.oldTexture = null;
                            }
                        }
                    }
                }
            }
        }

        XSStyles.HelpBox("You can use this to create a custom shadow ramp in realtime. \nIf you do not save, the ramp will be reverted back to what it was previously. \n\n - Click the Gradient box. \n - Choose resolution of the texture. \n - Save.", MessageType.Info);
    }
    //static bool disableOutlinePass = false;
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
    {
        XSStyles.setupIcons();
        Material material = materialEditor.target as Material;

        {
            //Find all the properties within the shader
            shadowRamp           = ShaderGUI.FindProperty("_ShadowRamp", props);
            specMap              = ShaderGUI.FindProperty("_SpecularMap", props);
            specPattern          = ShaderGUI.FindProperty("_SpecularPattern", props);
            tint                 = ShaderGUI.FindProperty("_Color", props);
            mainTex              = ShaderGUI.FindProperty("_MainTex", props);
            normal               = ShaderGUI.FindProperty("_Normal", props);
            specIntensity        = ShaderGUI.FindProperty("_SpecularIntensity", props);
            specArea             = ShaderGUI.FindProperty("_SpecularArea", props);
            rimWidth             = ShaderGUI.FindProperty("_RimWidth", props);
            rimIntensity         = ShaderGUI.FindProperty("_RimIntensity", props);
            emissiveToggle       = ShaderGUI.FindProperty("_Emissive", props);
            emissiveTex          = ShaderGUI.FindProperty("_EmissiveTex", props);
            emissiveColor        = ShaderGUI.FindProperty("_EmissiveColor", props);
            alphaCutoff          = ShaderGUI.FindProperty("_Cutoff", props);
            culling              = ShaderGUI.FindProperty("_Culling", props);
            rimStyle             = ShaderGUI.FindProperty("_RimlightType", props);
            advMode              = ShaderGUI.FindProperty("_advMode", props);
            reflSmooth           = ShaderGUI.FindProperty("_ReflSmoothness", props);
            metal                = ShaderGUI.FindProperty("_Metallic", props);
            metalMap             = ShaderGUI.FindProperty("_MetallicMap", props);
            roughMap             = ShaderGUI.FindProperty("_RoughMap", props);
            bakedCube            = ShaderGUI.FindProperty("_BakedCube", props);
            shadowType           = ShaderGUI.FindProperty("_ShadowType", props);
            reflType             = ShaderGUI.FindProperty("_ReflType", props);
            saturation           = ShaderGUI.FindProperty("_Saturation", props);
            useRefl              = ShaderGUI.FindProperty("_UseReflections", props);
            matcapStyle          = ShaderGUI.FindProperty("_MatcapStyle", props);
            stylizedType         = ShaderGUI.FindProperty("_StylizedReflStyle", props);
            rampColor            = ShaderGUI.FindProperty("_RampColor", props);
            rimColor             = ShaderGUI.FindProperty("_RimColor", props);
            aX                   = ShaderGUI.FindProperty("_anistropicAX", props);
            aY                   = ShaderGUI.FindProperty("_anistropicAY", props);
            specStyle            = ShaderGUI.FindProperty("_SpecularStyle", props);
            detailNormal         = ShaderGUI.FindProperty("_DetailNormal", props);
            detailMask           = ShaderGUI.FindProperty("_DetailMask", props);
            normalStrength       = ShaderGUI.FindProperty("_NormalStrength", props);
            detailNormalStrength = ShaderGUI.FindProperty("_DetailNormalStrength", props);
            occlusionMap         = ShaderGUI.FindProperty("_OcclusionMap", props);
            occlusionStrength    = ShaderGUI.FindProperty("_OcclusionStrength", props);
            ThicknessMap         = ShaderGUI.FindProperty("_ThicknessMap", props);
            SSSDist              = ShaderGUI.FindProperty("_SSSDist", props);
            SSSPow               = ShaderGUI.FindProperty("_SSSPow", props);
            SSSIntensity         = ShaderGUI.FindProperty("_SSSIntensity", props);
            SSSCol               = ShaderGUI.FindProperty("_SSSCol", props);
            invertThickness      = ShaderGUI.FindProperty("_invertThickness", props);
            ThicknessMapPower    = ShaderGUI.FindProperty("_ThicknessMapPower", props);
            UseSSS               = ShaderGUI.FindProperty("_UseSSS", props);
            UseSpecular          = ShaderGUI.FindProperty("_UseSpecular", props);
            UseUV2Emiss          = ShaderGUI.FindProperty("_EmissUv2", props);
            EmissScaleWithLight  = ShaderGUI.FindProperty("_ScaleWithLight", props);
            EmissTintToColor     = ShaderGUI.FindProperty("_EmissTintToColor", props);
            EmissionPower        = ShaderGUI.FindProperty("_EmissionPower", props);
            if (material.shader.name.Contains("Outlined"))      //Shader.Find("Xiexe/Toon/XSToonCutoutOutlined") || material.shader == Shader.Find("Xiexe/Toon/XSToonOutlined") || material.shader == Shader.Find("Xiexe/Toon/XSToonTransparentDitheredOUTLINED"))
            {
                OutlineColor      = ShaderGUI.FindProperty("_OutlineColor", props);
                OutlineThickness  = ShaderGUI.FindProperty("_OutlineThickness", props);
                OutlineTextureMap = ShaderGUI.FindProperty("_OutlineTextureMap", props);
                _LitOutline       = ShaderGUI.FindProperty("_LitOutlines", props);
                outlined          = true;
            }
            else
            {
                outlined = false;
                outlines = false;
            }

            _AORAMPMODE_ON  = ShaderGUI.FindProperty("_AORAMPMODE_ON", props);
            _OcclusionColor = ShaderGUI.FindProperty("_OcclusionColor", props);

            _DetailNormalUv2    = ShaderGUI.FindProperty("_DetailNormalUv2", props);
            _NormalUv2          = ShaderGUI.FindProperty("_NormalUv2", props);
            _MetallicUv2        = ShaderGUI.FindProperty("_MetallicUv2", props);
            _SpecularUv2        = ShaderGUI.FindProperty("_SpecularUv2", props);
            _SpecularPatternUv2 = ShaderGUI.FindProperty("_SpecularPatternUv2", props);
            _AOUV2 = ShaderGUI.FindProperty("_AOUV2", props);

            //advanced options
            colorMask    = ShaderGUI.FindProperty("_colormask", props);
            stencil      = ShaderGUI.FindProperty("_Stencil", props);
            stencilComp  = ShaderGUI.FindProperty("_StencilComp", props);
            stencilOp    = ShaderGUI.FindProperty("_StencilOp", props);
            stencilFail  = ShaderGUI.FindProperty("_StencilFail", props);
            stencilZFail = ShaderGUI.FindProperty("_StencilZFail", props);
            zwrite       = ShaderGUI.FindProperty("_ZWrite", props);
            ztest        = ShaderGUI.FindProperty("_ZTest", props);

            RampBaseAnchor = ShaderGUI.FindProperty("_RampBaseAnchor", props);
            //
            //Show Properties in Inspector
            //materialEditor.ShaderProperty(, .displayName);

            EditorGUI.BeginChangeCheck();
            {
                EditorGUI.BeginChangeCheck();

                EditorGUI.showMixedValue = advMode.hasMixedValue;
                var aMode = (DisplayType)advMode.floatValue;

                EditorGUI.BeginChangeCheck();
                aMode = (DisplayType)EditorGUILayout.Popup("Shader Mode", (int)aMode, Enum.GetNames(typeof(DisplayType)));

                if (EditorGUI.EndChangeCheck())
                {
                    materialEditor.RegisterPropertyChangeUndo("Shader Mode");
                    advMode.floatValue       = (float)aMode;
                    EditorGUI.showMixedValue = false;
                }

                materialEditor.ShaderProperty(culling, culling.displayName);

                //main
                //Rect rect = (0,0);
                XSStyles.Separator();
                EditorGUILayout.BeginHorizontal();
                materialEditor.TexturePropertySingleLine(Styles.MainTexText, mainTex, tint);
                XSStyles.helpPopup(XSStyles.mainURL);
                EditorGUILayout.EndHorizontal();
                GUI.skin = null;
                materialEditor.ShaderProperty(saturation, Styles.Saturation, 3);
                materialEditor.TextureScaleOffsetProperty(mainTex);

                //cutoff
                if (material.shader.name.Contains("Cutout") && !material.shader.name.Contains("AlphaToMask"))
                {
                    materialEditor.ShaderProperty(alphaCutoff, Styles.cutoutText);
                }
                if (material.shader.name.Contains("AlphaToMask"))
                {
                    //So that a fallback to standard works as intended.
                    material.SetFloat("_Cutoff", 0.5f);
                }
                //-----

                //outlines
                if (outlined == true)
                {
                    XSStyles.Separator();
                    EditorGUILayout.BeginHorizontal();
                    outlines = EditorGUILayout.Foldout(outlines, "OUTLINES", true);
                    XSStyles.helpPopup(XSStyles.outlineURL);
                    EditorGUILayout.EndHorizontal();
                    GUI.skin = null;
                    if (outlines)
                    {
                        XSStyles.SeparatorThin();
                        materialEditor.ShaderProperty(_LitOutline, "Outline Light Mode");
                        materialEditor.TexturePropertySingleLine(Styles.outlineTex, OutlineTextureMap);
                        materialEditor.ShaderProperty(OutlineColor, "Outline Color");
                        materialEditor.ShaderProperty(OutlineThickness, "Outline Scale");
                    }
                }
                //-----

                //normal map
                XSStyles.Separator();
                EditorGUILayout.BeginHorizontal();
                normals = EditorGUILayout.Foldout(normals, "NORMAL MAPS", true);
                XSStyles.helpPopup(XSStyles.normalsURL);
                EditorGUILayout.EndHorizontal();
                GUI.skin = null;
                if (normals)
                {
                    XSStyles.SeparatorThin();
                    materialEditor.TexturePropertySingleLine(Styles.normalText, normal, normalStrength);
                    materialEditor.TextureScaleOffsetProperty(normal);
                    materialEditor.TexturePropertySingleLine(Styles.detailNormal, detailNormal, detailNormalStrength);
                    materialEditor.TextureScaleOffsetProperty(detailNormal);
                    materialEditor.TexturePropertySingleLine(Styles.detailMask, detailMask);
                    materialEditor.ShaderProperty(_NormalUv2, "Normal UV");
                    materialEditor.ShaderProperty(_DetailNormalUv2, "Detail UV");
                }
                //-----

                //shadows
                XSStyles.Separator();
                EditorGUILayout.BeginHorizontal();
                shadows = EditorGUILayout.Foldout(shadows, "SHADOWS", true);
                XSStyles.helpPopup(XSStyles.shadowsURL);
                EditorGUILayout.EndHorizontal();
                GUI.skin = null;
                if (shadows)
                {
                    XSStyles.SeparatorThin();
                    materialEditor.TexturePropertySingleLine(Styles.rampText, shadowRamp);
                    materialEditor.ShaderProperty(rampColor, "Ramp Mode", 2);
                    materialEditor.ShaderProperty(shadowType, Styles.shadowTypeText, 2);
                    materialEditor.TexturePropertySingleLine(Styles.occlusionMap, occlusionMap);
                    materialEditor.ShaderProperty(_AORAMPMODE_ON, "AO Style", 2);

                    if (material.GetTexture("_OcclusionMap") && _AORAMPMODE_ON.floatValue == 1)
                    {
                        materialEditor.ShaderProperty(occlusionStrength, "Strength", 3);
                    }
                    else
                    {
                        material.SetFloat("_OcclusionStrength", 1);
                    }

                    if (_AORAMPMODE_ON.floatValue == 0)
                    {
                        materialEditor.ShaderProperty(_OcclusionColor, "AO Color", 2);
                    }

                    materialEditor.ShaderProperty(_AOUV2, "Occlusion UV");

                    XSStyles.callGradientEditor();
                }
                //ambient
                //ramp
                //mixed
                if (rampColor.floatValue == 0)
                {
                    material.SetFloat("_WORLDSHADOWCOLOR_ON", 1);
                    material.SetFloat("_MIXEDSHADOWCOLOR_ON", 0);
                }
                if (rampColor.floatValue == 1)
                {
                    material.SetFloat("_WORLDSHADOWCOLOR_ON", 0);
                    material.SetFloat("_MIXEDSHADOWCOLOR_ON", 0);
                }
                if (rampColor.floatValue == 2)
                {
                    material.SetFloat("_WORLDSHADOWCOLOR_ON", 0);
                    material.SetFloat("_MIXEDSHADOWCOLOR_ON", 1);
                }
                //-----

                //Rimlighting
                XSStyles.Separator();
                EditorGUILayout.BeginHorizontal();
                rimlighting = EditorGUILayout.Foldout(rimlighting, "RIMLIGHT", true);
                XSStyles.helpPopup(XSStyles.rimlightURL);
                EditorGUILayout.EndHorizontal();
                GUI.skin = null;
                if (rimlighting)
                {
                    XSStyles.SeparatorThin();
                    materialEditor.ShaderProperty(rimStyle, Styles.rimLightTypeText);

                    if (rimStyle.floatValue == 0)
                    {
                        materialEditor.ShaderProperty(rimWidth, Styles.rimWidthText, 2);
                        materialEditor.ShaderProperty(rimIntensity, Styles.rimIntText, 2);
                        materialEditor.ShaderProperty(rimColor, "Rimlight Tint", 2);
                    }

                    if (rimStyle.floatValue == 1)
                    {
                        materialEditor.ShaderProperty(rimWidth, Styles.rimWidthText, 2);
                        materialEditor.ShaderProperty(rimIntensity, Styles.rimIntText, 2);
                        materialEditor.ShaderProperty(rimColor, "Rimlight Tint", 2);
                    }

                    if (rimStyle.floatValue == 2)
                    {
                        material.SetFloat("_RimIntensity", 0);
                    }
                }
                //----

                //emission
                XSStyles.Separator();
                EditorGUILayout.BeginHorizontal();
                emission = EditorGUILayout.Foldout(emission, "EMISSION", true);
                XSStyles.helpPopup(XSStyles.emissionsURL);
                EditorGUILayout.EndHorizontal();
                GUI.skin = null;
                if (emission)
                {
                    XSStyles.SeparatorThin();
                    materialEditor.ShaderProperty(emissiveToggle, "Emission");
                    if (emissiveToggle.floatValue == 0)
                    {
                        materialEditor.TexturePropertySingleLine(Styles.emissText, emissiveTex, emissiveColor);
                        materialEditor.ShaderProperty(EmissTintToColor, "Tint To Diffuse");
                        materialEditor.ShaderProperty(EmissScaleWithLight, "Scale With Light");
                        if (EmissScaleWithLight.floatValue == 0)
                        {
                            materialEditor.ShaderProperty(EmissionPower, "Threshold", 2);
                        }
                        materialEditor.ShaderProperty(UseUV2Emiss, "Emission UV");
                    }
                    else
                    {
                        material.SetColor("_EmissiveColor", Color.black);
                    }
                }
                //-----

                //specular
                XSStyles.Separator();
                EditorGUILayout.BeginHorizontal();
                specular = EditorGUILayout.Foldout(specular, "SPECULAR", true);
                XSStyles.helpPopup(XSStyles.specularURL);
                EditorGUILayout.EndHorizontal();
                EditorGUI.BeginChangeCheck();
                if (specular)
                {
                    XSStyles.SeparatorThin();
                    materialEditor.ShaderProperty(UseSpecular, "Specular");
                    if (UseSpecular.floatValue == 0)
                    {
                        materialEditor.TexturePropertySingleLine(Styles.specMapText, specMap);
                        GUI.skin = null;
                        materialEditor.TextureScaleOffsetProperty(specMap);
                        materialEditor.TexturePropertySingleLine(Styles.specPatternText, specPattern);
                        materialEditor.TextureScaleOffsetProperty(specPattern);
                        materialEditor.ShaderProperty(stylizedType, "Specular Type");
                        materialEditor.ShaderProperty(specStyle, "Specular Style");
                        if (stylizedType.floatValue == 1)
                        {
                            material.SetFloat("_ANISTROPIC_ON", 1);
                            materialEditor.ShaderProperty(aX, "Length", 3);
                            materialEditor.ShaderProperty(aY, "Width", 3);
                        }
                        else
                        {
                            material.SetFloat("_ANISTROPIC_ON", 0);
                            materialEditor.ShaderProperty(specArea, Styles.SmoothnessText, 3);
                        }
                        materialEditor.ShaderProperty(specIntensity, Styles.sintensityText, 3);
                        materialEditor.ShaderProperty(_SpecularUv2, "Specular UV");
                        materialEditor.ShaderProperty(_SpecularPatternUv2, "Pattern UV");
                    }
                    else
                    {
                        material.SetFloat("_SpecularIntensity", 0);
                    }
                }
                //-----

                //metallic
                XSStyles.Separator();
                EditorGUILayout.BeginHorizontal();
                reflections = EditorGUILayout.Foldout(reflections, "REFLECTIONS", true);
                XSStyles.helpPopup(XSStyles.reflURL);
                EditorGUILayout.EndHorizontal();
                GUI.skin = null;
                if (reflections)
                {
                    XSStyles.SeparatorThin();
                    materialEditor.ShaderProperty(useRefl, "Reflections");
                    if (useRefl.floatValue == 0)
                    {
                        materialEditor.ShaderProperty(reflType, "Reflection Style");
                        material.EnableKeyword("_REFLECTIONS_ON");
                        //pbr
                        if (reflType.floatValue == 0)
                        {
                            materialEditor.TexturePropertySingleLine(Styles.bakedCube, bakedCube);
                            material.SetFloat("_PBRREFL_ON", 1);
                            material.SetFloat("_MATCAP_ON", 0);
                            material.SetFloat("_MATCAP_CUBEMAP_ON", 0);
                            materialEditor.TexturePropertySingleLine(Styles.MetalMap, metalMap);

                            if (!material.GetTexture("_MetallicMap"))
                            {
                                materialEditor.ShaderProperty(metal, "Metallic", 2);
                            }
                            else
                            {
                                material.SetFloat("_Metallic", 1);
                            }

                            materialEditor.ShaderProperty(reflSmooth, "Smoothness", 2);
                            materialEditor.ShaderProperty(_MetallicUv2, "Metal/Rough UV");
                        }
                        //matcap
                        if (reflType.floatValue == 1)
                        {
                            material.SetFloat("_MATCAP_ON", 1);
                            material.SetFloat("_MATCAP_CUBEMAP_ON", 0);
                            material.SetFloat("_PBRREFL_ON", 0);
                            materialEditor.ShaderProperty(matcapStyle, "Blend Mode");
                            materialEditor.TexturePropertySingleLine(Styles.Matcap, metalMap);
                            materialEditor.TexturePropertySingleLine(Styles.MatcapMask, roughMap);
                            materialEditor.ShaderProperty(metal, "Intensity", 2);
                            materialEditor.ShaderProperty(reflSmooth, "Blur", 2);
                        }
                        //bakedcubemap
                        if (reflType.floatValue == 2)
                        {
                            material.SetFloat("_MATCAP_CUBEMAP_ON", 1);
                            material.SetFloat("_MATCAP_ON", 0);
                            material.SetFloat("_PBRREFL_ON", 0);
                            materialEditor.TexturePropertySingleLine(Styles.bakedCube, bakedCube);
                            materialEditor.TexturePropertySingleLine(Styles.MetalMap, metalMap);

                            if (!material.GetTexture("_MetallicMap"))
                            {
                                materialEditor.ShaderProperty(metal, "Metallic", 2);
                            }
                            else
                            {
                                material.SetFloat("_Metallic", 1);
                            }

                            materialEditor.ShaderProperty(reflSmooth, "Smoothness", 2);
                            materialEditor.ShaderProperty(_MetallicUv2, "UVSet");
                        }
                    }
                    else
                    {
                        material.DisableKeyword("_REFLECTIONS_ON");
                        material.SetFloat("_PBRREFL_ON", 0);
                        material.SetFloat("_MATCAP_ON", 0);
                        material.SetFloat("_MATCAP_CUBEMAP_ON", 0);
                    }
                }
                //-----

                //Subsurface Scattering
                XSStyles.Separator();
                EditorGUILayout.BeginHorizontal();
                subsurface = EditorGUILayout.Foldout(subsurface, "SUBSURFACE SCATTERING", true);
                XSStyles.helpPopup(XSStyles.sssURL);
                GUI.skin = null;
                EditorGUILayout.EndHorizontal();
                if (subsurface)
                {
                    XSStyles.SeparatorThin();
                    materialEditor.ShaderProperty(UseSSS, "Subsurface Scattering");
                    if (UseSSS.floatValue == 0)
                    {
                        materialEditor.TexturePropertySingleLine(Styles.thicknessMap, ThicknessMap);
                        materialEditor.ShaderProperty(invertThickness, "Invert", 3);
                        materialEditor.ShaderProperty(ThicknessMapPower, "Power", 3);
                        materialEditor.ShaderProperty(SSSCol, "Subsurface Color", 2);
                        materialEditor.ShaderProperty(SSSDist, "Displacement", 2);
                        materialEditor.ShaderProperty(SSSPow, "Sharpness", 2);
                        materialEditor.ShaderProperty(SSSIntensity, "Intensity", 2);
                    }
                    else
                    {
                        material.SetFloat("_SSSIntensity", 0);
                    }
                }
                else
                {
                    if (UseSSS.floatValue == 1)
                    {
                        material.SetFloat("_SSSIntensity", 0);
                    }
                }
                //-----



                GUI.skin = null;
                if (advMode.floatValue == 1)
                {
                    XSStyles.Separator();
                    advancedSettings = EditorGUILayout.Foldout(advancedSettings, "ADVANCED SETTINGS", true);
                    if (advancedSettings)
                    {
                        XSStyles.SeparatorThin();
                        // GUILayout.Label(Styles.advancedOptions, EditorStyles.boldLabel);
                        //Stencil
                        GUILayout.Label("Stencil Buffer", EditorStyles.boldLabel);
                        materialEditor.ShaderProperty(colorMask, colorMask.displayName, 2);
                        materialEditor.ShaderProperty(stencil, stencil.displayName, 2);
                        materialEditor.ShaderProperty(stencilComp, stencilComp.displayName, 2);
                        materialEditor.ShaderProperty(stencilOp, stencilOp.displayName, 2);
                        materialEditor.ShaderProperty(stencilFail, stencilFail.displayName, 2);
                        materialEditor.ShaderProperty(stencilZFail, stencilZFail.displayName, 2);
                        materialEditor.ShaderProperty(ztest, ztest.displayName, 2);
                        materialEditor.ShaderProperty(zwrite, zwrite.displayName, 2);
                        materialEditor.ShaderProperty(RampBaseAnchor, "Ramp Anchor", 2);

                        // Reset ZWrite/ZTest
                        XSStyles.ResetAdv(material);
                        XSStyles.ResetAdvAll(material);

                        // disable pass toggle
                        // disableOutlinePass = EditorGUILayout.Toggle("Disable Outline Pass", disableOutlinePass);
                        // if(disableOutlinePass == true)
                        //     material.SetShaderPassEnabled("Always", false);
                        // else
                        //     material.SetShaderPassEnabled("Always", true);
                    }
                }
                if (advMode.floatValue == 0)
                {
                    XSStyles.CallResetAdv(material);
                }
            }
        }
        DoFooter();
    }
Exemplo n.º 23
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
    {
        Material material = materialEditor.target as Material;
        Shader   shader   = material.shader;

        isCutout   = shader.name.Contains("Cutout") && !shader.name.Contains("A2C");
        isOutlined = shader.name.Contains("Outline");

        //Find all material properties listed in the script using reflection, and set them using a loop only if they're of type MaterialProperty.
        //This makes things a lot nicer to maintain and cleaner to look at.
        foreach (var property in GetType().GetFields(bindingFlags))
        {
            if (property.FieldType == typeof(MaterialProperty))
            {
                property.SetValue(this, FindProperty(property.Name, props));
            }
        }

        EditorGUI.BeginChangeCheck();
        {
            if (!isCutout)// Do this to make sure that if you're using AlphaToCoverage that you fallback to cutout with 0.5 Cutoff if your shaders are blocked.
            {
                material.SetFloat("_Cutoff", 0.5f);
            }

            XSStyles.ShurikenHeaderCentered("XSToon v" + XSStyles.ver);
            materialEditor.ShaderProperty(_AdvMode, new GUIContent("Shader Mode", "Setting this to 'Advanced' will give you access to things such as stenciling, and other expiremental/advanced features."));
            materialEditor.ShaderProperty(_Culling, new GUIContent("Culling Mode", "Changes the culling mode. 'Off' will result in a two sided material, while 'Front' and 'Back' will cull those sides respectively"));
            materialEditor.ShaderProperty(_TilingMode, new GUIContent("Tiling Mode", "Setting this to Merged will tile and offset all textures based on the Main texture's Tiling/Offset."));

            showMainSettings = XSStyles.ShurikenFoldout("Main Settings", showMainSettings);
            if (showMainSettings)
            {
                materialEditor.TexturePropertySingleLine(new GUIContent("Main Texture", "The Main Texture."), _MainTex, _Color);
                if (isCutout)
                {
                    materialEditor.ShaderProperty(_Cutoff, new GUIContent("Cutoff", "The Cutoff Amount"), 2);
                }
                materialEditor.ShaderProperty(_UVSetAlbedo, new GUIContent("UV Set", "The UV set to use for the Albedo Texture"), 2);
                materialEditor.TextureScaleOffsetProperty(_MainTex);
                materialEditor.ShaderProperty(_Saturation, new GUIContent("Saturation", "Controls saturation of the final output from the shader."));
            }

            showShadows = XSStyles.ShurikenFoldout("Shadows", showShadows);
            if (showShadows)
            {
                materialEditor.TexturePropertySingleLine(new GUIContent("Ramp Selection Mask", "A black to white mask that determins how far up on the multi ramp to sample. 0 for bottom, 1 for top, 0.5 for middle, 0.25, and 0.75 for mid bottom and mid top respectively."), _RampSelectionMask);

                if (_RampSelectionMask.textureValue != null)
                {
                    string          rampMaskPath = AssetDatabase.GetAssetPath(_RampSelectionMask.textureValue);
                    TextureImporter ti           = (TextureImporter)TextureImporter.GetAtPath(rampMaskPath);
                    if (ti.sRGBTexture)
                    {
                        if (XSStyles.HelpBoxWithButton(new GUIContent("This texture is not marked as Linear.", "This is recommended for the mask"), new GUIContent("Fix Now")))
                        {
                            ti.sRGBTexture = false;
                            AssetDatabase.ImportAsset(rampMaskPath, ImportAssetOptions.ForceUpdate);
                            AssetDatabase.Refresh();
                        }
                    }
                }

                materialEditor.TexturePropertySingleLine(new GUIContent("Shadow Ramp", "Shadow Ramp, Dark to Light should be Left to Right, or Down to Up"), _Ramp);
                materialEditor.ShaderProperty(_ShadowSharpness, new GUIContent("Shadow Sharpness", "Controls the sharpness of recieved shadows, as well as the sharpness of 'shadows' from Vertex Lighting."));

                GUILayout.Space(5);
                materialEditor.TexturePropertySingleLine(new GUIContent("Occlusion Map", "Occlusion Map, used to darken areas on the model artifically."), _OcclusionMap);
                XSStyles.constrainedShaderProperty(materialEditor, _OcclusionColor, new GUIContent("Occlusion Tint", "Occlusion shadow tint."), 2);
                materialEditor.ShaderProperty(_UVSetOcclusion, new GUIContent("UV Set", "The UV set to use for the Occlusion Texture"), 2);
                materialEditor.TextureScaleOffsetProperty(_OcclusionMap);

                GUILayout.Space(5);
                XSStyles.constrainedShaderProperty(materialEditor, _ShadowRim, new GUIContent("Shadow Rim", "Shadow Rim Color. Set to white to disable."), 0);
                materialEditor.ShaderProperty(_ShadowRimRange, new GUIContent("Range", "Range of the Shadow Rim"), 2);
                materialEditor.ShaderProperty(_ShadowRimThreshold, new GUIContent("Threshold", "Threshold of the Shadow Rim"), 2);
                materialEditor.ShaderProperty(_ShadowRimSharpness, new GUIContent("Sharpness", "Sharpness of the Shadow Rim"), 2);
                XSStyles.callGradientEditor(material);
            }

            if (isOutlined)
            {
                showOutlines = XSStyles.ShurikenFoldout("Outlines", showOutlines);
                if (showOutlines)
                {
                    materialEditor.TexturePropertySingleLine(new GUIContent("Outline Mask", "Outline width mask, black will make the outline minimum width."), _OutlineMask);
                    materialEditor.ShaderProperty(_OutlineWidth, new GUIContent("Outline Width", "Width of the Outlines"));
                    XSStyles.constrainedShaderProperty(materialEditor, _OutlineColor, new GUIContent("Outline Color", "Color of the outlines"), 0);
                }
            }

            showNormalMapSettings = XSStyles.ShurikenFoldout("Normal Maps", showNormalMapSettings);
            if (showNormalMapSettings)
            {
                materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map", "Normal Map"), _BumpMap);
                materialEditor.ShaderProperty(_BumpScale, new GUIContent("Normal Strength", "Strength of the main Normal Map"), 2);
                materialEditor.ShaderProperty(_UVSetNormal, new GUIContent("UV Set", "The UV set to use for the Normal Map"), 2);
                materialEditor.TextureScaleOffsetProperty(_BumpMap);

                GUILayout.Space(5);
                materialEditor.TexturePropertySingleLine(new GUIContent("Detail Normal Map", "Detail Normal Map"), _DetailNormalMap);
                materialEditor.ShaderProperty(_DetailNormalMapScale, new GUIContent("Detail Normal Strength", "Strength of the detail Normal Map"), 2);
                materialEditor.ShaderProperty(_UVSetDetNormal, new GUIContent("UV Set", "The UV set to use for the Detail Normal Map"), 2);
                materialEditor.TextureScaleOffsetProperty(_DetailNormalMap);

                GUILayout.Space(5);
                materialEditor.TexturePropertySingleLine(new GUIContent("Detail Mask", "Mask for Detail Normal Map"), _DetailMask);
                materialEditor.ShaderProperty(_UVSetDetMask, new GUIContent("UV Set", "The UV set to use for the Detail Mask"), 2);
                materialEditor.TextureScaleOffsetProperty(_DetailMask);
            }

            showSpecular = XSStyles.ShurikenFoldout("Specular", showSpecular);
            if (showSpecular)
            {
                materialEditor.ShaderProperty(_SpecMode, new GUIContent("Specular Mode", "Specular Mode."));
                materialEditor.ShaderProperty(_SpecularStyle, new GUIContent("Specular Style", "Specular Style."));
                materialEditor.TexturePropertySingleLine(new GUIContent("Specular Map(R,G,B)", "Specular Map. Red channel controls Intensity, Green controls how much specular is tinted by Albedo, and Blue controls Smoothness (Only for Blinn-Phong, and GGX)."), _SpecularMap);
                materialEditor.TextureScaleOffsetProperty(_SpecularMap);
                materialEditor.ShaderProperty(_UVSetSpecular, new GUIContent("UV Set", "The UV set to use for the Specular Map"), 2);
                materialEditor.ShaderProperty(_SpecularIntensity, new GUIContent("Specular Intensity", "Specular Intensity."), 2);
                materialEditor.ShaderProperty(_SpecularAlbedoTint, new GUIContent("Specular Albedo Tint", "How much the specular highlight should derive color from the albedo of the object."), 2);
                if (_SpecMode.floatValue == 0 || _SpecMode.floatValue == 2)
                {
                    materialEditor.ShaderProperty(_SpecularArea, new GUIContent("Specular Area", "Specular Area."), 2);
                }
                else
                {
                    materialEditor.ShaderProperty(_AnisotropicAX, new GUIContent("Anisotropic Width", "Anisotropic Width, makes anistropic relfections more horizontal"), 2);
                    materialEditor.ShaderProperty(_AnisotropicAY, new GUIContent("Anisotropic Height", "Anisotropic Height, makes anistropic relfections more vertical"), 2);
                }
            }

            showReflection = XSStyles.ShurikenFoldout("Reflections", showReflection);
            if (showReflection)
            {
                materialEditor.ShaderProperty(_ReflectionMode, new GUIContent("Reflection Mode", "Reflection Mode."));

                if (_ReflectionMode.floatValue == 0) // PBR
                {
                    materialEditor.ShaderProperty(_ReflectionBlendMode, new GUIContent("Reflection Blend Mode", "Blend mode for reflection. Additive is Color + reflection, Multiply is Color * reflection, and subtractive is Color - reflection"));
                    materialEditor.ShaderProperty(_ClearCoat, new GUIContent("Clearcoat", "Clearcoat"));
                    materialEditor.TexturePropertySingleLine(new GUIContent("Fallback Cubemap", " Used as fallback in 'Unity' reflection mode if reflection probe is black."), _BakedCubemap);
                    materialEditor.TexturePropertySingleLine(new GUIContent("Metallic Map", "Metallic Map, Metallic on Red Channel, Smoothness on Alpha Channel. \nIf Clearcoat is enabled, Clearcoat Smoothness on Green Channel, Clearcoat Reflectivity on Blue Channel."), _MetallicGlossMap);
                    materialEditor.TextureScaleOffsetProperty(_MetallicGlossMap);
                    materialEditor.ShaderProperty(_UVSetMetallic, new GUIContent("UV Set", "The UV set to use for the Metallic Smoothness Map"), 2);
                    materialEditor.ShaderProperty(_Metallic, new GUIContent("Metallic", "Metallic, set to 1 if using metallic map"), 2);
                    materialEditor.ShaderProperty(_Glossiness, new GUIContent("Smoothness", "Smoothness, set to 1 if using metallic map"), 2);
                    materialEditor.ShaderProperty(_ClearcoatSmoothness, new GUIContent("Clearcoat Smoothness", "Smoothness of the clearcoat."), 2);
                    materialEditor.ShaderProperty(_ClearcoatStrength, new GUIContent("Clearcoat Reflectivity", "The strength of the clearcoat reflection."), 2);
                }
                else if (_ReflectionMode.floatValue == 1) //Baked cube
                {
                    materialEditor.ShaderProperty(_ReflectionBlendMode, new GUIContent("Reflection Blend Mode", "Blend mode for reflection. Additive is Color + reflection, Multiply is Color * reflection, and subtractive is Color - reflection"));
                    materialEditor.ShaderProperty(_ClearCoat, new GUIContent("Clearcoat", "Clearcoat"));
                    materialEditor.TexturePropertySingleLine(new GUIContent("Baked Cubemap", "Baked cubemap."), _BakedCubemap);
                    materialEditor.TexturePropertySingleLine(new GUIContent("Metallic Map", "Metallic Map, Metallic on Red Channel, Smoothness on Alpha Channel. \nIf Clearcoat is enabled, Clearcoat Smoothness on Green Channel, Clearcoat Reflectivity on Blue Channel."), _MetallicGlossMap);
                    materialEditor.TextureScaleOffsetProperty(_MetallicGlossMap);
                    materialEditor.ShaderProperty(_UVSetMetallic, new GUIContent("UV Set", "The UV set to use for the MetallicSmoothness Map"), 2);
                    materialEditor.ShaderProperty(_Metallic, new GUIContent("Metallic", "Metallic, set to 1 if using metallic map"), 2);
                    materialEditor.ShaderProperty(_Glossiness, new GUIContent("Smoothness", "Smoothness, set to 1 if using metallic map"), 2);
                    materialEditor.ShaderProperty(_ClearcoatSmoothness, new GUIContent("Clearcoat Smoothness", "Smoothness of the clearcoat."), 2);
                    materialEditor.ShaderProperty(_ClearcoatStrength, new GUIContent("Clearcoat Reflectivity", "The strength of the clearcoat reflection."), 2);
                }
                else if (_ReflectionMode.floatValue == 2) //Matcap
                {
                    materialEditor.ShaderProperty(_ReflectionBlendMode, new GUIContent("Reflection Blend Mode", "Blend mode for reflection. Additive is Color + reflection, Multiply is Color * reflection, and subtractive is Color - reflection"));
                    materialEditor.TexturePropertySingleLine(new GUIContent("Matcap", "Matcap Texture"), _Matcap, _MatcapTint);
                    materialEditor.ShaderProperty(_Glossiness, new GUIContent("Matcap Blur", "Matcap blur, blurs the Matcap, set to 1 for full clarity"), 2);
                    material.SetFloat("_Metallic", 0);
                    material.SetFloat("_ClearCoat", 0);
                    material.SetTexture("_MetallicGlossMap", null);
                }
                if (_ReflectionMode.floatValue != 3)
                {
                    materialEditor.TexturePropertySingleLine(new GUIContent("Reflectivity Mask", "Mask for reflections."), _ReflectivityMask);
                    materialEditor.TextureScaleOffsetProperty(_ReflectivityMask);
                    materialEditor.ShaderProperty(_UVSetReflectivity, new GUIContent("UV Set", "The UV set to use for the Reflectivity Mask"), 2);
                    materialEditor.ShaderProperty(_Reflectivity, new GUIContent("Reflectivity", "The strength of the reflections."), 2);
                }
                if (_ReflectionMode.floatValue == 3)
                {
                    material.SetFloat("_Metallic", 0);
                    material.SetFloat("_ReflectionBlendMode", 0);
                    material.SetFloat("_ClearCoat", 0);
                }
            }

            showEmission = XSStyles.ShurikenFoldout("Emission", showEmission);
            if (showEmission)
            {
                materialEditor.TexturePropertySingleLine(new GUIContent("Emission Map", "Emissive map. White to black, unless you want multiple colors."), _EmissionMap, _EmissionColor);
                materialEditor.TextureScaleOffsetProperty(_EmissionMap);
                materialEditor.ShaderProperty(_UVSetEmission, new GUIContent("UV Set", "The UV set to use for the Emission Map"), 2);
                materialEditor.ShaderProperty(_EmissionToDiffuse, new GUIContent("Tint To Diffuse", "Tints the emission to the Diffuse Color"), 2);

                GUILayout.Space(5);
                materialEditor.ShaderProperty(_ScaleWithLight, new GUIContent("Scale w/ Light", "Scales the emission intensity based on how dark or bright the environment is."));
                if (_ScaleWithLight.floatValue == 0)
                {
                    materialEditor.ShaderProperty(_ScaleWithLightSensitivity, new GUIContent("Scaling Sensitivity", "How agressively the emission should scale with the light."));
                }
            }

            showRimlight = XSStyles.ShurikenFoldout("Rimlight", showRimlight);
            if (showRimlight)
            {
                materialEditor.ShaderProperty(_RimColor, new GUIContent("Rimlight Tint", "The Tint of the Rimlight."));
                materialEditor.ShaderProperty(_RimIntensity, new GUIContent("Rimlight Intensity", "Strength of the Rimlight."));
                materialEditor.ShaderProperty(_RimRange, new GUIContent("Range", "Range of the Rim"), 2);
                materialEditor.ShaderProperty(_RimThreshold, new GUIContent("Threshold", "Threshold of the Rim"), 2);
                materialEditor.ShaderProperty(_RimSharpness, new GUIContent("Sharpness", "Sharpness of the Rim"), 2);
            }

            showSubsurface = XSStyles.ShurikenFoldout("Subsurface Scattering", showSubsurface);
            if (showSubsurface)
            {
                materialEditor.TexturePropertySingleLine(new GUIContent("Thickness Map", "Thickness Map, used to mask areas where subsurface can happen"), _ThicknessMap);
                materialEditor.TextureScaleOffsetProperty(_ThicknessMap);
                materialEditor.ShaderProperty(_UVSetThickness, new GUIContent("UV Set", "The UV set to use for the Thickness Map"), 2);

                XSStyles.constrainedShaderProperty(materialEditor, _SSColor, new GUIContent("Subsurface Color", "Subsurface Scattering Color"), 2);
                materialEditor.ShaderProperty(_SSDistortion, new GUIContent("Subsurface Distortion", "How much the subsurface follows the normals of the mesh, Normal map."), 2);
                materialEditor.ShaderProperty(_SSPower, new GUIContent("Subsurface Power", "Subsurface Power"), 2);
                materialEditor.ShaderProperty(_SSScale, new GUIContent("Subsurface Scale", "Subsurface Scale"), 2);
                materialEditor.ShaderProperty(_SSSRange, new GUIContent("Subsurface Range", "Subsurface Range"), 2);
                materialEditor.ShaderProperty(_SSSSharpness, new GUIContent("Subsurface Sharpness", "Subsurface Sharpness"), 2);
            }

            if (_AdvMode.floatValue == 1)
            {
                showAdvanced = XSStyles.ShurikenFoldout("Advanced Settings", showAdvanced);
                if (showAdvanced)
                {
                    materialEditor.ShaderProperty(_Stencil, _Stencil.displayName);
                    materialEditor.ShaderProperty(_StencilComp, _StencilComp.displayName);
                    materialEditor.ShaderProperty(_StencilOp, _StencilOp.displayName);
                }
            }

            XSStyles.DoFooter();
        }
    }
    public void OnGUI()
    {
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

        GUILayout.BeginHorizontal();
        GUILayout.Space(105);
        XSStyles.doLabel("1");
        GUILayout.Space(105);
        XSStyles.doLabel("2");
        GUILayout.Space(105);
        XSStyles.doLabel("3");
        GUILayout.Space(105);
        XSStyles.doLabel("4");
        GUILayout.EndHorizontal();

        XSStyles.SeparatorThin();
        GUILayout.BeginHorizontal();
        for (int i = 0; i < 4; i++)
        {
            EditorGUIUtility.labelWidth = 0.01f;
            textures[i] = (Texture2D)EditorGUILayout.ObjectField(new GUIContent("", ""), textures[i], typeof(Texture2D), true);
        }
        GUILayout.EndHorizontal();

        float oldLabelWidth = EditorGUIUtility.labelWidth;

        EditorGUIUtility.labelWidth = 40;
        GUIStyle headerStyle = EditorStyles.boldLabel;

        headerStyle.alignment    = TextAnchor.UpperLeft;
        headerStyle.fontStyle    = FontStyle.Bold;
        headerStyle.stretchWidth = true;

        XSStyles.SeparatorThin();
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Output Channel:", headerStyle);

        GUILayout.Label("R", headerStyle);
        GUILayout.Label("G", headerStyle);
        GUILayout.Label("B", headerStyle);
        GUILayout.Label("A", headerStyle);
        EditorGUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Src Texture:");
        GUILayout.Space(20);
        for (int i = 0; i < 4; i++)
        {
            pickTexture[i] = (ETextures)EditorGUILayout.EnumPopup("", pickTexture[i]);
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Src Channel:");
        GUILayout.Space(17);
        for (int i = 0; i < 4; i++)
        {
            texChannels[i] = (EChannels)EditorGUILayout.EnumPopup("", texChannels[i]);
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.Label("Invert Channel:");
        for (int i = 0; i < 4; i++)
        {
            invertChannel[i] = EditorGUILayout.Toggle("", invertChannel[i]);
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(20);
        EditorGUILayout.EndScrollView();

        //Button and Resolution
        GUILayout.BeginVertical();
        XSStyles.doLabel("Resolution");

        GUILayout.BeginHorizontal();
        GUILayout.Space(175);
        res = (resolutions)EditorGUILayout.EnumPopup("", res);
        GUILayout.Space(175);
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Merge Channels"))
        {
            //Set target textures to be ReadWriteable

            for (int i = 0; i < textures.Length; i++)
            {
                if (textures[i] == null)
                {
                    break;
                }

                string          texturePath = AssetDatabase.GetAssetPath(textures[i]);
                TextureImporter texture     = (TextureImporter)TextureImporter.GetAtPath(texturePath);
                if (texture != null)
                {
                    texture.isReadable = true;
                    texture.SaveAndReimport();
                }
            }

            switch (res)
            {
            case resolutions.Tiny_256x256:
                resolution = 256;
                break;

            case resolutions.Small_512x512:
                resolution = 512;
                break;

            case resolutions.Medium_1024x1024:
                resolution = 1024;
                break;

            case resolutions.Large_2048x2048:
                resolution = 2048;
                break;

            case resolutions.VeryLarge_4096x4096:
                resolution = 4096;
                break;

            case resolutions.Why_8192x8192:
                resolution = 8192;
                break;
            }

            XSStyles.findAssetPath(finalFilePath);
            finalFilePath = EditorUtility.SaveFilePanel("Save Merged Texture", finalFilePath + "/Textures/", "mergedTex.png", "png");

            Texture2D newTexture = new Texture2D(resolution, resolution, TextureFormat.RGBA32, false);

            //Get Colors textures and write them to the proper channel

            for (int y = 0; y < resolution; y++)
            {
                for (int x = 0; x < resolution; x++)
                {
                    float u = x / (float)resolution;
                    float v = y / (float)resolution;

                    // Grab out the texture values into an array for later lookup. Could probably just be done at the moment the texture color is needed.
                    for (int i = 0; i < textures.Length; i++)
                    {
                        if (textures[i] != null)
                        {
                            texColors[i] = textures[i].GetPixelBilinear(u, v);
                        }
                        else
                        {
                            texColors[i] = new Color(0, 0, 0, 1);
                        }
                    }

                    Color outputColor = new Color(0, 0, 0, 1);

                    // Iterate the output RGBA channels
                    for (int i = 0; i < 4; i++)
                    {
                        // Convert the enums to indices we can use. 'None' will turn into -1 which will be discarded as invalid.
                        int srcTexIdx     = ((int)pickTexture[i]) - 1;
                        int srcChannelIdx = ((int)texChannels[i]) - 1;

                        // Go through each channel in the output color and assign it
                        if (srcTexIdx >= 0 && srcChannelIdx >= 0)
                        {
                            outputColor[i] = texColors[srcTexIdx][srcChannelIdx];

                            //Allow you to invert specific channels.
                            if (invertChannel[i])
                            {
                                outputColor[i] = 1f - outputColor[i];
                            }
                        }
                    }

                    newTexture.SetPixel(x, y, outputColor);
                }
            }
            newTexture.Apply();
            ExportTexture(newTexture);
        }

        GUILayout.Space(10);
        GUILayout.EndVertical();

        EditorGUIUtility.labelWidth = oldLabelWidth;
    }
Exemplo n.º 25
0
    public void OnGUI()
    {
        changed = false;
        if (focusedMat != null)
        {
            XSStyles.ShurikenHeader("Current Material: " + focusedMat.name);
        }
        else
        {
            XSStyles.ShurikenHeader("Current Material: None");
        }

        if (preButton == null)
        {
            iconToolbarPlus  = EditorGUIUtility.IconContent("Toolbar Plus", "Add Gradient");
            iconToolbarMinus = EditorGUIUtility.IconContent("Toolbar Minus", "Remove Gradient");
            preButton        = new GUIStyle("RL FooterButton");
            buttonBackground = new GUIStyle("RL Header");
        }

        if (gradients.Count == 0)
        {
            gradients.Add(new Gradient());
            gradients.Add(new Gradient());
            gradients.Add(new Gradient());
            gradients.Add(new Gradient());
            gradients.Add(new Gradient());
        }

        if (grad_index_reorderable == null)
        {
            makeReorderedList();
        }

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        Rect  r         = EditorGUILayout.GetControlRect();
        float rightEdge = r.xMax;
        float leftEdge  = rightEdge - 48f;

        r = new Rect(leftEdge, r.y, rightEdge - leftEdge, r.height);
        if (Event.current.type == EventType.Repaint)
        {
            buttonBackground.Draw(r, false, false, false, false);
        }
        leftEdge += 18f;
        EditorGUI.BeginDisabledGroup(gradients_index.Count == 5);
        bool addE = GUI.Button(new Rect(leftEdge + 4, r.y, 25, 13), iconToolbarPlus, preButton);

        EditorGUI.EndDisabledGroup();
        EditorGUI.BeginDisabledGroup(gradients_index.Count == 1);
        bool removeE = GUI.Button(new Rect(leftEdge - 19, r.y, 25, 13), iconToolbarMinus, preButton);

        EditorGUI.EndDisabledGroup();

        if (addE)
        {
            grad_index_reorderable.index++;
            int wat = 0;
            for (int i = 0; i < 5; i++)
            {
                if (!gradients_index.Contains(i))
                {
                    wat = i;
                    break;
                }
            }
            gradients_index.Add(wat);
            changed = true;
        }
        if (removeE)
        {
            gradients_index.Remove(gradients_index[gradients_index.Count - 1]);
            grad_index_reorderable.index--;
            changed = true;
        }

        GUIStyle button = new GUIStyle(EditorStyles.miniButton);

        button.normal = !reorder ? EditorStyles.miniButton.normal : EditorStyles.miniButton.onNormal;
        if (GUILayout.Button(new GUIContent("Reorder", "Don't use Reorder if you want to undo a gradient change"), button, GUILayout.ExpandWidth(false)))
        {
            reorder = !reorder;
        }
        GUILayout.EndHorizontal();

        SerializedObject serializedObject = new SerializedObject(this);

        if (reorder)
        {
            grad_index_reorderable.DoLayoutList();
        }
        else
        {
            SerializedProperty colorGradients = serializedObject.FindProperty("gradients");
            if (colorGradients.arraySize == 5)
            {
                for (int i = 0; i < gradients_index.Count; i++)
                {
                    Rect _r = EditorGUILayout.GetControlRect();
                    _r.x      += 16f;
                    _r.width  -= 2f + 16f;
                    _r.height += 5f;
                    _r.y      += 2f + (3f * i);
                    EditorGUI.PropertyField(_r, colorGradients.GetArrayElementAtIndex(gradients_index[i]), new GUIContent(""));
                }
                GUILayout.Space(Mathf.Lerp(9f, 24f, gradients_index.Count / 5f));
            }
        }
        if (serializedObject.ApplyModifiedProperties())
        {
            changed = true;
        }

        if (oldFocusedMat != focusedMat)
        {
            changed = true;
            if (this.oldTexture != null)
            {
                if (this.oldTexture == EditorGUIUtility.whiteTexture)
                {
                    this.oldTexture = null;
                }
                oldFocusedMat.SetTexture(rampProperty, this.oldTexture);
                this.oldTexture = null;
            }
            oldFocusedMat = focusedMat;
        }

        Resolutions oldRes = res;

        res = (Resolutions)EditorGUILayout.EnumPopup("Resolution: ", res);
        if (oldRes != res)
        {
            changed = true;
        }

        int width  = (int)res;
        int height = 30;

        if (gradients_index.Count == 1)
        {
            height = 8;
        }
        else
        {
            height = 150;
        }
        if (tex == null)
        {
            tex = new Texture2D(width, height, TextureFormat.RGBA32, false);
        }

        bool old_isLinear = isLinear;

        drawAdvancedOptions();
        if (old_isLinear != isLinear)
        {
            changed = true;
        }

        if (manualMaterial)
        {
            focusedMat = (Material)EditorGUILayout.ObjectField(new GUIContent("", ""), focusedMat, typeof(Material), true);
        }

        if (focusedMat != null)
        {
            if (focusedMat.HasProperty("_Ramp"))
            {
                rampProperty = "_Ramp";
            }
            else
            {
                rampProperty = EditorGUILayout.TextField("Ramp Property Name", rampProperty);
                if (!focusedMat.HasProperty(rampProperty))
                {
                    GUILayout.Label("Property not found!");
                }
            }
        }

        if (changed)
        {
            updateTexture(width, height);
            if (focusedMat != null)
            {
                if (focusedMat.HasProperty(rampProperty))
                {
                    if (this.oldTexture == null)
                    {
                        if (focusedMat.GetTexture(rampProperty) == null)
                        {
                            this.oldTexture = EditorGUIUtility.whiteTexture;
                        }
                        else
                        {
                            this.oldTexture = focusedMat.GetTexture(rampProperty);
                        }
                    }
                    tex.wrapMode = TextureWrapMode.Clamp;
                    tex.Apply(false, false);
                    focusedMat.SetTexture(rampProperty, tex);
                }
            }
        }

        XSStyles.Separator();
        drawMGInputOutput();


        if (GUILayout.Button("Save Ramp"))
        {
            finalFilePath = XSStyles.findAssetPath(finalFilePath);
            string path = EditorUtility.SaveFilePanel("Save Ramp as PNG", finalFilePath + "/Textures/Shadow Ramps/Generated", "gradient", "png");
            if (path.Length != 0)
            {
                updateTexture(width, height);
                bool success = GenTexture(tex, path);
                if (success)
                {
                    if (focusedMat != null)
                    {
                        string  s    = path.Substring(path.IndexOf("Assets"));
                        Texture ramp = AssetDatabase.LoadAssetAtPath <Texture>(s);
                        if (ramp != null)
                        {
                            focusedMat.SetTexture(rampProperty, ramp);
                            this.oldTexture = null;
                        }
                    }
                }
            }
        }
        drawHelpText();
    }
Exemplo n.º 26
0
    public void OnGUI()
    {
        if (gradient == null)
        {
            gradient = new Gradient();
        }
        EditorGUI.BeginChangeCheck();
        SerializedObject   serializedGradient = new SerializedObject(this);
        SerializedProperty colorGradient      = serializedGradient.FindProperty("gradient");

        EditorGUILayout.PropertyField(colorGradient, true, null);
        serializedGradient.ApplyModifiedProperties();

        int width  = 128;
        int height = 8;

        res = (resolutions)EditorGUILayout.EnumPopup("Resolution: ", res);

        switch (res)
        {
        case resolutions.Large512x8:
            width = 512;
            break;

        case resolutions.Medium256x8:
            width = 256;
            break;

        case resolutions.Small128x8:
            width = 128;
            break;

        case resolutions.Tiny64x8:
            width = 64;
            break;
        }

        if (gradient != null)
        {
            Texture2D tex = new Texture2D(width, height, TextureFormat.RGBA32, false);


            for (int y = 0; y < tex.height; y++)
            {
                for (int x = 0; x < tex.width; x++)
                {
                    tex.SetPixel(x, y, gradient.Evaluate((float)x / (float)width));
                }
            }


            XSStyles.Separator();
            if (GUILayout.Button("Save Ramp"))
            {
                XSStyles.findAssetPath(finalFilePath);
                string path = EditorUtility.SaveFilePanel("Save Ramp as PNG", finalFilePath + "/Textures/Shadow Ramps/Generated", "gradient.png", "png");
                if (path.Length != 0)
                {
                    GenTexture(tex, path);
                }
            }
        }

        XSStyles.HelpBox("You can use this to create a custom shadow ramp. \nYou must save the asset with the save button to apply changes. \n\n - Click the Gradient box. \n - Choose resolution. \n - Save. \n - Drag texture into slot.", MessageType.Info);
    }
Exemplo n.º 27
0
    public void OnGUI()
    {
        tab = GUILayout.Toolbar(tab, new string[] { "Documentation", "Updater", "Social" });
        XSStyles.SeparatorThin();
        switch (tab)
        {
        case 0:
            //show Docs from git
            XSStyles.doLabel("You can find Documentation here.");
            if (GUILayout.Button("Open Documentation"))
            {
                Application.OpenURL(docsURL);
            }

            break;

        case 1:
            EditorGUI.BeginChangeCheck();

            XSStyles.HelpBox("The currently installed version is: v" + XSStyles.ver + "\n\nTo check for updates, use the update button. If you choose to download an update, you will need to manually overwrite the old install by extracting the .zip into the project using the windows explorer. \n\nDo not drag the update directly into Unity - it won't ask to overwrite - it'll just create a duplicate and break.", MessageType.Info);
            XSStyles.SeparatorThin();
            if (GUILayout.Button("Check for Updates"))
            {
                req(updateUrl);
                EditorApplication.update += changelogEditorUpdate;
                showInfo = true;
            }

            if (showInfo)
            {
                scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
                Repaint();
                XSStyles.doLabelLeft("Newest version: ");
                XSStyles.doLabelSmall(curVer);
                XSStyles.SeparatorThin();

                XSStyles.doLabelLeft("Release Date: ");
                XSStyles.doLabelSmall(publishdate);
                XSStyles.SeparatorThin();

                XSStyles.doLabelLeft("Changelog: ");
                XSStyles.doLabelSmall(changelog);

                EditorGUILayout.EndScrollView();
                XSStyles.SeparatorThin();
                if (GUILayout.Button("Download"))
                {
                    Application.OpenURL(downloadLink);
                }
            }
            else
            {
                XSStyles.doLabel("Hit 'Check for Updates' to begin");
            }
            EditorGUI.EndChangeCheck();

            break;

        case 2:
            //show Patrons

            XSStyles.doLabel("Thank you to my patreon supporters, and the people who have helped me along the way, you guys are great!\n Note: You must be in the Discord server to show on this list.");
            XSStyles.SeparatorThin();
            XSStyles.doLabel("Current Patrons");
            XSStyles.SeparatorThin();
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
            if (!hasCalledPatronlist)
            {
                hasCalledPatronlist = true;
                req(patronsURL);
                EditorApplication.update += EditorUpdate;
            }
            for (int i = 0; i < patrons.Length; i++)
            {
                XSStyles.doLabel(" - " + patrons[i]);
            }
            EditorGUILayout.EndScrollView();

            XSStyles.SeparatorThin();
            //show social links
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            XSStyles.discordButton(70, 30);
            XSStyles.patreonButton(70, 30);
            XSStyles.githubButton(70, 30);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            break;
        }
    }
Exemplo n.º 28
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
    {
        Material material = materialEditor.target as Material;
        Shader   shader   = material.shader;

        isCutout   = shader.name.Contains("Cutout") && !shader.name.Contains("A2C");
        isOutlined = shader.name.Contains("Outline");

        //Find all material properties listed in the script using reflection, and set them using a loop only if they're of type MaterialProperty.
        //This makes things a lot nicer to maintain and cleaner to look at.
        foreach (var property in GetType().GetFields(bindingFlags))
        {
            if (property.FieldType == typeof(MaterialProperty))
            {
                property.SetValue(this, FindProperty(property.Name, props));
            }
        }

        EditorGUI.BeginChangeCheck();
        {
            if (!isCutout)            // Do this to make sure that if you're using AlphaToCoverage that you fallback to cutout with 0.5 Cutoff if your shaders are blocked.
            {
                material.SetFloat("_Cutoff", 0.5f);
            }

            XSStyles.ShurikenHeaderCentered("XSToon v" + XSStyles.ver);

            showMainSettings = XSStyles.ShurikenFoldout("Main Settings", showMainSettings);
            if (showMainSettings)
            {
                materialEditor.TexturePropertySingleLine(new GUIContent("Main Texture", "The Main Texture."), _MainTex, _Color);
                if (isCutout)
                {
                    materialEditor.ShaderProperty(_Cutoff, new GUIContent("Cutoff", "The Cutoff Amount"), 2);
                }
                materialEditor.ShaderProperty(_UVSetAlbedo, new GUIContent("UV Set", "The UV set to use for the Albedo Texture"), 2);
                materialEditor.TextureScaleOffsetProperty(_MainTex);
                materialEditor.ShaderProperty(_Saturation, new GUIContent("Saturation", "Controls saturation of the final output from the shader."));
                materialEditor.ShaderProperty(_Culling, _Culling.displayName);
                materialEditor.ShaderProperty(_AdvMode, "Shader Mode");
            }

            showShadows = XSStyles.ShurikenFoldout("Shadows", showShadows);
            if (showShadows)
            {
                materialEditor.TexturePropertySingleLine(new GUIContent("Shadow Ramp", "Shadow Ramp, Dark to Light should be Left to Right, or Down to Up"), _Ramp);
                materialEditor.ShaderProperty(_ShadowSharpness, new GUIContent("Shadow Sharpness", "Only affects recieved shadows and self shadows. Does not affect shadow ramp. You need a realtime directional light with shadows to see changes from this!"));

                GUILayout.Space(5);
                materialEditor.TexturePropertySingleLine(new GUIContent("Occlusion Map", "Occlusion Map, used to darken areas on the model artifically."), _OcclusionMap);
                XSStyles.constrainedShaderProperty(materialEditor, _OcclusionColor, new GUIContent("Occlusion Tint", "Occlusion shadow tint."), 2);
                materialEditor.ShaderProperty(_UVSetOcclusion, new GUIContent("UV Set", "The UV set to use for the Occlusion Texture"), 2);

                GUILayout.Space(5);
                XSStyles.constrainedShaderProperty(materialEditor, _ShadowRim, new GUIContent("Shadow Rim", "Shadow Rim Color. Set to white to disable."), 0);
                materialEditor.ShaderProperty(_ShadowRimRange, new GUIContent("Range", "Range of the Shadow Rim"), 2);
                materialEditor.ShaderProperty(_ShadowRimThreshold, new GUIContent("Threshold", "Threshold of the Shadow Rim"), 2);
                materialEditor.ShaderProperty(_ShadowRimSharpness, new GUIContent("Sharpness", "Sharpness of the Shadow Rim"), 2);
                XSStyles.callGradientEditor(material);
            }

            if (isOutlined)
            {
                showOutlines = XSStyles.ShurikenFoldout("Outlines", showOutlines);
                if (showOutlines)
                {
                    materialEditor.TexturePropertySingleLine(new GUIContent("Outline Mask", "Outline width mask, black will make the outline minimum width."), _OutlineMask);
                    materialEditor.ShaderProperty(_OutlineWidth, new GUIContent("Outline Width", "Width of the Outlines"));
                    XSStyles.constrainedShaderProperty(materialEditor, _OutlineColor, new GUIContent("Outline Color", "Color of the outlines"), 0);
                }
            }

            showNormalMapSettings = XSStyles.ShurikenFoldout("Normal Maps", showNormalMapSettings);
            if (showNormalMapSettings)
            {
                materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map", "Normal Map"), _BumpMap);
                materialEditor.ShaderProperty(_BumpScale, new GUIContent("Normal Strength", "Strength of the main Normal Map"), 2);
                materialEditor.ShaderProperty(_UVSetNormal, new GUIContent("UV Set", "The UV set to use for the Normal Map"), 2);
                materialEditor.TextureScaleOffsetProperty(_BumpMap);

                GUILayout.Space(5);
                materialEditor.TexturePropertySingleLine(new GUIContent("Detail Normal Map", "Detail Normal Map"), _DetailNormalMap);
                materialEditor.ShaderProperty(_DetailNormalMapScale, new GUIContent("Detail Normal Strength", "Strength of the detail Normal Map"), 2);
                materialEditor.ShaderProperty(_UVSetDetNormal, new GUIContent("UV Set", "The UV set to use for the Detail Normal Map"), 2);
                materialEditor.TextureScaleOffsetProperty(_DetailNormalMap);

                GUILayout.Space(5);
                materialEditor.TexturePropertySingleLine(new GUIContent("Detail Mask", "Mask for Detail Normal Map"), _DetailMask);
                materialEditor.ShaderProperty(_UVSetDetMask, new GUIContent("UV Set", "The UV set to use for the Detail Mask"), 2);
                materialEditor.TextureScaleOffsetProperty(_DetailMask);
            }

            showSpecular = XSStyles.ShurikenFoldout("Specular", showSpecular);
            if (showSpecular)
            {
                materialEditor.ShaderProperty(_SpecMode, new GUIContent("Specular Mode", "Specular Mode."));
                materialEditor.ShaderProperty(_SpecularStyle, new GUIContent("Specular Style", "Specular Style."));
                materialEditor.TexturePropertySingleLine(new GUIContent("Specular Map(R,G,B)", "Specular Map. Red channel controls Intensity, Green controls how much specular is tinted by Albedo, and Blue controls Smoothness (Only for Blinn-Phong, and GGX)."), _SpecularMap);
                materialEditor.TextureScaleOffsetProperty(_SpecularMap);
                materialEditor.ShaderProperty(_UVSetSpecular, new GUIContent("UV Set", "The UV set to use for the Specular Map"), 2);
                materialEditor.ShaderProperty(_SpecularIntensity, new GUIContent("Specular Intensity", "Specular Intensity."), 2);
                materialEditor.ShaderProperty(_SpecularAlbedoTint, new GUIContent("Specular Albedo Tint", "How much the specular highlight should derive color from the albedo of the object."), 2);
                if (_SpecMode.floatValue == 0 || _SpecMode.floatValue == 2)
                {
                    materialEditor.ShaderProperty(_SpecularArea, new GUIContent("Specular Area", "Specular Area."), 2);
                }
                else
                {
                    materialEditor.ShaderProperty(_AnisotropicAX, new GUIContent("Anisotropic Width", "Anisotropic Width"), 2);
                    materialEditor.ShaderProperty(_AnisotropicAY, new GUIContent("Anisotropic Height", "Anisotropic Height"), 2);
                }
            }

            showReflection = XSStyles.ShurikenFoldout("Reflections", showReflection);
            if (showReflection)
            {
                materialEditor.ShaderProperty(_ReflectionMode, new GUIContent("Reflection Mode", "Reflection Mode."));
                if (_ReflectionMode.floatValue == 0)                 // PBR
                {
                    materialEditor.ShaderProperty(_ReflectionBlendMode, new GUIContent("Reflection Blend Mode", "Blend mode for reflection. Additive is Color + reflection, Multiply is Color * reflection, and subtractive is Color - reflection"));
                    materialEditor.TexturePropertySingleLine(new GUIContent("Fallback Cubemap", " Used as fallback in 'Unity' reflection mode if reflection probe is black."), _BakedCubemap);
                    materialEditor.TexturePropertySingleLine(new GUIContent("Metallic Map", "Metallic Map, Metallic on Red Channel, Smoothness on Alpha Channel"), _MetallicGlossMap);
                    materialEditor.TextureScaleOffsetProperty(_MetallicGlossMap);
                    materialEditor.ShaderProperty(_UVSetMetallic, new GUIContent("UV Set", "The UV set to use for the MetallicSmoothness Map"), 2);
                    materialEditor.ShaderProperty(_Metallic, new GUIContent("Metallic", "Metallic, set to 1 if using metallic map"), 2);
                    materialEditor.ShaderProperty(_Glossiness, new GUIContent("Smoothness", "Smoothness, set to 1 if using metallic map"), 2);
                }
                else if (_ReflectionMode.floatValue == 1)                 //Baked cube
                {
                    materialEditor.ShaderProperty(_ReflectionBlendMode, new GUIContent("Reflection Blend Mode", "Blend mode for reflection. Additive is Color + reflection, Multiply is Color * reflection, and subtractive is Color - reflection"));
                    materialEditor.TexturePropertySingleLine(new GUIContent("Baked Cubemap", "Baked cubemap."), _BakedCubemap);
                    materialEditor.TexturePropertySingleLine(new GUIContent("Metallic Map", "Metallic Map, Metallic on Red Channel, Smoothness on Alpha Channel"), _MetallicGlossMap);
                    materialEditor.TextureScaleOffsetProperty(_MetallicGlossMap);
                    materialEditor.ShaderProperty(_UVSetMetallic, new GUIContent("UV Set", "The UV set to use for the MetallicSmoothness Map"), 2);
                    materialEditor.ShaderProperty(_Metallic, new GUIContent("Metallic", "Metallic, set to 1 if using metallic map"), 2);
                    materialEditor.ShaderProperty(_Glossiness, new GUIContent("Smoothness", "Smoothness, set to 1 if using metallic map"), 2);
                }
                else if (_ReflectionMode.floatValue == 2)                 //Matcap
                {
                    materialEditor.ShaderProperty(_ReflectionBlendMode, new GUIContent("Reflection Blend Mode", "Blend mode for reflection. Additive is Color + reflection, Multiply is Color * reflection, and subtractive is Color - reflection"));
                    materialEditor.TexturePropertySingleLine(new GUIContent("Matcap", "Matcap Texture"), _Matcap);
                    materialEditor.ShaderProperty(_Glossiness, new GUIContent("Matcap Blur", "Matcap blur, blurs the Matcap, set to 1 for full clarity"), 2);
                    material.SetFloat("_Metallic", 0);
                    material.SetTexture("_MetallicGlossMap", null);
                }
                if (_ReflectionMode.floatValue != 3)
                {
                    materialEditor.TexturePropertySingleLine(new GUIContent("Reflectivity Mask", "Mask for reflections."), _ReflectivityMask);
                    materialEditor.TextureScaleOffsetProperty(_ReflectivityMask);
                    materialEditor.ShaderProperty(_UVSetReflectivity, new GUIContent("UV Set", "The UV set to use for the Reflectivity Mask"), 2);
                    materialEditor.ShaderProperty(_Reflectivity, new GUIContent("Reflectivity", "The strength of the reflections."), 2);
                }
                if (_ReflectionMode.floatValue == 3)
                {
                    material.SetFloat("_Metallic", 0);
                    material.SetFloat("_ReflectionBlendMode", 0);
                }
            }

            showEmission = XSStyles.ShurikenFoldout("Emission", showEmission);
            if (showEmission)
            {
                materialEditor.TexturePropertySingleLine(new GUIContent("Emission Map", "Emissive map. White to black, unless you want multiple colors."), _EmissionMap, _EmissionColor);
                materialEditor.ShaderProperty(_UVSetEmission, new GUIContent("UV Set", "The UV set to use for the Emission Map"), 2);
                materialEditor.TextureScaleOffsetProperty(_EmissionMap);
            }

            showRimlight = XSStyles.ShurikenFoldout("Rimlight", showRimlight);
            if (showRimlight)
            {
                materialEditor.ShaderProperty(_RimIntensity, new GUIContent("Rimlight Intensity", "Strnegth of the Rimlight."));
                materialEditor.ShaderProperty(_RimRange, new GUIContent("Range", "Range of the Rim"), 2);
                materialEditor.ShaderProperty(_RimThreshold, new GUIContent("Threshold", "Threshold of the Rim"), 2);
                materialEditor.ShaderProperty(_RimSharpness, new GUIContent("Sharpness", "Sharpness of the Rim"), 2);
            }

            showSubsurface = XSStyles.ShurikenFoldout("Subsurface Scattering", showSubsurface);
            if (showSubsurface)
            {
                materialEditor.TexturePropertySingleLine(new GUIContent("Thickness Map", "Thickness Map, used to mask areas where subsurface can happen"), _ThicknessMap);
                materialEditor.TextureScaleOffsetProperty(_ThicknessMap);
                materialEditor.ShaderProperty(_UVSetThickness, new GUIContent("UV Set", "The UV set to use for the Thickness Map"), 2);

                XSStyles.constrainedShaderProperty(materialEditor, _SSColor, new GUIContent("Subsurface Color", "Subsurface Scattering Color"), 2);
                materialEditor.ShaderProperty(_SSDistortion, new GUIContent("Subsurface Distortion", "How much the subsurface follows the normals of the mesh, Normal map."), 2);
                materialEditor.ShaderProperty(_SSPower, new GUIContent("Subsurface Power", "Subsurface Power"), 2);
                materialEditor.ShaderProperty(_SSScale, new GUIContent("Subsurface Scale", "Subsurface Scale"), 2);
                materialEditor.ShaderProperty(_SSSRange, new GUIContent("Subsurface Range", "Subsurface Range"), 2);
                materialEditor.ShaderProperty(_SSSSharpness, new GUIContent("Subsurface Sharpness", "Subsurface Sharpness"), 2);
            }

            if (_AdvMode.floatValue == 1)
            {
                showAdvanced = XSStyles.ShurikenFoldout("Advanced Settings", showAdvanced);
                if (showAdvanced)
                {
                    materialEditor.ShaderProperty(_Stencil, _Stencil.displayName);
                    materialEditor.ShaderProperty(_StencilComp, _StencilComp.displayName);
                    materialEditor.ShaderProperty(_StencilOp, _StencilOp.displayName);
                }
            }

            XSStyles.DoFooter();
        }
    }
Exemplo n.º 29
0
    private void DrawReflectionsSettings(MaterialEditor materialEditor, Material material)
    {
        showReflection = XSStyles.ShurikenFoldout("Reflections", showReflection);
        if (showReflection)
        {
            materialEditor.ShaderProperty(_ReflectionMode, new GUIContent("Reflection Mode", "Reflection Mode."));

            if (_ReflectionMode.floatValue == 0) // PBR
            {
                materialEditor.ShaderProperty(_ReflectionBlendMode, new GUIContent("Reflection Blend Mode", "Blend mode for reflection. Additive is Color + reflection, Multiply is Color * reflection, and subtractive is Color - reflection"));
                materialEditor.ShaderProperty(_ClearCoat, new GUIContent("Clearcoat", "Clearcoat"));

                XSStyles.SeparatorThin();
                materialEditor.TexturePropertySingleLine(new GUIContent("Fallback Cubemap", " Used as fallback in 'Unity' reflection mode if reflection probe is black."), _BakedCubemap);

                XSStyles.SeparatorThin();
                materialEditor.TexturePropertySingleLine(new GUIContent("Metallic Map", "Metallic Map, Metallic on Red Channel, Smoothness on Alpha Channel. \nIf Clearcoat is enabled, Clearcoat Smoothness on Green Channel, Clearcoat Reflectivity on Blue Channel."), _MetallicGlossMap);
                materialEditor.TextureScaleOffsetProperty(_MetallicGlossMap);
                materialEditor.ShaderProperty(_UVSetMetallic, new GUIContent("UV Set", "The UV set to use for the Metallic Smoothness Map"), 2);
                materialEditor.ShaderProperty(_Metallic, new GUIContent("Metallic", "Metallic, set to 1 if using metallic map"), 2);
                materialEditor.ShaderProperty(_Glossiness, new GUIContent("Smoothness", "Smoothness, set to 1 if using metallic map"), 2);
                materialEditor.ShaderProperty(_ClearcoatSmoothness, new GUIContent("Clearcoat Smoothness", "Smoothness of the clearcoat."), 2);
                materialEditor.ShaderProperty(_ClearcoatStrength, new GUIContent("Clearcoat Reflectivity", "The strength of the clearcoat reflection."), 2);
            }
            else if (_ReflectionMode.floatValue == 1) //Baked cube
            {
                materialEditor.ShaderProperty(_ReflectionBlendMode, new GUIContent("Reflection Blend Mode", "Blend mode for reflection. Additive is Color + reflection, Multiply is Color * reflection, and subtractive is Color - reflection"));
                materialEditor.ShaderProperty(_ClearCoat, new GUIContent("Clearcoat", "Clearcoat"));

                XSStyles.SeparatorThin();
                materialEditor.TexturePropertySingleLine(new GUIContent("Baked Cubemap", "Baked cubemap."), _BakedCubemap);

                XSStyles.SeparatorThin();
                materialEditor.TexturePropertySingleLine(new GUIContent("Metallic Map", "Metallic Map, Metallic on Red Channel, Smoothness on Alpha Channel. \nIf Clearcoat is enabled, Clearcoat Smoothness on Green Channel, Clearcoat Reflectivity on Blue Channel."), _MetallicGlossMap);
                materialEditor.TextureScaleOffsetProperty(_MetallicGlossMap);
                materialEditor.ShaderProperty(_UVSetMetallic, new GUIContent("UV Set", "The UV set to use for the MetallicSmoothness Map"), 2);
                materialEditor.ShaderProperty(_Metallic, new GUIContent("Metallic", "Metallic, set to 1 if using metallic map"), 2);
                materialEditor.ShaderProperty(_Glossiness, new GUIContent("Smoothness", "Smoothness, set to 1 if using metallic map"), 2);
                materialEditor.ShaderProperty(_ClearcoatSmoothness, new GUIContent("Clearcoat Smoothness", "Smoothness of the clearcoat."), 2);
                materialEditor.ShaderProperty(_ClearcoatStrength, new GUIContent("Clearcoat Reflectivity", "The strength of the clearcoat reflection."), 2);
            }
            else if (_ReflectionMode.floatValue == 2) //Matcap
            {
                materialEditor.ShaderProperty(_ReflectionBlendMode, new GUIContent("Reflection Blend Mode", "Blend mode for reflection. Additive is Color + reflection, Multiply is Color * reflection, and subtractive is Color - reflection"));

                XSStyles.SeparatorThin();
                materialEditor.TexturePropertySingleLine(new GUIContent("Matcap", "Matcap Texture"), _Matcap, _MatcapTint);
                materialEditor.ShaderProperty(_Glossiness, new GUIContent("Matcap Blur", "Matcap blur, blurs the Matcap, set to 1 for full clarity"), 2);
                materialEditor.ShaderProperty(_MatcapTintToDiffuse, new GUIContent("Tint To Diffuse", "Tints matcap to diffuse color."), 2);
                material.SetFloat("_Metallic", 0);
                material.SetFloat("_ClearCoat", 0);
                material.SetTexture("_MetallicGlossMap", null);
            }
            if (_ReflectionMode.floatValue != 3)
            {
                XSStyles.SeparatorThin();
                materialEditor.TexturePropertySingleLine(new GUIContent("Reflectivity Mask", "Mask for reflections."), _ReflectivityMask);
                materialEditor.TextureScaleOffsetProperty(_ReflectivityMask);
                materialEditor.ShaderProperty(_UVSetReflectivity, new GUIContent("UV Set", "The UV set to use for the Reflectivity Mask"), 2);
                materialEditor.ShaderProperty(_Reflectivity, new GUIContent("Reflectivity", "The strength of the reflections."), 2);
            }
            if (_ReflectionMode.floatValue == 3)
            {
                material.SetFloat("_Metallic", 0);
                material.SetFloat("_ReflectionBlendMode", 0);
                material.SetFloat("_ClearCoat", 0);
            }
        }
    }