resume GetNormalMatrix/GetNormal in auto shader.

This commit is contained in:
hyzboy 2024-03-12 23:04:12 +08:00
parent 13b2ca0575
commit ba8b44659b
3 changed files with 15 additions and 18 deletions

View File

@ -39,21 +39,10 @@ Output
Code Code
{ {
mat3 GetNormalMatrix()
{
return mat3(camera.view*GetLocalToWorld());
}
vec3 GetNormal(mat3 normal_matrix,vec3 normal)
{
return normalize(normal_matrix*normal);
}
void main() void main()
{ {
mat3 normal_matrix=GetNormalMatrix(); Output.Normal =GetNormal(GetNormalMatrix(),Normal);
Output.Normal =GetNormal(normal_matrix,Normal);
Output.Position =GetPosition3D(); Output.Position =GetPosition3D();
HandoverMI(); HandoverMI();

View File

@ -30,12 +30,13 @@ bool Std3DMaterial::CustomVertexShader(ShaderCreateInfoVertex *vsc)
else else
vsc->AddFunction(cfg->camera?func::GetPosition3DCamera:func::GetPosition3D); vsc->AddFunction(cfg->camera?func::GetPosition3DCamera:func::GetPosition3D);
//if(cfg->camera if(cfg->camera
// &&cfg->local_to_world) &&cfg->local_to_world)
//{ {
// vsc->AddFunction(func::GetNormalMatrix); vsc->AddFunction(func::GetNormalMatrix);
// vsc->AddFunction(func::GetNormal); vsc->AddFunction(func::GetNormal);
//} // vsc->AddFunction(func::GetNormalVS);
}
mci->AddStruct(SBS_ViewportInfo); mci->AddStruct(SBS_ViewportInfo);

View File

@ -17,6 +17,13 @@ vec3 GetNormal(mat3 normal_matrix,vec3 normal)
{ {
return normalize(normal_matrix*normal); return normalize(normal_matrix*normal);
} }
)";
constexpr const char *GetNormalVS=R"(
vec3 GetNormal()
{
return normalize(mat3(camera.view*GetLocalToWorld())*Normal);
}
)"; )";
}//namespace func }//namespace func
STD_MTL_NAMESPACE_END STD_MTL_NAMESPACE_END