增加材质和纹理
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
#pragma once
|
||||
|
||||
#include "dvc_config.h"
|
||||
#include "dvc_pre_declare.h"
|
||||
#include "math/dvc_vector4.h"
|
||||
|
||||
DV_CORE_BEGIN_NAMESPACE
|
||||
|
||||
class DV_CORE_API Material
|
||||
{
|
||||
public:
|
||||
struct TextureInfo
|
||||
{
|
||||
TextureConstPtr texture;
|
||||
int32_t texCoord = 0;
|
||||
};
|
||||
|
||||
public:
|
||||
int32_t getID(void) const { return m_id; }
|
||||
|
||||
void setBaseColorTexture(const TextureConstPtr& texture, int32_t texCoord, const fVector4& baseColorfactor) {
|
||||
m_baseColorTexture.texture = texture;
|
||||
m_baseColorTexture.texCoord = texCoord;
|
||||
m_baseColorFactor = baseColorfactor;
|
||||
}
|
||||
const TextureInfo& getBaseColorTexture() const {
|
||||
return m_baseColorTexture;
|
||||
}
|
||||
|
||||
const fVector4& getBaseColorFactor() const {
|
||||
return m_baseColorFactor;
|
||||
}
|
||||
|
||||
void setMetallicRoughnessTexture(const TextureConstPtr& texture, int32_t texCoord, float32_t metallicFactor=1.f, float32_t roughnessFactor=1.f ) {
|
||||
m_metallicRoughnessTexture.texture = texture;
|
||||
m_metallicRoughnessTexture.texCoord = texCoord;
|
||||
m_metallicFactor = metallicFactor;
|
||||
m_roughnessFactor = roughnessFactor;
|
||||
}
|
||||
|
||||
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, float32_t scale=1.f) {
|
||||
m_normalTexture.texture = texture;
|
||||
m_normalTexture.texCoord = texCoord;
|
||||
m_normalScale = scale;
|
||||
}
|
||||
|
||||
const TextureInfo& getNormalTexture() const {
|
||||
return m_normalTexture;
|
||||
}
|
||||
|
||||
float32_t getNormalScale() const {
|
||||
return m_normalScale;
|
||||
}
|
||||
|
||||
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<sampled normal texture value> * 2.0 - 1.0) * vec3(<normal scale>, <normal scale>, 1.0).
|
||||
*/
|
||||
float32_t m_normalScale = 1.0f;
|
||||
|
||||
protected:
|
||||
VertexShaderInterface* m_vertexShader = nullptr;
|
||||
PixelShaderInterface* m_pixelShader = nullptr;
|
||||
|
||||
public:
|
||||
Material(int32_t id);
|
||||
~Material();
|
||||
};
|
||||
|
||||
DV_CORE_END_NAMESPACE
|
||||
Reference in New Issue
Block a user