Ejemplo n.º 1
0
        public static void SetupMaterialWithBlendMode(Material material, ShurikenMaster.ShaderBlendMode blendMode)
        {
            switch (blendMode)
            {
            case ShurikenMaster.ShaderBlendMode.Cutout:
                SetupMaterialBlendStates(material, BlendOp.Add, BlendMode.One, BlendMode.Zero, false, false);
                break;

            case ShurikenMaster.ShaderBlendMode.Additive:
                SetupMaterialBlendStates(material, BlendOp.Add, BlendMode.SrcAlpha, BlendMode.One, true, false);
                break;

            case ShurikenMaster.ShaderBlendMode.AlphaBlend:
                SetupMaterialBlendStates(material, BlendOp.Add, BlendMode.SrcAlpha, BlendMode.OneMinusSrcAlpha, true, false);
                break;

            case ShurikenMaster.ShaderBlendMode.PremultipliedAlpha:
                SetupMaterialBlendStates(material, BlendOp.Add, BlendMode.One, BlendMode.OneMinusSrcAlpha, true, false);
                break;

            case ShurikenMaster.ShaderBlendMode.Dithered:
                SetupMaterialBlendStates(material, BlendOp.Add, BlendMode.One, BlendMode.Zero, false, true);
                break;

            case ShurikenMaster.ShaderBlendMode.Modulate:
                SetupMaterialBlendStates(material, BlendOp.Multiply, BlendMode.DstColor, BlendMode.OneMinusSrcAlpha, true, false);
                break;
            }
        }
        public void ShaderPropertiesGUI(Material material)
        {
            bool changed = false;

            m_ProgressBar.DoProgressBar(GetShaderComplexity(material));

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();


            ShurikenMaster.ShaderBlendMode blend = (ShurikenMaster.ShaderBlendMode)material.GetInt("_BlendMode");

            // Blending Options
            ShurikenMaster.DrawHeader(Content.blendingHeader, EditorGUIUtility.IconContent("SceneViewFx").image);

            using (new IndentScope(1))
            {
                blendMode.floatValue = (float)(ShurikenMaster.ShaderBlendMode)EditorGUILayout.EnumPopup("Blend Mode", blend);
                if (blend == ShurikenMaster.ShaderBlendMode.Cutout)
                {
                    alphaCutoff.floatValue = EditorGUILayout.Slider(Content.alphaCutoff, alphaCutoff.floatValue, 0.0f, 1.0f);
                }

                if (GetCapability(ShurikenMaster.Capabilities.PremultiplyRGBbyA) && blend == ShurikenMaster.ShaderBlendMode.PremultipliedAlpha)
                {
                    premultiplyRGBbyA.floatValue = EditorGUILayout.Toggle(Content.premultiplyRGBbyA, premultiplyRGBbyA.floatValue == 1.0f) ? 1.0f : 0.0f;
                }
            }

            EditorGUILayout.Space();

            // Lighting Options
            if (GetCapability(ShurikenMaster.Capabilities.Lighting))
            {
                ShurikenMaster.DrawHeader(Content.lightingHeader, EditorGUIUtility.IconContent("SceneViewLighting").image);

                using (new IndentScope(1))
                {
                    ShaderPropertiesLightingGUI(material);
                }

                EditorGUILayout.Space();
            }

            // Shader Options
            ShurikenMaster.DrawHeader(Content.configHeader, EditorGUIUtility.IconContent("PreTextureRGB").image);

            using (new IndentScope(1))
            {
                m_MaterialEditor.TexturePropertySingleLine(Content.colorMap, colorMap, null);

                if (GetCapability(ShurikenMaster.Capabilities.SwitchColorSource))
                {
                    ShurikenMaster.ColorSetup colorsetup = (ShurikenMaster.ColorSetup)material.GetInt("_ColorSetup");
                    if (colorsetup == ShurikenMaster.ColorSetup.RGBFromColorMapAndAlternateAlpha)
                    {
                        m_MaterialEditor.TexturePropertySingleLine(Content.alphaMap, alternateAlphaMap, null);
                    }
                    colorSetup.floatValue = (float)(ShurikenMaster.ColorSetup)EditorGUILayout.EnumPopup("Color Map Type", colorsetup);
                }

                rgbBrightness.floatValue = Mathf.Max(0, EditorGUILayout.FloatField(Content.rgbBrightness, rgbBrightness.floatValue));

                ShaderPropertiesCustomOptionsGUI(material);
            }

            EditorGUILayout.Space();

            // Other Options
            ShurikenMaster.DrawHeader(Content.optionsHeader, EditorGUIUtility.IconContent("Lighting").image);

            using (new IndentScope(1))
            {
                softParticle.floatValue = material.IsKeywordEnabled("VFX_DEPTHFADING") ? 1.0f : 0.0f;
                cameraFade.floatValue   = material.IsKeywordEnabled("VFX_CAMERAFADING") ? 1.0f : 0.0f;

                softParticle.floatValue = EditorGUILayout.Toggle(Content.softParticle, softParticle.floatValue == 1.0f) ? 1.0f : 0.0f;
                if (softParticle.floatValue == 1.0f)
                {
                    using (new IndentScope(1))
                    {
                        softParticleDistance.floatValue = EditorGUILayout.FloatField(Content.softParticleDistance, softParticleDistance.floatValue);
                    }
                }

                cameraFade.floatValue = EditorGUILayout.Toggle(Content.cameraFade, cameraFade.floatValue == 1.0f) ? 1.0f : 0.0f;

                if (cameraFade.floatValue == 1.0f)
                {
                    using (new IndentScope(1))
                    {
                        cameraFadeNear.floatValue = EditorGUILayout.FloatField(Content.cameraFadeNear, cameraFadeNear.floatValue);
                        cameraFadeFar.floatValue  = EditorGUILayout.FloatField(Content.cameraFadeFar, cameraFadeFar.floatValue);
                    }
                }
                flipbookBlend.floatValue = material.IsKeywordEnabled("VFX_FLIPBOOKBLEND") ? 1.0f : 0.0f;
                flipbookBlend.floatValue = EditorGUILayout.Toggle(Content.flipbookBlend, flipbookBlend.floatValue == 1.0f) ? 1.0f : 0.0f;

                if (flipbookBlend.floatValue == 1.0f)
                {
                    flipbookOflow.floatValue = material.IsKeywordEnabled("VFX_FLIPBOOKBLEND_OFLOW") ? 1.0f : 0.0f;
                    flipbookOflow.floatValue = EditorGUILayout.Toggle(Content.flipbookOflowBlend, flipbookOflow.floatValue == 1.0f) ? 1.0f : 0.0f;
                    if (flipbookOflow.floatValue == 1.0f)
                    {
                        using (new IndentScope(1))
                        {
                            m_MaterialEditor.TexturePropertySingleLine(Content.oFlowMap, oFlowMap, null);
                            oFlowIntensity.floatValue = EditorGUILayout.FloatField(Content.oFlowIntensity, oFlowIntensity.floatValue);
                        }
                    }
                }
            }

            // Info
            EditorGUILayout.Space();

            if (EditorGUI.EndChangeCheck())
            {
                HandleMiniLog(material);
                changed = true;
            }

            ShaderPropertiesVertexStreamsGUI(material);

            // Log
            ShurikenMaster.DrawHeader(Content.logHeader, EditorGUIUtility.ObjectContent(null, typeof(UnityEngine.UI.Text)).image);

            m_MiniLog.DoLog(80);

            if (changed)
            {
                MaterialChanged(material);
            }
        }