2023-09-27 20:31:46 +08:00
|
|
|
#include"Std3DMaterial.h"
|
|
|
|
#include<hgl/shadergen/MaterialCreateInfo.h>
|
2023-10-07 20:59:44 +08:00
|
|
|
#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);
|
|
|
|
|
2023-09-28 17:41:45 +08:00
|
|
|
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();
|
2023-09-28 17:41:45 +08:00
|
|
|
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
|
2023-09-28 17:41:45 +08:00
|
|
|
vsc->AddFunction(cfg->camera?func::GetPosition3DCamera:func::GetPosition3D);
|
2023-09-27 20:31:46 +08:00
|
|
|
|
2023-10-05 01:32:00 +08:00
|
|
|
//if(cfg->camera
|
|
|
|
// &&cfg->local_to_world)
|
|
|
|
//{
|
|
|
|
// vsc->AddFunction(func::GetNormalMatrix);
|
|
|
|
// vsc->AddFunction(func::GetNormal);
|
|
|
|
//}
|
|
|
|
|
2024-03-12 22:54:33 +08:00
|
|
|
mci->AddStruct(SBS_ViewportInfo);
|
|
|
|
|
2023-10-13 19:21:34 +08:00
|
|
|
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
|