#pragma once #include "dvc_config.h" #include "dvc_pre_declare.h" #include "math/dvc_vector4.h" #include "math/dvc_matrix3.h" DV_CORE_BEGIN_NAMESPACE class DV_CORE_API Material { public: struct TextureInfo { TextureConstPtr texture; int32_t texCoord = 0; fMatrix3 uvTransform; }; public: int32_t getID(void) const { return m_id; } void setBaseColorTexture(const TextureConstPtr& texture, int32_t texCoord, const fMatrix3& uvTransform, const fVector4& baseColorfactor); const TextureInfo& getBaseColorTexture() const { return m_baseColorTexture; } const fVector4& getBaseColorFactor() const { return m_baseColorFactor; } void setMetallicRoughnessTexture(const TextureConstPtr& texture, int32_t texCoord, const fMatrix3& uvTransform, float32_t metallicFactor = 1, float32_t roughnessFactor = 1); const TextureInfo& getMetallicRoughnessTexture() const { return m_metallicRoughnessTexture; } float32_t getMetallicFactor() const { return m_metallicFactor; } float32_t getRoughnessFactor() const { return m_roughnessFactor; } void setNormalTexture(const TextureConstPtr& texture, int32_t texCoord, const fMatrix3& uvTransform, float32_t scale = 1); const TextureInfo& getNormalTexture() const { return m_normalTexture; } float32_t getNormalScale() const { return m_normalScale; } void setVertexShader(const char* szShaderFile, const char* vertexShaderName); void setFragementShader(const char* szShaderFile, const char* fragementShaderName); VertexShaderInterface* getVertexShader() const { return m_vertexShader; } PixelShaderInterface* getPixelShader() const { return m_pixelShader; } public: bool loadShader(); protected: int32_t m_id; /*The base color texture. * The first three components (RGB) MUST be encoded with the sRGB transfer function. */ TextureInfo m_baseColorTexture; fVector4 m_baseColorFactor = fVector4::ONE; /*The metallic - roughness texture. * The metalness values are sampled from the B channel. * The roughness values are sampled from the G channel. */ TextureInfo m_metallicRoughnessTexture; float32_t m_metallicFactor = 1.0f; float32_t m_roughnessFactor = 1.0f; /*The normal texture. */ TextureInfo m_normalTexture; /*The scalar parameter applied to each normal vector of the texture. * This value scales the normal vector in X and Y directions using the formula: * scaledNormal = (normalize * 2.0 - 1.0) * vec3(, , 1.0). */ float32_t m_normalScale = 1.0f; protected: VertexShaderInterface* m_vertexShader = nullptr; PixelShaderInterface* m_pixelShader = nullptr; std::string m_vertexshaderFile; std::string m_vertexShaderName; std::string m_fragementShaderFile; std::string m_fragementShaderName; public: Material(int32_t id); ~Material(); }; DV_CORE_END_NAMESPACE