Shader生成准备增加WorldPosition
This commit is contained in:
@@ -81,6 +81,7 @@ namespace hgl::graph
|
||||
bool SetMaterialInstance(const AnsiString &mi_glsl_codes,const uint32_t mi_struct_bytes,const uint32_t shader_stage_flag_bits);
|
||||
|
||||
bool SetLocalToWorld(const uint32_t shader_stage_flag_bits);
|
||||
//bool SetWorldPosition(const uint32_t shader_stage_flag_bits);
|
||||
|
||||
bool AddStruct(const AnsiString &ubo_typename,const AnsiString &codes);
|
||||
|
||||
|
@@ -3,33 +3,34 @@
|
||||
#include<hgl/shadergen/ShaderCreateInfo.h>
|
||||
#include<hgl/shadergen/ShaderDescriptorInfo.h>
|
||||
|
||||
namespace hgl{namespace graph{
|
||||
class ShaderCreateInfoGeometry:public ShaderCreateInfo
|
||||
namespace hgl::graph
|
||||
{
|
||||
GeometryShaderDescriptorInfo gsdi;
|
||||
class ShaderCreateInfoGeometry:public ShaderCreateInfo
|
||||
{
|
||||
GeometryShaderDescriptorInfo gsdi;
|
||||
|
||||
AnsiString input_prim;
|
||||
AnsiString output_prim;
|
||||
uint32_t max_vertices;
|
||||
AnsiString input_prim;
|
||||
AnsiString output_prim;
|
||||
uint32_t max_vertices;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
bool IsEmptyOutput()const override{return gsdi.IsEmptyOutput();}
|
||||
void GetOutputStrcutString(AnsiString &str) override;
|
||||
bool IsEmptyOutput()const override{return gsdi.IsEmptyOutput();}
|
||||
void GetOutputStrcutString(AnsiString &str) override;
|
||||
|
||||
ShaderDescriptorInfo *GetSDI()override{return &gsdi;}
|
||||
ShaderDescriptorInfo *GetSDI()override{return &gsdi;}
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
ShaderCreateInfoGeometry(MaterialDescriptorInfo *m):ShaderCreateInfo(){ShaderCreateInfo::Init(&gsdi,m);}
|
||||
~ShaderCreateInfoGeometry()override=default;
|
||||
ShaderCreateInfoGeometry(MaterialDescriptorInfo *m):ShaderCreateInfo(){ShaderCreateInfo::Init(&gsdi,m);}
|
||||
~ShaderCreateInfoGeometry()override=default;
|
||||
|
||||
bool SetGeom(const PrimitiveType &ip,const PrimitiveType &op,const uint32_t mv);
|
||||
bool SetGeom(const PrimitiveType &ip,const PrimitiveType &op,const uint32_t mv);
|
||||
|
||||
int AddOutput(SVList &);
|
||||
int AddOutput(const ShaderVariableType &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth);
|
||||
void AddMaterialInstanceOutput() override;
|
||||
int AddOutput(SVList &);
|
||||
int AddOutput(const ShaderVariableType &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth);
|
||||
void AddMaterialInstanceOutput() override;
|
||||
|
||||
bool ProcLayout() override;
|
||||
};
|
||||
}}//namespace hgl::graph
|
||||
bool ProcLayout() override;
|
||||
};
|
||||
}//namespace hgl::graph
|
||||
|
@@ -3,44 +3,41 @@
|
||||
#include<hgl/shadergen/ShaderCreateInfo.h>
|
||||
#include<hgl/shadergen/ShaderDescriptorInfo.h>
|
||||
|
||||
namespace hgl
|
||||
namespace hgl::graph
|
||||
{
|
||||
namespace graph
|
||||
class ShaderCreateInfoVertex:public ShaderCreateInfo
|
||||
{
|
||||
class ShaderCreateInfoVertex:public ShaderCreateInfo
|
||||
{
|
||||
VertexShaderDescriptorInfo vsdi;
|
||||
VertexShaderDescriptorInfo vsdi;
|
||||
|
||||
bool ProcSubpassInput();
|
||||
bool ProcInput(ShaderCreateInfo *) override;
|
||||
bool ProcSubpassInput();
|
||||
bool ProcInput(ShaderCreateInfo *) override;
|
||||
|
||||
bool IsEmptyOutput()const override{return vsdi.IsEmptyOutput();}
|
||||
void GetOutputStrcutString(AnsiString &str) override;
|
||||
bool IsEmptyOutput()const override{return vsdi.IsEmptyOutput();}
|
||||
void GetOutputStrcutString(AnsiString &str) override;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
VIAArray &GetInput(){return vsdi.GetInput();}
|
||||
VIAArray &GetInput(){return vsdi.GetInput();}
|
||||
|
||||
ShaderDescriptorInfo *GetSDI()override{return &vsdi;}
|
||||
ShaderDescriptorInfo *GetSDI()override{return &vsdi;}
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
ShaderCreateInfoVertex(MaterialDescriptorInfo *m):ShaderCreateInfo(){ShaderCreateInfo::Init(&vsdi,m);}
|
||||
~ShaderCreateInfoVertex()override=default;
|
||||
ShaderCreateInfoVertex(MaterialDescriptorInfo *m):ShaderCreateInfo(){ShaderCreateInfo::Init(&vsdi,m);}
|
||||
~ShaderCreateInfoVertex()override=default;
|
||||
|
||||
int AddInput(VIAList &);
|
||||
int AddInput(const graph::VAType &type,const AnsiString &name,const VkVertexInputRate input_rate=VK_VERTEX_INPUT_RATE_VERTEX,const VertexInputGroup &group=VertexInputGroup::Basic);
|
||||
int AddInput(const AnsiString &type,const AnsiString &name,const VkVertexInputRate input_rate=VK_VERTEX_INPUT_RATE_VERTEX,const VertexInputGroup &group=VertexInputGroup::Basic);
|
||||
int AddInput(VIAList &);
|
||||
int AddInput(const graph::VAType &type,const AnsiString &name,const VkVertexInputRate input_rate=VK_VERTEX_INPUT_RATE_VERTEX,const VertexInputGroup &group=VertexInputGroup::Basic);
|
||||
int AddInput(const AnsiString &type,const AnsiString &name,const VkVertexInputRate input_rate=VK_VERTEX_INPUT_RATE_VERTEX,const VertexInputGroup &group=VertexInputGroup::Basic);
|
||||
|
||||
int hasInput(const char *);
|
||||
int hasInput(const char *);
|
||||
|
||||
int AddOutput(SVList &);
|
||||
int AddOutput(const SVType &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth);
|
||||
void AddMaterialInstanceOutput() override;
|
||||
int AddOutput(SVList &);
|
||||
int AddOutput(const SVType &type,const AnsiString &name,Interpolation inter=Interpolation::Smooth);
|
||||
void AddMaterialInstanceOutput() override;
|
||||
|
||||
void AddAssign();
|
||||
void AddAssign();
|
||||
|
||||
void AddJoint();
|
||||
};//class ShaderCreateInfoVertex:public ShaderCreateInfo
|
||||
}//namespace graph
|
||||
void AddJoint();
|
||||
};//class ShaderCreateInfoVertex:public ShaderCreateInfo
|
||||
}//namespace hgl::graph
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include<hgl/graph/mtl/UBOCommon.h>
|
||||
#include<hgl/graph/VKDeviceAttribute.h>
|
||||
#include"common/MFCommon.h"
|
||||
#include"common/MFGetPosition.h"
|
||||
#include"ShaderLibrary.h"
|
||||
|
||||
using namespace hgl;
|
||||
@@ -217,22 +218,50 @@ bool MaterialCreateInfo::SetLocalToWorld(const uint32_t shader_stage_flag_bits)
|
||||
|
||||
const AnsiString L2W_MAX_COUNT_STRING=AnsiString::numberOf(l2w_max_count);
|
||||
|
||||
auto *it=shader_map.GetDataList();
|
||||
|
||||
for(int i=0;i<shader_map.GetCount();i++)
|
||||
for(auto it:shader_map)
|
||||
{
|
||||
if((*it)->key&shader_stage_flag_bits)
|
||||
if(it->key&shader_stage_flag_bits)
|
||||
{
|
||||
(*it)->value->AddDefine("L2W_MAX_COUNT",L2W_MAX_COUNT_STRING);
|
||||
it->value->AddDefine("L2W_MAX_COUNT",L2W_MAX_COUNT_STRING);
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
l2w_shader_stage=shader_stage_flag_bits;
|
||||
|
||||
return(true);
|
||||
}
|
||||
//
|
||||
//bool MaterialCreateInfo::SetWorldPosition(const uint32_t shader_stage_flag_bits)
|
||||
//{
|
||||
// if(shader_stage_flag_bits==0)return(false);
|
||||
//
|
||||
// {
|
||||
// vert->AddOutput(SVT_VEC4,"WorldPosition");
|
||||
//
|
||||
// if(l2w_shader_stage)
|
||||
// {
|
||||
// vert->AddFunction(func::GetWorldPosition3DL2W_VS);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// vert->AddFunction(func::GetWorldPosition3D_VS);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(shader_stage_flag_bits&VK_SHADER_STAGE_GEOMETRY_BIT)
|
||||
// {
|
||||
// geom->AddOutput(SVT_VEC4,"WorldPosition");
|
||||
//
|
||||
// geom->AddFunction(func::GetWorldPosition3D_Other);
|
||||
// }
|
||||
//
|
||||
// if(shader_stage_flag_bits&VK_SHADER_STAGE_FRAGMENT_BIT)
|
||||
// {
|
||||
// geom->AddFunction(func::GetWorldPosition3D_Other);
|
||||
// }
|
||||
//
|
||||
// return(true);
|
||||
//}
|
||||
|
||||
void MaterialCreateInfo::SetDevice(const VulkanDevAttr *dev_attr)
|
||||
{
|
||||
|
@@ -19,6 +19,10 @@ namespace func
|
||||
"vec4 GetPosition2D(){return GetLocalToWorld()*viewport.ortho_matrix*vec4(Position,0,1);}" //Ortho
|
||||
};
|
||||
|
||||
constexpr const char *GetWorldPosition3D_VS ="vec4 GetWorldPosition3D(){return vec4(Position,1);}";
|
||||
constexpr const char *GetWorldPosition3DL2W_VS ="vec4 GetWorldPosition3D(){return GetLocalToWorld()*vec4(Position,1);}";
|
||||
constexpr const char *GetWorldPosition3D_Other ="vec4 GetWorldPosition3D(){return WorldPosition;}";
|
||||
|
||||
constexpr const char *GetPosition3D ="vec4 GetPosition3D(){return vec4(Position,1);}";
|
||||
constexpr const char *GetPosition3DL2W ="vec4 GetPosition3D(){return GetLocalToWorld()*vec4(Position,1);}";
|
||||
constexpr const char *GetPosition3DCamera ="vec4 GetPosition3D(){return camera.vp*vec4(Position,1);}";
|
||||
|
Reference in New Issue
Block a user