1.splited CoordinateSystem.h, MaterialConfig.h,RenderTargetOutputConfig.h,Material2DConfig.h,StdMaterial.h/.cpp,UBOCommon.h,MFCommon.h
2.adjust namespace.
This commit is contained in:
27
inc/hgl/graph/mtl/2d/Material2DConfig.h
Normal file
27
inc/hgl/graph/mtl/2d/Material2DConfig.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef HGL_GRAPH_MTL_2D_CONFIG_INCLUDE
|
||||
#define HGL_GRAPH_MTL_2D_CONFIG_INCLUDE
|
||||
|
||||
#include<hgl/graph/mtl/MaterialConfig.h>
|
||||
#include<hgl/graph/CoordinateSystem.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
struct Material2DConfig:public MaterialConfig
|
||||
{
|
||||
CoordinateSystem2D coordinate_system; ///<使用的坐标系
|
||||
|
||||
bool local_to_world; ///<包含LocalToWorld矩阵
|
||||
|
||||
public:
|
||||
|
||||
Material2DConfig(const AnsiString &name):MaterialConfig(name)
|
||||
{
|
||||
rt_output.color=1;
|
||||
rt_output.depth=false;
|
||||
rt_output.stencil=false;
|
||||
|
||||
coordinate_system=CoordinateSystem2D::NDC;
|
||||
local_to_world=false;
|
||||
}
|
||||
};//struct Material2DConfig:public MaterialConfig
|
||||
STD_MTL_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_MTL_2D_CONFIG_INCLUDE
|
@@ -1,26 +1,10 @@
|
||||
#ifndef HGL_GRAPH_MTL_2D_VERTEX2D_INCLUDE
|
||||
#define HGL_GRAPH_MTL_2D_VERTEX2D_INCLUDE
|
||||
|
||||
#include<hgl/graph/mtl/StdMaterial.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
class MaterialCreateInfo;
|
||||
|
||||
namespace mtl
|
||||
{
|
||||
struct Material2DConfig
|
||||
{
|
||||
CoordinateSystem2D coordinate_system; ///<使用的坐标系
|
||||
|
||||
bool local_to_world=false; ///<包含LocalToWorld矩阵
|
||||
};
|
||||
|
||||
MaterialCreateInfo *CreateVertexColor2D(const Material2DConfig *);
|
||||
}//namespace mtl
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#include"Std2DMaterial.h"
|
||||
#include<hgl/graph/CoordinateSystem.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
MaterialCreateInfo *CreateVertexColor2D(const Material2DConfig *);
|
||||
STD_MTL_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_MTL_2D_VERTEX2D_INCLUDE
|
||||
|
31
inc/hgl/graph/mtl/MaterialConfig.h
Normal file
31
inc/hgl/graph/mtl/MaterialConfig.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef HGL_GRAPH_MTL_CONFIG_INCLUDE
|
||||
#define HGL_GRAPH_MTL_CONFIG_INCLUDE
|
||||
|
||||
#include<hgl/graph/mtl/StdMaterial.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/graph/RenderTargetOutputConfig.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
/**
|
||||
* 材质配置结构
|
||||
*/
|
||||
struct MaterialConfig
|
||||
{
|
||||
AnsiString mtl_name; ///<材质名称
|
||||
|
||||
RenderTargetOutputConfig rt_output; ///<渲染目标输出配置
|
||||
|
||||
uint32 shader_stage; ///<需要的shader
|
||||
|
||||
public:
|
||||
|
||||
MaterialConfig(const AnsiString &name)
|
||||
{
|
||||
mtl_name=name;
|
||||
|
||||
shader_stage=VK_SHADER_STAGE_VERTEX_BIT|VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
}
|
||||
};//struct MaterialConfig
|
||||
STD_MTL_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_MTL_CONFIG_INCLUDE
|
@@ -4,104 +4,3 @@
|
||||
#define STD_MTL_NAMESPACE_END }}}
|
||||
|
||||
#define STD_MTL_NAMESPACE_USING using namespace hgl::graph::mtl;
|
||||
|
||||
#include<hgl/TypeFunc.h>
|
||||
#include<hgl/graph/mtl/ShaderBuffer.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
|
||||
enum class CoordinateSystem2D
|
||||
{
|
||||
NDC,
|
||||
ZeroToOne, //左上角为0,0;右下角为1,1
|
||||
Ortho, //左上角为0,0;右下角为(width-1),(height-1)
|
||||
|
||||
ENUM_CLASS_RANGE(NDC,Ortho)
|
||||
};
|
||||
|
||||
constexpr const ShaderBufferSource SBS_ViewportInfo=
|
||||
{
|
||||
"ViewportInfo",
|
||||
"viewport",
|
||||
|
||||
R"(
|
||||
mat4 ortho_matrix;
|
||||
|
||||
vec2 canvas_resolution;
|
||||
vec2 viewport_resolution;
|
||||
vec2 inv_viewport_resolution;
|
||||
)"
|
||||
};
|
||||
|
||||
constexpr const ShaderBufferSource SBS_CameraInfo=
|
||||
{
|
||||
"CameraInfo",
|
||||
"camera",
|
||||
|
||||
R"(
|
||||
mat4 projection;
|
||||
mat4 inverse_projection;
|
||||
|
||||
mat4 view;
|
||||
mat4 inverse_view;
|
||||
|
||||
mat4 vp;
|
||||
mat4 inverse_vp;
|
||||
|
||||
mat4 sky;
|
||||
|
||||
vec3 pos; //eye
|
||||
vec3 view_line; //pos-target
|
||||
vec3 world_up;
|
||||
|
||||
float znear,zfar;)"
|
||||
};
|
||||
|
||||
constexpr const ShaderBufferSource SBS_MaterialInstance=
|
||||
{
|
||||
"MaterialInstanceData",
|
||||
"mtl",
|
||||
|
||||
"MaterialInstance mi[256];"
|
||||
};
|
||||
|
||||
constexpr const ShaderBufferSource SBS_JointInfo=
|
||||
{
|
||||
"JointInfo",
|
||||
"joint",
|
||||
|
||||
R"(
|
||||
mat4 mats[];
|
||||
)"
|
||||
};
|
||||
|
||||
namespace func
|
||||
{
|
||||
constexpr const char GetLocalToWorld[]=R"(
|
||||
mat4 GetLocalToWorld()
|
||||
{
|
||||
return mat4(LocalToWorld_0,
|
||||
LocalToWorld_1,
|
||||
LocalToWorld_2,
|
||||
LocalToWorld_3);
|
||||
}
|
||||
)";
|
||||
|
||||
constexpr const char GetJointMatrix[]=R"(
|
||||
mat4 GetJointMatrix()
|
||||
{
|
||||
return joint.mats[JointID.x]*JointWeight.x+
|
||||
joint.mats[JointID.y]*JointWeight.y+
|
||||
joint.mats[JointID.z]*JointWeight.z+
|
||||
joint.mats[JointID.w]*JointWeight.w;
|
||||
}
|
||||
)";
|
||||
|
||||
constexpr const char GetMI[]=R"(
|
||||
MaterialInstance GetMI()
|
||||
{
|
||||
return mtl.mi[MaterialInstanceID];
|
||||
}
|
||||
)";
|
||||
}//namespace func
|
||||
STD_MTL_NAMESPACE_END
|
||||
|
Reference in New Issue
Block a user