浏览代码

tabs->spaces

/main
vlad-andreev 8 年前
当前提交
000cb2f4
共有 2 个文件被更改,包括 61 次插入61 次删除
  1. 56
      Assets/ScriptableRenderLoop/HDRenderLoop/Editor/UpgradeStandardShaderMaterials.cs
  2. 66
      Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Editor/StandardToHDLitMaterialUpgrader.cs

56
Assets/ScriptableRenderLoop/HDRenderLoop/Editor/UpgradeStandardShaderMaterials.cs


namespace UnityEditor.Experimental.ScriptableRenderLoop
{
public class UpgradeStandardShaderMaterials
{
static List<MaterialUpgrader> GetHDUpgraders()
{
var upgraders = new List<MaterialUpgrader> ();
upgraders.Add(new StandardToHDLitMaterialUpgrader ());
public class UpgradeStandardShaderMaterials
{
static List<MaterialUpgrader> GetHDUpgraders()
{
var upgraders = new List<MaterialUpgrader>();
upgraders.Add(new StandardToHDLitMaterialUpgrader());
}
}
[MenuItem("HDRenderLoop/Upgrade Materials - Project")]
static void UpgradeMaterialsProject()
{
MaterialUpgrader.UpgradeProjectFolder (GetHDUpgraders(), "Upgrade to HD Material");
}
[MenuItem("HDRenderLoop/Upgrade Materials - Selection")]
static void UpgradeMaterialsSelection()
{
MaterialUpgrader.UpgradeSelection (GetHDUpgraders(), "Upgrade to HD Material");
}
[MenuItem("HDRenderLoop/Upgrade Materials - Project")]
static void UpgradeMaterialsProject()
{
MaterialUpgrader.UpgradeProjectFolder(GetHDUpgraders(), "Upgrade to HD Material");
}
[MenuItem("HDRenderLoop/Modify Light Intensity for Upgrade - Scene Only")]
static void UpgradeLights()
{
Light[] lights = Light.GetLights(LightType.Directional, 0);
foreach (var l in lights)
{
l.intensity *= Mathf.PI;
}
}
}
[MenuItem("HDRenderLoop/Upgrade Materials - Selection")]
static void UpgradeMaterialsSelection()
{
MaterialUpgrader.UpgradeSelection(GetHDUpgraders(), "Upgrade to HD Material");
}
[MenuItem("HDRenderLoop/Modify Light Intensity for Upgrade - Scene Only")]
static void UpgradeLights()
{
Light[] lights = Light.GetLights(LightType.Directional, 0);
foreach (var l in lights)
{
l.intensity *= Mathf.PI;
}
}
}
}

66
Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Editor/StandardToHDLitMaterialUpgrader.cs


namespace UnityEditor.Experimental.ScriptableRenderLoop
{
class StandardToHDLitMaterialUpgrader : MaterialUpgrader
{
public StandardToHDLitMaterialUpgrader()
{
RenameShader("Standard", "HDRenderLoop/LitLegacySupport");
class StandardToHDLitMaterialUpgrader : MaterialUpgrader
{
public StandardToHDLitMaterialUpgrader()
{
RenameShader("Standard", "HDRenderLoop/LitLegacySupport");
RenameFloat("_Glossiness", "_Smoothness");
RenameTexture("_BumpMap", "_NormalMap");
RenameColor("_EmissionColor", "_EmissiveColor");
RenameFloat("_Glossiness", "_Smoothness");
RenameTexture("_BumpMap", "_NormalMap");
RenameColor("_EmissionColor", "_EmissiveColor");
RenameFloat("_DetailNormalMapScale", "_DetailNormalScale");
// the HD renderloop packs detail albedo and detail normals into a single texture.

// @Seb: Should we convert?
RenameFloat("_Metallic", "_Metallic");
//@TODO: Seb. Why do we multiply color by intensity
// in shader when we can just store a color?
// builtinData.emissiveColor * builtinData.emissiveIntensity
}
//@TODO: Seb. Why do we multiply color by intensity
// in shader when we can just store a color?
// builtinData.emissiveColor * builtinData.emissiveIntensity
}
public override void Convert(Material srcMaterial, Material dstMaterial)
{
base.Convert (srcMaterial, dstMaterial);
//@TODO: Find a good way of setting up keywords etc from properties.
// Code should be shared with material UI code.
}
public override void Convert(Material srcMaterial, Material dstMaterial)
{
base.Convert(srcMaterial, dstMaterial);
//@TODO: Find a good way of setting up keywords etc from properties.
// Code should be shared with material UI code.
}
[Test]
public void UpgradeMaterial()
{
var newShader = Shader.Find("HDRenderLoop/LitLegacySupport");
var mat = new Material (Shader.Find("Standard"));
var albedo = new Texture2D(1, 1);
[Test]
public void UpgradeMaterial()
{
var newShader = Shader.Find("HDRenderLoop/LitLegacySupport");
var mat = new Material(Shader.Find("Standard"));
var albedo = new Texture2D(1, 1);
mat.mainTexture = albedo;
mat.mainTexture = albedo;
mat.color = color;
mat.color = color;
MaterialUpgrader.Upgrade(mat, new StandardToHDLitMaterialUpgrader (), MaterialUpgrader.UpgradeFlags.CleanupNonUpgradedProperties);
MaterialUpgrader.Upgrade(mat, new StandardToHDLitMaterialUpgrader(), MaterialUpgrader.UpgradeFlags.CleanupNonUpgradedProperties);
Assert.AreEqual (newShader, mat.shader);
Assert.AreEqual (albedo, mat.GetTexture("_BaseColorMap"));
Assert.AreEqual (color, mat.GetColor("_BaseColor"));
Assert.AreEqual (baseScale, mat.GetTextureScale("_BaseColorMap"));
Assert.AreEqual (normals, mat.GetTexture("_NormalMap"));
Assert.AreEqual(newShader, mat.shader);
Assert.AreEqual(albedo, mat.GetTexture("_BaseColorMap"));
Assert.AreEqual(color, mat.GetColor("_BaseColor"));
Assert.AreEqual(baseScale, mat.GetTextureScale("_BaseColorMap"));
Assert.AreEqual(normals, mat.GetTexture("_NormalMap"));
}
}
}
正在加载...
取消
保存