mirror of https://github.com/mosra/magnum.git
Browse Source
Well, "basic". Practically mirrors glTF PBR materials: - builtin metallic/roughness - the KHR_materials_pbrSpecularGlossiness extension - extra normal/occlusion/emission maps - exposes the implicit metallic/roughness and specular/glossiness packing, but also allows separate maps with arbitrary packings as well as two-channel normal maps (instead of three-channel) - provides convenience checks for the most common packing schemes including MSFT_packing_normalRoughnessMetallic and the three variants of MSFT_packing_occlusionRoughnessMetallic - teaches PhongMaterialData to recognize packed specular/glossiness maps as well Next up is exposing at least one layer extension, and then I'm done here.pull/459/head
13 changed files with 3271 additions and 51 deletions
@ -0,0 +1,302 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include "PbrMetallicRoughnessMaterialData.h" |
||||
|
||||
#include "Magnum/Math/Color.h" |
||||
#include "Magnum/Math/Matrix3.h" |
||||
|
||||
namespace Magnum { namespace Trade { |
||||
|
||||
using namespace Math::Literals; |
||||
|
||||
bool PbrMetallicRoughnessMaterialData::hasMetalnessTexture() const { |
||||
return hasAttribute(MaterialAttribute::MetalnessTexture) || |
||||
hasAttribute(MaterialAttribute::MetallicRoughnessTexture); |
||||
} |
||||
|
||||
bool PbrMetallicRoughnessMaterialData::hasRoughnessTexture() const { |
||||
return hasAttribute(MaterialAttribute::RoughnessTexture) || |
||||
hasAttribute(MaterialAttribute::MetallicRoughnessTexture); |
||||
} |
||||
|
||||
bool PbrMetallicRoughnessMaterialData::hasMetallicRoughnessTexture() const { |
||||
return (hasAttribute(MaterialAttribute::MetallicRoughnessTexture) || |
||||
(hasAttribute(MaterialAttribute::MetalnessTexture) && |
||||
hasAttribute(MaterialAttribute::RoughnessTexture) && |
||||
metalnessTextureSwizzle() == MaterialTextureSwizzle::R && |
||||
roughnessTextureSwizzle() == MaterialTextureSwizzle::G)) && |
||||
metalnessTextureMatrix() == roughnessTextureMatrix() && |
||||
metalnessTextureCoordinates() == roughnessTextureCoordinates(); |
||||
} |
||||
|
||||
bool PbrMetallicRoughnessMaterialData::hasRoughnessMetallicOcclusionTexture() const { |
||||
if(!(hasAttribute(MaterialAttribute::RoughnessTexture) && |
||||
hasAttribute(MaterialAttribute::MetalnessTexture) && |
||||
hasAttribute(MaterialAttribute::OcclusionTexture) && |
||||
roughnessTextureSwizzle() == MaterialTextureSwizzle::R && |
||||
metalnessTextureSwizzle() == MaterialTextureSwizzle::G && |
||||
occlusionTextureSwizzle() == MaterialTextureSwizzle::B)) |
||||
return false; |
||||
|
||||
const Matrix3 roughnessTextureMatrix = this->roughnessTextureMatrix(); |
||||
const UnsignedInt roughnessTextureCoordinates = this->roughnessTextureCoordinates(); |
||||
return metalnessTextureMatrix() == roughnessTextureMatrix && |
||||
occlusionTextureMatrix() == roughnessTextureMatrix && |
||||
metalnessTextureCoordinates() == roughnessTextureCoordinates && |
||||
occlusionTextureCoordinates() == roughnessTextureCoordinates; |
||||
} |
||||
|
||||
bool PbrMetallicRoughnessMaterialData::hasOcclusionRoughnessMetallicTexture() const { |
||||
if(!(hasAttribute(MaterialAttribute::OcclusionTexture) && |
||||
hasAttribute(MaterialAttribute::RoughnessTexture) && |
||||
hasAttribute(MaterialAttribute::MetalnessTexture) && |
||||
occlusionTextureSwizzle() == MaterialTextureSwizzle::R && |
||||
roughnessTextureSwizzle() == MaterialTextureSwizzle::G && |
||||
metalnessTextureSwizzle() == MaterialTextureSwizzle::B)) |
||||
return false; |
||||
|
||||
const Matrix3 occlusionTextureMatrix = this->occlusionTextureMatrix(); |
||||
const UnsignedInt occlusionTextureCoordinates = this->occlusionTextureCoordinates(); |
||||
return roughnessTextureMatrix() == occlusionTextureMatrix && |
||||
metalnessTextureMatrix() == occlusionTextureMatrix && |
||||
roughnessTextureCoordinates() == occlusionTextureCoordinates && |
||||
metalnessTextureCoordinates() == occlusionTextureCoordinates; |
||||
} |
||||
|
||||
bool PbrMetallicRoughnessMaterialData::hasNormalRoughnessMetallicTexture() const { |
||||
if(!(hasAttribute(MaterialAttribute::NormalTexture) && |
||||
hasAttribute(MaterialAttribute::RoughnessTexture) && |
||||
hasAttribute(MaterialAttribute::MetalnessTexture) && |
||||
normalTextureSwizzle() == MaterialTextureSwizzle::RG && |
||||
roughnessTextureSwizzle() == MaterialTextureSwizzle::B && |
||||
metalnessTextureSwizzle() == MaterialTextureSwizzle::A)) |
||||
return false; |
||||
|
||||
const Matrix3 normalTextureMatrix = this->normalTextureMatrix(); |
||||
const UnsignedInt normalTextureCoordinates = this->normalTextureCoordinates(); |
||||
return roughnessTextureMatrix() == normalTextureMatrix && |
||||
metalnessTextureMatrix() == normalTextureMatrix && |
||||
roughnessTextureCoordinates() == normalTextureCoordinates && |
||||
metalnessTextureCoordinates() == normalTextureCoordinates; |
||||
} |
||||
|
||||
bool PbrMetallicRoughnessMaterialData::hasTextureTransformation() const { |
||||
return hasAttribute(MaterialAttribute::TextureMatrix) || |
||||
hasAttribute(MaterialAttribute::BaseColorTextureMatrix) || |
||||
hasAttribute(MaterialAttribute::MetalnessTextureMatrix) || |
||||
hasAttribute(MaterialAttribute::RoughnessTextureMatrix) || |
||||
hasAttribute(MaterialAttribute::NormalTextureMatrix) || |
||||
hasAttribute(MaterialAttribute::OcclusionTextureMatrix) || |
||||
hasAttribute(MaterialAttribute::EmissiveTextureMatrix);; |
||||
} |
||||
|
||||
bool PbrMetallicRoughnessMaterialData::hasTextureCoordinates() const { |
||||
return hasAttribute(MaterialAttribute::TextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::BaseColorTextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::MetalnessTextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::RoughnessTextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::NormalTextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::OcclusionTextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::EmissiveTextureCoordinates); |
||||
} |
||||
|
||||
Color4 PbrMetallicRoughnessMaterialData::baseColor() const { |
||||
return attributeOr(MaterialAttribute::BaseColor, 0xffffffff_rgbaf); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::baseColorTexture() const { |
||||
return attribute<UnsignedInt>(MaterialAttribute::BaseColorTexture); |
||||
} |
||||
|
||||
Matrix3 PbrMetallicRoughnessMaterialData::baseColorTextureMatrix() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::BaseColorTexture), |
||||
"Trade::PbrMetallicRoughnessMaterialData::baseColorTextureMatrix(): the material doesn't have a base color texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::BaseColorTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::baseColorTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::BaseColorTexture), |
||||
"Trade::PbrMetallicRoughnessMaterialData::baseColorTextureCoordinates(): the material doesn't have a base color texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::BaseColorTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
Float PbrMetallicRoughnessMaterialData::metalness() const { |
||||
return attributeOr(MaterialAttribute::Metalness, 1.0f); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::metalnessTexture() const { |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::MetallicRoughnessTexture)) |
||||
return *value; |
||||
return attribute<UnsignedInt>(MaterialAttribute::MetalnessTexture); |
||||
} |
||||
|
||||
MaterialTextureSwizzle PbrMetallicRoughnessMaterialData::metalnessTextureSwizzle() const { |
||||
CORRADE_ASSERT(hasMetalnessTexture(), |
||||
"Trade::PbrMetallicRoughnessMaterialData::metalnessTextureSwizzle(): the material doesn't have a metalness texture", {}); |
||||
if(hasAttribute(MaterialAttribute::MetallicRoughnessTexture)) |
||||
return MaterialTextureSwizzle::R; |
||||
return attributeOr(MaterialAttribute::MetalnessTextureSwizzle, MaterialTextureSwizzle::R); |
||||
} |
||||
|
||||
Matrix3 PbrMetallicRoughnessMaterialData::metalnessTextureMatrix() const { |
||||
CORRADE_ASSERT(hasMetalnessTexture(), |
||||
"Trade::PbrMetallicRoughnessMaterialData::metalnessTextureMatrix(): the material doesn't have a metalness texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::MetalnessTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::metalnessTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasMetalnessTexture(), |
||||
"Trade::PbrMetallicRoughnessMaterialData::metalnessTextureCoordinates(): the material doesn't have a metalness texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::MetalnessTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
Float PbrMetallicRoughnessMaterialData::roughness() const { |
||||
return attributeOr(MaterialAttribute::Roughness, 1.0f); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::roughnessTexture() const { |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::MetallicRoughnessTexture)) |
||||
return *value; |
||||
return attribute<UnsignedInt>(MaterialAttribute::RoughnessTexture); |
||||
} |
||||
|
||||
MaterialTextureSwizzle PbrMetallicRoughnessMaterialData::roughnessTextureSwizzle() const { |
||||
CORRADE_ASSERT(hasRoughnessTexture(), |
||||
"Trade::PbrMetallicRoughnessMaterialData::roughnessTextureSwizzle(): the material doesn't have a roughness texture", {}); |
||||
if(hasAttribute(MaterialAttribute::MetallicRoughnessTexture)) |
||||
return MaterialTextureSwizzle::G; |
||||
return attributeOr(MaterialAttribute::RoughnessTextureSwizzle, MaterialTextureSwizzle::R); |
||||
} |
||||
|
||||
Matrix3 PbrMetallicRoughnessMaterialData::roughnessTextureMatrix() const { |
||||
CORRADE_ASSERT(hasRoughnessTexture(), |
||||
"Trade::PbrMetallicRoughnessMaterialData::roughnessTextureMatrix(): the material doesn't have a roughness texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::RoughnessTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::roughnessTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasRoughnessTexture(), |
||||
"Trade::PbrMetallicRoughnessMaterialData::roughnessTextureCoordinates(): the material doesn't have a roughness texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::RoughnessTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::normalTexture() const { |
||||
return attribute<UnsignedInt>(MaterialAttribute::NormalTexture); |
||||
} |
||||
|
||||
MaterialTextureSwizzle PbrMetallicRoughnessMaterialData::normalTextureSwizzle() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), |
||||
"Trade::PbrMetallicRoughnessMaterialData::normalTextureSwizzle(): the material doesn't have a normal texture", {}); |
||||
return attributeOr(MaterialAttribute::NormalTextureSwizzle, MaterialTextureSwizzle::RGB); |
||||
} |
||||
|
||||
Matrix3 PbrMetallicRoughnessMaterialData::normalTextureMatrix() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), |
||||
"Trade::PbrMetallicRoughnessMaterialData::normalTextureMatrix(): the material doesn't have a normal texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::NormalTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::normalTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), |
||||
"Trade::PbrMetallicRoughnessMaterialData::normalTextureCoordinates(): the material doesn't have a normal texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::NormalTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::occlusionTexture() const { |
||||
return attribute<UnsignedInt>(MaterialAttribute::OcclusionTexture); |
||||
} |
||||
|
||||
MaterialTextureSwizzle PbrMetallicRoughnessMaterialData::occlusionTextureSwizzle() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), |
||||
"Trade::PbrMetallicRoughnessMaterialData::occlusionTextureSwizzle(): the material doesn't have an occlusion texture", {}); |
||||
return attributeOr(MaterialAttribute::OcclusionTextureSwizzle, MaterialTextureSwizzle::R); |
||||
} |
||||
|
||||
Matrix3 PbrMetallicRoughnessMaterialData::occlusionTextureMatrix() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), |
||||
"Trade::PbrMetallicRoughnessMaterialData::occlusionTextureMatrix(): the material doesn't have an occlusion texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::OcclusionTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::occlusionTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), |
||||
"Trade::PbrMetallicRoughnessMaterialData::occlusionTextureCoordinates(): the material doesn't have an occlusion texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::OcclusionTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
Color3 PbrMetallicRoughnessMaterialData::emissiveColor() const { |
||||
return attributeOr(MaterialAttribute::EmissiveColor, 0x000000_srgbf); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::emissiveTexture() const { |
||||
return attribute<UnsignedInt>(MaterialAttribute::EmissiveTexture); |
||||
} |
||||
|
||||
Matrix3 PbrMetallicRoughnessMaterialData::emissiveTextureMatrix() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture), |
||||
"Trade::PbrMetallicRoughnessMaterialData::emissiveTextureMatrix(): the material doesn't have an emissive texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::EmissiveTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::emissiveTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture), |
||||
"Trade::PbrMetallicRoughnessMaterialData::emissiveTextureCoordinates(): the material doesn't have an emissive texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::EmissiveTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
Matrix3 PbrMetallicRoughnessMaterialData::textureMatrix() const { |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrMetallicRoughnessMaterialData::textureCoordinates() const { |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
}} |
||||
@ -0,0 +1,566 @@
|
||||
#ifndef Magnum_Trade_PbrMetallicRoughnessMaterialData_h |
||||
#define Magnum_Trade_PbrMetallicRoughnessMaterialData_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Class @ref Magnum::Trade::PbrMetallicRoughnessMaterialData |
||||
* @m_since_latest |
||||
*/ |
||||
|
||||
#include "Magnum/Trade/MaterialData.h" |
||||
|
||||
namespace Magnum { namespace Trade { |
||||
|
||||
/**
|
||||
@brief PBR metallic/roughness material data |
||||
@m_since_latest |
||||
|
||||
@see @ref AbstractImporter::material(), @ref PbrSpecularGlossinessMaterialData, |
||||
@ref PhongMaterialData |
||||
*/ |
||||
class MAGNUM_TRADE_EXPORT PbrMetallicRoughnessMaterialData: public MaterialData { |
||||
public: |
||||
#ifndef DOXYGEN_GENERATING_OUTPUT |
||||
/* Allow constructing subclasses directly. While not used in the
|
||||
general Importer workflow, it allows users to create instances with |
||||
desired convenience APIs easier (and simplifies testing). It's |
||||
however hidden from the docs as constructing instances this way |
||||
isn't really common and it would add a lot of noise. */ |
||||
using MaterialData::MaterialData; |
||||
#endif |
||||
|
||||
/**
|
||||
* @brief Whether the material has a metalness texture |
||||
* |
||||
* Returns @cpp true @ce if any of the |
||||
* @ref MaterialAttribute::MetalnessTexture or |
||||
* @ref MaterialAttribute::MetallicRoughnessTexture attributes is |
||||
* present, @cpp false @ce otherwise. |
||||
* @see @ref hasRoughnessTexture(), @ref hasMetallicRoughnessTexture() |
||||
*/ |
||||
bool hasMetalnessTexture() const; |
||||
|
||||
/**
|
||||
* @brief Whether the material has a roughness texture |
||||
* |
||||
* Returns @cpp true @ce if any of the |
||||
* @ref MaterialAttribute::RoughnessTexture or |
||||
* @ref MaterialAttribute::MetallicRoughnessTexture attributes is |
||||
* present, @cpp false @ce otherwise. |
||||
* @see @ref hasMetalnessTexture(), @ref hasMetallicRoughnessTexture() |
||||
*/ |
||||
bool hasRoughnessTexture() const; |
||||
|
||||
/**
|
||||
* @brief Whether the material has a combined metallic/roughness texture |
||||
* |
||||
* Returns @cpp true @ce if either the |
||||
* @ref MaterialAttribute::MetallicRoughnessTexture attribute is |
||||
* present or both @ref MaterialAttribute::MetalnessTexture and |
||||
* @ref MaterialAttribute::RoughnessTexture are present, point to |
||||
* the same texture ID, @ref MaterialAttribute::MetalnessTextureSwizzle |
||||
* is set to @ref MaterialTextureSwizzle::R (or omitted, in which case |
||||
* it's the default) and @ref MaterialAttribute::RoughnessTextureSwizzle |
||||
* is set to @ref MaterialTextureSwizzle::G, and ddditionally |
||||
* @ref MaterialAttribute::MetalnessTextureMatrix and |
||||
* @ref MaterialAttribute::RoughnessTextureMatrix are both either not |
||||
* present or have the same value, and |
||||
* @ref MaterialAttribute::MetalnessTextureCoordinates and |
||||
* @ref MaterialAttribute::RoughnessTextureCoordinates are both either |
||||
* not present or have the same value; @cpp false @ce otherwise. |
||||
* |
||||
* In other words, if this function returns @cpp true @ce, |
||||
* @ref metalnessTexture(), @ref metalnessTextureMatrix() and |
||||
* @ref metalnessTextureCoordinates() return values common for both |
||||
* metalness and roughness texture, and the two are packed together |
||||
* with metalness occupying the R channel and roughness the G channel. |
||||
* @see @ref hasMetalnessTexture(), @ref hasRoughnessTexture(), |
||||
* @ref hasOcclusionRoughnessMetallicTexture(), |
||||
* @ref hasRoughnessMetallicOcclusionTexture(), |
||||
* @ref hasNormalRoughnessMetallicTexture() |
||||
*/ |
||||
bool hasMetallicRoughnessTexture() const; |
||||
|
||||
/**
|
||||
* @brief Whether the material has a combined occlusion/roughness/metallic texture |
||||
* |
||||
* Returns @cpp true @ce if @ref MaterialAttribute::OcclusionTexture, |
||||
* @ref MaterialAttribute::RoughnessTexture and |
||||
* @ref MaterialAttribute::MetalnessTexture are all present, point to |
||||
* the same texture ID, @ref MaterialAttribute::OcclusionTextureSwizzle |
||||
* is set to @ref MaterialTextureSwizzle::R (or omitted, in which case |
||||
* it's the default), @ref MaterialAttribute::RoughnessTextureSwizzle |
||||
* is set to @ref MaterialTextureSwizzle::G and |
||||
* @ref MaterialAttribute::MetalnessTextureSwizzle is set to |
||||
* @ref MaterialTextureSwizzle::B, and additionally |
||||
* @ref MaterialAttribute::OcclusionTextureMatrix, |
||||
* @ref MaterialAttribute::RoughnessTextureMatrix and |
||||
* @ref MaterialAttribute::MetalnessTextureMatrix are all other not |
||||
* present or have the same value, and |
||||
* @ref MaterialAttribute::OcclusionTextureCoordinates, |
||||
* @ref MaterialAttribute::RoughnessTextureCoordinates and |
||||
* @ref MaterialAttribute::MetalnessTextureCoordinates are all either |
||||
* not present or have the same value; @cpp false @ce otherwise. |
||||
* |
||||
* In other words, if this function returns @cpp true @ce, |
||||
* @ref occlusionTexture(), @ref occlusionTextureMatrix() and |
||||
* @ref 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. |
||||
* @see @ref hasMetalnessTexture(), @ref hasRoughnessTexture(), |
||||
* @ref hasMetallicRoughnessTexture(), |
||||
* @ref hasRoughnessMetallicOcclusionTexture(), |
||||
* @ref hasNormalRoughnessMetallicTexture() |
||||
*/ |
||||
bool hasOcclusionRoughnessMetallicTexture() const; |
||||
|
||||
/**
|
||||
* @brief Whether the material has a combined roughness/metallic/occlusion texture |
||||
* |
||||
* Returns @cpp true @ce if @ref MaterialAttribute::RoughnessTexture, |
||||
* @ref MaterialAttribute::MetalnessTexture and |
||||
* @ref MaterialAttribute::OcclusionTexture are all present, point to |
||||
* the same texture ID, @ref MaterialAttribute::RoughnessTextureSwizzle |
||||
* is set to @ref MaterialTextureSwizzle::R (or omitted, in which case |
||||
* it's the default), @ref MaterialAttribute::MetalnessTextureSwizzle |
||||
* is set to @ref MaterialTextureSwizzle::G and |
||||
* @ref MaterialAttribute::OcclusionTextureSwizzle is set to |
||||
* @ref MaterialTextureSwizzle::B, and additionally |
||||
* @ref MaterialAttribute::RoughnessTextureMatrix, |
||||
* @ref MaterialAttribute::MetalnessTextureMatrix and |
||||
* @ref MaterialAttribute::OcclusionTextureMatrix are all other not |
||||
* present or have the same value, and |
||||
* @ref MaterialAttribute::RoughnessTextureCoordinates, |
||||
* @ref MaterialAttribute::MetalnessTextureCoordinates and |
||||
* @ref MaterialAttribute::OcclusionTextureCoordinates are all either |
||||
* not present or have the same value; @cpp false @ce otherwise. |
||||
* |
||||
* In other words, if this function returns @cpp true @ce, |
||||
* @ref roughnessTexture(), @ref roughnessTextureMatrix() and |
||||
* @ref 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. |
||||
* @see @ref hasMetalnessTexture(), @ref hasRoughnessTexture(), |
||||
* @ref hasMetallicRoughnessTexture(), |
||||
* @ref hasOcclusionRoughnessMetallicTexture(), |
||||
* @ref hasNormalRoughnessMetallicTexture() |
||||
*/ |
||||
bool hasRoughnessMetallicOcclusionTexture() const; |
||||
|
||||
/**
|
||||
* @brief Whether the material has a combined normal/roughness/metallic texture |
||||
* |
||||
* Returns @cpp true @ce if @ref MaterialAttribute::NormalTexture, |
||||
* @ref MaterialAttribute::RoughnessTexture and |
||||
* @ref MaterialAttribute::MetalnessTexture are all present, point to |
||||
* the same texture ID, @ref MaterialAttribute::NormalTextureSwizzle |
||||
* is set to @ref MaterialTextureSwizzle::RG (with the third channel |
||||
* implicit), @ref MaterialAttribute::RoughnessTextureSwizzle |
||||
* is set to @ref MaterialTextureSwizzle::B and |
||||
* @ref MaterialAttribute::MetalnessTextureSwizzle is set to |
||||
* @ref MaterialTextureSwizzle::A, and additionally |
||||
* @ref MaterialAttribute::NormalTextureMatrix, |
||||
* @ref MaterialAttribute::RoughnessTextureMatrix and |
||||
* @ref MaterialAttribute::MetalnessTextureMatrix are all other not |
||||
* present or have the same value, and |
||||
* @ref MaterialAttribute::NormalTextureCoordinates, |
||||
* @ref MaterialAttribute::RoughnessTextureCoordinates and |
||||
* @ref MaterialAttribute::MetalnessTextureCoordinates are all either |
||||
* not present or have the same value; @cpp false @ce otherwise. |
||||
* |
||||
* In other words, if this function returns @cpp true @ce, |
||||
* @ref normalTexture(), @ref normalTextureMatrix() and |
||||
* @ref 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. |
||||
* @see @ref hasMetalnessTexture(), @ref hasRoughnessTexture(), |
||||
* @ref hasMetallicRoughnessTexture(), |
||||
* @ref hasRoughnessMetallicOcclusionTexture(), |
||||
* @ref hasOcclusionRoughnessMetallicTexture() |
||||
*/ |
||||
bool hasNormalRoughnessMetallicTexture() const; |
||||
|
||||
/**
|
||||
* @brief Whether the material has texture transformation |
||||
* |
||||
* Returns @cpp true @ce if any of the |
||||
* @ref MaterialAttribute::BaseColorTextureMatrix, |
||||
* @ref MaterialAttribute::MetalnessTextureMatrix, |
||||
* @ref MaterialAttribute::RoughnessTextureMatrix, |
||||
* @ref MaterialAttribute::NormalTextureMatrix, |
||||
* @ref MaterialAttribute::OcclusionTextureMatrix, |
||||
* @ref MaterialAttribute::EmissiveTextureMatrix or |
||||
* @ref MaterialAttribute::TextureMatrix attributes is present, |
||||
* @cpp false @ce otherwise. |
||||
*/ |
||||
bool hasTextureTransformation() const; |
||||
|
||||
/**
|
||||
* @brief Whether the material uses extra texture coordinate sets |
||||
* |
||||
* Returns @cpp true @ce if any of the |
||||
* @ref MaterialAttribute::BaseColorTextureCoordinates, |
||||
* @ref MaterialAttribute::MetalnessTextureCoordinates, |
||||
* @ref MaterialAttribute::RoughnessTextureCoordinates, |
||||
* @ref MaterialAttribute::NormalTextureCoordinates, |
||||
* @ref MaterialAttribute::OcclusionTextureCoordinates, |
||||
* @ref MaterialAttribute::EmissiveTextureCoordinates or |
||||
* @ref MaterialAttribute::TextureCoordinates attributes is present and |
||||
* has a non-zero value, @cpp false @ce otherwise. |
||||
*/ |
||||
bool hasTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Base color |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::BaseColor |
||||
* attribute. If not present, the default is @cpp 0xffffffff_srgbaf @ce. |
||||
* |
||||
* If the material has @ref MaterialAttribute::BaseColorTexture, the |
||||
* color and texture is meant to be multiplied together. |
||||
*/ |
||||
Color4 baseColor() const; |
||||
|
||||
/**
|
||||
* @brief Base color texture ID |
||||
* |
||||
* Available only if @ref MaterialAttribute::BaseColorTexture is |
||||
* present. Meant to be multiplied with @ref baseColor(). |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt baseColorTexture() const; |
||||
|
||||
/**
|
||||
* @brief Base color texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::BaseColorTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has @ref MaterialAttribute::BaseColorTexture. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
Matrix3 baseColorTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Base color texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::BaseColorTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither |
||||
* is present, the default is @cpp 0 @ce. Available only if the |
||||
* material has @ref MaterialAttribute::BaseColorTexture. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
UnsignedInt baseColorTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Metalness factor |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::Metalness |
||||
* attribute. If not present, the default is @cpp 1.0f @ce. |
||||
* |
||||
* If the material has a metalness texture, the factor and texture is |
||||
* meant to be multiplied together. |
||||
* @see @ref hasMetalnessTexture() |
||||
*/ |
||||
Float metalness() const; |
||||
|
||||
/**
|
||||
* @brief Metalness texture ID |
||||
* |
||||
* Available only if either @ref MaterialAttribute::MetalnessTexture or |
||||
* @ref MaterialAttribute::MetallicRoughnessTexture is present. Meant |
||||
* to be multiplied with @ref metalness(). |
||||
* @see @ref hasMetalnessTexture(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt metalnessTexture() const; |
||||
|
||||
/**
|
||||
* @brief Metalness texture swizzle |
||||
* |
||||
* If @ref MaterialAttribute::MetallicRoughnessTexture is present, |
||||
* returns always @ref MaterialTextureSwizzle::R. Otherwise returns the |
||||
* @ref MaterialAttribute::MetalnessTextureSwizzle attribute, or |
||||
* @ref MaterialTextureSwizzle::R, if it's not present. Available only |
||||
* if the material has a metalness texture. |
||||
* @see @ref hasMetalnessTexture() |
||||
*/ |
||||
MaterialTextureSwizzle metalnessTextureSwizzle() const; |
||||
|
||||
/**
|
||||
* @brief Metalness texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::MetalnessTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has a metalness texture. |
||||
* @see @ref hasMetalnessTexture() |
||||
*/ |
||||
Matrix3 metalnessTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Metalness texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::MetalnessTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither |
||||
* is present, the default is @cpp 0 @ce. Available only if the |
||||
* material has a metalness texture. |
||||
* @see @ref hasMetalnessTexture() |
||||
*/ |
||||
UnsignedInt metalnessTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Roughness factor |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::Roughness |
||||
* attribute. If not present, the default is @cpp 1.0f @ce. |
||||
* |
||||
* If the material has a roughness texture, the factor and texture is |
||||
* meant to be multiplied together. |
||||
* @see @ref hasRoughnessTexture() |
||||
*/ |
||||
Float roughness() const; |
||||
|
||||
/**
|
||||
* @brief Roughness texture ID |
||||
* |
||||
* Available only if either @ref MaterialAttribute::RoughnessTexture or |
||||
* @ref MaterialAttribute::MetallicRoughnessTexture is present. Meant |
||||
* to be multiplied with @ref roughness(). |
||||
* @see @ref hasRoughnessTexture(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt roughnessTexture() const; |
||||
|
||||
/**
|
||||
* @brief Roughness texture swizzle |
||||
* |
||||
* If @ref MaterialAttribute::MetallicRoughnessTexture is present, |
||||
* returns always @ref MaterialTextureSwizzle::G. Otherwise returns the |
||||
* @ref MaterialAttribute::RoughnessTextureSwizzle attribute, or |
||||
* @ref MaterialTextureSwizzle::R, if it's not present. Available only |
||||
* if the material has a roughness texture. |
||||
* @see @ref hasRoughnessTexture() |
||||
*/ |
||||
MaterialTextureSwizzle roughnessTextureSwizzle() const; |
||||
|
||||
/**
|
||||
* @brief Roughness texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::RoughnessTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has a roughness texture. |
||||
* @see @ref hasRoughnessTexture() |
||||
*/ |
||||
Matrix3 roughnessTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Roughness texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::RoughnessTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither |
||||
* is present, the default is @cpp 0 @ce. Available only if the |
||||
* material has a roughness texture. |
||||
* @see @ref hasRoughnessTexture() |
||||
*/ |
||||
UnsignedInt roughnessTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Normal texture ID |
||||
* |
||||
* Available only if @ref MaterialAttribute::NormalTexture is present. |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt normalTexture() const; |
||||
|
||||
/**
|
||||
* @brief Normal texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::NormalTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has @ref MaterialAttribute::NormalTexture. |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
Matrix3 normalTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Normal texture swizzle |
||||
* @m_since_latest |
||||
* |
||||
* Convenience access to the |
||||
* @ref MaterialAttribute::NormalTextureSwizzle attribute. If not |
||||
* present, the default is @ref MaterialTextureSwizzle::RGB. Available |
||||
* only if @ref MaterialAttribute::NormalTexture is present. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
MaterialTextureSwizzle normalTextureSwizzle() const; |
||||
|
||||
/**
|
||||
* @brief Normal texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::NormalTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither is |
||||
* present, the default is @cpp 0 @ce. Available only if the material |
||||
* has @ref MaterialAttribute::NormalTexture. |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt normalTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Occlusion texture ID |
||||
* |
||||
* Available only if @ref MaterialAttribute::OcclusionTexture is present. |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt occlusionTexture() const; |
||||
|
||||
/**
|
||||
* @brief Occlusion texture swizzle |
||||
* |
||||
* Convenience access to the |
||||
* @ref MaterialAttribute::OcclusionTextureSwizzle attribute. If not |
||||
* present, the default is @ref MaterialTextureSwizzle::R. Available |
||||
* only if @ref MaterialAttribute::OcclusionTexture is present. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
MaterialTextureSwizzle occlusionTextureSwizzle() const; |
||||
|
||||
/**
|
||||
* @brief Occlusion texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::OcclusionTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has @ref MaterialAttribute::OcclusionTexture. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
Matrix3 occlusionTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Occlusion texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::OcclusionTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither |
||||
* is present, the default is @cpp 0 @ce. Available only if the |
||||
* material has @ref MaterialAttribute::OcclusionTexture. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
UnsignedInt occlusionTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Emissive color |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::EmissiveColor |
||||
* attribute. If not present, the default is @cpp 0x000000_srgbf @ce |
||||
* (i.e, no emission). |
||||
* |
||||
* If the material has @ref MaterialAttribute::EmissiveTexture, the |
||||
* color and texture is meant to be multiplied together. |
||||
*/ |
||||
Color3 emissiveColor() const; |
||||
|
||||
/**
|
||||
* @brief Emissive texture ID |
||||
* |
||||
* Available only if @ref MaterialAttribute::EmissiveTexture is present. |
||||
* Meant to be multiplied with @ref emissiveColor(). |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt emissiveTexture() const; |
||||
|
||||
/* No EmissiveTextureSwizzle attribute right now (implicitly RGB) */ |
||||
|
||||
/**
|
||||
* @brief Emissive texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::EmissiveTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has @ref MaterialAttribute::EmissiveTexture. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
Matrix3 emissiveTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Emissive texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::EmissiveTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither |
||||
* is present, the default is @cpp 0 @ce. Available only if the |
||||
* material has @ref MaterialAttribute::EmissiveTexture. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
UnsignedInt emissiveTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Common texture coordinate transformation matrix for all textures |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::TextureMatrix |
||||
* attribute. If not present, the default is an identity matrix. Note |
||||
* that the material may also define per-texture transformation using |
||||
* the @ref MaterialAttribute::BaseColorTextureMatrix, |
||||
* @ref MaterialAttribute::MetalnessTextureMatrix, |
||||
* @ref MaterialAttribute::RoughnessTextureMatrix, |
||||
* @ref MaterialAttribute::NormalTextureMatrix, |
||||
* @ref MaterialAttribute::OcclusionTextureMatrix and |
||||
* @ref MaterialAttribute::EmissiveTextureMatrix attributes, which then |
||||
* take precedence over the common one. |
||||
* @see @ref hasAttribute(), @ref baseColorTextureMatrix(), |
||||
* @ref metalnessTextureMatrix(), @ref roughnessTextureMatrix(), |
||||
* @ref normalTextureMatrix(), @ref occlusionTextureMatrix(), |
||||
* @ref emissiveTextureMatrix() |
||||
*/ |
||||
Matrix3 textureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Common texture coordinate set index for all textures |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::TextureCoordinates |
||||
* attribute. If not present, the default is @cpp 0 @ce. Note that the |
||||
* material may also define per-texture coordinate set using the |
||||
* @ref MaterialAttribute::BaseColorTextureCoordinates, |
||||
* @ref MaterialAttribute::MetalnessTextureCoordinates, |
||||
* @ref MaterialAttribute::RoughnessTextureCoordinates, |
||||
* @ref MaterialAttribute::NormalTextureCoordinates, |
||||
* @ref MaterialAttribute::OcclusionTextureCoordinates and |
||||
* @ref MaterialAttribute::EmissiveTextureCoordinates attributes, which |
||||
* then take precedence over the common one. |
||||
* @see @ref hasAttribute(), @ref baseColorTextureCoordinates(), |
||||
* @ref metalnessTextureCoordinates(), |
||||
* @ref roughnessTextureCoordinates(), |
||||
* @ref normalTextureCoordinates(), |
||||
* @ref occlusionTextureCoordinates(), |
||||
* @ref emissiveTextureCoordinates() |
||||
*/ |
||||
UnsignedInt textureCoordinates() const; |
||||
}; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -0,0 +1,251 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include "PbrSpecularGlossinessMaterialData.h" |
||||
|
||||
#include "Magnum/Math/Color.h" |
||||
#include "Magnum/Math/Matrix3.h" |
||||
|
||||
namespace Magnum { namespace Trade { |
||||
|
||||
using namespace Math::Literals; |
||||
|
||||
bool PbrSpecularGlossinessMaterialData::hasSpecularTexture() const { |
||||
return hasAttribute(MaterialAttribute::SpecularTexture) || |
||||
hasAttribute(MaterialAttribute::SpecularGlossinessTexture); |
||||
} |
||||
|
||||
bool PbrSpecularGlossinessMaterialData::hasGlossinessTexture() const { |
||||
return hasAttribute(MaterialAttribute::GlossinessTexture) || |
||||
hasAttribute(MaterialAttribute::SpecularGlossinessTexture); |
||||
} |
||||
|
||||
bool PbrSpecularGlossinessMaterialData::hasSpecularGlossinessTexture() const { |
||||
return (hasAttribute(MaterialAttribute::SpecularGlossinessTexture) || |
||||
(hasAttribute(MaterialAttribute::SpecularTexture) && |
||||
hasAttribute(MaterialAttribute::GlossinessTexture) && |
||||
specularTextureSwizzle() == MaterialTextureSwizzle::RGB && |
||||
glossinessTextureSwizzle() == MaterialTextureSwizzle::A)) && |
||||
specularTextureMatrix() == glossinessTextureMatrix() && |
||||
specularTextureCoordinates() == glossinessTextureCoordinates(); |
||||
} |
||||
|
||||
bool PbrSpecularGlossinessMaterialData::hasTextureTransformation() const { |
||||
return hasAttribute(MaterialAttribute::TextureMatrix) || |
||||
hasAttribute(MaterialAttribute::DiffuseTextureMatrix) || |
||||
hasAttribute(MaterialAttribute::SpecularTextureMatrix) || |
||||
hasAttribute(MaterialAttribute::GlossinessTextureMatrix) || |
||||
hasAttribute(MaterialAttribute::NormalTextureMatrix) || |
||||
hasAttribute(MaterialAttribute::OcclusionTextureMatrix) || |
||||
hasAttribute(MaterialAttribute::EmissiveTextureMatrix); |
||||
} |
||||
|
||||
bool PbrSpecularGlossinessMaterialData::hasTextureCoordinates() const { |
||||
return hasAttribute(MaterialAttribute::TextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::DiffuseTextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::SpecularTextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::GlossinessTextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::NormalTextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::OcclusionTextureCoordinates) || |
||||
hasAttribute(MaterialAttribute::EmissiveTextureCoordinates); |
||||
} |
||||
|
||||
Color4 PbrSpecularGlossinessMaterialData::diffuseColor() const { |
||||
return attributeOr(MaterialAttribute::DiffuseColor, 0xffffffff_srgbaf); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::diffuseTexture() const { |
||||
return attribute<UnsignedInt>(MaterialAttribute::DiffuseTexture); |
||||
} |
||||
|
||||
Matrix3 PbrSpecularGlossinessMaterialData::diffuseTextureMatrix() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture), |
||||
"Trade::PbrSpecularGlossinessMaterialData::diffuseTextureMatrix(): the material doesn't have a diffuse texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::DiffuseTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::diffuseTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::DiffuseTexture), |
||||
"Trade::PbrSpecularGlossinessMaterialData::diffuseTextureCoordinates(): the material doesn't have a diffuse texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::DiffuseTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
Color4 PbrSpecularGlossinessMaterialData::specularColor() const { |
||||
return attributeOr(MaterialAttribute::SpecularColor, 0xffffff00_srgbaf); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::specularTexture() const { |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularGlossinessTexture)) |
||||
return *value; |
||||
return attribute<UnsignedInt>(MaterialAttribute::SpecularTexture); |
||||
} |
||||
|
||||
MaterialTextureSwizzle PbrSpecularGlossinessMaterialData::specularTextureSwizzle() const { |
||||
CORRADE_ASSERT(hasSpecularTexture(), |
||||
"Trade::PbrSpecularGlossinessMaterialData::specularTextureSwizzle(): the material doesn't have a specular texture", {}); |
||||
if(hasAttribute(MaterialAttribute::SpecularGlossinessTexture)) |
||||
return MaterialTextureSwizzle::RGB; |
||||
return attributeOr(MaterialAttribute::SpecularTextureSwizzle, MaterialTextureSwizzle::RGB); |
||||
} |
||||
|
||||
Matrix3 PbrSpecularGlossinessMaterialData::specularTextureMatrix() const { |
||||
CORRADE_ASSERT(hasSpecularTexture(), |
||||
"Trade::PbrSpecularGlossinessMaterialData::specularTextureMatrix(): the material doesn't have a specular texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::SpecularTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::specularTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasSpecularTexture(), |
||||
"Trade::PbrSpecularGlossinessMaterialData::specularTextureCoordinates(): the material doesn't have a specular texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
Float PbrSpecularGlossinessMaterialData::glossiness() const { |
||||
return attributeOr(MaterialAttribute::Glossiness, 1.0f); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::glossinessTexture() const { |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::SpecularGlossinessTexture)) |
||||
return *value; |
||||
return attribute<UnsignedInt>(MaterialAttribute::GlossinessTexture); |
||||
} |
||||
|
||||
MaterialTextureSwizzle PbrSpecularGlossinessMaterialData::glossinessTextureSwizzle() const { |
||||
CORRADE_ASSERT(hasGlossinessTexture(), |
||||
"Trade::PbrSpecularGlossinessMaterialData::glossinessTextureSwizzle(): the material doesn't have a glossiness texture", {}); |
||||
if(hasAttribute(MaterialAttribute::SpecularGlossinessTexture)) |
||||
return MaterialTextureSwizzle::A; |
||||
return attributeOr(MaterialAttribute::GlossinessTextureSwizzle, MaterialTextureSwizzle::R); |
||||
} |
||||
|
||||
Matrix3 PbrSpecularGlossinessMaterialData::glossinessTextureMatrix() const { |
||||
CORRADE_ASSERT(hasGlossinessTexture(), |
||||
"Trade::PbrSpecularGlossinessMaterialData::glossinessTextureMatrix(): the material doesn't have a glossiness texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::GlossinessTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::glossinessTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasGlossinessTexture(), |
||||
"Trade::PbrSpecularGlossinessMaterialData::glossinessTextureCoordinates(): the material doesn't have a glossiness texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::GlossinessTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::normalTexture() const { |
||||
return attribute<UnsignedInt>(MaterialAttribute::NormalTexture); |
||||
} |
||||
|
||||
MaterialTextureSwizzle PbrSpecularGlossinessMaterialData::normalTextureSwizzle() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), |
||||
"Trade::PbrSpecularGlossinessMaterialData::normalTextureSwizzle(): the material doesn't have a normal texture", {}); |
||||
return attributeOr(MaterialAttribute::NormalTextureSwizzle, MaterialTextureSwizzle::RGB); |
||||
} |
||||
|
||||
Matrix3 PbrSpecularGlossinessMaterialData::normalTextureMatrix() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), |
||||
"Trade::PbrSpecularGlossinessMaterialData::normalTextureMatrix(): the material doesn't have a normal texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::NormalTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::normalTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::NormalTexture), |
||||
"Trade::PbrSpecularGlossinessMaterialData::normalTextureCoordinates(): the material doesn't have a normal texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::NormalTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::occlusionTexture() const { |
||||
return attribute<UnsignedInt>(MaterialAttribute::OcclusionTexture); |
||||
} |
||||
|
||||
MaterialTextureSwizzle PbrSpecularGlossinessMaterialData::occlusionTextureSwizzle() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), |
||||
"Trade::PbrSpecularGlossinessMaterialData::occlusionTextureSwizzle(): the material doesn't have an occlusion texture", {}); |
||||
return attributeOr(MaterialAttribute::OcclusionTextureSwizzle, MaterialTextureSwizzle::R); |
||||
} |
||||
|
||||
Matrix3 PbrSpecularGlossinessMaterialData::occlusionTextureMatrix() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), |
||||
"Trade::PbrSpecularGlossinessMaterialData::occlusionTextureMatrix(): the material doesn't have an occlusion texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::OcclusionTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::occlusionTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::OcclusionTexture), |
||||
"Trade::PbrSpecularGlossinessMaterialData::occlusionTextureCoordinates(): the material doesn't have an occlusion texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::OcclusionTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
Color3 PbrSpecularGlossinessMaterialData::emissiveColor() const { |
||||
return attributeOr(MaterialAttribute::EmissiveColor, 0x000000_srgbf); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::emissiveTexture() const { |
||||
return attribute<UnsignedInt>(MaterialAttribute::EmissiveTexture); |
||||
} |
||||
|
||||
Matrix3 PbrSpecularGlossinessMaterialData::emissiveTextureMatrix() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture), |
||||
"Trade::PbrSpecularGlossinessMaterialData::emissiveTextureMatrix(): the material doesn't have an emissive texture", {}); |
||||
if(Containers::Optional<Matrix3> value = tryAttribute<Matrix3>(MaterialAttribute::EmissiveTextureMatrix)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::emissiveTextureCoordinates() const { |
||||
CORRADE_ASSERT(hasAttribute(MaterialAttribute::EmissiveTexture), |
||||
"Trade::PbrSpecularGlossinessMaterialData::emissiveTextureCoordinates(): the material doesn't have an emissive texture", {}); |
||||
if(Containers::Optional<UnsignedInt> value = tryAttribute<UnsignedInt>(MaterialAttribute::EmissiveTextureCoordinates)) |
||||
return *value; |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
Matrix3 PbrSpecularGlossinessMaterialData::textureMatrix() const { |
||||
return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); |
||||
} |
||||
|
||||
UnsignedInt PbrSpecularGlossinessMaterialData::textureCoordinates() const { |
||||
return attributeOr(MaterialAttribute::TextureCoordinates, 0u); |
||||
} |
||||
|
||||
}} |
||||
@ -0,0 +1,460 @@
|
||||
#ifndef Magnum_Trade_PbrSpecularGlossinessMaterialData_h |
||||
#define Magnum_Trade_PbrSpecularGlossinessMaterialData_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Class @ref Magnum::Trade::PbrSpecularGlossinessMaterialData |
||||
* @m_since_latest |
||||
*/ |
||||
|
||||
#include "Magnum/Trade/MaterialData.h" |
||||
|
||||
namespace Magnum { namespace Trade { |
||||
|
||||
/**
|
||||
@brief PBR specular/glossiness material data |
||||
@m_since_latest |
||||
|
||||
@see @ref AbstractImporter::material(), @ref PbrMetallicRoughnessMaterialData, |
||||
@ref PhongMaterialData |
||||
*/ |
||||
class MAGNUM_TRADE_EXPORT PbrSpecularGlossinessMaterialData: public MaterialData { |
||||
public: |
||||
#ifndef DOXYGEN_GENERATING_OUTPUT |
||||
/* Allow constructing subclasses directly. While not used in the
|
||||
general Importer workflow, it allows users to create instances with |
||||
desired convenience APIs easier (and simplifies testing). It's |
||||
however hidden from the docs as constructing instances this way |
||||
isn't really common and it would add a lot of noise. */ |
||||
using MaterialData::MaterialData; |
||||
#endif |
||||
|
||||
/**
|
||||
* @brief Whether the material has a specular texture |
||||
* |
||||
* Returns @cpp true @ce if any of the |
||||
* @ref MaterialAttribute::SpecularTexture or |
||||
* @ref MaterialAttribute::SpecularGlossinessTexture attributes is |
||||
* present, @cpp false @ce otherwise. |
||||
* @see @ref hasGlossinessTexture(), |
||||
* @ref hasSpecularGlossinessTexture() |
||||
*/ |
||||
bool hasSpecularTexture() const; |
||||
|
||||
/**
|
||||
* @brief Whether the material has a glossiness texture |
||||
* |
||||
* Returns @cpp true @ce if any of the |
||||
* @ref MaterialAttribute::GlossinessTexture or |
||||
* @ref MaterialAttribute::SpecularGlossinessTexture attributes is |
||||
* present, @cpp false @ce otherwise. |
||||
* @see @ref hasSpecularTexture(), |
||||
* @ref hasSpecularGlossinessTexture() |
||||
*/ |
||||
bool hasGlossinessTexture() const; |
||||
|
||||
/**
|
||||
* @brief Whether the material has a combined specular/glossiness texture |
||||
* |
||||
* Returns @cpp true @ce if either the |
||||
* @ref MaterialAttribute::SpecularGlossinessTexture attribute is |
||||
* present or both @ref MaterialAttribute::SpecularTexture and |
||||
* @ref MaterialAttribute::GlossinessTexture are present, point to |
||||
* the same texture ID and @ref MaterialAttribute::GlossinessTextureSwizzle |
||||
* is set to @ref MaterialTextureSwizzle::A, and ddditionally |
||||
* @ref MaterialAttribute::SpecularTextureMatrix and |
||||
* @ref MaterialAttribute::GlossinessTextureMatrix are both either not |
||||
* present or have the same value, and |
||||
* @ref MaterialAttribute::SpecularTextureCoordinates and |
||||
* @ref MaterialAttribute::GlossinessTextureCoordinates are both either |
||||
* not present or have the same value; @cpp false @ce otherwise. |
||||
* |
||||
* In other words, if this function returns @cpp true @ce, |
||||
* @ref specularTexture(), @ref specularTextureMatrix() and |
||||
* @ref specularTextureCoordinates() return values common for both |
||||
* specular and glossiness texture, and the two are packed together |
||||
* with specular occupying the RGB channels and glossiness the alpha. |
||||
* @see @ref hasSpecularTexture(), @ref hasGlossinessTexture() |
||||
*/ |
||||
bool hasSpecularGlossinessTexture() const; |
||||
|
||||
/**
|
||||
* @brief Whether the material has texture transformation |
||||
* |
||||
* Returns @cpp true @ce if any of the |
||||
* @ref MaterialAttribute::DiffuseTextureMatrix, |
||||
* @ref MaterialAttribute::SpecularTextureMatrix, |
||||
* @ref MaterialAttribute::GlossinessTextureMatrix, |
||||
* @ref MaterialAttribute::NormalTextureMatrix, |
||||
* @ref MaterialAttribute::OcclusionTextureMatrix, |
||||
* @ref MaterialAttribute::EmissiveTextureMatrix or |
||||
* @ref MaterialAttribute::TextureMatrix attributes is present, |
||||
* @cpp false @ce otherwise. |
||||
*/ |
||||
bool hasTextureTransformation() const; |
||||
|
||||
/**
|
||||
* @brief Whether the material uses extra texture coordinate sets |
||||
* |
||||
* Returns @cpp true @ce if any of the |
||||
* @ref MaterialAttribute::DiffuseTextureCoordinates, |
||||
* @ref MaterialAttribute::SpecularTextureCoordinates, |
||||
* @ref MaterialAttribute::GlossinessTextureCoordinates, |
||||
* @ref MaterialAttribute::NormalTextureCoordinates, |
||||
* @ref MaterialAttribute::OcclusionTextureCoordinates, |
||||
* @ref MaterialAttribute::EmissiveTextureCoordinates or |
||||
* @ref MaterialAttribute::TextureCoordinates attributes is present and |
||||
* has a non-zero value, @cpp false @ce otherwise. |
||||
*/ |
||||
bool hasTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Base color |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::DiffuseColor |
||||
* attribute. If not present, the default is @cpp 0xffffffff_srgbaf @ce. |
||||
* |
||||
* If the material has @ref MaterialAttribute::DiffuseTexture, the |
||||
* color and texture is meant to be multiplied together. |
||||
*/ |
||||
Color4 diffuseColor() const; |
||||
|
||||
/**
|
||||
* @brief Base color texture ID |
||||
* |
||||
* Available only if @ref MaterialAttribute::DiffuseTexture is |
||||
* present. Meant to be multiplied with @ref diffuseColor(). |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt diffuseTexture() const; |
||||
|
||||
/**
|
||||
* @brief Base color texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::DiffuseTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has @ref MaterialAttribute::DiffuseTexture. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
Matrix3 diffuseTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Base color texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::DiffuseTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither is |
||||
* present, the default is @cpp 0 @ce. Available only if the material |
||||
* has @ref MaterialAttribute::DiffuseTexture. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
UnsignedInt diffuseTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Specular color |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::SpecularColor |
||||
* attribute. If not present, the default is @cpp 0xffffff00_srgbaf @ce. |
||||
* |
||||
* If the material has a specular texture, the color and texture is |
||||
* meant to be multiplied together. |
||||
* @see @ref hasSpecularTexture() |
||||
*/ |
||||
Color4 specularColor() const; |
||||
|
||||
/**
|
||||
* @brief Specular texture ID |
||||
* |
||||
* Available only if either @ref MaterialAttribute::SpecularTexture or |
||||
* @ref MaterialAttribute::SpecularGlossinessTexture is present. Meant |
||||
* to be multiplied with @ref specularColor(). |
||||
* @see @ref hasSpecularTexture(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt specularTexture() const; |
||||
|
||||
/**
|
||||
* @brief Specular texture swizzle |
||||
* |
||||
* If @ref MaterialAttribute::SpecularGlossinessTexture is present, |
||||
* returns always @ref MaterialTextureSwizzle::RGB. Otherwise returns |
||||
* the @ref MaterialAttribute::SpecularTextureSwizzle attribute, or |
||||
* @ref MaterialTextureSwizzle::RGB if it's not present. Available only |
||||
* if the material has a specular texture. |
||||
* @see @ref hasSpecularTexture() |
||||
*/ |
||||
MaterialTextureSwizzle specularTextureSwizzle() const; |
||||
|
||||
/**
|
||||
* @brief Specular texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::SpecularTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has a specular texture. |
||||
* @see @ref hasSpecularTexture() |
||||
*/ |
||||
Matrix3 specularTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Specular texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::SpecularTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither is |
||||
* present, the default is @cpp 0 @ce. Available only if the material |
||||
* has a specular texture. |
||||
* @see @ref hasSpecularTexture() |
||||
*/ |
||||
UnsignedInt specularTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Glossiness factor |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::Glossiness |
||||
* attribute. If not present, the default is @cpp 1.0f @ce. |
||||
* |
||||
* If the material has a glossiness texture, the factor and texture is |
||||
* meant to be multiplied together. |
||||
* @see @ref hasGlossinessTexture() |
||||
*/ |
||||
Float glossiness() const; |
||||
|
||||
/**
|
||||
* @brief Glossiness texture ID |
||||
* |
||||
* Available only if either @ref MaterialAttribute::GlossinessTexture or |
||||
* @ref MaterialAttribute::SpecularGlossinessTexture is present. Meant |
||||
* to be multiplied with @ref glossiness(). |
||||
* @see @ref hasGlossinessTexture(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt glossinessTexture() const; |
||||
|
||||
/**
|
||||
* @brief Glossiness texture swizzle |
||||
* |
||||
* If @ref MaterialAttribute::SpecularGlossinessTexture is present, |
||||
* returns always @ref MaterialTextureSwizzle::A. Otherwise returns the |
||||
* @ref MaterialAttribute::GlossinessTextureSwizzle attribute, or |
||||
* @ref MaterialTextureSwizzle::R if it's not present. Available only |
||||
* if the material has a glossiness texture. |
||||
* @see @ref hasGlossinessTexture() |
||||
*/ |
||||
MaterialTextureSwizzle glossinessTextureSwizzle() const; |
||||
|
||||
/**
|
||||
* @brief Glossiness texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::GlossinessTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has a glossiness texture. |
||||
* @see @ref hasGlossinessTexture() |
||||
*/ |
||||
Matrix3 glossinessTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Glossiness texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::GlossinessTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither is |
||||
* present, the default is @cpp 0 @ce. Available only if the material |
||||
* has a glossiness texture. |
||||
* @see @ref hasGlossinessTexture() |
||||
*/ |
||||
UnsignedInt glossinessTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Normal texture ID |
||||
* |
||||
* Available only if @ref MaterialAttribute::NormalTexture is present. |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt normalTexture() const; |
||||
|
||||
/**
|
||||
* @brief Normal texture swizzle |
||||
* |
||||
* Convenience access to the |
||||
* @ref MaterialAttribute::NormalTextureSwizzle attribute. If not |
||||
* present, the default is @ref MaterialTextureSwizzle::RGB. Available |
||||
* only if @ref MaterialAttribute::NormalTexture is present. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
MaterialTextureSwizzle normalTextureSwizzle() const; |
||||
|
||||
/**
|
||||
* @brief Normal texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::NormalTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has @ref MaterialAttribute::NormalTexture. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
Matrix3 normalTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Normal texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::NormalTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither is |
||||
* present, the default is @cpp 0 @ce. Available only if the material |
||||
* has @ref MaterialAttribute::NormalTexture. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
UnsignedInt normalTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Occlusion texture ID |
||||
* |
||||
* Available only if @ref MaterialAttribute::OcclusionTexture is present. |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt occlusionTexture() const; |
||||
|
||||
/**
|
||||
* @brief Occlusion texture swizzle |
||||
* |
||||
* Convenience access to the |
||||
* @ref MaterialAttribute::OcclusionTextureSwizzle attribute. If not |
||||
* present, the default is @ref MaterialTextureSwizzle::R. Available |
||||
* only if @ref MaterialAttribute::OcclusionTexture is present. |
||||
* @see @ref hasAttribute() |
||||
*/ |
||||
MaterialTextureSwizzle occlusionTextureSwizzle() const; |
||||
|
||||
/**
|
||||
* @brief Occlusion texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::OcclusionTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has @ref MaterialAttribute::OcclusionTexture. |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
Matrix3 occlusionTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Occlusion texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::OcclusionTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither is |
||||
* present, the default is @cpp 0 @ce. Available only if the material |
||||
* has @ref MaterialAttribute::OcclusionTexture. |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt occlusionTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Emissive color |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::EmissiveColor |
||||
* attribute. If not present, the default is @cpp 0x000000_srgbf @ce |
||||
* (i.e, no emission). |
||||
* |
||||
* If the material has @ref MaterialAttribute::EmissiveTexture, the |
||||
* color and texture is meant to be multiplied together. |
||||
*/ |
||||
Color3 emissiveColor() const; |
||||
|
||||
/**
|
||||
* @brief Emissive texture ID |
||||
* |
||||
* Available only if @ref MaterialAttribute::EmissiveTexture is present. |
||||
* Meant to be multiplied with @ref emissiveColor(). |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt emissiveTexture() const; |
||||
|
||||
/* No EmissiveTextureSwizzle attribute right now (implicitly RGB) */ |
||||
|
||||
/**
|
||||
* @brief Emissive texture coordinate transformation matrix |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::EmissiveTextureMatrix |
||||
* / @ref MaterialAttribute::TextureMatrix attributes. If neither is |
||||
* present, the default is an identity matrix. Available only if the |
||||
* material has @ref MaterialAttribute::EmissiveTexture. |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
Matrix3 emissiveTextureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Emissive texture coordinate set |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::EmissiveTextureCoordinates |
||||
* / @ref MaterialAttribute::TextureCoordinates attributes. If neither |
||||
* is present, the default is @cpp 0 @ce. Available only if the |
||||
* material has @ref MaterialAttribute::EmissiveTexture. |
||||
* @see @ref hasAttribute(), @ref AbstractImporter::texture() |
||||
*/ |
||||
UnsignedInt emissiveTextureCoordinates() const; |
||||
|
||||
/**
|
||||
* @brief Common texture coordinate transformation matrix for all textures |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::TextureMatrix |
||||
* attribute. If not present, the default is an identity matrix. Note |
||||
* that the material may also define per-texture transformation using |
||||
* the @ref MaterialAttribute::DiffuseTextureMatrix, |
||||
* @ref MaterialAttribute::SpecularTextureMatrix, |
||||
* @ref MaterialAttribute::GlossinessTextureMatrix, |
||||
* @ref MaterialAttribute::NormalTextureMatrix, |
||||
* @ref MaterialAttribute::OcclusionTextureMatrix and |
||||
* @ref MaterialAttribute::EmissiveTextureMatrix attributes, which then |
||||
* take precedence over the common one. |
||||
* @see @ref hasAttribute(), @ref diffuseTextureMatrix(), |
||||
* @ref specularTextureMatrix(), @ref glossinessTextureMatrix(), |
||||
* @ref normalTextureMatrix(), @ref occlusionTextureMatrix(), |
||||
* @ref emissiveTextureMatrix() |
||||
*/ |
||||
Matrix3 textureMatrix() const; |
||||
|
||||
/**
|
||||
* @brief Common texture coordinate set index for all textures |
||||
* |
||||
* Convenience access to the @ref MaterialAttribute::TextureCoordinates |
||||
* attribute. If not present, the default is @cpp 0 @ce. Note that the |
||||
* material may also define per-texture coordinate set using the |
||||
* @ref MaterialAttribute::DiffuseTextureCoordinates, |
||||
* @ref MaterialAttribute::SpecularTextureCoordinates, |
||||
* @ref MaterialAttribute::GlossinessTextureCoordinates, |
||||
* @ref MaterialAttribute::NormalTextureCoordinates, |
||||
* @ref MaterialAttribute::OcclusionTextureCoordinates and |
||||
* @ref MaterialAttribute::EmissiveTextureCoordinates attributes, which |
||||
* then take precedence over the common one. |
||||
* @see @ref hasAttribute(), @ref diffuseTextureCoordinates(), |
||||
* @ref specularTextureCoordinates(), |
||||
* @ref glossinessTextureCoordinates(), |
||||
* @ref normalTextureCoordinates(), |
||||
* @ref occlusionTextureCoordinates(), |
||||
* @ref emissiveTextureCoordinates() |
||||
*/ |
||||
UnsignedInt textureCoordinates() const; |
||||
}; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue