This commit is contained in:
2025-11-15 16:27:19 +08:00
parent 8db6f7b115
commit a0beb9eac7
35 changed files with 886 additions and 128 deletions
+18 -16
View File
@@ -3,6 +3,7 @@
#include "dvc_config.h"
#include "dvc_pre_declare.h"
#include "math/dvc_vector4.h"
#include "math/dvc_matrix3.h"
DV_CORE_BEGIN_NAMESPACE
@@ -13,16 +14,14 @@ public:
{
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 fVector4& baseColorfactor) {
m_baseColorTexture.texture = texture;
m_baseColorTexture.texCoord = texCoord;
m_baseColorFactor = baseColorfactor;
}
void setBaseColorTexture(const TextureConstPtr& texture, int32_t texCoord, const fMatrix3& uvTransform,
const fVector4& baseColorfactor);
const TextureInfo& getBaseColorTexture() const {
return m_baseColorTexture;
}
@@ -31,12 +30,8 @@ public:
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;
}
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;
@@ -50,11 +45,8 @@ public:
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;
}
void setNormalTexture(const TextureConstPtr& texture, int32_t texCoord, const fMatrix3& uvTransform,
float32_t scale = 1);
const TextureInfo& getNormalTexture() const {
return m_normalTexture;
@@ -64,6 +56,9 @@ public:
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;
}
@@ -72,6 +67,7 @@ public:
return m_pixelShader;
}
public:
bool loadShader();
@@ -105,6 +101,12 @@ 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();
+1
View File
@@ -4,6 +4,7 @@
#include "dvc_pre_declare.h"
#include "math/dvc_vector2.h"
#include "math/dvc_vector4.h"
#include "math/dvc_matrix3.h"
DV_CORE_BEGIN_NAMESPACE
+39
View File
@@ -94,6 +94,45 @@ public:
template<typename U>
friend TMatrix3<U> operator * (U fScalar, const TMatrix3<U>& rkMatrix);
public:
static inline TMatrix3 makeTrans(T x, T y) {
return TMatrix3(
1, 0, x,
0, 1, y,
0, 0, 1);
}
static inline TMatrix3 makeTrans(const TVector2<T>& pos) {
return TMatrix3(
1, 0, pos.x,
0, 1, pos.y,
0, 0, 1);
}
static inline TMatrix3 makeScale(T x, T y) {
return TMatrix3(
x, 0, 0,
0, y, 0,
0, 0, 1);
}
static inline TMatrix3 makeScale(const TVector2<T>& scale) {
return TMatrix3(
scale.x, 0, 0,
0, scale.y, 0,
0, 0, 1);
}
//2D rotate, left multiplication
static inline TMatrix3 makeRotate(T angle) {
T s = sin(angle);
T c = cos(angle);
return TMatrix3(
c, -s, 0,
s, c, 0,
0, 0, 1);
}
public:
// Utilities
@@ -4,6 +4,7 @@
#include "dvc_pre_declare.h"
#include "math/dvc_vector2.h"
#include "math/dvc_vector4.h"
#include "asset/dvc_material.h"
DV_CORE_BEGIN_NAMESPACE
@@ -30,7 +31,7 @@ public:
return (a < b) ? a : b;
}
static DV_CORE_API fVector4 texture2D(const RenderPipe& pipe, const char* textName, const fVector2& uv, const fVector4& defaultValue);
static DV_CORE_API fVector4 texture2D(const RenderPipe& pipe, const Material::TextureInfo& texturePtr, const fVector2& uv, const fVector4& defaultValue);
};
DV_CORE_END_NAMESPACE
@@ -26,8 +26,7 @@ class PixelShaderInterface
public:
virtual const char* getName(void) const = 0;
typedef std::function<size_t(const std::string&)> SetInputAttributeFunc;
virtual void prepare(const RenderPipe* pipe, SetInputAttributeFunc setInputAttributeFunc) = 0;
virtual void prepare(const RenderPipe* pipe, MaterialConstPtr material) = 0;
virtual void process(const VertexDesc& veretexDesc, const float32_t* pixelData, fVector4& color) = 0;
};