浏览代码

Fixed upgrade issues regarding shininess values being zero.

/vr_sandbox
Felipe Lira 8 年前
当前提交
06640421
共有 5 个文件被更改,包括 40 次插入20 次删除
  1. 12
      Assets/LowEndMobilePipeline/Editor/LegacyShadersToLowEndUpgrader.cs
  2. 10
      Assets/LowEndMobilePipeline/Editor/LowendMobilePipelineMaterialEditor.cs
  3. 18
      Assets/LowEndMobilePipeline/Editor/LowendUpgraders.cs
  4. 18
      Assets/LowEndMobilePipeline/Editor/StandardToLowEndMaterialUpgrader.cs
  5. 2
      Assets/LowEndMobilePipeline/Shaders/LowEndMobilePipeline.shader

12
Assets/LowEndMobilePipeline/Editor/LegacyShadersToLowEndUpgrader.cs


};
}
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Materials to LowEndMobile - Selection", false, 3)]
public static void UpgradeMaterialsToLDSelection()
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Materials to LowEndMobile - Project", false, 3)]
public static void UpgradeMaterialsToLDProject()
MaterialUpgrader.UpgradeSelection(materialUpgraders, "Upgrade to LD Materials");
MaterialUpgrader.UpgradeProjectFolder(materialUpgraders, "Upgrade to LD Materials");
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Materials to LowEndMobile - Project", false, 4)]
public static void UpgradeMaterialsToLDProject()
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Materials to LowEndMobile - Selection", false, 4)]
public static void UpgradeMaterialsToLDSelection()
MaterialUpgrader.UpgradeProjectFolder(materialUpgraders, "Upgrade to LD Materials");
MaterialUpgrader.UpgradeSelection(materialUpgraders, "Upgrade to LD Materials");
}
// TODO: Replace this logic with AssignNewShaderToMaterial

10
Assets/LowEndMobilePipeline/Editor/LowendMobilePipelineMaterialEditor.cs


public class LowendMobilePipelineMaterialEditor : ShaderGUI
{
private const float kMinShininessValue = 0.01f;
private MaterialProperty blendModeProp = null;
private MaterialProperty albedoMapProp = null;
private MaterialProperty albedoColorProp = null;

{
base.AssignNewShaderToMaterial(material, oldShader, newShader);
// Shininess value cannot be zero since it will produce undefined values for cases where pow(0, 0).
float shininess = material.GetFloat("_Shininess");
material.SetFloat("_Shininess", Mathf.Clamp(shininess, kMinShininessValue, 1.0f));
UpdateMaterialKeywords(material);
}

if (specSource != SpecularSource.NoSpecular)
{
m_MaterialEditor.RangeProperty(shininessProp, Styles.shininessLabel);
EditorGUI.BeginChangeCheck();
float shininess = EditorGUILayout.Slider(Styles.shininessLabel, shininessProp.floatValue, kMinShininessValue, 1.0f);
if (EditorGUI.EndChangeCheck())
shininessProp.floatValue = shininess;
}
}

18
Assets/LowEndMobilePipeline/Editor/LowendUpgraders.cs


RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/Particles/Additive");
}
}
public class StandardUpgrader : MaterialUpgrader
{
public StandardUpgrader(string oldShaderName)
{
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/NonPBR");
RenameFloat("_Glossiness", "_Shininess");
}
}
public class TerrainUpgrader : MaterialUpgrader
{
public TerrainUpgrader(string oldShaderName)
{
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/NonPBR");
SetNewFloatProperty("_Shininess", 1.0f);
}
}

18
Assets/LowEndMobilePipeline/Editor/StandardToLowEndMaterialUpgrader.cs


using UnityEditor;
using UnityEditor.Experimental.Rendering;
public class StandardToLowEndMaterialUpgrader : MaterialUpgrader
public class StandardToLowEndMaterialUpgrader
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile - Selection", false, 1)]
[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>();

}
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile - Project Folder", false, 2)]
[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>();

private static void GetUpgraders(ref List<MaterialUpgrader> upgraders)
{
upgraders.Add(new StandardToLowEndMaterialUpgrader("Standard (Specular setup)"));
upgraders.Add(new StandardToLowEndMaterialUpgrader("Standard"));
upgraders.Add(new StandardToLowEndMaterialUpgrader("TerrainSurface"));
}
StandardToLowEndMaterialUpgrader(string oldShaderName)
{
RenameShader(oldShaderName, "ScriptableRenderPipeline/LowEndMobile/NonPBR");
RenameFloat("_Glossiness", "_Shininess");
upgraders.Add(new StandardUpgrader("Standard (Specular setup)"));
upgraders.Add(new StandardUpgrader("Standard"));
upgraders.Add(new TerrainUpgrader("TerrainSurface"));
}
}

2
Assets/LowEndMobilePipeline/Shaders/LowEndMobilePipeline.shader


_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_Shininess("Shininess", Range(0.0, 1.0)) = 1.0
_Shininess("Shininess", Range(0.01, 1.0)) = 1.0
_GlossMapScale("Smoothness Factor", Range(0.0, 1.0)) = 1.0
_Glossiness("Glossiness", Range(0.0, 1.0)) = 0.5

正在加载...
取消
保存