added main_function value and SetMain function at ShaderCreateInfo class.
This commit is contained in:
parent
5521c53c94
commit
a2c3438c58
@ -28,6 +28,7 @@ protected:
|
||||
AnsiString output_struct;
|
||||
|
||||
AnsiStringList function_list;
|
||||
AnsiString main_function;
|
||||
|
||||
AnsiString final_shader;
|
||||
|
||||
@ -67,6 +68,8 @@ public:
|
||||
|
||||
void SetMaterialInstance(UBODescriptor *);
|
||||
|
||||
void SetMain(const AnsiString &str){main_function=str;}
|
||||
|
||||
const AnsiString &GetOutputStruct()const{return output_struct;}
|
||||
const AnsiString &GetShaderSource()const{return final_shader;}
|
||||
|
||||
|
@ -44,7 +44,7 @@ void main()
|
||||
if(!Std2DMaterial::CreateVertexShader(vsc))
|
||||
return(false);
|
||||
|
||||
vsc->AddFunction(vs_main);
|
||||
vsc->SetMain(vs_main);
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ void main()
|
||||
{
|
||||
fsc->AddOutput(VAT_VEC4,"Color"); //Fragment shader的输出等于最终的RT了,所以这个名称其实随便起。
|
||||
|
||||
fsc->AddFunction(fs_main);
|
||||
fsc->SetMain(fs_main);
|
||||
return(true);
|
||||
}
|
||||
};//class MaterialPureColor2D:public Std2DMaterial
|
||||
|
@ -40,7 +40,7 @@ void main()
|
||||
|
||||
vsc->AddOutput(VAT_VEC4,"Color");
|
||||
|
||||
vsc->AddFunction(vs_main);
|
||||
vsc->SetMain(vs_main);
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ void main()
|
||||
{
|
||||
fsc->AddOutput(VAT_VEC4,"Color"); //Fragment shader的输出等于最终的RT了,所以这个名称其实随便起。
|
||||
|
||||
fsc->AddFunction(fs_main);
|
||||
fsc->SetMain(fs_main);
|
||||
return(true);
|
||||
}
|
||||
};//class MaterialVertexColor2D:public Std2DMaterial
|
||||
|
@ -98,7 +98,7 @@ bool ShaderCreateInfo::ProcInput(ShaderCreateInfo *last_sc)
|
||||
|
||||
final_shader+="layout(location=0) in ";
|
||||
final_shader+=last_output;
|
||||
final_shader+="Input;\n\n";
|
||||
final_shader+="Input;\n";
|
||||
|
||||
return(true);
|
||||
}
|
||||
@ -111,6 +111,8 @@ bool ShaderCreateInfo::ProcOutput()
|
||||
|
||||
if(ssd.count<=0)return(true);
|
||||
|
||||
output_struct="\n";
|
||||
|
||||
output_struct=GetShaderStageName(shader_stage);
|
||||
output_struct+="_Output\n{\n";
|
||||
|
||||
@ -139,7 +141,7 @@ bool ShaderCreateInfo::ProcOutput()
|
||||
|
||||
final_shader+="layout(location=0) out ";
|
||||
final_shader+=output_struct;
|
||||
final_shader+="Output;\n";
|
||||
final_shader+="Output;";
|
||||
|
||||
return(true);
|
||||
}
|
||||
@ -268,6 +270,9 @@ bool ShaderCreateInfo::ProcSampler()
|
||||
|
||||
bool ShaderCreateInfo::CreateShader(ShaderCreateInfo *last_sc)
|
||||
{
|
||||
if(main_function.IsEmpty())
|
||||
return(false);
|
||||
|
||||
final_shader="#version 460 core\n";
|
||||
|
||||
if(!ProcSubpassInput())
|
||||
@ -294,6 +299,9 @@ bool ShaderCreateInfo::CreateShader(ShaderCreateInfo *last_sc)
|
||||
final_shader+=function_list[i];
|
||||
}
|
||||
|
||||
final_shader+="\n";
|
||||
final_shader+=main_function;
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
LOG_INFO(AnsiString(GetShaderStageName(shader_stage))+" shader: \n"+final_shader);
|
||||
|
Loading…
x
Reference in New Issue
Block a user