A3DGraphMaterialData Struct Reference

Material data. More...

Data Fields

A3DDouble m_dAmbientAlpha
 
A3DDouble m_dDiffuseAlpha
 
A3DDouble m_dEmissiveAlpha
 
A3DDouble m_dShininess
 
A3DDouble m_dSpecularAlpha
 
A3DUns32 m_uiAmbient
 
A3DUns32 m_uiDiffuse
 
A3DUns32 m_uiEmissive
 
A3DUns32 m_uiSpecular
 

Detailed Description

Material data.

Version
2.0
Note
Use A3DGlobalGetGraphRgbColorData to get ambient, diffuse, emissive and specular colors.
The conventions described here are similar to the common scene graphics conventions described for other 3D standards such as OpenGL and DirectX.
Support for PBR (Physically-Based Rendering):
The following properties are supported:
  • base color
  • emissive color
  • normals
  • metallness
  • roughness
  • occlusion
They are all optional, and available as textures and constants.

The textures can have the following types (see m_uiMappingAttributes in A3DGraphTextureDefinitionData):

Two combinations of these flags are also provided for simplicity, as these data are often packed in a single texture:

If a kA3DTextureMappingMetallnessRoughnessOcclusion texture is used, its components are packed with:

  • red = occlusion
  • green = roughness
  • blue = metallness

The base color and emissive color constants are A3DGraphRgbColorData provided through the m_uiDiffuse and m_uiEmissive members of the A3DGraphMaterialData structure.

The other constants are provided as A3DMiscAttribute attached to the A3DGraphMaterialData:

constantnametype
alpha cut-off"AlphaCutOff"A3DDouble
alpha mode"AlphaMode"A3DInt32
metallness"MetallicFactor"A3DDouble
normals"NormalTextureFactor"A3DDouble
occlusion"OcclusionTextureFactor"A3DDouble
roughness"RoughnessFactor"A3DDouble

The alpha mode values are defined in A3DETextureAlphaMode.

Each attribute contains a single A3DMiscSingleAttributeData of type kA3DModellerAttributeTypeReal (see A3DEModellerAttributeType).

If both texture and constant are provided for a given type, the constant is used as a texel multiplier.

Pseudocode to access these attributes:

A3DGlobal* pGlobal = NULL;
A3DGlobalData sGlobalData;
A3DGlobalGet(pGlobal, &sGlobalData);
A3DInt32 iAlphaMode = 0;
A3DDouble dAlphaCutOff = 0, dMetallicFactor = 0, dNormalTextureFactor = 0, dOcclusionTextureFactor = 0, dRoughnessFactor = 0;
// browse material definitions
for (A3DUns32 i = 0; i < sGlobalData.m_uiMaterialsSize; ++i)
{
A3DBool bIsTexture;
A3DGlobalIsMaterialTexture(i, &bIsTexture);
if (bIsTexture)
continue;
// get material pointer
A3DEntity* pMaterial = NULL;
A3DMiscPointerFromIndexGet(i, kA3DTypeGraphMaterial, &pMaterial);
if (pMaterial)
{
A3DRootBaseData sBaseData;
A3DRootBaseGet(pMaterial, &sBaseData);
if (!strcmp(sBaseData.m_pcName, "MyMaterial")) // test here for the name of the searched material
{
// browse attributes
for (A3DUns32 j = 0; j < sBaseData.m_uiSize; ++j)
{
A3DMiscAttributeGet(sBaseData.m_ppAttributes[j], &sAttrData);
for (A3DUns32 k = 0; k < sAttrData.m_uiSize; ++k)
{
const A3DMiscSingleAttributeData* psAttrDatum = sAttrData.m_asSingleAttributesData + k;
{
if (!strcmp(sAttrData.m_pcTitle, "AlphaMode"))
iAlphaMode = *(A3DInt32*)(psAttrDatum->m_pcData);
}
else if (psAttrDatum->m_eType == kA3DModellerAttributeTypeReal)
{
const A3DDouble dValue = *(A3DDouble*)(psAttrDatum->m_pcData);
if (!strcmp(sAttrData.m_pcTitle, "AlphaCutOff"))
dAlphaCutOff = dValue;
else if (!strcmp(sAttrData.m_pcTitle, "MetallicFactor"))
dMetallicFactor = dValue;
else if (!strcmp(sAttrData.m_pcTitle, "NormalTextureFactor"))
dNormalTextureFactor = dValue;
else if (!strcmp(sAttrData.m_pcTitle, "OcclusionTextureFactor"))
dOcclusionTextureFactor = dValue;
else if (!strcmp(sAttrData.m_pcTitle, "RoughnessFactor"))
dRoughnessFactor = dValue;
}
}
A3DMiscAttributeGet(NULL, &sAttrData);
}
}
A3DRootBaseGet(NULL, &sBaseData);
}
}
A3DGlobalGet(NULL, &sGlobalData);

Field Documentation

A3DUns32 A3DGraphMaterialData::m_uiAmbient

Ambient color.

A3DUns32 A3DGraphMaterialData::m_uiDiffuse

Diffuse color.

A3DUns32 A3DGraphMaterialData::m_uiEmissive

Emissive color.

A3DUns32 A3DGraphMaterialData::m_uiSpecular

Specular color.

A3DDouble A3DGraphMaterialData::m_dAmbientAlpha

Ambient alpha value. Not yet implemented. Use A3DGraphStyleData::m_ucTransparency instead.

A3DDouble A3DGraphMaterialData::m_dDiffuseAlpha

Diffuse alpha value. Not yet implemented. Use A3DGraphStyleData::m_ucTransparency instead.

A3DDouble A3DGraphMaterialData::m_dEmissiveAlpha

Emissive alpha value. Not yet implemented. Use A3DGraphStyleData::m_ucTransparency instead.

A3DDouble A3DGraphMaterialData::m_dSpecularAlpha

Specular alpha value. Not yet implemented. Use A3DGraphStyleData::m_ucTransparency instead.

A3DDouble A3DGraphMaterialData::m_dShininess

Shininess. Valid values are between 0.0 and 1.0.