Beispiel #1
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();
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }
Beispiel #4
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();
        }
Beispiel #5
0
        public override void SectionContent(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            FindProperties(properties);

            EditorGUILayout.Space();
            if (level == InspectorLevel.Normal)
            {
                //Rect r = TSFunctions.GetControlRectForSingleLine();
                EditorGUI.BeginChangeCheck();
                materialEditor.TexturePropertySingleLine(Styles.thickness, _ThicknessMap);
                if (EditorGUI.EndChangeCheck())
                {
                    inspector.RegenerateMSOT();
                }
            }
            TSFunctions.ProperColorBox(ref _SSColor, Styles.color);
            //materialEditor.ShaderProperty(_SSColor, Styles.color);
            materialEditor.ShaderProperty(_SSDistortion, Styles.distortion);
            materialEditor.ShaderProperty(_SSPower, Styles.power);
            materialEditor.ShaderProperty(_SSScale, Styles.scale);
            EditorGUILayout.Space();
        }
        public override void SectionContent(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            FindProperties(properties);

            bool isToonyHighlightsEnabled;

            EditorGUILayout.Space();

            TSFunctions.DrawSelector(Enum.GetNames(typeof(Workflow)), _workflow, Styles.workflow, materialEditor);
            if ((Workflow)_workflow.floatValue == Workflow.Metallic)
            {
                if (level == InspectorLevel.Normal)
                {
                    Rect r = TSFunctions.GetControlRectForSingleLine();
                    EditorGUI.BeginChangeCheck();
                    materialEditor.TexturePropertyMiniThumbnail(r, _MetallicMap, Styles.metallic.text, Styles.metallic.tooltip);
                    if (EditorGUI.EndChangeCheck())
                    {
                        inspector.RegenerateMSOT();
                    }
                    TSFunctions.ProperSlider(MaterialEditor.GetRectAfterLabelWidth(r), ref _Metallic);
                }
                else
                {
                    materialEditor.ShaderProperty(_Metallic, Styles.metallic);
                }
            }
            else if ((Workflow)_workflow.floatValue == Workflow.Specular)
            {
                materialEditor.TexturePropertySingleLine(Styles.specular, _MetallicMap);
            }

            if (level == InspectorLevel.Normal)
            {
                Rect r = TSFunctions.GetControlRectForSingleLine();
                EditorGUI.BeginChangeCheck();
                materialEditor.TexturePropertyMiniThumbnail(r, _GlossinessMap, Styles.smoothness.text, Styles.smoothness.tooltip);
                if (EditorGUI.EndChangeCheck())
                {
                    inspector.RegenerateMSOT();
                }
                TSFunctions.ProperSlider(MaterialEditor.GetRectAfterLabelWidth(r), ref _Glossiness);
            }
            else
            {
                materialEditor.ShaderProperty(_Glossiness, Styles.smoothness);
            }

            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);
            }
            if ((IndirectSpecular)_indirectSpecular.floatValue != IndirectSpecular.None)
            {
                TSFunctions.ProperToggle(ref _IndirectOverride, Styles.indirectOverride);
            }
            else
            {
                _IndirectOverride.floatValue = 0;
            }

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

            if (isToonyHighlightsEnabled)
            {
                EditorGUILayout.BeginHorizontal();
                materialEditor.TexturePropertySingleLine(Styles.highlightRamp, _HighlightRamp, _HighlightRampColor);

                if (GUILayout.Button(Styles.GradientEditorButton))
                {
                    EditorGUILayout.EndHorizontal();
                    isGradientEditorOpen = !isGradientEditorOpen;
                    Styles.ToggleGradientEditorToggle(isGradientEditorOpen);
                }
                else
                {
                    EditorGUILayout.EndHorizontal();
                }
                if (isGradientEditorOpen)
                {
                    EditorGUILayout.BeginVertical("box");
                    if (needToStorePreviousRamp)
                    {
                        needToStorePreviousRamp = false;
                        gradientEditor.TranslateTextureToGradient((Texture2D)_HighlightRamp.textureValue);
                        PreviousRamp = _HighlightRamp.textureValue;
                    }
                    if (_HighlightRamp.textureValue != (Texture)gradientEditor.GetGradientTexture())
                    {
                        _HighlightRamp.textureValue = (Texture)gradientEditor.GetGradientTexture();
                    }
                    if (gradientEditor.DrawGUI())
                    {
                        materialEditor.Repaint();
                    }
                    if (GUILayout.Button("Save and apply"))
                    {
                        string path = inspector.GetTextureDestinationPath((Material)_HighlightRamp.targets[0], "_highlight_ramp.png");
                        _HighlightRamp.textureValue = (Texture)gradientEditor.SaveGradient(path);
                        needToStorePreviousRamp     = true;
                        PreviousRamp         = null;
                        isGradientEditorOpen = false;
                    }
                    EditorGUILayout.EndVertical();
                }
                else
                {
                    if (PreviousRamp != null)
                    {
                        _HighlightRamp.textureValue = PreviousRamp;
                        PreviousRamp            = null;
                        needToStorePreviousRamp = true;
                    }
                }

                materialEditor.ShaderProperty(_HighlightRampOffset, Styles.hightlightRampOffset);
                materialEditor.ShaderProperty(_HighlightIntensity, Styles.highlightIntensity);
            }

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

            EditorGUILayout.Space();
        }