ULRE/src/ShaderGen/3d/Std3DMaterial.cpp

50 lines
1.3 KiB
C++
Raw Normal View History

2023-09-27 20:31:46 +08:00
#include"Std3DMaterial.h"
#include<hgl/shadergen/MaterialCreateInfo.h>
#include<hgl/graph/mtl/Material3DCreateConfig.h>
2023-09-27 20:31:46 +08:00
#include<hgl/graph/mtl/UBOCommon.h>
#include"common/MFGetPosition.h"
2023-10-05 01:32:00 +08:00
#include"common/MFGetNormal.h"
2023-09-27 20:31:46 +08:00
#include"common/MFRectPrimitive.h"
STD_MTL_NAMESPACE_BEGIN
bool Std3DMaterial::CustomVertexShader(ShaderCreateInfoVertex *vsc)
{
vsc->AddInput(cfg->position_format,VAN::Position);
if(cfg->camera)
{
mci->AddStruct(SBS_CameraInfo);
mci->AddUBO(VK_SHADER_STAGE_ALL_GRAPHICS,
DescriptorSetType::Global,
SBS_CameraInfo);
}
2023-09-27 20:31:46 +08:00
if(cfg->local_to_world)
{
mci->SetLocalToWorld(VK_SHADER_STAGE_ALL_GRAPHICS);
vsc->AddAssign();
vsc->AddFunction(cfg->camera?func::GetPosition3DL2WCamera:func::GetPosition3DL2W);
2023-09-27 20:31:46 +08:00
}
2023-09-28 15:03:34 +08:00
else
vsc->AddFunction(cfg->camera?func::GetPosition3DCamera:func::GetPosition3D);
2023-09-27 20:31:46 +08:00
if(cfg->camera
&&cfg->local_to_world)
{
vsc->AddFunction(func::GetNormalMatrix);
vsc->AddFunction(func::GetNormal);
// vsc->AddFunction(func::GetNormalVS);
}
2023-10-05 01:32:00 +08:00
2024-03-12 22:54:33 +08:00
mci->AddStruct(SBS_ViewportInfo);
mci->AddUBO(VK_SHADER_STAGE_ALL_GRAPHICS,
2024-03-12 22:54:33 +08:00
DescriptorSetType::Static,
2023-09-27 20:31:46 +08:00
SBS_ViewportInfo);
return(true);
}
STD_MTL_NAMESPACE_END