浏览代码

Added ReflectionCubemap support to lowend mobile. Added Material upgraders to most of legacy shaders.

/vr_sandbox
Felipe Lira 8 年前
当前提交
85eec1f1
共有 9 个文件被更改,包括 294 次插入62 次删除
  1. 59
      Assets/LowEndMobilePipeline/Editor/LowendMobilePipelineMaterialEditor.cs
  2. 18
      Assets/LowEndMobilePipeline/Editor/StandardToLowEndMaterialUpgrader.cs
  3. 17
      Assets/LowEndMobilePipeline/LowEndMobilePipeline.shader
  4. 16
      Assets/LowEndMobilePipeline/LowEndMobilePipelineCore.cginc
  5. 32
      Assets/ScriptableRenderPipeline/Editor/MaterialUpgrader.cs
  6. 164
      Assets/LowEndMobilePipeline/Editor/LegacyShadersToLowEndUpgrader.cs
  7. 12
      Assets/LowEndMobilePipeline/Editor/LegacyShadersToLowEndUpgrader.cs.meta
  8. 12
      Assets/LowEndMobilePipeline/Editor/LegacyMobileToLowendMobileUpgrader.cs.meta
  9. 26
      Assets/LowEndMobilePipeline/Editor/LegacyMobileToLowendMobileUpgrader.cs

59
Assets/LowEndMobilePipeline/Editor/LowendMobilePipelineMaterialEditor.cs


private MaterialProperty alphaCutoffProp = null;
private MaterialProperty specularSourceProp = null;
private MaterialProperty glossinessSourceProp = null;
private MaterialProperty reflectionSourceProp = null;
private MaterialProperty specularGlossMapProp = null;
private MaterialProperty specularColorProp = null;
private MaterialProperty shininessProp = null;

private MaterialProperty reflectionMapProp = null;
private MaterialProperty reflectionColorProp = null;
public enum BlendMode
{

SpecularAlpha
}
public enum ReflectionSource
{
NoReflection,
Cubemap,
ReflectionProbe
}
private void Awake()
{
Material material = target as Material;

public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map");
public static GUIContent emissionMapLabel = new GUIContent("Emission Map", "Emission Map");
public static GUIContent reflectionMapLabel = new GUIContent("Reflection Source", "Reflection Source Map");
public static GUIContent alphaCutoutWarning =
new GUIContent(

public static readonly string[] blendNames = Enum.GetNames(typeof(BlendMode));
public static readonly string[] specSourceNames = Enum.GetNames(typeof(SpecularSource));
public static readonly string[] glossinessSourceNames = Enum.GetNames(typeof(GlossinessSource));
public static readonly string[] speculaSourceNames = Enum.GetNames(typeof(ReflectionSource));
public static string renderingModeLabel = "Rendering Mode";
public static string specularSourceLabel = "Specular Color Source";

public static string shininessLabel = "Shininess";
public static string normalMapLabel = "Normal map";
public static string emissionColorLabel = "Emission Color";
public static string reflectionSourceLabel = "Reflection Source";
}
private void FindMaterialProperties(Material material)

bumpMapProp = GetMaterialProperty(mats, "_BumpMap");
emissionMapProp = GetMaterialProperty(mats, "_EmissionMap");
emissionColorProp = GetMaterialProperty(mats, "_EmissionColor");
reflectionMapProp = GetMaterialProperty(mats, "_Cube");
reflectionColorProp = GetMaterialProperty(mats, "_ReflectColor");
reflectionSourceProp = GetMaterialProperty(mats, "_ReflectionSource");
}
public override void OnInspectorGUI()

EditorGUILayout.Space();
TexturePropertySingleLine(Styles.emissionMapLabel, emissionMapProp, emissionColorProp);
EditorGUILayout.Space();
DoReflection();
if (EditorGUI.EndChangeCheck())
UpdateMaterialKeywords(material);

}
}
private void DoReflection()
{
EditorGUILayout.Space();
int source = (int) reflectionSourceProp.floatValue;
EditorGUI.BeginChangeCheck();
source = EditorGUILayout.Popup(Styles.reflectionSourceLabel, source, Styles.speculaSourceNames);
if (EditorGUI.EndChangeCheck())
reflectionSourceProp.floatValue = (float) source;
EditorGUILayout.Space();
ReflectionSource reflectionSource = (ReflectionSource) reflectionSourceProp.floatValue;
if (reflectionSource == ReflectionSource.Cubemap)
TexturePropertySingleLine(Styles.reflectionMapLabel, reflectionMapProp, reflectionColorProp);
}
UpdateMaterialReflectionSource(material);
SetKeyword(material, "_CUBEMAP_REFLECTION", material.GetTexture("_Cube"));
}
private void UpdateMaterialBlendMode(Material material)

SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", true);
else
SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", false);
}
private void UpdateMaterialReflectionSource(Material material)
{
ReflectionSource reflectionSource = (ReflectionSource) reflectionSourceProp.floatValue;
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 void SetKeyword(Material material, string keyword, bool enable)

18
Assets/LowEndMobilePipeline/Editor/StandardToLowEndMaterialUpgrader.cs


public class StandardToLowEndMaterialUpgrader : MaterialUpgrader
{
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile - Selection")]
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile - Selection", false, 1)]
upgraders.Add(new StandardToLowEndMaterialUpgrader("Standard (Specular setup)"));
upgraders.Add(new StandardToLowEndMaterialUpgrader("Standard"));
upgraders.Add(new StandardToLowEndMaterialUpgrader("TerrainSurface"));
GetUpgraders(ref upgraders);
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile - Project Folder")]
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile - Project Folder", false, 2)]
GetUpgraders(ref upgraders);
MaterialUpgrader.UpgradeSelection(upgraders, "Upgrade to LD Materials");
}
private static void GetUpgraders(ref List<MaterialUpgrader> upgraders)
{
MaterialUpgrader.UpgradeSelection(upgraders, "Upgrade to LD Materials");
RenameFloat("_Glossiness", "_Shininess");
}
}

17
Assets/LowEndMobilePipeline/LowEndMobilePipeline.shader


_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_Glossiness("Glossiness", Range(0.0, 1.0)) = 0.5
_Glossiness("Glossiness", Range(0.0, 1.0)) = 0.5
_Cube ("Reflection Cubemap", CUBE) = "" {}
_ReflectColor("Reflection Color", Color) = (1, 1, 1, 1)
_ReflectionSource("Reflection Source", Float) = 0
[HideInInspector] _SpecSource("Specular Color Source", Float) = 0.0
_SpecColor("Specular", Color) = (1.0, 1.0, 1.0)

_Parallax("Height Scale", Range(0.005, 0.08)) = 0.02
_ParallaxMap("Height Map", 2D) = "black" {}
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
_OcclusionMap("Occlusion", 2D) = "white" {}
_EmissionColor("Emission Color", Color) = (0,0,0)
_EmissionMap("Emission", 2D) = "white" {}

#pragma shader_feature _GLOSSINESS_FROM_BASE_ALPHA
#pragma shader_feature _NORMALMAP
#pragma shader_feature _EMISSION_MAP
#pragma shader_feature _CUBEMAP_REFLECTION
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ HARD_SHADOWS SOFT_SHADOWS

SpecularGloss(diffuse, alpha, specularGloss);
// Indirect Light Contribution
half3 indirectDiffuse;
IndirectDiffuse(i, diffuse, indirectDiffuse);
half3 indirect;
Indirect(i, diffuse, normal, alpha, indirect);
half3 emissionColor;
Emission(i, emissionColor);

directColor += EvaluateOneLight(additionalLight, diffuse, specularGloss, normal, i.posWS, viewDir);
}
half3 color = directColor + indirectDiffuse + emissionColor;
half3 color = directColor + indirect + emissionColor;
UNITY_APPLY_FOG(i.fogCoord, color);
return OutputColor(color, alpha);

16
Assets/LowEndMobilePipeline/LowEndMobilePipelineCore.cginc


half4x4 _WorldToShadow[MAX_SHADOW_CASCADES];
float4 _DirShadowSplitSpheres[MAX_SHADOW_CASCADES];
half _Shininess;
samplerCUBE _Cube;
half4 _ReflectColor;
inline void NormalMap(v2f i, out half3 normal)
{

#endif
}
inline void IndirectDiffuse(v2f i, half3 diffuse, out half3 indirectDiffuse)
inline void Indirect(v2f i, half3 diffuse, half3 normal, half glossiness, out half3 indirect)
indirectDiffuse = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uv01.zw)) * diffuse;
indirect = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uv01.zw)) * diffuse;
indirectDiffuse = i.fogCoord.yzw * diffuse;
indirect = i.fogCoord.yzw * diffuse;
#endif
// TODO: we can use reflect vec to compute specular instead of half when computing cubemap reflection
#ifdef _CUBEMAP_REFLECTION
half3 reflectVec = reflect(-i.viewDir.xyz, normal);
half3 indirectSpecular = texCUBE(_Cube, reflectVec) * _ReflectColor * glossiness;
indirect += indirectSpecular;
#endif
}

32
Assets/ScriptableRenderPipeline/Editor/MaterialUpgrader.cs


Dictionary<string, string> m_TextureRename = new Dictionary<string, string>();
Dictionary<string, string> m_FloatRename = new Dictionary<string, string>();
Dictionary<string, string> m_ColorRename = new Dictionary<string, string>();
Dictionary<string, float> m_FloatPropertiesToSet = new Dictionary<string, float>();
List<string> m_TexturesToRemove = new List<string>();
[Flags]

LogErrorOnNonExistingProperty = 1,
CleanupNonUpgradedProperties = 2,
LogMessageWhenNoUpgraderFound = 4
}
public void Upgrade(Material material, UpgradeFlags flags)

material.shader = Shader.Find(m_NewShader);
material.CopyPropertiesFromMaterial(newMaterial);
UnityEngine.Object.DestroyImmediate(newMaterial);
material.shaderKeywords = new string[0];
var matEditor = Editor.CreateEditor(material) as MaterialEditor;
matEditor.SetShader(Shader.Find(m_NewShader), false);
matEditor.serializedObject.ApplyModifiedPropertiesWithoutUndo();
}
// Overridable function to implement custom material upgrading functionality

foreach (var prop in m_TexturesToRemove)
dstMaterial.SetTexture(prop, null);
foreach (var prop in m_FloatPropertiesToSet)
dstMaterial.SetFloat(prop.Key, prop.Value);
}
public void RenameShader(string oldName, string newName)

m_TexturesToRemove.Add(name);
}
public void SetNewFloatProperty(string propertyName, float value)
{
m_FloatPropertiesToSet[propertyName] = value;
}
static bool IsMaterialPath(string path)
{
return path.EndsWith(".mat", StringComparison.OrdinalIgnoreCase);

AssetDatabase.Refresh();
}
public static void UpgradeProjectFolder(List<MaterialUpgrader> upgraders, string progressBarName)
public static void UpgradeProjectFolder(List<MaterialUpgrader> upgraders, string progressBarName, UpgradeFlags flags = UpgradeFlags.None)
{
if (!EditorUtility.DisplayDialog("Material Upgrader", "The upgrade will overwrite material settings in your project." +
"Be sure to have a project backup before proceeding", "Proceed", "Cancel"))

break;
Material m = UnityEditor.AssetDatabase.LoadMainAssetAtPath(path) as Material;
Upgrade(m, upgraders, UpgradeFlags.None);
Upgrade(m, upgraders, flags);
//SaveAssetsAndFreeMemory();
}

public static void Upgrade(Material material, List<MaterialUpgrader> upgraders, UpgradeFlags flags)
{
var upgrader = GetUpgrader(upgraders, material);
else if ((flags & UpgradeFlags.LogMessageWhenNoUpgraderFound) == UpgradeFlags.LogMessageWhenNoUpgraderFound)
Debug.Log(string.Format("There's no upgrader to convert {0} shader to selected pipeline", material.shader.name));
public static void UpgradeSelection(List<MaterialUpgrader> upgraders, string progressBarName)
public static void UpgradeSelection(List<MaterialUpgrader> upgraders, string progressBarName, UpgradeFlags flags = UpgradeFlags.None)
if (!EditorUtility.DisplayDialog("Material Upgrader", "The upgrade will overwrite all selected material settings" +
var selection = Selection.objects;
if (!EditorUtility.DisplayDialog("Material Upgrader", string.Format("The upgrade will possibly overwrite all the {0} selected material settings", selection.Length) +
var selection = Selection.objects;
for (int i = 0; i < selection.Length; i++)
{

var material = selection[i] as Material;
Upgrade(material, upgraders, UpgradeFlags.None);
Upgrade(material, upgraders, flags);
if (material != null)
lastMaterialName = material.name;
}

164
Assets/LowEndMobilePipeline/Editor/LegacyShadersToLowEndUpgrader.cs


using System.Collections.Generic;
using UnityEditor.Experimental.Rendering;
using UnityEditor;
public class LegacyShadersToLowEndUpgrader : MaterialUpgrader
{
private struct UpgradeParams
{
public float blendMode;
public float specularSource;
public float glosinessSource;
public float reflectionSource;
}
private static class SupportedUpgradeParams
{
static public UpgradeParams diffuseOpaque = new UpgradeParams()
{
blendMode = (float)LowendMobilePipelineMaterialEditor.BlendMode.Opaque,
specularSource = (float)LowendMobilePipelineMaterialEditor.SpecularSource.NoSpecular,
glosinessSource = (float)LowendMobilePipelineMaterialEditor.GlossinessSource.BaseAlpha,
reflectionSource = (float)LowendMobilePipelineMaterialEditor.ReflectionSource.NoReflection
};
static public UpgradeParams specularOpaque = new UpgradeParams()
{
blendMode = (float)LowendMobilePipelineMaterialEditor.BlendMode.Opaque,
specularSource = (float)LowendMobilePipelineMaterialEditor.SpecularSource.SpecularTextureAndColor,
glosinessSource = (float)LowendMobilePipelineMaterialEditor.GlossinessSource.BaseAlpha,
reflectionSource = (float)LowendMobilePipelineMaterialEditor.ReflectionSource.NoReflection
};
static public UpgradeParams diffuseAlpha = new UpgradeParams()
{
blendMode = (float)LowendMobilePipelineMaterialEditor.BlendMode.Alpha,
specularSource = (float)LowendMobilePipelineMaterialEditor.SpecularSource.NoSpecular,
glosinessSource = (float)LowendMobilePipelineMaterialEditor.GlossinessSource.SpecularAlpha,
reflectionSource = (float)LowendMobilePipelineMaterialEditor.ReflectionSource.NoReflection
};
static public UpgradeParams specularAlpha = new UpgradeParams()
{
blendMode = (float)LowendMobilePipelineMaterialEditor.BlendMode.Alpha,
specularSource = (float)LowendMobilePipelineMaterialEditor.SpecularSource.SpecularTextureAndColor,
glosinessSource = (float)LowendMobilePipelineMaterialEditor.GlossinessSource.SpecularAlpha,
reflectionSource = (float)LowendMobilePipelineMaterialEditor.ReflectionSource.NoReflection
};
static public UpgradeParams diffuseAlphaCutout = new UpgradeParams()
{
blendMode = (float)LowendMobilePipelineMaterialEditor.BlendMode.Cutout,
specularSource = (float)LowendMobilePipelineMaterialEditor.SpecularSource.NoSpecular,
glosinessSource = (float)LowendMobilePipelineMaterialEditor.GlossinessSource.SpecularAlpha,
reflectionSource = (float)LowendMobilePipelineMaterialEditor.ReflectionSource.NoReflection
};
static public UpgradeParams specularAlphaCutout = new UpgradeParams()
{
blendMode = (float)LowendMobilePipelineMaterialEditor.BlendMode.Cutout,
specularSource = (float)LowendMobilePipelineMaterialEditor.SpecularSource.SpecularTextureAndColor,
glosinessSource = (float)LowendMobilePipelineMaterialEditor.GlossinessSource.SpecularAlpha,
reflectionSource = (float)LowendMobilePipelineMaterialEditor.ReflectionSource.NoReflection
};
static public UpgradeParams diffuseCubemap = new UpgradeParams()
{
blendMode = (float)LowendMobilePipelineMaterialEditor.BlendMode.Opaque,
specularSource = (float)LowendMobilePipelineMaterialEditor.SpecularSource.NoSpecular,
glosinessSource = (float)LowendMobilePipelineMaterialEditor.GlossinessSource.BaseAlpha,
reflectionSource = (float)LowendMobilePipelineMaterialEditor.ReflectionSource.Cubemap
};
static public UpgradeParams specularCubemap = new UpgradeParams()
{
blendMode = (float)LowendMobilePipelineMaterialEditor.BlendMode.Opaque,
specularSource = (float)LowendMobilePipelineMaterialEditor.SpecularSource.SpecularTextureAndColor,
glosinessSource = (float)LowendMobilePipelineMaterialEditor.GlossinessSource.BaseAlpha,
reflectionSource = (float)LowendMobilePipelineMaterialEditor.ReflectionSource.Cubemap
};
static public UpgradeParams specularCubemapAlpha = new UpgradeParams()
{
blendMode = (float)LowendMobilePipelineMaterialEditor.BlendMode.Alpha,
specularSource = (float)LowendMobilePipelineMaterialEditor.SpecularSource.SpecularTextureAndColor,
glosinessSource = (float)LowendMobilePipelineMaterialEditor.GlossinessSource.BaseAlpha,
reflectionSource = (float)LowendMobilePipelineMaterialEditor.ReflectionSource.Cubemap
};
}
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Materials to LowEndMobile - Selection", false, 3)]
public static void UpgradeMaterialsToLDSelection()
{
List<MaterialUpgrader> materialUpgraders = new List<MaterialUpgrader>();
GetUpgraders(ref materialUpgraders);
MaterialUpgrader.UpgradeSelection(materialUpgraders, "Upgrade to LD Materials");
}
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Materials to LowEndMobile - Project", false, 4)]
public static void UpgradeMaterialsToLDProject()
{
List<MaterialUpgrader> materialUpgraders = new List<MaterialUpgrader>();
GetUpgraders(ref materialUpgraders);
MaterialUpgrader.UpgradeProjectFolder(materialUpgraders, "Upgrade to LD Materials");
}
private static void GetUpgraders(ref List<MaterialUpgrader> materialUpgraders)
{
/////////////////////////////////////
// Legacy Shaders upgraders /
/////////////////////////////////////
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Diffuse", SupportedUpgradeParams.diffuseOpaque));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Specular", SupportedUpgradeParams.specularOpaque));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Bumped Diffuse", SupportedUpgradeParams.diffuseOpaque));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Bumped Specular", SupportedUpgradeParams.specularOpaque));
// TODO: option to use environment map as texture or use reflection probe
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Reflective/Bumped Diffuse", SupportedUpgradeParams.diffuseCubemap));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Reflective/Bumped Specular", SupportedUpgradeParams.specularOpaque));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Reflective/Diffuse", SupportedUpgradeParams.diffuseCubemap));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Reflective/Specular", SupportedUpgradeParams.specularOpaque));
// Self-Illum upgrade still not supported
//materialUpgraders.Add(new LegacyShaderToLowEndUpgrader("Legacy Shaders/Self-Illum/Bumped Specular"));
// Alpha Blended
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Transparent/Diffuse", SupportedUpgradeParams.diffuseAlpha));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Transparent/Specular", SupportedUpgradeParams.specularCubemap));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Transparent/Bumped Diffuse", SupportedUpgradeParams.diffuseAlpha));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Transparent/Bumped Specular", SupportedUpgradeParams.specularCubemap));
// Cutout
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Transparent/Cutout/Diffuse", SupportedUpgradeParams.diffuseAlphaCutout));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Transparent/Cutout/Specular", SupportedUpgradeParams.specularAlphaCutout));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Transparent/Cutout/Bumped Diffuse", SupportedUpgradeParams.diffuseAlphaCutout));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Legacy Shaders/Transparent/Cutout/Bumped Specular", SupportedUpgradeParams.specularAlphaCutout));
/////////////////////////////////////
// Reflective Shader Upgraders /
/////////////////////////////////////
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Reflective/Diffuse Reflection Spec", SupportedUpgradeParams.specularCubemap));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Reflective/Diffuse Reflection Spec Transp", SupportedUpgradeParams.specularCubemapAlpha));
/////////////////////////////////////
// Mobile Upgraders /
/////////////////////////////////////
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Mobile/Diffuse", SupportedUpgradeParams.diffuseOpaque));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Mobile/Bumped Specular", SupportedUpgradeParams.specularOpaque));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Mobile/Bumped Specular(1 Directional Light)", SupportedUpgradeParams.specularOpaque));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Mobile/Bumped Diffuse", SupportedUpgradeParams.diffuseOpaque));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Mobile/Unlit (Supports Lightmap)", SupportedUpgradeParams.diffuseOpaque));
materialUpgraders.Add(new LegacyShadersToLowEndUpgrader("Mobile/VertexLit", SupportedUpgradeParams.specularOpaque));
}
LegacyShadersToLowEndUpgrader(string oldShaderName, UpgradeParams upgraderParams)
{
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile");
SetNewFloatProperty("_Mode", upgraderParams.blendMode);
SetNewFloatProperty("_SpecSource", upgraderParams.specularSource);
SetNewFloatProperty("_GlossinessSource", upgraderParams.glosinessSource);
SetNewFloatProperty("_ReflectionSource", upgraderParams.reflectionSource);
}
}

12
Assets/LowEndMobilePipeline/Editor/LegacyShadersToLowEndUpgrader.cs.meta


fileFormatVersion: 2
guid: 6d97da3faef6c8a46bc29fcc467932b4
timeCreated: 1489573636
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

12
Assets/LowEndMobilePipeline/Editor/LegacyMobileToLowendMobileUpgrader.cs.meta


fileFormatVersion: 2
guid: 8ca28808ea3d6ea48a14815a267f8016
timeCreated: 1487764514
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/LowEndMobilePipeline/Editor/LegacyMobileToLowendMobileUpgrader.cs


using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Experimental.Rendering;
public class LegacyMobileToLowendMobileUpgrader : MaterialUpgrader
{
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Mobile Materials to LowEndMobile")]
public static void UpgradeMaterialsToLD()
{
List<MaterialUpgrader> materialUpgraders = new List<MaterialUpgrader>();
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Diffuse"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Bumped Specular"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Bumped Specular(1 Directional Light)"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Bumped Diffuse"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Unlit (Supports Lightmap)"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/VertexLit"));
MaterialUpgrader.UpgradeProjectFolder(materialUpgraders, "Upgrade to LD Materials");
}
LegacyMobileToLowendMobileUpgrader(string oldShaderName)
{
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile");
RenameFloat("_Shininess", "_Glossiness");
}
}
正在加载...
取消
保存