finished the branch,,,local to world in VertexInputStreaming.

This commit is contained in:
2023-05-06 22:19:50 +08:00
parent abfc84feff
commit 958183bb29
12 changed files with 109 additions and 53 deletions

View File

@@ -16,7 +16,7 @@ namespace hgl
struct RenderNode2D
{
Matrix3x4f local_to_world;
Matrix4f local_to_world;
Renderable *ri;
};
@@ -81,7 +81,7 @@ namespace hgl
MaterialRenderList2D(GPUDevice *d,Material *m);
~MaterialRenderList2D();
void Add(Renderable *ri,const Matrix3x4f &mat);
void Add(Renderable *ri,const Matrix4f &mat);
void ClearData()
{

View File

@@ -1,4 +1,4 @@
#ifndef HGL_GRAPH_MTL_2D_VERTEX2D_INCLUDE
#ifndef HGL_GRAPH_MTL_2D_VERTEX2D_INCLUDE
#define HGL_GRAPH_MTL_2D_VERTEX2D_INCLUDE
#include<hgl/graph/mtl/StdMaterial.h>
@@ -11,7 +11,14 @@ namespace hgl
namespace mtl
{
MaterialCreateInfo *CreateVertexColor2D(const CoordinateSystem2D &);
struct Material2DConfig
{
CoordinateSystem2D coordinate_system; ///<使用的坐标系
bool local_to_world=false; ///<包含LocalToWorld矩阵
};
MaterialCreateInfo *CreateVertexColor2D(const Material2DConfig *);
}//namespace mtl
}//namespace graph
}//namespace hgl

View File

@@ -5,6 +5,7 @@
#define STD_MTL_NAMESPACE_USING using namespace hgl::graph::mtl;
#include<hgl/TypeFunc.h>
#include<hgl/graph/mtl/ShaderBuffer.h>
STD_MTL_NAMESPACE_BEGIN
@@ -13,7 +14,9 @@ enum class CoordinateSystem2D
{
NDC,
ZeroToOne, //左上角为0,0右下角为1,1
Ortho //左上角为0,0右下角为(width-1),(height-1)
Ortho, //左上角为0,0右下角为(width-1),(height-1)
ENUM_CLASS_RANGE(NDC,Ortho)
};
constexpr const ShaderBufferSource SBS_ViewportInfo=
@@ -53,4 +56,17 @@ vec3 world_up;
float znear,zfar;)"
};
namespace func
{
constexpr const char GetLocalToWorld[]=R"(
mat4 GetLocalToWorld()
{
return mat4(LocalToWorld_0,
LocalToWorld_1,
LocalToWorld_2,
LocalToWorld_3);
}
)";
}//namespace func
STD_MTL_NAMESPACE_END

View File

@@ -3,6 +3,7 @@
#include<hgl/graph/VertexAttrib.h>
#include<hgl/graph/VK.h>
#include<hgl/type/StringList.h>
namespace hgl{namespace graph
{
@@ -21,10 +22,10 @@ protected:
protected:
AnsiString main_codes;
AnsiString output_struct;
AnsiStringList function_list;
AnsiString final_shader;
SPVData *spv_data;
@@ -59,10 +60,7 @@ public:
int AddOutput(const graph::VAT &type,const AnsiString &name);
int AddOutput(const AnsiString &type,const AnsiString &name);
void SetShaderCodes(const AnsiString &str)
{
main_codes=str;
}
void AddFunction(const AnsiString &str){function_list.Add(str);}
const AnsiString &GetOutputStruct()const{return output_struct;}
const AnsiString &GetShaderSource()const{return final_shader;}

View File

@@ -28,17 +28,17 @@ namespace hgl
AddInput(weight,VAN::BoneWeight,VK_VERTEX_INPUT_RATE_VERTEX,VertexInputGroup::Bone);
}
void AddLocalToWorld(const uint count)
void AddLocalToWorld()
{
VAT l2w{VertexAttribType::BaseType::Float,4};
VAT vat{VertexAttribType::BaseType::Float,4};
char name[]= "LocalToWorld_?";
for(uint i=0;i<count;i++)
for(uint i=0;i<4;i++)
{
name[sizeof(name)-2]='0'+i;
AddInput(l2w,name,VK_VERTEX_INPUT_RATE_INSTANCE,VertexInputGroup::LocalToWorld);
AddInput(vat,name,VK_VERTEX_INPUT_RATE_INSTANCE,VertexInputGroup::LocalToWorld);
}
}
};//class ShaderCreateInfoVertex:public ShaderCreateInfo