Skip to content

Commit

Permalink
[core] improve doc
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasPaulin committed Aug 29, 2023
1 parent d85e9a9 commit 6a4274a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
27 changes: 24 additions & 3 deletions src/Core/Material/BaseGLTFMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Ra {
namespace Core {
namespace Material {

/// GLTF Alpha mode definition
/// \brief GLTF Alpha mode definition
enum AlphaMode : unsigned int { Opaque = 0, Mask, Blend };

/**
Expand All @@ -32,40 +32,52 @@ struct RA_CORE_API GLTFMaterialExtensionData : public Ra::Core::Asset::MaterialD
class RA_CORE_API BaseGLTFMaterial : public Ra::Core::Asset::MaterialData
{
public:
/// Attributes of a gltf material
/// Normal texture
///\{
std::string m_normalTexture {};
float m_normalTextureScale { 1 };
GLTFSampler m_normalSampler {};
bool m_hasNormalTexture { false };
mutable std::unique_ptr<GLTFTextureTransform> m_normalTextureTransform { nullptr };
///\}

/// Occlusion texture
///\{
std::string m_occlusionTexture {};
float m_occlusionStrength { 1 };
GLTFSampler m_occlusionSampler {};
bool m_hasOcclusionTexture { false };
mutable std::unique_ptr<GLTFTextureTransform> m_occlusionTextureTransform { nullptr };
///}

/// Emissive texture
///\{
std::string m_emissiveTexture {};
Ra::Core::Utils::Color m_emissiveFactor { 0.0, 0.0, 0.0, 1.0 };
GLTFSampler m_emissiveSampler {};
bool m_hasEmissiveTexture { false };
mutable std::unique_ptr<GLTFTextureTransform> m_emissiveTextureTransform { nullptr };
///\}

/// Transparency parameters
///\{
AlphaMode m_alphaMode { AlphaMode::Opaque };
float m_alphaCutoff { 0.5 };
///\}

/// Face culling parameter
bool m_doubleSided { false };

// Extension data pass through the system
/// Material extensions data
std::map<std::string, std::unique_ptr<GLTFMaterialExtensionData>> m_extensions {};

explicit BaseGLTFMaterial( const std::string& gltfType, const std::string& instanceName );
~BaseGLTFMaterial() override = default;

/**
* \defgroup ExtensionManagement Material extension management
* \{
*/
virtual bool supportExtension( const std::string& extensionName ) {
auto it = m_allowedExtensions.find( extensionName );
return ( it != m_allowedExtensions.end() ) && ( it->second );
Expand All @@ -79,7 +91,16 @@ class RA_CORE_API BaseGLTFMaterial : public Ra::Core::Asset::MaterialData

void allowExtension( const std::string& extension ) { m_allowedExtensions[extension] = true; }

void allowExtensionList( std::initializer_list<std::string> extensions ) {
std::for_each( extensions.begin(), extensions.end(), [this]( const std::string& e ) {
this->allowExtension( e );
} );
}
/// \}
private:
/***
* \ingroup ExtensionManagement
*/
std::map<std::string, bool> m_allowedExtensions {};
};

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Material/GLTFTextureParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct RA_CORE_API GLTFTextureTransform {

/**
* \brief Sampler Data as defined by GlTF specification
* Enums correspond to OpenGL specification
* Enums correspond to OpenGL specification as requested by gltf
*/
struct RA_CORE_API GLTFSampler {
enum class MagFilter : uint16_t { Nearest = 9728, Linear = 9729 };
Expand Down
9 changes: 5 additions & 4 deletions src/Core/Material/MetallicRoughnessMaterialData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ namespace Material {
MetallicRoughnessData::MetallicRoughnessData( const std::string& name ) :
BaseGLTFMaterial( { "MetallicRoughness" }, name ) {
// extension supported by MetallicRoughness gltf materials
allowExtension( "KHR_materials_clearcoat" );
allowExtension( "KHR_materials_ior" );
allowExtension( "KHR_materials_specular" );
allowExtension( "KHR_materials_sheen" );
allowExtensionList( { "KHR_materials_clearcoat",
"KHR_materials_ior",
"KHR_materials_specular",
"KHR_materials_sheen" } );

// TODO : uncomment the extension when supported by the implementation.
/*
allowExtension("KHR_materials_transmission");
Expand Down

0 comments on commit 6a4274a

Please sign in to comment.