added MFGetPosition.h
This commit is contained in:
parent
c5699fd1af
commit
d660691cec
@ -15,9 +15,9 @@ public:
|
||||
|
||||
Material2DConfig(const AnsiString &name):MaterialConfig(name)
|
||||
{
|
||||
rt_output.color=1;
|
||||
rt_output.depth=false;
|
||||
rt_output.stencil=false;
|
||||
rt_output.color=1; //输出一个颜色
|
||||
rt_output.depth=false; //不输出深度
|
||||
rt_output.stencil=false; //不输出stencil
|
||||
|
||||
coordinate_system=CoordinateSystem2D::NDC;
|
||||
local_to_world=false;
|
||||
|
@ -13,23 +13,12 @@ MaterialCreateInfo *CreateVertexColor2D(const Material2DConfig *cfg)
|
||||
|
||||
RANGE_CHECK_RETURN_NULLPTR(cfg->coordinate_system)
|
||||
|
||||
AnsiString mtl_name;
|
||||
|
||||
const RenderTargetOutputConfig rtoc
|
||||
{
|
||||
1, //输出一个颜色
|
||||
false, //不输出深度
|
||||
false //不输出stencil
|
||||
};
|
||||
|
||||
MaterialCreateInfo *mci=new MaterialCreateInfo(cfg);
|
||||
|
||||
AnsiString sfComputePosition;
|
||||
|
||||
if(cfg->coordinate_system==CoordinateSystem2D::Ortho)
|
||||
{
|
||||
mtl_name="VertexColor2DOrtho";
|
||||
|
||||
{
|
||||
mci->AddUBO(VK_SHADER_STAGE_VERTEX_BIT,
|
||||
DescriptorSetType::Global,
|
||||
SBS_ViewportInfo);
|
||||
@ -39,14 +28,10 @@ MaterialCreateInfo *CreateVertexColor2D(const Material2DConfig *cfg)
|
||||
else
|
||||
if(cfg->coordinate_system==CoordinateSystem2D::ZeroToOne)
|
||||
{
|
||||
mtl_name="VertexColor2DZeroToOne";
|
||||
|
||||
sfComputePosition="vec4 ComputePosition(vec4 pos){return vec4(pos.xy*2-1,pos.z,pos.w);}";
|
||||
}
|
||||
else
|
||||
{
|
||||
mtl_name="VertexColor2DNDC";
|
||||
|
||||
sfComputePosition="vec4 ComputePosition(vec4 pos){return pos;}";
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ bool ShaderCreateInfo::CreateShader(ShaderCreateInfo *last_sc)
|
||||
|
||||
ProcOutput();
|
||||
|
||||
for(uint i=0;i<function_list.GetCount();i++)
|
||||
for(int i=0;i<function_list.GetCount();i++)
|
||||
{
|
||||
final_shader+="\n";
|
||||
final_shader+=function_list[i];
|
||||
|
@ -31,5 +31,7 @@ MaterialInstance GetMI()
|
||||
return mtl.mi[MaterialInstanceID];
|
||||
}
|
||||
)";
|
||||
|
||||
|
||||
}//namespace func
|
||||
STD_MTL_NAMESPACE_END
|
||||
|
26
src/ShaderGen/common/MFGetPosition.h
Normal file
26
src/ShaderGen/common/MFGetPosition.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/mtl/StdMaterial.h>
|
||||
#include<hgl/graph/CoordinateSystem.h>
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
namespace func
|
||||
{
|
||||
constexpr const char *GetPosition2D[size_t(CoordinateSystem2D::RANGE_SIZE)]=
|
||||
{
|
||||
R"(vec4 GetPosition2D(vec4 pos)
|
||||
{
|
||||
return pos;
|
||||
})",
|
||||
|
||||
R"(vec4 GetPosition2D(vec4 pos)
|
||||
{
|
||||
return vec4(pos.xy*2-1,pos.z,pos.w);
|
||||
})",
|
||||
|
||||
R"(vec4 GetPosition2D(vec4 pos)
|
||||
{
|
||||
return viewport.ortho_matrix*pos;
|
||||
})"
|
||||
};
|
||||
}//namespace func
|
||||
STD_MTL_NAMESPACE_END
|
Loading…
x
Reference in New Issue
Block a user