From 13f28d6bdbff84107bbb048c54fa7fb37d567cb3 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Sat, 4 Mar 2023 15:55:04 +0800 Subject: [PATCH] Fixed shiny highlight shaders --- Assets/Shaders/ShinyHighlight_FS.glsl | 10 +++++-- .../MiddleEnd/Interface/SHGraphicsSystem.cpp | 30 +++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Assets/Shaders/ShinyHighlight_FS.glsl b/Assets/Shaders/ShinyHighlight_FS.glsl index 8d7f4a90..bb41a0fb 100644 --- a/Assets/Shaders/ShinyHighlight_FS.glsl +++ b/Assets/Shaders/ShinyHighlight_FS.glsl @@ -78,8 +78,14 @@ void main() outEntityID = In2.eid; lightLayerIndices = In2.lightLayerIndex; - float vpHeight = float (In2.screenSpacePos.y) - MatProp.data[In2.materialIndex].highlightPosition; - vpHeight = float (int (vpHeight) % genericDataBuffer.data.viewportHeight); + // float vpHeight = float (In2.screenSpacePos.y) - MatProp.data[In2.materialIndex].highlightPosition; + // bring the frame of reference to the object's screen space pos + int scale = 470; + float vpHeight = float (In2.screenSpacePos.y); + float relativePos = float(int (-MatProp.data[In2.materialIndex].highlightPosition) % scale) - float (scale / 2); + vpHeight += relativePos; + + // vpHeight = float (int (vpHeight) % genericDataBuffer.data.viewportHeight); float scanlineScale = MatProp.data[In2.materialIndex].thickness * (1.0f - In2.screenSpacePos.z) * 100.0f; float lowerLimit = vpHeight - scanlineScale; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index e3d30812..bbbbd1dd 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -128,7 +128,7 @@ namespace SHADE SHFreetypeInstance::Init(); - SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false); + //SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false); //SHAssetManager::CompileAsset("../../Assets/Shaders/ShadowMap_FS.glsl", false); //SHAssetManager::CompileAsset("../../Assets/Shaders/ShadowMap_FS.glsl", false); //SHAssetManager::CompileAsset("../../Assets/Shaders/SSAO_CS.glsl", false); @@ -669,21 +669,21 @@ namespace SHADE #endif } - static bool shadowAdded = false; + //static bool shadowAdded = false; - if (shadowAdded == false && SHInputManager::GetKey(SHInputManager::SH_KEYCODE::B)) - { - shadowAdded = true; - auto& lightComps = SHComponentManager::GetDense(); - //if (lightComps.size() > 2) - //{ - // lightComps[2].SetEnableShadow(true); - //} - for (auto& comp : lightComps) - { - comp.SetEnableShadow(true); - } - } + //if (shadowAdded == false && SHInputManager::GetKey(SHInputManager::SH_KEYCODE::B)) + //{ + // shadowAdded = true; + // auto& lightComps = SHComponentManager::GetDense(); + // //if (lightComps.size() > 2) + // //{ + // // lightComps[2].SetEnableShadow(true); + // //} + // for (auto& comp : lightComps) + // { + // comp.SetEnableShadow(true); + // } + //} renderGraph->Begin(frameIndex); auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex);