diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index b616c7f2..ea5f8ca9 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -62,8 +62,7 @@ #include "src/Rendering/Vulkan/VulkanRenderer.h" #include #include - - +#include namespace Nuake { ImFont* normalFont; @@ -631,23 +630,24 @@ namespace Nuake { if (SelectedViewport == 1) { - textureDesc = pipeline.GetRenderPass("GBuffer").GetAttachment("Albedo").Image->GetImGuiDescriptorSet(); + //pipeline.GetRenderPass("Shadow").GetDepthAttachment().Image->TransitionLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + textureDesc = pipeline.GetRenderPass("Shadow").GetDepthAttachment().Image->GetImGuiDescriptorSet(); texture = Engine::GetCurrentScene()->m_SceneRenderer->GetGBuffer().GetTexture(GL_COLOR_ATTACHMENT0); } else if (SelectedViewport == 2) { - textureDesc = pipeline.GetRenderPass("GBuffer").GetAttachment("Normal").Image->GetImGuiDescriptorSet(); - texture = Engine::GetCurrentScene()->m_SceneRenderer->GetGBuffer().GetTexture(GL_COLOR_ATTACHMENT1); + //textureDesc = pipeline.GetRenderPass("GBuffer").GetAttachment("Normal").Image->GetImGuiDescriptorSet(); + //texture = Engine::GetCurrentScene()->m_SceneRenderer->GetGBuffer().GetTexture(GL_COLOR_ATTACHMENT1); } else if (SelectedViewport == 3) { - textureDesc = pipeline.GetRenderPass("GBuffer").GetDepthAttachment().Image->GetImGuiDescriptorSet(); - texture = Engine::GetCurrentScene()->m_SceneRenderer->GetScaledDepthTexture(); + //textureDesc = pipeline.GetRenderPass("GBuffer").GetDepthAttachment().Image->GetImGuiDescriptorSet(); + //texture = Engine::GetCurrentScene()->m_SceneRenderer->GetScaledDepthTexture(); } else if (SelectedViewport == 4) { - textureDesc = pipeline.GetRenderPass("GBuffer").GetAttachment("Material").Image->GetImGuiDescriptorSet(); - texture = Engine::GetCurrentScene()->m_SceneRenderer->GetVelocityTexture(); + //textureDesc = pipeline.GetRenderPass("GBuffer").GetAttachment("Material").Image->GetImGuiDescriptorSet(); + //texture = Engine::GetCurrentScene()->m_SceneRenderer->GetVelocityTexture(); } ImVec2 imagePos = ImGui::GetWindowPos() + ImGui::GetCursorPos(); diff --git a/Nuake/src/Rendering/Vulkan/VulkanSceneRenderer.cpp b/Nuake/src/Rendering/Vulkan/VulkanSceneRenderer.cpp index faa7c14f..da86e88a 100644 --- a/Nuake/src/Rendering/Vulkan/VulkanSceneRenderer.cpp +++ b/Nuake/src/Rendering/Vulkan/VulkanSceneRenderer.cpp @@ -825,6 +825,7 @@ void VkSceneRenderer::BuildMatrixBuffer() auto [transform, lightComp] = lightView.get(e); Vector3 direction = transform.GetGlobalRotation() * Vector3(0, 0, -1); + lightComp.Direction = direction; LightData light = {}; light.position = Vector3(transform.GetGlobalTransform()[3]); diff --git a/Nuake/src/Rendering/Vulkan/VulkanSceneRenderer.h b/Nuake/src/Rendering/Vulkan/VulkanSceneRenderer.h index 39d66db8..1cb4f850 100644 --- a/Nuake/src/Rendering/Vulkan/VulkanSceneRenderer.h +++ b/Nuake/src/Rendering/Vulkan/VulkanSceneRenderer.h @@ -149,8 +149,7 @@ namespace Nuake void BeginScene(RenderContext inContext); void EndScene(); - RenderPipeline& GetRenderPipeline() { return GBufferPipeline; } - + RenderPipeline& GetRenderPipeline() { return ShadowPipeline; } private: void LoadShaders(); void CreateBuffers(); diff --git a/Nuake/src/Scene/Components/LightComponent.h b/Nuake/src/Scene/Components/LightComponent.h index 8bb8754a..045fc17a 100644 --- a/Nuake/src/Scene/Components/LightComponent.h +++ b/Nuake/src/Scene/Components/LightComponent.h @@ -62,7 +62,7 @@ namespace Nuake void CalculateViewProjection(glm::mat4& view, const glm::mat4& projection) { Matrix4 normalProj = projection; - normalProj *= -1.0f; + //normalProj *= -1.0f; glm::mat4 viewProjection = normalProj * view; glm::mat4 inverseViewProjection = glm::inverse(viewProjection); @@ -158,9 +158,8 @@ namespace Nuake roundOffset.w = 0.0f; lightProjectionMatrix[3] += roundOffset; - m_LightViews[cascade].View = view; - m_LightViews[cascade].Proj = projection; - //m_LightViews[cascade].Proj[1][1] *= -1.0f; + m_LightViews[cascade].View = lightViewMatrix; + m_LightViews[cascade].Proj = lightProjectionMatrix; // Store SplitDistance and ViewProjection-Matrix mCascadeSplitDepth[cascade] = (nearClip + splitDist * clipRange) * 1.0f; diff --git a/Resources/Shaders/Vulkan/shadow.vert b/Resources/Shaders/Vulkan/shadow.vert index 8c0c8cc9..de8c15d8 100644 --- a/Resources/Shaders/Vulkan/shadow.vert +++ b/Resources/Shaders/Vulkan/shadow.vert @@ -81,7 +81,7 @@ VSOutput main(uint vertexIndex : SV_VertexID) Camera camData = camera[0]; ModelData modelData = model[pushConstants.modelIndex]; - CameraView camView = cameras[pushConstants.cameraID]; + CameraView camView = cameras[pushConstants.cameraID]; // Load vertex data from the buffer Vertex v = vertexBuffer[vertexIndex];