added MFGetNormal.h

This commit is contained in:
hyzboy 2023-10-05 01:32:00 +08:00
parent 10d4f2f04a
commit 9b5157594f
No known key found for this signature in database
GPG Key ID: 067EE4525D4FB6D3
3 changed files with 33 additions and 1 deletions

View File

@ -3,6 +3,7 @@
#include<hgl/graph/mtl/3d/Material3DCreateConfig.h>
#include<hgl/graph/mtl/UBOCommon.h>
#include"common/MFGetPosition.h"
#include"common/MFGetNormal.h"
#include"common/MFRectPrimitive.h"
STD_MTL_NAMESPACE_BEGIN
@ -36,6 +37,13 @@ bool Std3DMaterial::CustomVertexShader(ShaderCreateInfoVertex *vsc)
else
vsc->AddFunction(cfg->camera?func::GetPosition3DCamera:func::GetPosition3D);
//if(cfg->camera
// &&cfg->local_to_world)
//{
// vsc->AddFunction(func::GetNormalMatrix);
// vsc->AddFunction(func::GetNormal);
//}
mci->AddUBO(VK_SHADER_STAGE_VERTEX_BIT,
DescriptorSetType::Global,
SBS_ViewportInfo);

View File

@ -39,7 +39,9 @@ set(STD_MTL_HEADER_PATH ${ROOT_INCLUDE_PATH}/hgl/graph/mtl)
SET(SHADERGEN_COMMON_FILES ${STD_MTL_HEADER_PATH}/UBOCommon.h
${STD_MTL_HEADER_PATH}/SamplerName.h
common/MFCommon.h
common/MFGetPosition.h)
common/MFGetPosition.h
common/MFGetNormal.h
)
SOURCE_GROUP("Common" FILES ${SHADERGEN_COMMON_FILES})

View File

@ -0,0 +1,22 @@
#pragma once
#include<hgl/graph/mtl/StdMaterial.h>
#include<hgl/graph/CoordinateSystem.h>
STD_MTL_NAMESPACE_BEGIN
namespace func
{
constexpr const char *GetNormalMatrix=R"(
mat3 GetNormalMatrix()
{
return mat3(camera.view*GetLocalToWorld());
}
)";
constexpr const char *GetNormal=R"(
vec3 GetNormal(mat3 normal_matrix,vec3 normal)
{
return normalize(normal_matrix*normal);
}
)";
}//namespace func
STD_MTL_NAMESPACE_END