Exemple #1
0
        //Functions to delegate to the ramp option section
        #region RampOptionsDelegates

        public void DrawRampOptionsSection(MaterialEditor materialEditor)
        {
            bool isOcclusionOffsetEnabled;
            bool isFakeLightEnabled;

            EditorGUILayout.Space();
            materialEditor.TexturePropertySingleLine(Styles.ramp, _Ramp, _RampColor);
            materialEditor.ShaderProperty(_RampOffset, Styles.rampOffset);
            materialEditor.ShaderProperty(_ShadowIntensity, Styles.shadowIntensity);

            isOcclusionOffsetEnabled = TSFunctions.ProperToggle(ref _OcclusionOffset, Styles.occlusionOffsetIntensity);
            if (!isOcclusionOffsetEnabled && !_OcclusionOffset.hasMixedValue)
            {
                _OcclusionOffsetIntensity.floatValue = 0;
            }
            if (isOcclusionOffsetEnabled)
            {
                materialEditor.ShaderProperty(_OcclusionOffsetIntensity, Styles.occlusionOffsetIntensity);
            }

            isFakeLightEnabled = TSFunctions.ProperToggle(ref _FakeLight, Styles.fakeLight);
            if (isFakeLightEnabled)
            {
                TSFunctions.ProperColorBox(ref _FakeLightColor, Styles.fakeLightColor);
                materialEditor.ShaderProperty(_FakeLightX, Styles.fakeLightX);
                materialEditor.ShaderProperty(_FakeLightY, Styles.fakeLightY);
                materialEditor.ShaderProperty(_FakeLightZ, Styles.fakeLightZ);
            }

            EditorGUILayout.Space();
        }
Exemple #2
0
        //Functions to delegate to the specular section
        #region SpecularOptionsDelegates

        public void DrawSpecularOptionsSection(MaterialEditor materialEditor)
        {
            bool isToonyHighlightsEnabled;

            EditorGUILayout.Space();

            TSFunctions.DrawSelector(Enum.GetNames(typeof(Workflow)), _workflow, Styles.workflow, materialEditor);
            if ((Workflow)_workflow.floatValue == Workflow.Metallic)
            {
                materialEditor.TexturePropertySingleLine(Styles.metallic, _MetallicMap, _Metallic);
            }
            else if ((Workflow)_workflow.floatValue == Workflow.Specular)
            {
                materialEditor.TexturePropertySingleLine(Styles.specular, _MetallicMap);
            }

            materialEditor.TexturePropertySingleLine(Styles.smoothness, _GlossinessMap, _Glossiness);

            TSFunctions.DrawSelector(Enum.GetNames(typeof(SpMode)), _SpMode, Styles.spMode, materialEditor);
            if ((SpMode)_SpMode.floatValue == SpMode.Anisotropic)
            {
                materialEditor.TexturePropertySingleLine(Styles.anisotropy, _AnisotropyMap, _Anisotropy);
                materialEditor.TexturePropertySingleLine(Styles.tangent, _TangentMap);
            }
            else if ((SpMode)_SpMode.floatValue == SpMode.Fake)
            {
                materialEditor.TexturePropertySingleLine(Styles.fakeHighlights, _FakeHightlights);
                materialEditor.ShaderProperty(_FakeHighlightIntensity, Styles.fakeHighlightIntensity);
            }

            TSFunctions.DrawSelector(Enum.GetNames(typeof(IndirectSpecular)), _indirectSpecular, Styles.indirectSpecular, materialEditor);
            if ((IndirectSpecular)_indirectSpecular.floatValue == IndirectSpecular.Matcap)
            {
                materialEditor.TexturePropertySingleLine(Styles.matcap, _Matcap);
            }
            else if ((IndirectSpecular)_indirectSpecular.floatValue == IndirectSpecular.Cubemap)
            {
                materialEditor.TexturePropertySingleLine(Styles.cubemap, _Cubemap);
            }
            else if ((IndirectSpecular)_indirectSpecular.floatValue == IndirectSpecular.Color)
            {
                TSFunctions.ProperColorBox(ref _IndirectColor, Styles.indirectColor);
            }

            isToonyHighlightsEnabled = TSFunctions.ProperToggle(ref _ToonyHighlights, Styles.toonyHighlight);

            if (isToonyHighlightsEnabled)
            {
                materialEditor.TexturePropertySingleLine(Styles.highlightRamp, _HighlightRamp, _HighlightRampColor);
                materialEditor.ShaderProperty(_HighlightRampOffset, Styles.hightlightRampOffset);
                materialEditor.ShaderProperty(_HighlightIntensity, Styles.highlightIntensity);
            }

            materialEditor.TexturePropertySingleLine(Styles.highlightPattern, _HighlightPattern);
            EditorGUI.indentLevel++;
            materialEditor.TextureScaleOffsetProperty(_HighlightPattern);
            EditorGUI.indentLevel--;

            EditorGUILayout.Space();
        }
Exemple #3
0
        public void CheckSpecularOptionsSection(bool isOpen, bool isEnabled)
        {
            _SpecularBox.floatValue = TSFunctions.floatBoolean(isOpen);
            foreach (Material mat in _SpecularOn.targets)
            {
                if (!isEnabled)
                {
                    if (!_SpecularOn.hasMixedValue)
                    {
                        TSFunctions.SetKeyword(mat, "_ENABLE_SPECULAR", isEnabled);
                        _SpecularOn.floatValue = TSFunctions.floatBoolean(material.IsKeywordEnabled("_ENABLE_SPECULAR"));
                    }
                }
            }

            foreach (Material mat in _workflow.targets)
            {
                SetupWorkflow(mat, (Workflow)_workflow.floatValue);
            }
            foreach (Material mat in _SpMode.targets)
            {
                SetupSpMode(mat, (SpMode)_SpMode.floatValue);
            }
            foreach (Material mat in _indirectSpecular.targets)
            {
                SetupIndirectSource(mat, (IndirectSpecular)_indirectSpecular.floatValue);
            }
        }
 public override void OnAdd()
 {
     foreach (Material mat in _DetailMapOn.targets)
     {
         TSFunctions.SetKeyword(mat, "_DETAIL_MULX2", mat.GetFloat(_DetailMapOn.name) != 0);
     }
 }
Exemple #5
0
 public override void OnAdd()
 {
     foreach (Material mat in _SpecularOn.targets)
     {
         TSFunctions.SetKeyword(mat, "_SPECULARHIGHLIGHTS_OFF", !(mat.GetFloat(_SpecularOn.name) != 0));
     }
 }
Exemple #6
0
        public BasicSpecularSection(MaterialProperty[] properties, bool open, bool enabled) : base(Styles.title, open, enabled)
        {
            FindProperties(properties);

            foreach (Material mat in _SpecularOn.targets)
            {
                TSFunctions.SetKeyword(mat, "_SPECULARHIGHLIGHTS_OFF", !(mat.GetFloat(_SpecularOn.name) != 0));
            }
        }
        public DetailSection(MaterialProperty[] properties, bool open, bool enabled) : base(Styles.title, open, enabled)
        {
            FindProperties(properties);

            foreach (Material mat in _DetailMapOn.targets)
            {
                TSFunctions.SetKeyword(mat, "_DETAIL_MULX2", mat.GetFloat(_DetailMapOn.name) != 0);
            }
        }
 public override void EndBoxCheck(bool isOpen, bool isEnabled)
 {
     _ToonRampBox.floatValue = TSFunctions.floatBoolean(isOpen);
     if (!isEnabled)
     {
         if (!_RampOn.hasMixedValue)
         {
             _RampOn.floatValue = 0;
         }
     }
 }
Exemple #9
0
 public void CheckRimLightOptionsSection(bool isOpen, bool isEnabled)
 {
     _RimLightBox.floatValue = TSFunctions.floatBoolean(isOpen);
     if (!isEnabled)
     {
         if (!_RimLightOn.hasMixedValue)
         {
             _RimLightOn.floatValue = 0;
         }
     }
 }
        public override void SectionContent(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            FindProperties(properties);

            EditorGUILayout.Space();
            materialEditor.TexturePropertySingleLine(Styles.outlineTexture, _OutlineTexture, _OutlineColor);
            materialEditor.TexturePropertySingleLine(Styles.outlineWidth, _OutlineWidthMap, _OutlineWidth);
            materialEditor.ShaderProperty(_OutlineOffsetX, Styles.outlineOffsetX);
            materialEditor.ShaderProperty(_OutlineOffsetY, Styles.outlineOffsetY);
            TSFunctions.ProperToggle(ref _IsOutlineEmissive, Styles.isOutlineEmissive);

            EditorGUILayout.Space();
        }
Exemple #11
0
        /// <summary>
        /// Draws the section header with the foldout style
        /// </summary>
        /// <param name="bCol">original background color</param>
        private void drawFoldoutSection(Color bCol)
        {
            TSFunctions.DrawLine(new Color(0.35f, 0.35f, 0.35f, 1), 1, 0);
            GUI.backgroundColor = bCol;

            Rect r = EditorGUILayout.BeginHorizontal();

            isOpen = EditorGUILayout.Toggle(isOpen, EditorStyles.foldout, GUILayout.MaxWidth(15.0f));
            EditorGUILayout.LabelField(sectionTitle, TSConstants.Styles.sectionTitle);
            isEnabled = EditorGUILayout.Toggle(isEnabled, TSConstants.Styles.deleteStyle, GUILayout.MaxWidth(15.0f));
            isOpen    = GUI.Toggle(r, isOpen, GUIContent.none, new GUIStyle());
            EditorGUILayout.EndHorizontal();
        }
Exemple #12
0
 public void CheckBasicSpecularOptionsSection(bool isOpen, bool isEnabled)
 {
     _SpecularBox.floatValue = TSFunctions.floatBoolean(isOpen);
     foreach (Material mat in _SpecularOn.targets)
     {
         if (!isEnabled)
         {
             if (!_SpecularOn.hasMixedValue)
             {
                 TSFunctions.SetKeyword(mat, "_ENABLE_SPECULAR", isEnabled);
                 _SpecularOn.floatValue = TSFunctions.floatBoolean(material.IsKeywordEnabled("_ENABLE_SPECULAR"));
             }
         }
     }
 }
Exemple #13
0
 public void CheckDrawDetailOptionsSection(bool isOpen, bool isEnabled)
 {
     _DetailBox.floatValue = TSFunctions.floatBoolean(isOpen);
     foreach (Material mat in _DetailMapOn.targets)
     {
         TSFunctions.SetKeyword(mat, "_DETAIL_MAP", isEnabled);
     }
     if (!isEnabled)
     {
         if (!_DetailMapOn.hasMixedValue)
         {
             _DetailMapOn.floatValue = 0;
         }
     }
 }
 public override void EndBoxCheck(bool isOpen, bool isEnabled)
 {
     _OutlineBox.floatValue = TSFunctions.floatBoolean(isOpen);
     if (!isEnabled)
     {
         if (!_OutlineOn.hasMixedValue)
         {
             _OutlineOn.floatValue = 0;
             foreach (Material mat in _OutlineOn.targets)
             {
                 ToonyStandardGUI.SetupMaterialWithBlendMode(mat, (ToonyStandardGUI.BlendMode)mat.GetFloat("_Mode"), mat.GetFloat("_OutlineOn") > 0);
             }
         }
     }
 }
 public override void EndBoxCheck(bool isOpen, bool isEnabled)
 {
     _DetailBox.floatValue = TSFunctions.floatBoolean(isOpen);
     foreach (Material mat in _DetailMapOn.targets)
     {
         TSFunctions.SetKeyword(mat, "_DETAIL_MULX2", isEnabled);
     }
     if (!isEnabled)
     {
         if (!_DetailMapOn.hasMixedValue)
         {
             _DetailMapOn.floatValue = 0;
         }
     }
 }
Exemple #16
0
 public void CheckRampOptionsChanges(bool isOpen, bool isEnabled)
 {
     _ToonRampBox.floatValue = TSFunctions.floatBoolean(isOpen);
     if (!isEnabled)
     {
         if (!_RampOn.hasMixedValue)
         {
             _RampOn.floatValue = 0;
         }
         _Ramp.textureValue                   = TSConstants.DefaultRamp;
         _RampOffset.floatValue               = 0f;
         _ShadowIntensity.floatValue          = 0.4f;
         _OcclusionOffset.floatValue          = 0f;
         _OcclusionOffsetIntensity.floatValue = 0f;
         _FakeLight.floatValue                = 0f;
     }
 }
Exemple #17
0
        public override void SectionContent(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            bool isToonyHighlightsEnabled;

            EditorGUILayout.Space();
            materialEditor.ShaderProperty(_Metallic, Styles.metallic);
            materialEditor.ShaderProperty(_Glossiness, Styles.smoothness);

            isToonyHighlightsEnabled = TSFunctions.ProperToggle(ref _ToonyHighlights, Styles.toonyHighlight);

            if (isToonyHighlightsEnabled)
            {
                materialEditor.ShaderProperty(_HighlightIntensity, Styles.highlightIntensity);
            }

            EditorGUILayout.Space();
        }
Exemple #18
0
        //Functions to delegate to the rim light section
        #region RimLightOptionsDelegates

        public void DrawRimLightOptionsSection(MaterialEditor materialEditor)
        {
            bool isEmissiveRimEnabled;

            EditorGUILayout.Space();
            TSFunctions.ProperColorBox(ref _RimColor, Styles.rimColor);
            materialEditor.ShaderProperty(_RimIntensity, Styles.rimIntensity);
            materialEditor.ShaderProperty(_RimStrength, Styles.rimStrength);
            materialEditor.ShaderProperty(_RimSharpness, Styles.rimSharpness);
            EditorGUI.BeginChangeCheck();
            isEmissiveRimEnabled = TSFunctions.ProperToggle(ref _EmissiveRim, Styles.emissiveRim);
            if (EditorGUI.EndChangeCheck())
            {
                _EmissiveRim.floatValue = TSFunctions.floatBoolean(isEmissiveRimEnabled);
            }

            EditorGUILayout.Space();
        }
        public override void EndBoxCheck(bool isOpen, bool isEnabled)
        {
            _StencilBox.floatValue = TSFunctions.floatBoolean(isOpen);
            if (!isEnabled)
            {
                if (!_StencilOn.hasMixedValue)
                {
                    _StencilOn.floatValue = 0;

                    _StencilID.floatValue   = 0;
                    _StencilComp.floatValue = 0;
                    _StencilOp.floatValue   = 0;

                    _OutlineStencilID.floatValue   = 0;
                    _OutlineStencilComp.floatValue = 0;
                    _OutlineStencilOp.floatValue   = 0;
                }
            }
        }
Exemple #20
0
        void OnGUI()
        {
            TSFunctions.DrawHeader(position.width, 20);
            EditorGUILayout.LabelField("Seems like this is your first time installing Toony Standard, first of all, thanks for using it, it makes me happy.", TSConstants.Styles.multilineLabel);
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Now, the only thing that you need to set immediately is the inspector level, this will tell the shader what features to expose based on your experience with making stuff in unity.", TSConstants.Styles.multilineLabel);
            GUILayout.Space(10);
            EditorGUILayout.LabelField("You can edit this choice later and modify other options by going on Window/Toony Standard/Settings ", TSConstants.Styles.multilineLabel);
            GUILayout.Space(10);
            EditorGUI.BeginChangeCheck();
            inspectorLevel = (InspectorLevel)EditorGUILayout.EnumPopup(TSConstants.TSWindowLabels.InspectorLevel, inspectorLevel);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetInt(TSConstants.TSEPInspectorLevel, (int)inspectorLevel);

                switch (inspectorLevel)
                {
                case InspectorLevel.Basic:
                    boxMessage = "The basic level is suited for people who are relatively new to avatar creation giving them just the basic stuff they need to get started.";
                    break;

                case InspectorLevel.Normal:
                    boxMessage = "Normal level will give the vast majority of the features this shader has to offer, this is the default setting and probably will be the most used one.";
                    break;

                case InspectorLevel.Expert:
                    boxMessage = "Warning, i expect you to be experienced in what you're doing in order to select this.\nThis level grants access to all the features and little adjustments that you can do with this shader, even if you don't know what the hell they do.";
                    break;
                }
            }

            EditorGUILayout.HelpBox(boxMessage, MessageType.Info);

            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Done!", GUILayout.MinWidth(100)))
            {
                this.Close();
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(10);
        }
Exemple #21
0
        public override void SectionContent(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            FindProperties(properties);

            bool isEmissiveRimEnabled;

            EditorGUILayout.Space();
            TSFunctions.ProperColorBox(ref _RimColor, Styles.rimColor);
            materialEditor.ShaderProperty(_RimIntensity, Styles.rimIntensity);
            materialEditor.ShaderProperty(_RimStrength, Styles.rimStrength);
            materialEditor.ShaderProperty(_RimSharpness, Styles.rimSharpness);
            EditorGUI.BeginChangeCheck();
            isEmissiveRimEnabled = TSFunctions.ProperToggle(ref _EmissiveRim, Styles.emissiveRim);
            if (EditorGUI.EndChangeCheck())
            {
                _EmissiveRim.floatValue = TSFunctions.floatBoolean(isEmissiveRimEnabled);
            }

            EditorGUILayout.Space();
        }
Exemple #22
0
        //Functions to delegate to the specular section of the masic inspector level
        #region BasicSpecularOptionsDelegates

        public void DrawBasicSpecularOptionsSection(MaterialEditor materialEditor)
        {
            bool isToonyHighlightsEnabled;

            EditorGUILayout.Space();


            materialEditor.ShaderProperty(_Metallic, Styles.metallic);


            materialEditor.ShaderProperty(_Glossiness, Styles.smoothness);

            isToonyHighlightsEnabled = TSFunctions.ProperToggle(ref _ToonyHighlights, Styles.toonyHighlight);

            if (isToonyHighlightsEnabled)
            {
                materialEditor.ShaderProperty(_HighlightIntensity, Styles.highlightIntensity);
            }

            EditorGUILayout.Space();
        }
Exemple #23
0
        void OnGUI()
        {
            // If this is the first iteration since the window is opened, do the needed initializzations
            if (firstCycle)
            {
                Start();
                firstCycle = false;
            }

            packer.DrawGUI();

            if (GUILayout.Button("Save Packed Texture"))
            {
                string path = TSFunctions.GetSelectedPathOrFallback();
                path = EditorUtility.SaveFilePanel("Save Texture", path, "Packed", "png");
                if (path.Length != 0)
                {
                    packer.PackTexture(path);
                }
            }
        }