// 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;
	}
	public static int FindTextureParamByNameOrTag(HEU_SessionBase session, HAPI_NodeId nodeID, HAPI_ParmInfo[] parameters, string parameterName, string useTextureParmName)
	{
	    int outParmId = GetParameterIndexFromNameOrTag(session, nodeID, parameters, parameterName);
	    if (outParmId < 0)
	    {
		return outParmId;
	    }

	    // Check if the matching "use" parameter exists.
	    int foundUseParmId = GetParameterIndexFromNameOrTag(session, nodeID, parameters, useTextureParmName);
	    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!
			return -1;
		    }
		}
	    }

	    // Finally, make sure that the found texture parm is not empty!
	    int[] parmValueHandle = new int[1];
	    if (session.GetParamStringValues(nodeID, parmValueHandle, parameters[outParmId].stringValuesIndex, 1))
	    {
		string parmValue = HEU_SessionManager.GetString(parmValueHandle[0], session);
		if (string.IsNullOrEmpty(parmValue))
		{
		    return -1;
		}
	    }

	    return outParmId;
	}