// Gets the alpha of the material
// Checks ogl_use_alpha_transparency to make sure that it's enabled.
internal static bool GetMaterialAlpha(HEU_SessionBase session, HAPI_NodeId nodeID, HAPI_ParmInfo[] parameters, float defaultValue, out float alpha)
{
int foundUseParmId = HEU_ParameterUtility.GetParameterIndexFromNameOrTag(session, nodeID, parameters, HEU_Defines.MAT_OGL_TRANSPARENCY_ATTR_ENABLED);
if (foundUseParmId >= 0)
{
// Found a valid "use" parameter. Check if it is disabled.
int[] useValue = new int[1];
int intValuesIndex = parameters[foundUseParmId].intValuesIndex;
if (session.GetParamIntValues(nodeID, useValue, parameters[foundUseParmId].intValuesIndex, 1))
{
if (useValue.Length > 0 && useValue[0] == 0)
{
// We found the texture, but the use tag is disabled, so don't use it!
alpha = defaultValue;
return false;
}
}
}
if (HEU_ParameterUtility.GetParameterFloatValue(session, nodeID, parameters, HEU_Defines.MAT_OGL_ALPHA_ATTR, defaultValue, out alpha))
{
return true;
}
if (HEU_ParameterUtility.GetParameterFloatValue(session, nodeID, parameters, HEU_Defines.MAT_ALPHA_ATTR, defaultValue, out alpha))
{
return true;
}
if (HEU_ParameterUtility.GetParameterFloatValue(session, nodeID, parameters, HEU_Defines.MAT_OGL_TRANSPARENCY_ATTR, defaultValue, out alpha))
{
alpha = 1 - alpha;
return true;
}
alpha = defaultValue;
return false;
}