texture_rect run ok!
This commit is contained in:
parent
907cb3c852
commit
4e144072e4
@ -21,8 +21,10 @@ constexpr uint32_t SCREEN_HEIGHT=256;
|
|||||||
|
|
||||||
constexpr float position_data[4]=
|
constexpr float position_data[4]=
|
||||||
{
|
{
|
||||||
-1,-1,
|
-1, //left
|
||||||
2,2
|
-1, //top
|
||||||
|
1, //right
|
||||||
|
1 //bottom;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr float tex_coord_data[4]=
|
constexpr float tex_coord_data[4]=
|
||||||
|
@ -92,6 +92,8 @@ public:
|
|||||||
hgl_zero(*this);
|
hgl_zero(*this);
|
||||||
|
|
||||||
descriptor_pool=1024;
|
descriptor_pool=1024;
|
||||||
|
|
||||||
|
geometry_shader=true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,6 +32,6 @@ namespace SamplerName
|
|||||||
MaterialCreateInfo *CreateVertexColor2D(const Material2DCreateConfig *);
|
MaterialCreateInfo *CreateVertexColor2D(const Material2DCreateConfig *);
|
||||||
MaterialCreateInfo *CreatePureColor2D(const Material2DCreateConfig *);
|
MaterialCreateInfo *CreatePureColor2D(const Material2DCreateConfig *);
|
||||||
MaterialCreateInfo *CreatePureTexture2D(const Material2DCreateConfig *);
|
MaterialCreateInfo *CreatePureTexture2D(const Material2DCreateConfig *);
|
||||||
MaterialCreateInfo *CreateRectTexture2D(const Material2DCreateConfig *);
|
MaterialCreateInfo *CreateRectTexture2D(Material2DCreateConfig *);
|
||||||
STD_MTL_NAMESPACE_END
|
STD_MTL_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_MTL_2D_CREATE_CONFIG_INCLUDE
|
#endif//HGL_GRAPH_MTL_2D_CREATE_CONFIG_INCLUDE
|
||||||
|
@ -46,6 +46,7 @@ protected:
|
|||||||
virtual bool ProcHeader(){return(true);}
|
virtual bool ProcHeader(){return(true);}
|
||||||
|
|
||||||
virtual bool ProcDefine();
|
virtual bool ProcDefine();
|
||||||
|
virtual bool ProcLayout(){return(true);}
|
||||||
|
|
||||||
virtual bool ProcSubpassInput();
|
virtual bool ProcSubpassInput();
|
||||||
virtual bool ProcInput(ShaderCreateInfo *);
|
virtual bool ProcInput(ShaderCreateInfo *);
|
||||||
@ -57,7 +58,7 @@ protected:
|
|||||||
|
|
||||||
virtual bool ProcUBO();
|
virtual bool ProcUBO();
|
||||||
virtual bool ProcSSBO();
|
virtual bool ProcSSBO();
|
||||||
virtual bool ProcConst();
|
virtual bool ProcConstantID();
|
||||||
virtual bool ProcSampler();
|
virtual bool ProcSampler();
|
||||||
|
|
||||||
bool CompileToSPV();
|
bool CompileToSPV();
|
||||||
|
@ -15,5 +15,7 @@ public:
|
|||||||
~ShaderCreateInfoGeometry()=default;
|
~ShaderCreateInfoGeometry()=default;
|
||||||
|
|
||||||
bool SetGeom(const Prim &ip,const Prim &op,const uint32_t mv);
|
bool SetGeom(const Prim &ip,const Prim &op,const uint32_t mv);
|
||||||
|
|
||||||
|
bool ProcLayout() override;
|
||||||
};
|
};
|
||||||
}}//namespace hgl::graph
|
}}//namespace hgl::graph
|
@ -12,7 +12,7 @@ void main()
|
|||||||
{
|
{
|
||||||
Output.TexCoord=TexCoord;
|
Output.TexCoord=TexCoord;
|
||||||
|
|
||||||
gl_Position=RectVertexPosition(GetPosition2D());
|
gl_Position=GetPosition2D();
|
||||||
})";
|
})";
|
||||||
|
|
||||||
//一个shader中输出的所有数据,会被定义在一个名为Output的结构中。所以编写时要用Output.XXXX来使用。
|
//一个shader中输出的所有数据,会被定义在一个名为Output的结构中。所以编写时要用Output.XXXX来使用。
|
||||||
@ -23,8 +23,8 @@ void main()
|
|||||||
{
|
{
|
||||||
vec2 vlt=gl_in[0].gl_Position.xy;
|
vec2 vlt=gl_in[0].gl_Position.xy;
|
||||||
vec2 vrb=gl_in[0].gl_Position.zw;
|
vec2 vrb=gl_in[0].gl_Position.zw;
|
||||||
vec2 tlt=Input.TexCoord[0].xy;
|
vec2 tlt=Input[0].TexCoord.xy;
|
||||||
vec2 trb=Input.TexCoord[0].zw;
|
vec2 trb=Input[0].TexCoord.zw;
|
||||||
|
|
||||||
gl_Position=vec4(vlt, vec2(0,1));Output.TexCoord=tlt; EmitVertex();
|
gl_Position=vec4(vlt, vec2(0,1));Output.TexCoord=tlt; EmitVertex();
|
||||||
gl_Position=vec4(vlt.x, vrb.y, vec2(0,1));Output.TexCoord=vec2(tlt.x,trb.y); EmitVertex();
|
gl_Position=vec4(vlt.x, vrb.y, vec2(0,1));Output.TexCoord=vec2(tlt.x,trb.y); EmitVertex();
|
||||||
@ -40,12 +40,12 @@ void main()
|
|||||||
Color=texture(TextureColor,Input.TexCoord);
|
Color=texture(TextureColor,Input.TexCoord);
|
||||||
})";
|
})";
|
||||||
|
|
||||||
class MaterialPureTexture2D:public Std2DMaterial
|
class MaterialRectTexture2D:public Std2DMaterial
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using Std2DMaterial::Std2DMaterial;
|
using Std2DMaterial::Std2DMaterial;
|
||||||
~MaterialPureTexture2D()=default;
|
~MaterialRectTexture2D()=default;
|
||||||
|
|
||||||
bool CustomVertexShader(ShaderCreateInfoVertex *vsc) override
|
bool CustomVertexShader(ShaderCreateInfoVertex *vsc) override
|
||||||
{
|
{
|
||||||
@ -68,8 +68,6 @@ void main()
|
|||||||
|
|
||||||
vsc->AddOutput(VAT_VEC4,"TexCoord");
|
vsc->AddOutput(VAT_VEC4,"TexCoord");
|
||||||
|
|
||||||
vsc->AddFunction(func::RectVertexPosition);
|
|
||||||
|
|
||||||
vsc->SetMain(vs_main);
|
vsc->SetMain(vs_main);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -80,7 +78,7 @@ void main()
|
|||||||
|
|
||||||
gsc->AddOutput(VAT_VEC2,"TexCoord");
|
gsc->AddOutput(VAT_VEC2,"TexCoord");
|
||||||
|
|
||||||
gsc->SetMain(fs_main);
|
gsc->SetMain(gs_main);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,12 +91,17 @@ void main()
|
|||||||
fsc->SetMain(fs_main);
|
fsc->SetMain(fs_main);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
};//class MaterialPureTexture2D:public Std2DMaterial
|
};//class MaterialRectTexture2D:public Std2DMaterial
|
||||||
}//namespace
|
}//namespace
|
||||||
|
|
||||||
MaterialCreateInfo *CreatePureTexture2D(const mtl::Material2DCreateConfig *cfg)
|
MaterialCreateInfo *CreateRectTexture2D(mtl::Material2DCreateConfig *cfg)
|
||||||
{
|
{
|
||||||
MaterialPureTexture2D mvc2d(cfg);
|
if(!cfg)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
cfg->shader_stage_flag_bit|=VK_SHADER_STAGE_GEOMETRY_BIT;
|
||||||
|
|
||||||
|
MaterialRectTexture2D mvc2d(cfg);
|
||||||
|
|
||||||
return mvc2d.Create();
|
return mvc2d.Create();
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,11 @@ bool ShaderCreateInfo::ProcInput(ShaderCreateInfo *last_sc)
|
|||||||
|
|
||||||
final_shader+="\nlayout(location=0) in ";
|
final_shader+="\nlayout(location=0) in ";
|
||||||
final_shader+=last_output;
|
final_shader+=last_output;
|
||||||
final_shader+="Input;\n";
|
|
||||||
|
if(shader_stage==VK_SHADER_STAGE_GEOMETRY_BIT)
|
||||||
|
final_shader+="Input[];\n";
|
||||||
|
else
|
||||||
|
final_shader+="Input;\n";
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -308,7 +312,7 @@ bool ShaderCreateInfo::ProcSSBO()
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShaderCreateInfo::ProcConst()
|
bool ShaderCreateInfo::ProcConstantID()
|
||||||
{
|
{
|
||||||
auto const_list=sdm->GetConstList();
|
auto const_list=sdm->GetConstList();
|
||||||
|
|
||||||
@ -377,6 +381,9 @@ bool ShaderCreateInfo::CreateShader(ShaderCreateInfo *last_sc)
|
|||||||
|
|
||||||
ProcDefine();
|
ProcDefine();
|
||||||
|
|
||||||
|
if(!ProcLayout())
|
||||||
|
return(false);
|
||||||
|
|
||||||
if(!ProcSubpassInput())
|
if(!ProcSubpassInput())
|
||||||
return(false);
|
return(false);
|
||||||
if(!ProcInput(last_sc))
|
if(!ProcInput(last_sc))
|
||||||
@ -390,7 +397,7 @@ bool ShaderCreateInfo::CreateShader(ShaderCreateInfo *last_sc)
|
|||||||
return(false);
|
return(false);
|
||||||
//if(!ProcSSBO())
|
//if(!ProcSSBO())
|
||||||
//return(false);
|
//return(false);
|
||||||
if(!ProcConst())
|
if(!ProcConstantID())
|
||||||
return(false);
|
return(false);
|
||||||
if(!ProcSampler())
|
if(!ProcSampler())
|
||||||
return(false);
|
return(false);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include<hgl/shadergen/ShaderCreateInfoGeometry.h>
|
#include<hgl/shadergen/ShaderCreateInfoGeometry.h>
|
||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
@ -24,5 +24,13 @@ namespace hgl
|
|||||||
max_vertices=mv;
|
max_vertices=mv;
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ShaderCreateInfoGeometry::ProcLayout()
|
||||||
|
{
|
||||||
|
final_shader+="layout("+input_prim+") in;\n"
|
||||||
|
"layout("+output_prim+", max_vertices = "+AnsiString::numberOf(max_vertices)+") out;\n";
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
@ -17,30 +17,19 @@ vec4 GetPosition2D()
|
|||||||
R"(
|
R"(
|
||||||
vec4 GetPosition2D()
|
vec4 GetPosition2D()
|
||||||
{
|
{
|
||||||
return vec4(Position.xy*2-1,Position.zw);
|
return vec4(Position.xy*2-1,Position.zw*2-1);
|
||||||
}
|
}
|
||||||
)",
|
)",
|
||||||
|
|
||||||
R"(
|
R"(
|
||||||
vec4 GetPosition2D()
|
vec4 GetPosition2D()
|
||||||
{
|
{
|
||||||
vec4 tmp=viewport.ortho_matrix*vec4(Position.xy,0,1);
|
vec4 lt=viewport.ortho_matrix*vec4(Position.xy,0,1);
|
||||||
|
vec4 rb=viewport.ortho_matrix*vec4(Position.zw,0,1);
|
||||||
|
|
||||||
return vec4(tmp.xy,Position.zw);
|
return vec4(lt.xy,rb.xy);
|
||||||
}
|
}
|
||||||
)"
|
)"
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr const char RectVertexPosition[]=R"(
|
|
||||||
vec4 RectVertexPosition(vec4 pos)
|
|
||||||
{
|
|
||||||
vec4 lt=vec4(pos.xy,vec2(0,1));
|
|
||||||
vec4 rb=vec4(pos.zw,vec2(0,1));
|
|
||||||
vec4 lt_fin=g_camera.ortho*lt;
|
|
||||||
vec4 rb_fin=g_camera.ortho*rb;
|
|
||||||
|
|
||||||
return vec4(lt_fin.xy,rb_fin.xy);
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
}//namespace func
|
}//namespace func
|
||||||
STD_MTL_NAMESPACE_END
|
STD_MTL_NAMESPACE_END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user