浏览代码

Don't set white color for emissive if emissive is checked of in the source materials.

Add smoothness and metallic remap
/main
Remy 6 年前
当前提交
0ec2b280
共有 1 个文件被更改,包括 16 次插入15 次删除
  1. 31
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Lit/StandardsToHDLitMaterialUpgrader.cs

31
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Lit/StandardsToHDLitMaterialUpgrader.cs


// Metallic
bool hasMetallic = false;
Texture metallicMap = Texture2D.blackTexture;
Texture metallicMap = TextureCombiner.TextureFromColor(Color.black);
// Convert _Metallic value from Gamma to Linear
float metallicValue = Mathf.Pow(srcMaterial.GetFloat("_Metallic"), 2.2f);
dstMaterial.SetFloat("_Metallic", metallicValue);
hasMetallic = srcMaterial.GetTexture("_MetallicGlossMap") != null;
if (hasMetallic)
{

{
float metallicValue = Mathf.Pow(srcMaterial.GetFloat("_Metallic"), 2.2f); // Convert _Metallic value from Gamma to Linear
dstMaterial.SetFloat("_Metallic", metallicValue);
metallicMap = TextureCombiner.TextureFromColor(Color.white * metallicValue);
metallicMap = TextureCombiner.TextureFromColor(Color.white);
}
}

if (hasOcclusion) occlusionMap = TextureCombiner.GetTextureSafe(srcMaterial, "_OcclusionMap", Color.white);
dstMaterial.SetFloat("_AORemapMin", 1f - srcMaterial.GetFloat("_OcclusionStrength"));
// Detail Mask
bool hasDetailMask = srcMaterial.GetTexture("_DetailMask") != null;
Texture detailMaskMap = Texture2D.whiteTexture;

bool hasSmoothness = false;
Texture2D smoothnessMap = TextureCombiner.TextureFromColor(Color.grey);
Texture2D smoothnessMap = TextureCombiner.TextureFromColor(Color.white);
dstMaterial.SetFloat("_SmoothnessRemapMax", srcMaterial.GetFloat("_Glossiness"));
if (srcMaterial.shader.name == Standard_Rough)
{

}
else
{
smoothnessMap = TextureCombiner.TextureFromColor(Color.white * srcMaterial.GetFloat("_Glossiness"));
smoothnessMap = TextureCombiner.TextureFromColor(Color.white);
}
}

Texture2D maskMap;
TextureCombiner maskMapCombiner = new TextureCombiner(
metallicMap, 0, // R: Metallic from red
occlusionMap, 1, // G: Occlusion from green
detailMaskMap, 3, // B: Detail Mask from alpha
metallicMap, 0, // R: Metallic from red
occlusionMap, 1, // G: Occlusion from green
detailMaskMap, 3, // B: Detail Mask from alpha
dstMaterial.SetFloat("_Metallic", 1f); // Force _Metallic value to 1, to use the value stored in the mask map without modification
string maskMapPath = AssetDatabase.GetAssetPath(srcMaterial);
maskMapPath = maskMapPath.Remove(maskMapPath.Length - 4) + "_MaskMap.png";

dstMaterial.SetFloat("_AORemapMin", 1f - srcMaterial.GetFloat("_OcclusionStrength"));
// Specular Setup Specific
if (srcMaterial.shader.name == Standard_Spec)

}
Color hdrEmission = srcMaterial.GetColor("_EmissionColor");
dstMaterial.SetColor("_EmissiveColor", hdrEmission);
dstMaterial.SetColor("_EmissiveColor", (srcMaterial.GetFloat("_EmissionEnabled") != 0)?hdrEmission: Color.black);
HDEditorUtils.ResetMaterialKeywords(dstMaterial);
}
正在加载...
取消
保存