From b9f5c69f85ba3246bd6654a9edda1ddfd62c6b27 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 12 Mar 2024 23:29:38 +0800 Subject: [PATCH] optimized to get normal in AutoShader --- .../Std3D/BlinnPhong/SunLightPureColor.mtl | 2 +- .../LightBasic/BlinnPhongDirectionLight.cpp | 24 +++++++++---------- src/ShaderGen/3d/Std3DMaterial.cpp | 4 +++- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/ShaderLibrary/Std3D/BlinnPhong/SunLightPureColor.mtl b/ShaderLibrary/Std3D/BlinnPhong/SunLightPureColor.mtl index 0a85d8f2..7feade05 100644 --- a/ShaderLibrary/Std3D/BlinnPhong/SunLightPureColor.mtl +++ b/ShaderLibrary/Std3D/BlinnPhong/SunLightPureColor.mtl @@ -42,7 +42,7 @@ Code void main() { - Output.Normal =GetNormal(GetNormalMatrix(),Normal); + Output.Normal =GetNormal(); Output.Position =GetPosition3D(); HandoverMI(); diff --git a/example/LightBasic/BlinnPhongDirectionLight.cpp b/example/LightBasic/BlinnPhongDirectionLight.cpp index b55a622d..ae3d23b0 100644 --- a/example/LightBasic/BlinnPhongDirectionLight.cpp +++ b/example/LightBasic/BlinnPhongDirectionLight.cpp @@ -122,18 +122,18 @@ private: { using namespace inline_geometry; - //Plane Grid - { - struct PlaneGridCreateInfo pgci; + ////Plane Grid + //{ + // struct PlaneGridCreateInfo pgci; - pgci.grid_size.Set(32,32); - pgci.sub_count.Set(8,8); + // pgci.grid_size.Set(32,32); + // pgci.sub_count.Set(8,8); - pgci.lum=0.5; - pgci.sub_lum=0.75; + // pgci.lum=0.5; + // pgci.sub_lum=0.75; - prim_plane_grid=CreatePlaneGrid(db,mtl_vertex_lum->GetDefaultVIL(),&pgci); - } + // prim_plane_grid=CreatePlaneGrid(db,mtl_vertex_lum->GetDefaultVIL(),&pgci); + //} //Sphere { @@ -145,7 +145,7 @@ private: bool InitScene() { - Add(prim_plane_grid,mi_plane_grid,p_line); + //Add(prim_plane_grid,mi_plane_grid,p_line); Add(prim_sphere,mi_sphere,p_sphere); camera->pos=Vector3f(32,32,32); @@ -165,8 +165,8 @@ public: if(!SceneAppFramework::Init(w,h)) return(false); - if(!InitVertexLumMP()) - return(false); + //if(!InitVertexLumMP()) + // return(false); if(!CreateBlinnPhongUBO()) return(false); diff --git a/src/ShaderGen/3d/Std3DMaterial.cpp b/src/ShaderGen/3d/Std3DMaterial.cpp index 9e2da53a..29e988ae 100644 --- a/src/ShaderGen/3d/Std3DMaterial.cpp +++ b/src/ShaderGen/3d/Std3DMaterial.cpp @@ -35,7 +35,9 @@ bool Std3DMaterial::CustomVertexShader(ShaderCreateInfoVertex *vsc) { vsc->AddFunction(func::GetNormalMatrix); vsc->AddFunction(func::GetNormal); -// vsc->AddFunction(func::GetNormalVS); + + if(vsc->hasInput(VAN::Normal)) + vsc->AddFunction(func::GetNormalVS); } mci->AddStruct(SBS_ViewportInfo);