static void UpgradeV3(Material material, ShaderID shaderID) { if (shaderID.IsShaderGraph()) { return; } switch (shaderID) { case ShaderID.Lit: case ShaderID.SimpleLit: case ShaderID.ParticlesLit: case ShaderID.ParticlesSimpleLit: case ShaderID.ParticlesUnlit: var propertyID = Shader.PropertyToID("_EmissionColor"); if (material.HasProperty(propertyID)) { // In older version there was a bug that these shaders did not had HDR attribute on emission property. // This caused emission color to be converted from gamma to linear space. // In order to avoid visual regression on older projects we will do gamma to linear conversion here. var emissionGamma = material.GetColor(propertyID); var emissionLinear = emissionGamma.linear; material.SetColor(propertyID, emissionLinear); } break; } }
static void UpgradeV2(Material material, ShaderID shaderID) { if (shaderID.IsShaderGraph()) { return; } // fix 50 offset on shaders if (material.HasProperty("_QueueOffset")) { BaseShaderGUI.SetupMaterialBlendMode(material); } }
static void UpgradeV1(Material material, ShaderID shaderID) { if (shaderID.IsShaderGraph()) { return; } var shaderPath = ShaderUtils.GetShaderPath((ShaderPathID)shaderID); var upgradeFlag = MaterialUpgrader.UpgradeFlags.LogMessageWhenNoUpgraderFound; switch (shaderID) { case ShaderID.Unlit: MaterialUpgrader.Upgrade(material, new UnlitUpdaterV1(shaderPath), upgradeFlag); UnlitShader.SetMaterialKeywords(material); break; case ShaderID.SimpleLit: MaterialUpgrader.Upgrade(material, new SimpleLitUpdaterV1(shaderPath), upgradeFlag); SimpleLitShader.SetMaterialKeywords(material, SimpleLitGUI.SetMaterialKeywords); break; case ShaderID.Lit: MaterialUpgrader.Upgrade(material, new LitUpdaterV1(shaderPath), upgradeFlag); LitShader.SetMaterialKeywords(material, LitGUI.SetMaterialKeywords); break; case ShaderID.ParticlesLit: MaterialUpgrader.Upgrade(material, new ParticleUpdaterV1(shaderPath), upgradeFlag); ParticlesLitShader.SetMaterialKeywords(material, LitGUI.SetMaterialKeywords, ParticleGUI.SetMaterialKeywords); break; case ShaderID.ParticlesSimpleLit: MaterialUpgrader.Upgrade(material, new ParticleUpdaterV1(shaderPath), upgradeFlag); ParticlesSimpleLitShader.SetMaterialKeywords(material, SimpleLitGUI.SetMaterialKeywords, ParticleGUI.SetMaterialKeywords); break; case ShaderID.ParticlesUnlit: MaterialUpgrader.Upgrade(material, new ParticleUpdaterV1(shaderPath), upgradeFlag); ParticlesUnlitShader.SetMaterialKeywords(material, null, ParticleGUI.SetMaterialKeywords); break; } }
static void UpgradeV5(Material material, ShaderID shaderID) { if (shaderID.IsShaderGraph()) { return; } var propertyID = Shader.PropertyToID("_Surface"); if (material.HasProperty(propertyID)) { float surfaceType = material.GetFloat(propertyID); if (surfaceType >= 1.0f) { material.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); } else { material.DisableKeyword("_SURFACE_TYPE_TRANSPARENT"); } } }