Felipe Lira
8 年前
当前提交
6c22422b
共有 8 个文件被更改,包括 594 次插入 和 478 次删除
-
136Assets/LowEndMobilePipeline/Editor/LegacyShadersToLowEndUpgrader.cs
-
576Assets/LowEndMobilePipeline/Editor/LowendMobilePipelineMaterialEditor.cs
-
264Assets/LowEndMobilePipeline/Editor/LowendUpgraders.cs
-
43Assets/LowEndMobilePipeline/Editor/StandardToLowEndMaterialUpgrader.cs
-
2Assets/LowEndMobilePipeline/LowEndMobilePipeline.cs
-
2Assets/ScriptableRenderPipeline/Editor/MaterialUpgrader.cs
-
37Assets/LowEndMobilePipeline/Editor/UpgradeCommon.cs
-
12Assets/LowEndMobilePipeline/Editor/UpgradeCommon.cs.meta
|
|||
using System.Collections.Generic; |
|||
using UnityEditor.Experimental.Rendering; |
|||
using UnityEditor; |
|||
public class LegacyShadersToLowEndUpgrader |
|||
namespace UnityEditor.Experimental.Rendering.LowendMobile |
|||
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Materials to LowEndMobile - Project", false, 3)] |
|||
public static void UpgradeMaterialsToLDProject() |
|||
public class LegacyShadersToLowEndUpgrader |
|||
List<MaterialUpgrader> materialUpgraders = new List<MaterialUpgrader>(); |
|||
GetUpgraders(ref materialUpgraders); |
|||
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Materials to LowEndMobile - Project", false, 3)] |
|||
public static void UpgradeMaterialsToLDProject() |
|||
{ |
|||
List<MaterialUpgrader> materialUpgraders = new List<MaterialUpgrader>(); |
|||
GetUpgraders(ref materialUpgraders); |
|||
MaterialUpgrader.UpgradeProjectFolder(materialUpgraders, "Upgrade to LD Materials"); |
|||
} |
|||
MaterialUpgrader.UpgradeProjectFolder(materialUpgraders, "Upgrade to LD Materials"); |
|||
} |
|||
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Materials to LowEndMobile - Selection", false, 4)] |
|||
public static void UpgradeMaterialsToLDSelection() |
|||
{ |
|||
List<MaterialUpgrader> materialUpgraders = new List<MaterialUpgrader>(); |
|||
GetUpgraders(ref materialUpgraders); |
|||
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Materials to LowEndMobile - Selection", false, 4)] |
|||
public static void UpgradeMaterialsToLDSelection() |
|||
{ |
|||
List<MaterialUpgrader> materialUpgraders = new List<MaterialUpgrader>(); |
|||
GetUpgraders(ref materialUpgraders); |
|||
MaterialUpgrader.UpgradeSelection(materialUpgraders, "Upgrade to LD Materials"); |
|||
} |
|||
MaterialUpgrader.UpgradeSelection(materialUpgraders, "Upgrade to LD Materials"); |
|||
} |
|||
// TODO: Replace this logic with AssignNewShaderToMaterial
|
|||
private static void GetUpgraders(ref List<MaterialUpgrader> materialUpgraders) |
|||
{ |
|||
/////////////////////////////////////
|
|||
// Legacy Shaders upgraders /
|
|||
/////////////////////////////////////
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Lmegacy Shaders/Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Specular")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Bumped Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Bumped Specular")); |
|||
private static void GetUpgraders(ref List<MaterialUpgrader> materialUpgraders) |
|||
{ |
|||
/////////////////////////////////////
|
|||
// Legacy Shaders upgraders /
|
|||
/////////////////////////////////////
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Diffuse", SupportedUpgradeParams.diffuseOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Specular", SupportedUpgradeParams.specularOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Bumped Diffuse", SupportedUpgradeParams.diffuseOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Bumped Specular", SupportedUpgradeParams.specularOpaque)); |
|||
// TODO: option to use environment map as texture or use reflection probe
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Reflective/Bumped Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Reflective/Bumped Specular")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Reflective/Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Reflective/Specular")); |
|||
// TODO: option to use environment map as texture or use reflection probe
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Reflective/Bumped Diffuse", SupportedUpgradeParams.diffuseCubemap)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Reflective/Bumped Specular", SupportedUpgradeParams.specularOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Reflective/Diffuse", SupportedUpgradeParams.diffuseCubemap)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Reflective/Specular", SupportedUpgradeParams.specularOpaque)); |
|||
// Self-Illum upgrader
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Self-Illumin/Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Self-Illumin/Bumped Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Self-Illumin/Specular")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Self-Illumin/Bumped Specular")); |
|||
// Self-Illum upgrader
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Self-Illumin/Diffuse", SupportedUpgradeParams.diffuseOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Self-Illumin/Bumped Diffuse", SupportedUpgradeParams.diffuseOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Self-Illumin/Specular", SupportedUpgradeParams.specularOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Self-Illumin/Bumped Specular", SupportedUpgradeParams.specularOpaque)); |
|||
// Alpha Blended
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Specular")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Bumped Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Bumped Specular")); |
|||
// Alpha Blended
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Diffuse", SupportedUpgradeParams.diffuseAlpha)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Specular", SupportedUpgradeParams.specularAlpha)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Bumped Diffuse", SupportedUpgradeParams.diffuseAlpha)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Bumped Specular", SupportedUpgradeParams.specularAlpha)); |
|||
// Cutout
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Cutout/Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Cutout/Specular")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Cutout/Bumped Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Cutout/Bumped Specular")); |
|||
// Cutout
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Cutout/Diffuse", SupportedUpgradeParams.diffuseAlphaCutout)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Cutout/Specular", SupportedUpgradeParams.specularAlphaCutout)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Cutout/Bumped Diffuse", SupportedUpgradeParams.diffuseAlphaCutout)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Transparent/Cutout/Bumped Specular", SupportedUpgradeParams.specularAlphaCutout)); |
|||
/////////////////////////////////////
|
|||
// Reflective Shader Upgraders /
|
|||
/////////////////////////////////////
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Reflective/Diffuse Transperant")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Reflective/Diffuse Reflection Spec")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Reflective/Diffuse Reflection Spec Transp")); |
|||
/////////////////////////////////////
|
|||
// Reflective Shader Upgraders /
|
|||
/////////////////////////////////////
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Reflective/Diffuse Transperant", SupportedUpgradeParams.diffuseCubemapAlpha)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Reflective/Diffuse Reflection Spec", SupportedUpgradeParams.specularCubemap)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Reflective/Diffuse Reflection Spec Transp", SupportedUpgradeParams.specularCubemapAlpha)); |
|||
/////////////////////////////////////
|
|||
// Mobile Upgraders /
|
|||
/////////////////////////////////////
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/Bumped Specular")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/Bumped Specular(1 Directional Light)")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/Bumped Diffuse")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/Unlit (Supports Lightmap)")); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/VertexLit")); |
|||
/////////////////////////////////////
|
|||
// Mobile Upgraders /
|
|||
/////////////////////////////////////
|
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/Diffuse", SupportedUpgradeParams.diffuseOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/Bumped Specular", SupportedUpgradeParams.specularOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/Bumped Specular(1 Directional Light)", SupportedUpgradeParams.specularOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/Bumped Diffuse", SupportedUpgradeParams.diffuseOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/Unlit (Supports Lightmap)", SupportedUpgradeParams.diffuseOpaque)); |
|||
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Mobile/VertexLit", SupportedUpgradeParams.specularOpaque)); |
|||
/////////////////////////////////////
|
|||
// Particles /
|
|||
/////////////////////////////////////
|
|||
materialUpgraders.Add(new ParticlesAdditiveUpgrader("Particles/Additive")); |
|||
materialUpgraders.Add(new ParticlesAdditiveUpgrader("Mobile/Particles/Additive")); |
|||
materialUpgraders.Add(new ParticlesMultiplyUpgrader("Particles/Multiply")); |
|||
materialUpgraders.Add(new ParticlesMultiplyUpgrader("Mobile/Particles/Multiply")); |
|||
/////////////////////////////////////
|
|||
// Particles /
|
|||
/////////////////////////////////////
|
|||
materialUpgraders.Add(new ParticlesAdditiveUpgrader("Particles/Additive")); |
|||
materialUpgraders.Add(new ParticlesAdditiveUpgrader("Mobile/Particles/Additive")); |
|||
materialUpgraders.Add(new ParticlesMultiplyUpgrader("Particles/Multiply")); |
|||
materialUpgraders.Add(new ParticlesMultiplyUpgrader("Mobile/Particles/Multiply")); |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEditor.Experimental.Rendering; |
|||
using UnityEngine; |
|||
using UnityEngine; |
|||
using UnityEngine.Rendering; |
|||
public class LegacyBlinnPhongUpgrader : MaterialUpgrader |
|||
namespace UnityEditor.Experimental.Rendering.LowendMobile |
|||
public LegacyBlinnPhongUpgrader(string oldShaderName) |
|||
public static class SupportedUpgradeParams |
|||
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/NonPBR"); |
|||
static public UpgradeParams diffuseOpaque = new UpgradeParams() |
|||
{ |
|||
blendMode = UpgradeBlendMode.Opaque, |
|||
specularSource = SpecularSource.NoSpecular, |
|||
glosinessSource = GlossinessSource.BaseAlpha, |
|||
reflectionSource = ReflectionSource.NoReflection |
|||
}; |
|||
|
|||
static public UpgradeParams specularOpaque = new UpgradeParams() |
|||
{ |
|||
blendMode = UpgradeBlendMode.Opaque, |
|||
specularSource = SpecularSource.SpecularTextureAndColor, |
|||
glosinessSource = GlossinessSource.BaseAlpha, |
|||
reflectionSource = ReflectionSource.NoReflection |
|||
}; |
|||
|
|||
static public UpgradeParams diffuseAlpha = new UpgradeParams() |
|||
{ |
|||
blendMode = UpgradeBlendMode.Alpha, |
|||
specularSource = SpecularSource.NoSpecular, |
|||
glosinessSource = GlossinessSource.SpecularAlpha, |
|||
reflectionSource = ReflectionSource.NoReflection |
|||
}; |
|||
|
|||
static public UpgradeParams specularAlpha = new UpgradeParams() |
|||
{ |
|||
blendMode = UpgradeBlendMode.Alpha, |
|||
specularSource = SpecularSource.SpecularTextureAndColor, |
|||
glosinessSource = GlossinessSource.SpecularAlpha, |
|||
reflectionSource = ReflectionSource.NoReflection |
|||
}; |
|||
|
|||
static public UpgradeParams diffuseAlphaCutout = new UpgradeParams() |
|||
{ |
|||
blendMode = UpgradeBlendMode.Cutout, |
|||
specularSource = SpecularSource.NoSpecular, |
|||
glosinessSource = GlossinessSource.SpecularAlpha, |
|||
reflectionSource = ReflectionSource.NoReflection |
|||
}; |
|||
|
|||
static public UpgradeParams specularAlphaCutout = new UpgradeParams() |
|||
{ |
|||
blendMode = UpgradeBlendMode.Cutout, |
|||
specularSource = SpecularSource.SpecularTextureAndColor, |
|||
glosinessSource = GlossinessSource.SpecularAlpha, |
|||
reflectionSource = ReflectionSource.NoReflection |
|||
}; |
|||
|
|||
static public UpgradeParams diffuseCubemap = new UpgradeParams() |
|||
{ |
|||
blendMode = UpgradeBlendMode.Opaque, |
|||
specularSource = SpecularSource.NoSpecular, |
|||
glosinessSource = GlossinessSource.BaseAlpha, |
|||
reflectionSource = ReflectionSource.Cubemap |
|||
}; |
|||
|
|||
static public UpgradeParams specularCubemap = new UpgradeParams() |
|||
{ |
|||
blendMode = UpgradeBlendMode.Opaque, |
|||
specularSource = SpecularSource.SpecularTextureAndColor, |
|||
glosinessSource = GlossinessSource.BaseAlpha, |
|||
reflectionSource = ReflectionSource.Cubemap |
|||
}; |
|||
|
|||
static public UpgradeParams diffuseCubemapAlpha = new UpgradeParams() |
|||
{ |
|||
blendMode = UpgradeBlendMode.Alpha, |
|||
specularSource = SpecularSource.NoSpecular, |
|||
glosinessSource = GlossinessSource.BaseAlpha, |
|||
reflectionSource = ReflectionSource.Cubemap |
|||
}; |
|||
|
|||
static public UpgradeParams specularCubemapAlpha = new UpgradeParams() |
|||
{ |
|||
blendMode = UpgradeBlendMode.Alpha, |
|||
specularSource = SpecularSource.SpecularTextureAndColor, |
|||
glosinessSource = GlossinessSource.BaseAlpha, |
|||
reflectionSource = ReflectionSource.Cubemap |
|||
}; |
|||
} |
|||
public class ParticlesMultiplyUpgrader : MaterialUpgrader |
|||
{ |
|||
public ParticlesMultiplyUpgrader(string oldShaderName) |
|||
public class LegacyBlinnPhongUpgrader : MaterialUpgrader |
|||
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/Particles/Multiply"); |
|||
public LegacyBlinnPhongUpgrader(string oldShaderName, UpgradeParams upgradeParams) |
|||
{ |
|||
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/NonPBR", UpdateMaterialKeywords); |
|||
SetFloat("_Mode", (float)upgradeParams.blendMode); |
|||
SetFloat("_SpecSource", (float)upgradeParams.specularSource); |
|||
SetFloat("_GlossinessSource", (float)upgradeParams.glosinessSource); |
|||
SetFloat("_ReflectionSource", (float)upgradeParams.reflectionSource); |
|||
|
|||
if (oldShaderName.Contains("Legacy Shaders/Self-Illumin")) |
|||
{ |
|||
RenameTexture("_MainTex", "_EmissionMap"); |
|||
RemoveTexture("_MainTex"); |
|||
SetColor("_EmissionColor", Color.white); |
|||
} |
|||
} |
|||
|
|||
public static void UpdateMaterialKeywords(Material material) |
|||
{ |
|||
UpdateMaterialBlendMode(material); |
|||
UpdateMaterialSpecularSource(material); |
|||
UpdateMaterialReflectionSource(material); |
|||
SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap")); |
|||
SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap")); |
|||
SetKeyword(material, "_CUBEMAP_REFLECTION", material.GetTexture("_Cube")); |
|||
SetKeyword(material, "_EMISSION_MAP", material.GetTexture("_EmissionMap")); |
|||
} |
|||
|
|||
private static void UpdateMaterialBlendMode(Material material) |
|||
{ |
|||
UpgradeBlendMode mode = (UpgradeBlendMode)material.GetFloat("_Mode"); |
|||
switch (mode) |
|||
{ |
|||
case UpgradeBlendMode.Opaque: |
|||
material.SetOverrideTag("RenderType", ""); |
|||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); |
|||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); |
|||
material.SetInt("_ZWrite", 1); |
|||
SetKeyword(material, "_ALPHATEST_ON", false); |
|||
SetKeyword(material, "_ALPHABLEND_ON", false); |
|||
material.renderQueue = -1; |
|||
break; |
|||
|
|||
case UpgradeBlendMode.Cutout: |
|||
material.SetOverrideTag("RenderType", "Transparent"); |
|||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One); |
|||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero); |
|||
material.SetInt("_ZWrite", 1); |
|||
SetKeyword(material, "_ALPHATEST_ON", true); |
|||
SetKeyword(material, "_ALPHABLEND_ON", false); |
|||
material.renderQueue = (int)RenderQueue.AlphaTest; |
|||
break; |
|||
|
|||
case UpgradeBlendMode.Alpha: |
|||
material.SetOverrideTag("RenderType", "Transparent"); |
|||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); |
|||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); |
|||
material.SetInt("_ZWrite", 0); |
|||
SetKeyword(material, "_ALPHATEST_ON", false); |
|||
SetKeyword(material, "_ALPHABLEND_ON", true); |
|||
material.renderQueue = (int)RenderQueue.Transparent; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
private static void UpdateMaterialSpecularSource(Material material) |
|||
{ |
|||
SpecularSource specSource = (SpecularSource)material.GetFloat("_SpecSource"); |
|||
if (specSource == SpecularSource.NoSpecular) |
|||
{ |
|||
SetKeyword(material, "_SHARED_SPECULAR_DIFFUSE", false); |
|||
SetKeyword(material, "_SPECULAR_MAP", false); |
|||
SetKeyword(material, "_SPECULAR_COLOR", false); |
|||
} |
|||
else if (specSource == SpecularSource.BaseTexture) |
|||
{ |
|||
SetKeyword(material, "_SHARED_SPECULAR_DIFFUSE", true); |
|||
SetKeyword(material, "_SPECULAR_MAP", false); |
|||
SetKeyword(material, "_SPECULAR_COLOR", false); |
|||
} |
|||
else if (specSource == SpecularSource.SpecularTextureAndColor && material.GetTexture("_SpecGlossMap")) |
|||
{ |
|||
SetKeyword(material, "_SHARED_SPECULAR_DIFFUSE", false); |
|||
SetKeyword(material, "_SPECULAR_MAP", true); |
|||
SetKeyword(material, "_SPECULAR_COLOR", false); |
|||
} |
|||
else |
|||
{ |
|||
SetKeyword(material, "_SHARED_SPECULAR_DIFFUSE", false); |
|||
SetKeyword(material, "_SPECULAR_MAP", false); |
|||
SetKeyword(material, "_SPECULAR_COLOR", true); |
|||
} |
|||
|
|||
GlossinessSource glossSource = (GlossinessSource)material.GetFloat("_GlossinessSource"); |
|||
if (glossSource == GlossinessSource.BaseAlpha) |
|||
SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", true); |
|||
else |
|||
SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", false); |
|||
} |
|||
|
|||
private static void UpdateMaterialReflectionSource(Material material) |
|||
{ |
|||
ReflectionSource reflectionSource = (ReflectionSource)material.GetFloat("_ReflectionSource"); |
|||
if (reflectionSource == ReflectionSource.NoReflection) |
|||
{ |
|||
SetKeyword(material, "_CUBEMAP_REFLECTION", false); |
|||
} |
|||
else if (reflectionSource == ReflectionSource.Cubemap && material.GetTexture("_Cube")) |
|||
{ |
|||
SetKeyword(material, "_CUBEMAP_REFLECTION", true); |
|||
} |
|||
else if (reflectionSource == ReflectionSource.ReflectionProbe) |
|||
{ |
|||
Debug.LogWarning("Reflection probe not implemented yet"); |
|||
SetKeyword(material, "_CUBEMAP_REFLECTION", false); |
|||
} |
|||
else |
|||
{ |
|||
SetKeyword(material, "_CUBEMAP_REFLECTION", false); |
|||
} |
|||
} |
|||
|
|||
private static void SetKeyword(Material material, string keyword, bool enable) |
|||
{ |
|||
if (enable) |
|||
material.EnableKeyword(keyword); |
|||
else |
|||
material.DisableKeyword(keyword); |
|||
} |
|||
} |
|||
public class ParticlesAdditiveUpgrader : MaterialUpgrader |
|||
{ |
|||
public ParticlesAdditiveUpgrader(string oldShaderName) |
|||
public class ParticlesMultiplyUpgrader : MaterialUpgrader |
|||
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/Particles/Additive"); |
|||
public ParticlesMultiplyUpgrader(string oldShaderName) |
|||
{ |
|||
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/Particles/Multiply"); |
|||
} |
|||
} |
|||
|
|||
public class ParticlesAdditiveUpgrader : MaterialUpgrader |
|||
{ |
|||
public ParticlesAdditiveUpgrader(string oldShaderName) |
|||
{ |
|||
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/Particles/Additive"); |
|||
} |
|||
} |
|||
public class StandardUpgrader : MaterialUpgrader |
|||
{ |
|||
public StandardUpgrader(string oldShaderName) |
|||
public class StandardUpgrader : MaterialUpgrader |
|||
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/NonPBR"); |
|||
RenameFloat("_Glossiness", "_Shininess"); |
|||
public StandardUpgrader(string oldShaderName) |
|||
{ |
|||
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/NonPBR"); |
|||
RenameFloat("_Glossiness", "_Shininess"); |
|||
} |
|||
} |
|||
public class TerrainUpgrader : MaterialUpgrader |
|||
{ |
|||
public TerrainUpgrader(string oldShaderName) |
|||
public class TerrainUpgrader : MaterialUpgrader |
|||
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/NonPBR"); |
|||
SetFloat("_Shininess", 1.0f); |
|||
public TerrainUpgrader(string oldShaderName) |
|||
{ |
|||
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/NonPBR"); |
|||
SetFloat("_Shininess", 1.0f); |
|||
} |
|||
} |
|||
} |
|
|||
using System.Collections.Generic; |
|||
using UnityEditor; |
|||
using UnityEditor.Experimental.Rendering; |
|||
public class StandardToLowEndMaterialUpgrader |
|||
namespace UnityEditor.Experimental.Rendering.LowendMobile |
|||
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile - Project Folder", false, 1)] |
|||
private static void UpgradeMaterialsToLDProject() |
|||
public class StandardToLowEndMaterialUpgrader |
|||
List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>(); |
|||
GetUpgraders(ref upgraders); |
|||
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile - Project Folder", false, 1)] |
|||
private static void UpgradeMaterialsToLDProject() |
|||
{ |
|||
List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>(); |
|||
GetUpgraders(ref upgraders); |
|||
MaterialUpgrader.UpgradeProjectFolder(upgraders, "Upgrade to LD Materials"); |
|||
} |
|||
MaterialUpgrader.UpgradeProjectFolder(upgraders, "Upgrade to LD Materials"); |
|||
} |
|||
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile - Selection", false, 2)] |
|||
private static void UpgradeMaterialsToLDSelection() |
|||
{ |
|||
List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>(); |
|||
GetUpgraders(ref upgraders); |
|||
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile - Selection", false, 2)] |
|||
private static void UpgradeMaterialsToLDSelection() |
|||
{ |
|||
List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>(); |
|||
GetUpgraders(ref upgraders); |
|||
MaterialUpgrader.UpgradeSelection(upgraders, "Upgrade to LD Materials"); |
|||
} |
|||
MaterialUpgrader.UpgradeSelection(upgraders, "Upgrade to LD Materials"); |
|||
} |
|||
private static void GetUpgraders(ref List<MaterialUpgrader> upgraders) |
|||
{ |
|||
upgraders.Add(new StandardUpgrader("Standard (Specular setup)")); |
|||
upgraders.Add(new StandardUpgrader("Standard")); |
|||
upgraders.Add(new TerrainUpgrader("TerrainSurface")); |
|||
private static void GetUpgraders(ref List<MaterialUpgrader> upgraders) |
|||
{ |
|||
upgraders.Add(new StandardUpgrader("Standard (Specular setup)")); |
|||
upgraders.Add(new StandardUpgrader("Standard")); |
|||
upgraders.Add(new TerrainUpgrader("TerrainSurface")); |
|||
} |
|||
} |
|||
} |
|
|||
namespace UnityEditor.Experimental.Rendering.LowendMobile |
|||
{ |
|||
public enum UpgradeBlendMode |
|||
{ |
|||
Opaque, |
|||
Cutout, |
|||
Alpha |
|||
} |
|||
|
|||
public enum SpecularSource |
|||
{ |
|||
SpecularTextureAndColor, |
|||
BaseTexture, |
|||
NoSpecular |
|||
} |
|||
|
|||
public enum GlossinessSource |
|||
{ |
|||
BaseAlpha, |
|||
SpecularAlpha |
|||
} |
|||
|
|||
public enum ReflectionSource |
|||
{ |
|||
NoReflection, |
|||
Cubemap, |
|||
ReflectionProbe |
|||
} |
|||
|
|||
public struct UpgradeParams |
|||
{ |
|||
public UpgradeBlendMode blendMode; |
|||
public SpecularSource specularSource; |
|||
public GlossinessSource glosinessSource; |
|||
public ReflectionSource reflectionSource; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8fe5351dffe46e648adb2abd7a167ce7 |
|||
timeCreated: 1490691870 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue