diff --git a/SHADE_Engine/src/Camera/SHCameraSystem.cpp b/SHADE_Engine/src/Camera/SHCameraSystem.cpp index 8ef7ff64..924100d4 100644 --- a/SHADE_Engine/src/Camera/SHCameraSystem.cpp +++ b/SHADE_Engine/src/Camera/SHCameraSystem.cpp @@ -270,8 +270,12 @@ namespace SHADE camera.viewMatrix(1, 3) = -UP.Dot(camera.position + camera.offset); camera.viewMatrix(2, 3) = -view.Dot(camera.position + camera.offset); - - + //SHVec3 target{ 0.0f,0.0f,-1.0f }; + //target = SHVec3::RotateX(target, SHMath::DegreesToRadians(camera.pitch)); + //target = SHVec3::RotateY(target, SHMath::DegreesToRadians(camera.yaw)); + //target += camera.position; + + //camera.viewMatrix = SHMatrix::Transpose(SHMatrix::LookAtLH(camera.position, target, SHVec3(0.0f, -1.0f, 0.0f))); camera.dirtyView = false; } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp index 4082ba0f..ca68c709 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsPredefinedData.cpp @@ -205,7 +205,7 @@ namespace SHADE defaultVertexInputState.AddBinding(true, true, { SHVertexAttribute(SHAttribFormat::UINT32_2D) }); // Instanced integer data at index 8 shadowMapVertexInputState.AddBinding(false, false, { SHVertexAttribute(SHAttribFormat::FLOAT_3D)}); - shadowMapVertexInputState.AddBinding(true, true, { SHVertexAttribute(SHAttribFormat::MAT_4D) }, 4); // Transform at binding 4 - 7 (4 slots) + shadowMapVertexInputState.AddBinding(true, true, { SHVertexAttribute(SHAttribFormat::MAT_4D) }, 4, 4); // Transform at binding 4 - 7 (4 slots) } void SHGraphicsPredefinedData::Init(Handle logicalDevice) noexcept diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index e682e0a1..81d8b88e 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -776,7 +776,7 @@ namespace SHADE auto shadowMapNode = renderGraph->AddNodeAfter(SHGraphicsConstants::RenderGraphNodeNames::SHADOW_MAP_PASS.data() + resourceName, {resourceName.c_str()}, SHGraphicsConstants::RenderGraphNodeNames::GBUFFER_PASS.data()); // Add a subpass to render to that shadow map - auto newSubpass = shadowMapNode->RuntimeAddSubpass(resourceName + " Subpass", worldViewport, worldRenderer); + auto newSubpass = shadowMapNode->RuntimeAddSubpass(resourceName + " Subpass", worldViewport, lightComp->GetRenderer()); //auto newSubpass = shadowMapNode->RuntimeAddSubpass(resourceName + " Subpass", worldViewport, lightComp->GetRenderer()); newSubpass->AddDepthOutput(resourceName, SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp index 17cffe17..e16242cb 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp @@ -381,7 +381,7 @@ namespace SHADE switch (lightComp->GetLightData().type) { case SH_LIGHT_TYPE::DIRECTIONAL: - return SHMatrix::LookAtRH(lightComp->GetLightData().position, lightComp->GetLightData().position + lightComp->GetLightData().direction, SHVec3(0.0f, 1.0f, 0.0f)); + return SHMatrix::Transpose (SHMatrix::LookAtLH(/*lightComp->GetLightData().position*/SHVec3(-0.7768f, 3.82611f, 9.23839f), SHVec3(-0.7619f, 3.30361f, 8.38588f), SHVec3(0.0f, -1.0f, 0.0f))); case SH_LIGHT_TYPE::POINT: return {}; case SH_LIGHT_TYPE::SPOT: @@ -525,7 +525,7 @@ namespace SHADE if (auto renderer = light.GetRenderer()) { //SHMatrix orthoMatrix = SHMatrix::OrthographicRH() - renderer->UpdateDataManual (frameIndex, GetViewMatrix(&light), SHMatrix::OrthographicRH(80.0f, 80.0f, 0.01f, 10000.0f)); + renderer->UpdateDataManual (frameIndex, GetViewMatrix(&light), SHMatrix::OrthographicLH(12.0f, 12.0f, 0.1f, 20.0f)); } } diff --git a/SHADE_Engine/src/Graphics/Pipeline/SHPipelineState.cpp b/SHADE_Engine/src/Graphics/Pipeline/SHPipelineState.cpp index 49fa9086..30d81d89 100644 --- a/SHADE_Engine/src/Graphics/Pipeline/SHPipelineState.cpp +++ b/SHADE_Engine/src/Graphics/Pipeline/SHPipelineState.cpp @@ -195,7 +195,7 @@ namespace SHADE return *this; } - void SHVertexInputState::AddBinding(bool instanced, bool calcOffset, std::initializer_list inAttribs, uint32_t fixedAttributeLocation/* = static_cast(-1)*/) noexcept + void SHVertexInputState::AddBinding(bool instanced, bool calcOffset, std::initializer_list inAttribs, uint32_t fixedBinding /*= static_cast(-1)*/, uint32_t fixedAttributeLocation/* = static_cast(-1)*/) noexcept { // add a binding and get ref to it bindings.emplace_back(); @@ -210,7 +210,7 @@ namespace SHADE // Offset is 0 at first (for first element) uint32_t offset = 0; - binding.binding = static_cast(bindings.size() - 1); + binding.binding = (fixedBinding != static_cast(-1)) ? fixedBinding : static_cast(bindings.size() - 1); // for every attribute passed in for (auto const& attrib : inAttribs) @@ -226,7 +226,7 @@ namespace SHADE auto& vertexAttrib = attributes.back(); // The binding for that attribute description is index of the new binding created earlier in this function - vertexAttrib.binding = static_cast(bindings.size() - 1); + vertexAttrib.binding = (fixedBinding != static_cast(-1)) ? fixedBinding : static_cast(bindings.size() - 1); //Attribute location. New index is simply + 1 of the previous. Starts from 0 obviously vertexAttrib.location = (fixedAttributeLocation != static_cast(-1)) ? fixedAttributeLocation + i : static_cast(attributes.size () - 1); diff --git a/SHADE_Engine/src/Graphics/Pipeline/SHPipelineState.h b/SHADE_Engine/src/Graphics/Pipeline/SHPipelineState.h index 380c726e..73eb1ef5 100644 --- a/SHADE_Engine/src/Graphics/Pipeline/SHPipelineState.h +++ b/SHADE_Engine/src/Graphics/Pipeline/SHPipelineState.h @@ -34,7 +34,7 @@ namespace SHADE SHVertexInputState& operator= (SHVertexInputState const& rhs) noexcept; SHVertexInputState& operator= (SHVertexInputState&& rhs) noexcept; - void AddBinding(bool instanced, bool calcOffset, std::initializer_list inAttribs, uint32_t fixedAttributeLocation = static_cast(-1)) noexcept; + void AddBinding(bool instanced, bool calcOffset, std::initializer_list inAttribs, uint32_t fixedBinding = static_cast(-1), uint32_t fixedAttributeLocation = static_cast(-1)) noexcept; friend class SHVkPipelineState; friend class SHVkPipeline;