public LegacyBlinnPhongUpgrader(string oldShaderName, UpgradeParams upgradeParams)
        {
            RenameShader(oldShaderName, LightweightPipelineAsset.m_SimpleLightShaderPath, UpdateMaterialKeywords);
            SetFloat("_Mode", (float)upgradeParams.blendMode);
            SetFloat("_SpecSource", (float)upgradeParams.specularSource);
            SetFloat("_GlossinessSource", (float)upgradeParams.glosinessSource);

            if (oldShaderName.Contains("Legacy Shaders/Self-Illumin"))
            {
                RenameTexture("_MainTex", "_EmissionMap");
                RemoveTexture("_MainTex");
                SetColor("_EmissionColor", Color.white);
            }
        }
Esempio n. 2
0
        public StandardSimpleLightingUpgrader(string oldShaderName, UpgradeParams upgradeParams)
        {
            RenameShader(oldShaderName, LightweightShaderUtils.GetShaderPath(ShaderPathID.STANDARD_SIMPLE_LIGHTING), UpdateMaterialKeywords);
            SetFloat("_Mode", (float)upgradeParams.blendMode);
            SetFloat("_SpecSource", (float)upgradeParams.specularSource);
            SetFloat("_GlossinessSource", (float)upgradeParams.glosinessSource);

            if (oldShaderName.Contains("Legacy Shaders/Self-Illumin"))
            {
                RenameTexture("_MainTex", "_EmissionMap");
                RemoveTexture("_MainTex");
                SetColor("_EmissionColor", Color.white);
            }
        }
        private void ConvertFromLegacy(Material material, string oldShaderName)
        {
            UpgradeParams shaderUpgradeParams = new UpgradeParams();

            if (oldShaderName.Contains("Transp"))
            {
                shaderUpgradeParams.surfaceType     = UpgradeSurfaceType.Transparent;
                shaderUpgradeParams.blendMode       = UpgradeBlendMode.Alpha;
                shaderUpgradeParams.alphaClip       = false;
                shaderUpgradeParams.glosinessSource = GlossinessSource.SpecularAlpha;
            }
            else if (oldShaderName.Contains("Cutout"))
            {
                shaderUpgradeParams.surfaceType     = UpgradeSurfaceType.Opaque;
                shaderUpgradeParams.blendMode       = UpgradeBlendMode.Alpha;
                shaderUpgradeParams.alphaClip       = true;
                shaderUpgradeParams.glosinessSource = GlossinessSource.SpecularAlpha;
            }
            else
            {
                shaderUpgradeParams.surfaceType     = UpgradeSurfaceType.Opaque;
                shaderUpgradeParams.blendMode       = UpgradeBlendMode.Alpha;
                shaderUpgradeParams.alphaClip       = false;
                shaderUpgradeParams.glosinessSource = GlossinessSource.BaseAlpha;
            }

            if (oldShaderName.Contains("Spec"))
            {
                shaderUpgradeParams.specularSource = SpecularSource.SpecularTextureAndColor;
            }
            else
            {
                shaderUpgradeParams.specularSource = SpecularSource.NoSpecular;
            }

            material.SetFloat("_Surface", (float)shaderUpgradeParams.surfaceType);
            material.SetFloat("_Blend", (float)shaderUpgradeParams.blendMode);
            material.SetFloat("_SpecSource", (float)shaderUpgradeParams.specularSource);
            material.SetFloat("_GlossinessSource", (float)shaderUpgradeParams.glosinessSource);

            if (oldShaderName.Contains("Self-Illumin"))
            {
                material.SetTexture("_EmissionMap", material.GetTexture("_MainTex"));
                material.SetTexture("_MainTex", null);
                material.SetColor("_EmissionColor", Color.white);
            }
        }
        public StandardSimpleLightingUpgrader(string oldShaderName, UpgradeParams upgradeParams)
        {
            if (oldShaderName == null)
            {
                throw new ArgumentNullException("oldShaderName");
            }

            RenameShader(oldShaderName, ShaderUtils.GetShaderPath(ShaderPathID.SimpleLit), UpdateMaterialKeywords);

            SetFloat("_Surface", (float)upgradeParams.surfaceType);
            SetFloat("_Blend", (float)upgradeParams.blendMode);
            SetFloat("_AlphaClip", upgradeParams.alphaClip ? 1 : 0);
            SetFloat("_SpecSource", (float)upgradeParams.specularSource);
            SetFloat("_GlossinessSource", (float)upgradeParams.glosinessSource);

            if (oldShaderName.Contains("Legacy Shaders/Self-Illumin"))
            {
                RenameTexture("_Illum", "_EmissionMap");
                RemoveTexture("_Illum");
                SetColor("_EmissionColor", Color.white);
            }
        }