Here are the examples of the csharp api Unity.Formats.USD.HdrpShaderImporter.BuildMaskMap(UnityEngine.Texture2D, UnityEngine.Texture2D, UnityEngine.Texture2D, UnityEngine.Texture2D) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
View Source File : HdrpShaderImporter.cs
License : Apache License 2.0
Project Creator : Unity-Technologies
License : Apache License 2.0
Project Creator : Unity-Technologies
public override void ImportFromUsd()
{
Material mat = Material;
if (DiffuseMap)
{
Debug.Log("here");
mat.SetTexture("_BaseColorMap", DiffuseMap);
mat.SetColor("_BaseColor", Color.white);
}
else
{
mat.SetColor("_BaseColor", Diffuse.GetValueOrDefault(mat.color));
}
// TODO: What about opacity map?
if (!IsSpecularWorkflow)
{
// Robustness: It would be ideal if this parameter were provided by HDRP, however that
// would require this replacedet package having a dependency on the HDRP package itself,
// which is (yet) not desirable.
mat.SetFloat("_MaterialID", /*Standard Metallic*/ 1);
}
else
{
mat.SetFloat("_MaterialID", /*Spec Color*/ 4);
mat.EnableKeyword("_MATERIAL_FEATURE_SPECULAR_COLOR");
mat.EnableKeyword("_SPECULARCOLORMAP");
}
// R=Metallic, G=Occlusion, B=Displacement, A=Roughness(Smoothness)
var MaskMap = BuildMaskMap(!IsSpecularWorkflow ? MetallicMap : null, OcclusionMap, DisplacementMap,
RoughnessMap);
if (MaskMap)
{
mat.SetTexture("_MaskMap", MaskMap);
mat.EnableKeyword("_MASKMAP");
}
if (!IsSpecularWorkflow)
{
if (!MetallicMap)
{
mat.SetFloat("_Metallic", Metallic.GetValueOrDefault());
}
}
else
{
if (SpecularMap)
{
mat.SetTexture("_SpecularColorMap", SpecularMap);
}
else
{
mat.SetColor("_SpecularColor", Specular.GetValueOrDefault());
}
}
if (!RoughnessMap)
{
var smoothness = 1 - Roughness.GetValueOrDefault();
mat.SetFloat("_Smoothness", smoothness);
// HDRP Lit does not seem to respect smoothness, so just clamp to the correct value.
mat.SetFloat("_SmoothnessRemapMin", smoothness);
mat.SetFloat("_SmoothnessRemapMax", smoothness);
}
if (!OcclusionMap)
{
mat.SetFloat("_AORemapMin", Occlusion.GetValueOrDefault());
mat.SetFloat("_AORemapMax", Occlusion.GetValueOrDefault());
}
// Single displacement scalar value not supported.
if (ClearcoatMap)
{
mat.SetTexture("_CoatMaskMap", ClearcoatMap);
mat.EnableKeyword("_MATERIAL_FEATURE_CLEAR_COAT");
}
mat.SetFloat("_CoatMask", ClearcoatRoughness.GetValueOrDefault());
if (NormalMap)
{
mat.SetTexture("_NormalMap", NormalMap);
mat.EnableKeyword("_NORMALMAP");
}
if (EmissionMap)
{
mat.SetTexture("_EmissiveColorMap", EmissionMap);
mat.SetColor("_EmissiveColor", Color.white * 1000);
mat.SetColor("_EmissiveColorLDR", Color.white);
mat.globalIlluminationFlags = MaterialGlobalIlluminationFlags.BakedEmissive;
mat.EnableKeyword("_EMISSIVE_COLOR_MAP");
}
else
{
mat.SetColor("_EmissionColor", Emission.GetValueOrDefault());
}
}