Magnum::Trade::PbrMetallicRoughnessMaterialData class new in Git master

PBR metallic/roughness material data.

Contents

See Material types and convenience accessors for more information about how to use this class.

Base classes

class MaterialData new in Git master
Material data.

Public functions

auto hasMetalnessTexture() const -> bool
Whether the material has a metalness texture.
auto hasRoughnessTexture() const -> bool
Whether the material has a roughness texture.
auto hasNoneRoughnessMetallicTexture() const -> bool
Whether the material has a combined roughness/metallic texture.
auto hasOcclusionRoughnessMetallicTexture() const -> bool
Whether the material has a combined occlusion/roughness/metallic texture.
auto hasRoughnessMetallicOcclusionTexture() const -> bool
Whether the material has a combined roughness/metallic/occlusion texture.
auto hasNormalRoughnessMetallicTexture() const -> bool
Whether the material has a combined normal/roughness/metallic texture.
auto hasTextureTransformation() const -> bool
Whether the material has texture transformation.
auto hasCommonTextureTransformation() const -> bool
Whether the material has a common transformation for all textures.
auto hasTextureCoordinates() const -> bool
Whether the material uses extra texture coordinate sets.
auto hasCommonTextureCoordinates() const -> bool
Whether the material has a common coordinate set for all textures.
auto baseColor() const -> Color4
Base color.
auto baseColorTexture() const -> UnsignedInt
Base color texture ID.
auto baseColorTextureMatrix() const -> Matrix3
Base color texture coordinate transformation matrix.
auto baseColorTextureCoordinates() const -> UnsignedInt
Base color texture coordinate set.
auto metalness() const -> Float
Metalness factor.
auto metalnessTexture() const -> UnsignedInt
Metalness texture ID.
auto metalnessTextureSwizzle() const -> MaterialTextureSwizzle
Metalness texture swizzle.
auto metalnessTextureMatrix() const -> Matrix3
Metalness texture coordinate transformation matrix.
auto metalnessTextureCoordinates() const -> UnsignedInt
Metalness texture coordinate set.
auto roughness() const -> Float
Roughness factor.
auto roughnessTexture() const -> UnsignedInt
Roughness texture ID.
auto roughnessTextureSwizzle() const -> MaterialTextureSwizzle
Roughness texture swizzle.
auto roughnessTextureMatrix() const -> Matrix3
Roughness texture coordinate transformation matrix.
auto roughnessTextureCoordinates() const -> UnsignedInt
Roughness texture coordinate set.
auto normalTexture() const -> UnsignedInt
Normal texture ID.
auto normalTextureScale() const -> Float
Normal texture scale.
auto normalTextureMatrix() const -> Matrix3
Normal texture coordinate transformation matrix.
auto normalTextureSwizzle() const -> MaterialTextureSwizzle new in Git master
Normal texture swizzle.
auto normalTextureCoordinates() const -> UnsignedInt
Normal texture coordinate set.
auto occlusionTexture() const -> UnsignedInt
Occlusion texture ID.
auto occlusionTextureStrength() const -> Float
Occlusion texture strength.
auto occlusionTextureSwizzle() const -> MaterialTextureSwizzle
Occlusion texture swizzle.
auto occlusionTextureMatrix() const -> Matrix3
Occlusion texture coordinate transformation matrix.
auto occlusionTextureCoordinates() const -> UnsignedInt
Occlusion texture coordinate set.
auto emissiveColor() const -> Color3
Emissive color.
auto emissiveTexture() const -> UnsignedInt
Emissive texture ID.
auto emissiveTextureMatrix() const -> Matrix3
Emissive texture coordinate transformation matrix.
auto emissiveTextureCoordinates() const -> UnsignedInt
Emissive texture coordinate set.
auto commonTextureMatrix() const -> Matrix3
Common texture coordinate transformation matrix for all textures.
auto commonTextureCoordinates() const -> UnsignedInt
Common texture coordinate set index for all textures.

Function documentation

bool Magnum::Trade::PbrMetallicRoughnessMaterialData::hasMetalnessTexture() const

Whether the material has a metalness texture.

Returns true if any of the MaterialAttribute::MetalnessTexture or MaterialAttribute::NoneRoughnessMetallicTexture attributes is present, false otherwise.

bool Magnum::Trade::PbrMetallicRoughnessMaterialData::hasRoughnessTexture() const

Whether the material has a roughness texture.

Returns true if any of the MaterialAttribute::RoughnessTexture or MaterialAttribute::NoneRoughnessMetallicTexture attributes is present, false otherwise.

bool Magnum::Trade::PbrMetallicRoughnessMaterialData::hasNoneRoughnessMetallicTexture() const

Whether the material has a combined roughness/metallic texture.

Returns true if either the MaterialAttribute::NoneRoughnessMetallicTexture attribute is present or both MaterialAttribute::RoughnessTexture and MaterialAttribute::MetalnessTexture are present, point to the same texture ID, MaterialAttribute::RoughnessTextureSwizzle is set to MaterialTextureSwizzle::G and MaterialAttribute::MetalnessTextureSwizzle is set to MaterialTextureSwizzle::B, and ddditionally MaterialAttribute::RoughnessTextureMatrix and MaterialAttribute::MetalnessTextureMatrix are both either not present or have the same value, and MaterialAttribute::RoughnessTextureCoordinates and MaterialAttribute::MetalnessTextureCoordinates are both either not present or have the same value; false otherwise.

In other words, if this function returns true, roughnessTexture(), roughnessTextureMatrix() and roughnessTextureCoordinates() return values common for both metalness and roughness texture, and the two are packed together with roughness occupying the G channel and metalness the B channel. This packing is common in glTF metallic/roughness materials, which in turn is compatible with how UE4 assets are usually packed. Original rationale for this can be seen here.

The red and alpha channels are ignored and can be repurposed for other maps such as occlusion or transmission. This check is a subset of hasOcclusionRoughnessMetallicTexture() — if that function returns true, this will return true as well.

bool Magnum::Trade::PbrMetallicRoughnessMaterialData::hasOcclusionRoughnessMetallicTexture() const

Whether the material has a combined occlusion/roughness/metallic texture.

Returns true if MaterialAttribute::OcclusionTexture, MaterialAttribute::RoughnessTexture and MaterialAttribute::MetalnessTexture are all present, point to the same texture ID, MaterialAttribute::OcclusionTextureSwizzle is set to MaterialTextureSwizzle::R (or omitted, in which case it's the default), MaterialAttribute::RoughnessTextureSwizzle is set to MaterialTextureSwizzle::G and MaterialAttribute::MetalnessTextureSwizzle is set to MaterialTextureSwizzle::B, and additionally MaterialAttribute::OcclusionTextureMatrix, MaterialAttribute::RoughnessTextureMatrix and MaterialAttribute::MetalnessTextureMatrix are all other not present or have the same value, and MaterialAttribute::OcclusionTextureCoordinates, MaterialAttribute::RoughnessTextureCoordinates and MaterialAttribute::MetalnessTextureCoordinates are all either not present or have the same value; false otherwise.

In other words, if this function returns true, occlusionTexture(), occlusionTextureMatrix() and occlusionTextureCoordinates() return values common for occlusion, roughness and metalness textures, and the three are packed together with occlusion occupying the R channel, roughness the G channel and metalness the B channel. This packing is common in glTF metallic/roughness materials, which in turn is compatible with how UE4 assets are usually packed. Original rationale for this can be seen here, there's also a MSFT_packing_occlusionRoughnessMetallic glTF extension using this packing in a more explicit way.

The alpha channel is ignored and can be repurposed for other maps such as transmission. This check is a superset of hasNoneRoughnessMetallicTexture() — if this function returns true, that one will return true as well.

bool Magnum::Trade::PbrMetallicRoughnessMaterialData::hasRoughnessMetallicOcclusionTexture() const

Whether the material has a combined roughness/metallic/occlusion texture.

Returns true if MaterialAttribute::RoughnessTexture, MaterialAttribute::MetalnessTexture and MaterialAttribute::OcclusionTexture are all present, point to the same texture ID, MaterialAttribute::RoughnessTextureSwizzle is set to MaterialTextureSwizzle::R (or omitted, in which case it's the default), MaterialAttribute::MetalnessTextureSwizzle is set to MaterialTextureSwizzle::G and MaterialAttribute::OcclusionTextureSwizzle is set to MaterialTextureSwizzle::B, and additionally MaterialAttribute::RoughnessTextureMatrix, MaterialAttribute::MetalnessTextureMatrix and MaterialAttribute::OcclusionTextureMatrix are all other not present or have the same value, and MaterialAttribute::RoughnessTextureCoordinates, MaterialAttribute::MetalnessTextureCoordinates and MaterialAttribute::OcclusionTextureCoordinates are all either not present or have the same value; false otherwise.

In other words, if this function returns true, roughnessTexture(), roughnessTextureMatrix() and roughnessTextureCoordinates() return values common for roughness, metalness and occlusion textures, and the three are packed together with roughness occupying the R channel, metalness the G channel and occlusion the B channel. This check is present in order to provide support for the MSFT_packing_occlusionRoughnessMetallic glTF extension.

The alpha channel is ignored and can be repurposed for other maps such as transmission.

bool Magnum::Trade::PbrMetallicRoughnessMaterialData::hasNormalRoughnessMetallicTexture() const

Whether the material has a combined normal/roughness/metallic texture.

Returns true if MaterialAttribute::NormalTexture, MaterialAttribute::RoughnessTexture and MaterialAttribute::MetalnessTexture are all present, point to the same texture ID, MaterialAttribute::NormalTextureSwizzle is set to MaterialTextureSwizzle::RG (with the third channel implicit), MaterialAttribute::RoughnessTextureSwizzle is set to MaterialTextureSwizzle::B and MaterialAttribute::MetalnessTextureSwizzle is set to MaterialTextureSwizzle::A, and additionally MaterialAttribute::NormalTextureMatrix, MaterialAttribute::RoughnessTextureMatrix and MaterialAttribute::MetalnessTextureMatrix are all other not present or have the same value, and MaterialAttribute::NormalTextureCoordinates, MaterialAttribute::RoughnessTextureCoordinates and MaterialAttribute::MetalnessTextureCoordinates are all either not present or have the same value; false otherwise.

In other words, if this function returns true, normalTexture(), normalTextureMatrix() and normalTextureCoordinates() return values common for normal, roughness and metalness textures, and the three are packed together with normals occupying the RG channel, roughness the B channel and metalness the A channel. This check is present in order to provide support for the MSFT_packing_normalRoughnessMetallic glTF extension.

bool Magnum::Trade::PbrMetallicRoughnessMaterialData::hasCommonTextureTransformation() const

Whether the material has a common transformation for all textures.

Returns true if, for each texture that is present, baseColorTextureMatrix(), metalnessTextureMatrix(), roughnessTextureMatrix(), normalTextureMatrix(), occlusionTextureMatrix() and emissiveTextureMatrix() have the same value, false otherwise. In particular, returns true also if there's no texture transformation at all. Use hasTextureTransformation() to distinguish that case.

bool Magnum::Trade::PbrMetallicRoughnessMaterialData::hasCommonTextureCoordinates() const

Whether the material has a common coordinate set for all textures.

Returns true if, for each texture that is present, baseColorTextureCoordinates(), metalnessTextureCoordinates(), roughnessTextureCoordinates(), normalTextureCoordinates(), occlusionTextureCoordinates() and emissiveTextureCoordinates() have the same value, false otherwise. In particular, returns true also if there's no extra texture coordinate set used at all. Use hasTextureCoordinates() to distinguish that case.

Color4 Magnum::Trade::PbrMetallicRoughnessMaterialData::baseColor() const

Base color.

Convenience access to the MaterialAttribute::BaseColor attribute. If not present, the default is 0xffffffff_srgbaf.

If the material has MaterialAttribute::BaseColorTexture, the color and texture is meant to be multiplied together.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::baseColorTexture() const

Base color texture ID.

Available only if MaterialAttribute::BaseColorTexture is present. Meant to be multiplied with baseColor().

Matrix3 Magnum::Trade::PbrMetallicRoughnessMaterialData::baseColorTextureMatrix() const

Base color texture coordinate transformation matrix.

Convenience access to the MaterialAttribute::BaseColorTextureMatrix / MaterialAttribute::TextureMatrix attributes. If neither is present, the default is an identity matrix. Available only if the material has MaterialAttribute::BaseColorTexture.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::baseColorTextureCoordinates() const

Base color texture coordinate set.

Convenience access to the MaterialAttribute::BaseColorTextureCoordinates / MaterialAttribute::TextureCoordinates attributes. If neither is present, the default is 0. Available only if the material has MaterialAttribute::BaseColorTexture.

Float Magnum::Trade::PbrMetallicRoughnessMaterialData::metalness() const

Metalness factor.

Convenience access to the MaterialAttribute::Metalness attribute. If not present, the default is 1.0f.

If the material has a metalness texture, the factor and texture is meant to be multiplied together.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::metalnessTexture() const

Metalness texture ID.

Available only if either MaterialAttribute::MetalnessTexture or MaterialAttribute::NoneRoughnessMetallicTexture is present. Meant to be multiplied with metalness().

MaterialTextureSwizzle Magnum::Trade::PbrMetallicRoughnessMaterialData::metalnessTextureSwizzle() const

Metalness texture swizzle.

If MaterialAttribute::NoneRoughnessMetallicTexture is present, returns always MaterialTextureSwizzle::B. Otherwise returns the MaterialAttribute::MetalnessTextureSwizzle attribute, or MaterialTextureSwizzle::R, if it's not present. Available only if the material has a metalness texture.

Matrix3 Magnum::Trade::PbrMetallicRoughnessMaterialData::metalnessTextureMatrix() const

Metalness texture coordinate transformation matrix.

Convenience access to the MaterialAttribute::MetalnessTextureMatrix / MaterialAttribute::TextureMatrix attributes. If neither is present, the default is an identity matrix. Available only if the material has a metalness texture.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::metalnessTextureCoordinates() const

Metalness texture coordinate set.

Convenience access to the MaterialAttribute::MetalnessTextureCoordinates / MaterialAttribute::TextureCoordinates attributes. If neither is present, the default is 0. Available only if the material has a metalness texture.

Float Magnum::Trade::PbrMetallicRoughnessMaterialData::roughness() const

Roughness factor.

Convenience access to the MaterialAttribute::Roughness attribute. If not present, the default is 1.0f.

If the material has a roughness texture, the factor and texture is meant to be multiplied together.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::roughnessTexture() const

Roughness texture ID.

Available only if either MaterialAttribute::RoughnessTexture or MaterialAttribute::NoneRoughnessMetallicTexture is present. Meant to be multiplied with roughness().

MaterialTextureSwizzle Magnum::Trade::PbrMetallicRoughnessMaterialData::roughnessTextureSwizzle() const

Roughness texture swizzle.

If MaterialAttribute::NoneRoughnessMetallicTexture is present, returns always MaterialTextureSwizzle::G. Otherwise returns the MaterialAttribute::RoughnessTextureSwizzle attribute, or MaterialTextureSwizzle::R, if it's not present. Available only if the material has a roughness texture.

Matrix3 Magnum::Trade::PbrMetallicRoughnessMaterialData::roughnessTextureMatrix() const

Roughness texture coordinate transformation matrix.

Convenience access to the MaterialAttribute::RoughnessTextureMatrix / MaterialAttribute::TextureMatrix attributes. If neither is present, the default is an identity matrix. Available only if the material has a roughness texture.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::roughnessTextureCoordinates() const

Roughness texture coordinate set.

Convenience access to the MaterialAttribute::RoughnessTextureCoordinates / MaterialAttribute::TextureCoordinates attributes. If neither is present, the default is 0. Available only if the material has a roughness texture.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::normalTexture() const

Normal texture ID.

Available only if MaterialAttribute::NormalTexture is present.

Float Magnum::Trade::PbrMetallicRoughnessMaterialData::normalTextureScale() const

Normal texture scale.

Convenience access to the MaterialAttribute::NormalTextureScale attribute. If not present, the default is 1.0f. Available only if MaterialAttribute::NormalTexture is present.

Matrix3 Magnum::Trade::PbrMetallicRoughnessMaterialData::normalTextureMatrix() const

Normal texture coordinate transformation matrix.

Convenience access to the MaterialAttribute::NormalTextureMatrix / MaterialAttribute::TextureMatrix attributes. If neither is present, the default is an identity matrix. Available only if the material has MaterialAttribute::NormalTexture.

MaterialTextureSwizzle Magnum::Trade::PbrMetallicRoughnessMaterialData::normalTextureSwizzle() const new in Git master

Normal texture swizzle.

Convenience access to the MaterialAttribute::NormalTextureSwizzle attribute. If not present, the default is MaterialTextureSwizzle::RGB. Available only if MaterialAttribute::NormalTexture is present.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::normalTextureCoordinates() const

Normal texture coordinate set.

Convenience access to the MaterialAttribute::NormalTextureCoordinates / MaterialAttribute::TextureCoordinates attributes. If neither is present, the default is 0. Available only if the material has MaterialAttribute::NormalTexture.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::occlusionTexture() const

Occlusion texture ID.

Available only if MaterialAttribute::OcclusionTexture is present.

Float Magnum::Trade::PbrMetallicRoughnessMaterialData::occlusionTextureStrength() const

Occlusion texture strength.

Convenience access to the MaterialAttribute::OcclusionTextureStrength attribute. If not present, the default is 1.0f. Available only if MaterialAttribute::OcclusionTexture is present.

MaterialTextureSwizzle Magnum::Trade::PbrMetallicRoughnessMaterialData::occlusionTextureSwizzle() const

Occlusion texture swizzle.

Convenience access to the MaterialAttribute::OcclusionTextureSwizzle attribute. If not present, the default is MaterialTextureSwizzle::R. Available only if MaterialAttribute::OcclusionTexture is present.

Matrix3 Magnum::Trade::PbrMetallicRoughnessMaterialData::occlusionTextureMatrix() const

Occlusion texture coordinate transformation matrix.

Convenience access to the MaterialAttribute::OcclusionTextureMatrix / MaterialAttribute::TextureMatrix attributes. If neither is present, the default is an identity matrix. Available only if the material has MaterialAttribute::OcclusionTexture.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::occlusionTextureCoordinates() const

Occlusion texture coordinate set.

Convenience access to the MaterialAttribute::OcclusionTextureCoordinates / MaterialAttribute::TextureCoordinates attributes. If neither is present, the default is 0. Available only if the material has MaterialAttribute::OcclusionTexture.

Color3 Magnum::Trade::PbrMetallicRoughnessMaterialData::emissiveColor() const

Emissive color.

Convenience access to the MaterialAttribute::EmissiveColor attribute. If not present, the default is 0x000000_srgbf (i.e, no emission).

If the material has MaterialAttribute::EmissiveTexture, the color and texture is meant to be multiplied together.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::emissiveTexture() const

Emissive texture ID.

Available only if MaterialAttribute::EmissiveTexture is present. Meant to be multiplied with emissiveColor().

Matrix3 Magnum::Trade::PbrMetallicRoughnessMaterialData::emissiveTextureMatrix() const

Emissive texture coordinate transformation matrix.

Convenience access to the MaterialAttribute::EmissiveTextureMatrix / MaterialAttribute::TextureMatrix attributes. If neither is present, the default is an identity matrix. Available only if the material has MaterialAttribute::EmissiveTexture.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::emissiveTextureCoordinates() const

Emissive texture coordinate set.

Convenience access to the MaterialAttribute::EmissiveTextureCoordinates / MaterialAttribute::TextureCoordinates attributes. If neither is present, the default is 0. Available only if the material has MaterialAttribute::EmissiveTexture.

Matrix3 Magnum::Trade::PbrMetallicRoughnessMaterialData::commonTextureMatrix() const

Common texture coordinate transformation matrix for all textures.

Expects that hasCommonTextureTransformation() is true; returns a coordinate set index that's the same for all of baseColorTextureMatrix(), metalnessTextureMatrix(), roughnessTextureMatrix(), normalTextureMatrix(), occlusionTextureMatrix() and emissiveTextureMatrix() where a texture is present. If no texture is present, returns an identity matrix.

UnsignedInt Magnum::Trade::PbrMetallicRoughnessMaterialData::commonTextureCoordinates() const

Common texture coordinate set index for all textures.

Expects that hasCommonTextureCoordinates() is true; returns a coordinate set index that's the same for all of baseColorTextureCoordinates(), metalnessTextureCoordinates(), roughnessTextureCoordinates(), normalTextureCoordinates(), occlusionTextureCoordinates() and emissiveTextureCoordinates() where a texture is present. If no texture is present, returns 0.