|
|
|
|
|
|
RenameTexture("_SpecGlossMap", "_SpecularColorMap"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void Convert(Material srcMaterial, Material dstMaterial) |
|
|
|
{ |
|
|
|
dstMaterial.hideFlags = HideFlags.DontUnloadUnusedAsset; |
|
|
|
|
|
|
metallicMap = Texture2D.blackTexture; |
|
|
|
|
|
|
|
// Occlusion
|
|
|
|
bool hasOcclusion = srcMaterial.GetTexture("_OcclusionMap") != null; |
|
|
|
Texture occlusionMap; |
|
|
|
if (hasOcclusion) occlusionMap = TextureCombiner.GetTextureSafe(srcMaterial, "_OcclusionMap", Color.white); |
|
|
|
//bool hasOcclusion = srcMaterial.GetTexture("_OcclusionMap") != null;
|
|
|
|
//Texture occlusionMap;
|
|
|
|
//if (hasOcclusion) occlusionMap = TextureCombiner.GetTextureSafe(srcMaterial, "_OcclusionMap", Color.white);
|
|
|
|
bool hasDetailMask = srcMaterial.GetTexture("_DetailMask") != null; |
|
|
|
Texture detailMaskMap; |
|
|
|
if (hasDetailMask) detailMaskMap = TextureCombiner.GetTextureSafe(srcMaterial, "_DetailMask", Color.white); |
|
|
|
//bool hasDetailMask = srcMaterial.GetTexture("_DetailMask") != null;
|
|
|
|
//Texture detailMaskMap;
|
|
|
|
//if (hasDetailMask) detailMaskMap = TextureCombiner.GetTextureSafe(srcMaterial, "_DetailMask", Color.white);
|
|
|
|
|
|
|
|
// Smoothness
|
|
|
|
bool hasSmoothness = false; |
|
|
|
|
|
|
|
|
|
|
if (hasSmoothness) |
|
|
|
smoothnessMap = (Texture2D)TextureCombiner.GetTextureSafe(srcMaterial, "_SpecGlossMap", Color.grey); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
string smoothnessTextureChannel = "_MainTex"; |
|
|
|
|
|
|
dstMaterial.SetFloat("_AlphaCutoffEnable", 0); |
|
|
|
dstMaterial.SetFloat("_EnableBlendModePreserveSpecularLighting", 0); |
|
|
|
break; |
|
|
|
case 3: // Transparent -> Alpha
|
|
|
|
case 3: // Transparent -> Alpha
|
|
|
|
dstMaterial.SetFloat("_SurfaceType", 1); |
|
|
|
dstMaterial.SetFloat("_BlendMode", 0); |
|
|
|
dstMaterial.SetFloat("_AlphaCutoffEnable", 0); |
|
|
|
|
|
|
// Emission: Convert the HDR emissive color to ldr color + intensity
|
|
|
|
Color hdrEmission = srcMaterial.GetColor("_EmissionColor"); |
|
|
|
float intensity = Mathf.Max(hdrEmission.r, Mathf.Max(hdrEmission.g, hdrEmission.b)); |
|
|
|
|
|
|
|
|
|
|
|
if (intensity > 1f) |
|
|
|
{ |
|
|
|
hdrEmission.r /= intensity; |
|
|
|
|
|
|
intensity = 1f; |
|
|
|
|
|
|
|
intensity = Mathf.Pow(intensity, 2.2f); // Gamma to Linear conversion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |