浏览代码

Added emission self-illumin upgrader to low end mobile pipeline.

/vr_sandbox
Felipe Lira 8 年前
当前提交
6b76e6ce
共有 5 个文件被更改,包括 24 次插入6 次删除
  1. 7
      Assets/LowEndMobilePipeline/Editor/LegacyShadersToLowEndUpgrader.cs
  2. 4
      Assets/LowEndMobilePipeline/Editor/LowendMobilePipelineMaterialEditor.cs
  3. 8
      Assets/LowEndMobilePipeline/Editor/LowendUpgraders.cs
  4. 2
      Assets/LowEndMobilePipeline/Shaders/LowEndMobilePipelineCore.cginc
  5. 9
      Assets/ScriptableRenderPipeline/Editor/MaterialUpgrader.cs

7
Assets/LowEndMobilePipeline/Editor/LegacyShadersToLowEndUpgrader.cs


materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Reflective/Diffuse", SupportedUpgradeParams.diffuseCubemap));
materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Reflective/Specular", SupportedUpgradeParams.specularOpaque));
// Self-Illum upgrade still not supported
//materialUpgraders.Add(new LegacyBlinnPhongUpgrader("Legacy Shaders/Self-Illum/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", SupportedUpgradeParams.diffuseAlpha));

4
Assets/LowEndMobilePipeline/Editor/LowendMobilePipelineMaterialEditor.cs


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"));
Debug.Log("BlendMode");
BlendMode mode = (BlendMode) material.GetFloat("_Mode");
switch (mode)
{

private void UpdateMaterialSpecularSource(Material material)
{
Debug.Log("SpecularSource");
SpecularSource specSource = (SpecularSource) material.GetFloat("_SpecSource");
if (specSource == SpecularSource.NoSpecular)
{

private void UpdateMaterialReflectionSource(Material material)
{
Debug.Log("ReflectionSource");
ReflectionSource reflectionSource = (ReflectionSource) material.GetFloat("_ReflectionSource");
if (reflectionSource == ReflectionSource.NoReflection)
{

8
Assets/LowEndMobilePipeline/Editor/LowendUpgraders.cs


using UnityEditor.Experimental.Rendering;
using UnityEngine;
public struct UpgradeParams
{

SetNewFloatProperty("_SpecSource", upgraderParams.specularSource);
SetNewFloatProperty("_GlossinessSource", upgraderParams.glosinessSource);
SetNewFloatProperty("_ReflectionSource", upgraderParams.reflectionSource);
if (oldShaderName.Contains("Legacy Shaders/Self-Illumin"))
{
RenameTexture("_MainTex", "_EmissionMap");
RemoveTexture("_MainTex");
SetNewColorProperty("_EmissionColor", Color.white);
}
}
}

2
Assets/LowEndMobilePipeline/Shaders/LowEndMobilePipelineCore.cginc


inline void Emission(v2f i, out half3 emission)
{
#ifdef _EMISSION_MAP
emission = tex2D(_EmissionMap, i.uv01.xy) * _EmissionColor
emission = tex2D(_EmissionMap, i.uv01.xy) * _EmissionColor;
#else
emission = _EmissionColor;
#endif

9
Assets/ScriptableRenderPipeline/Editor/MaterialUpgrader.cs


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

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

public void SetNewFloatProperty(string propertyName, float value)
{
m_FloatPropertiesToSet[propertyName] = value;
}
public void SetNewColorProperty(string propertyName, Color value)
{
m_ColorPropertiesToSet[propertyName] = value;
}
static bool IsMaterialPath(string path)

正在加载...
取消
保存