Beispiel #1
0
 public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
 {
     if (newShader.name.Contains("Unlit"))
     {
         material.SetFloat("_LightingEnabled", 0f);
     }
     else
     {
         material.SetFloat("_LightingEnabled", 1f);
     }
     if (material.HasProperty("_Emission"))
     {
         material.SetColor("_EmissionColor", material.GetColor("_Emission"));
     }
     base.AssignNewShaderToMaterial(material, oldShader, newShader);
     if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
     {
         StandardParticlesShaderGUI.SetupMaterialWithBlendMode(material, (StandardParticlesShaderGUI.BlendMode)material.GetFloat("_Mode"));
     }
     else
     {
         StandardParticlesShaderGUI.BlendMode blendMode = StandardParticlesShaderGUI.BlendMode.Opaque;
         if (oldShader.name.Contains("/Transparent/Cutout/"))
         {
             blendMode = StandardParticlesShaderGUI.BlendMode.Cutout;
         }
         else if (oldShader.name.Contains("/Transparent/"))
         {
             blendMode = StandardParticlesShaderGUI.BlendMode.Fade;
         }
         material.SetFloat("_Mode", (float)blendMode);
         this.MaterialChanged(material);
     }
 }
Beispiel #2
0
 private void MaterialChanged(Material material)
 {
     StandardParticlesShaderGUI.SetupMaterialWithBlendMode(material, (StandardParticlesShaderGUI.BlendMode)material.GetFloat("_Mode"));
     if (this.colorMode != null)
     {
         StandardParticlesShaderGUI.SetupMaterialWithColorMode(material, (StandardParticlesShaderGUI.ColorMode)material.GetFloat("_ColorMode"));
     }
     this.SetMaterialKeywords(material);
 }
Beispiel #3
0
        private void SetMaterialKeywords(Material material)
        {
            bool flag  = material.GetInt("_ZWrite") != 0;
            bool flag2 = material.GetFloat("_LightingEnabled") > 0f;
            bool flag3 = material.GetFloat("_DistortionEnabled") > 0f && !flag;

            StandardParticlesShaderGUI.SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") && (flag2 || flag3));
            StandardParticlesShaderGUI.SetKeyword(material, "_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap") != null && flag2);
            material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.None;
            StandardParticlesShaderGUI.SetKeyword(material, "_EMISSION", material.GetFloat("_EmissionEnabled") > 0f);
            bool state = material.GetFloat("_FlipbookMode") > 0f;

            StandardParticlesShaderGUI.SetKeyword(material, "_REQUIRE_UV2", state);
            bool  flag4 = material.GetFloat("_SoftParticlesEnabled") > 0f;
            bool  flag5 = material.GetFloat("_CameraFadingEnabled") > 0f;
            float num   = material.GetFloat("_SoftParticlesNearFadeDistance");
            float num2  = material.GetFloat("_SoftParticlesFarFadeDistance");
            float num3  = material.GetFloat("_CameraNearFadeDistance");
            float num4  = material.GetFloat("_CameraFarFadeDistance");

            if (num < 0f)
            {
                num = 0f;
                material.SetFloat("_SoftParticlesNearFadeDistance", 0f);
            }
            if (num2 < 0f)
            {
                num2 = 0f;
                material.SetFloat("_SoftParticlesFarFadeDistance", 0f);
            }
            if (num3 < 0f)
            {
                num3 = 0f;
                material.SetFloat("_CameraNearFadeDistance", 0f);
            }
            if (num4 < 0f)
            {
                num4 = 0f;
                material.SetFloat("_CameraFarFadeDistance", 0f);
            }
            bool state2 = (flag4 || flag5) && !flag;

            StandardParticlesShaderGUI.SetKeyword(material, "_FADING_ON", state2);
            if (flag4)
            {
                material.SetVector("_SoftParticleFadeParams", new Vector4(num, 1f / (num2 - num), 0f, 0f));
            }
            else
            {
                material.SetVector("_SoftParticleFadeParams", new Vector4(0f, 0f, 0f, 0f));
            }
            if (flag5)
            {
                material.SetVector("_CameraFadeParams", new Vector4(num3, 1f / (num4 - num3), 0f, 0f));
            }
            else
            {
                material.SetVector("_CameraFadeParams", new Vector4(0f, float.PositiveInfinity, 0f, 0f));
            }
            StandardParticlesShaderGUI.SetKeyword(material, "EFFECT_BUMP", flag3);
            material.SetShaderPassEnabled("Always", flag3);
            if (flag3)
            {
                material.SetFloat("_DistortionStrengthScaled", material.GetFloat("_DistortionStrength") * 0.1f);
            }
        }