浏览代码

Create a material ID swap utility

/Branch_Batching2
Evgenii Golubev 7 年前
当前提交
849f1732
共有 2 个文件被更改,包括 40 次插入11 次删除
  1. 40
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs
  2. 11
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs

40
Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineMenuItems.cs


}
}
[MenuItem("HDRenderPipeline/Swap standard and SSS material IDs")]
static void SwapStandardAndSssMaterialIds()
{
try
{
Object[] materials = Resources.FindObjectsOfTypeAll<Material>();
for (int i = 0, length = materials.Length; i < length; i++)
{
Material mat = materials[i] as Material;
EditorUtility.DisplayProgressBar(
"Updating materials...",
string.Format("{0} / {1}", i, length),
i / (float)(length - 1));
if (mat.shader.name == "HDRenderPipeline/Lit" || mat.shader.name == "HDRenderPipeline/LitTessellation")
{
int matID = (int)mat.GetFloat("_MaterialID");
if (matID == 0)
{
matID = 1;
mat.SetInt("_MaterialID", matID);
EditorUtility.SetDirty(mat);
}
else if (matID == 1)
{
matID = 0;
mat.SetInt("_MaterialID", matID);
EditorUtility.SetDirty(mat);
}
}
}
}
finally
{
EditorUtility.ClearProgressBar();
}
}
[MenuItem("HDRenderPipeline/Debug/Remove tessellation materials (not reversible)")]
static void RemoveTessellationMaterials()
{

11
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs


bool depthOffsetEnable = material.GetFloat(kDepthOffsetEnable) > 0.0f;
SetKeyword(material, "_DEPTHOFFSET_ON", depthOffsetEnable);
// Temp. material ID upgrade workaround: determine the material ID from the stencil reference value.
// Select the menu item [HDRenderPipeline -> Reset all material keywords] to proceed.
// Remove after upgrading all projects!
if (material.HasProperty(kMaterialID))
{
int sr = (int)material.GetFloat(kStencilRef);
Debug.Assert(sr > 0, "The stencil reference value must be greater than 0. This material will have an incorrect ID assigned to it.");
material.SetInt(kMaterialID, sr - 1);
}
// Set the reference value for the stencil test.
int stencilRef = (int)UnityEngine.Experimental.Rendering.HDPipeline.StencilBits.Standard;
if (material.HasProperty(kMaterialID))

正在加载...
取消
保存