public bool IsAlphaMaterial(Material material)
{
if (material.HasOpacity && IsTransparent(material.Opacity))
{
return true;
}
// Also treat material as (potentially) semi-transparent if the alpha
// components of any of the diffuse, specular, ambient and emissive
// colors are non-1. It is not very well-defined how assimp handles
// these values so better count them into transparency as well.
//
// Ignore color values with alpha=0, however. These are most likely
// not intended to be fully transparent.
if (material.HasColorDiffuse && IsTransparent(material.ColorDiffuse.A))
{
return true;
}
if (material.HasColorSpecular && IsTransparent(material.ColorSpecular.A))
{
return true;
}
if (material.HasColorAmbient && IsTransparent(material.ColorAmbient.A))
{
return true;
}
if (material.HasColorEmissive && IsTransparent(material.ColorEmissive.A))
{
return true;
}
if (material.GetMaterialTextureCount(TextureType.Diffuse) > 0)
{
TextureSlot tex;
material.GetMaterialTexture(TextureType.Diffuse, 0, out tex);
var gtex = _scene.TextureSet.GetOriginalOrReplacement(tex.FilePath);
if(gtex.HasAlpha == Texture.AlphaState.HasAlpha)
{
return true;
}
}
return false;
}