diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp index 8adb45b5..9ebd47bc 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp @@ -470,6 +470,7 @@ namespace SHADE SHEditorWidgets::DragVec3("Direction", { "X", "Y", "Z" }, [component]() {return component->GetDirection(); }, [component](SHVec3 const& vec) {component->SetDirection(vec); }); SHEditorWidgets::ColorPicker("Color", [component]() {return component->GetColor(); }, [component](SHVec4 const& rgba) {component->SetColor(rgba); }); SHEditorWidgets::DragFloat("Strength", [component]() {return component->GetStrength(); }, [component](float const& value) {component->SetStrength(value); }); + SHEditorWidgets::CheckBox("Casting Shadows", [comp = component]() {return comp->GetEnableShadow(); }, [comp = component](bool b) {comp->SetEnableShadow(b);}); } else { diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 999337ae..69b4503c 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -672,22 +672,6 @@ namespace SHADE #endif } - 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); - } - } - renderGraph->Begin(frameIndex); auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.cpp index 6943ec09..61552614 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.cpp @@ -190,6 +190,11 @@ namespace SHADE return renderer; } + bool SHLightComponent::GetEnableShadow(void) const noexcept + { + return lightData.castShadows; + } + } RTTR_REGISTRATION @@ -212,5 +217,6 @@ RTTR_REGISTRATION .property("Color", &SHLightComponent::GetColor, &SHLightComponent::SetColor) .property("Layer", &SHLightComponent::GetCullingMask, &SHLightComponent::SetCullingMask) .property("Strength", &SHLightComponent::GetStrength, &SHLightComponent::SetStrength) + .property("Casting Shadows", &SHLightComponent::GetEnableShadow, &SHLightComponent::SetEnableShadow) ; } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.h b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.h index 4974f3f5..a90d23b0 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightComponent.h @@ -69,6 +69,7 @@ namespace SHADE //uint32_t GetIndexInBuffer (void) const noexcept; float GetStrength (void) const noexcept; Handle GetRenderer (void) const noexcept; + bool GetEnableShadow (void) const noexcept; RTTR_ENABLE() }; } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp index cd308487..f89582fc 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Lights/SHLightingSubSystem.cpp @@ -526,7 +526,7 @@ namespace SHADE if (auto renderer = light.GetRenderer()) { //SHMatrix orthoMatrix = SHMatrix::OrthographicRH() - renderer->UpdateDataManual(frameIndex, GetViewMatrix(&light), SHMatrix::OrthographicLH(12.0f, 12.0f, 1.0f, 80.0f)); + renderer->UpdateDataManual(frameIndex, GetViewMatrix(&light), SHMatrix::OrthographicLH(15.0f, 15.0f, 1.0f, 80.0f)); } auto enumValue = SHUtilities::ConvertEnum(light.GetLightData().type); diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp index e4e6889c..04d4af0b 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp @@ -479,7 +479,7 @@ namespace SHADE // get target node auto targetNode = nodes.begin() + nodeIndexing.at(nodeToAddAfter); - auto node = nodes.insert(targetNode, renderGraphStorage->resourceHub->Create(nodeName, renderGraphStorage, std::move(descInitParams), std::vector>())); + auto node = nodes.insert(targetNode, renderGraphStorage->resourceHub->Create(nodeName, renderGraphStorage, std::move(descInitParams), std::vector>(), true)); ReindexNodes (); return *node; @@ -583,6 +583,10 @@ namespace SHADE for (auto& node : nodes) { + // if node is dynamic check for active flag + if ((node->isDynamic) ? !node->dynamicIsActive : false) + continue; + if (node->renderpass) { // bind static global data diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp index 36d2e20a..2f316c79 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp @@ -292,7 +292,7 @@ namespace SHADE */ /***************************************************************************/ - SHRenderGraphNode::SHRenderGraphNode(std::string nodeName, Handle renderGraphStorage, std::vector attDescInitParams, std::vector> predecessors) noexcept + SHRenderGraphNode::SHRenderGraphNode(std::string nodeName, Handle renderGraphStorage, std::vector attDescInitParams, std::vector> predecessors, bool inIsDynamic) noexcept : graphStorage{ renderGraphStorage} , renderpass{} , framebuffers{} @@ -305,6 +305,8 @@ namespace SHADE , configured{ false } , nodeComputes{} , name { std::move(nodeName) } + , dynamicIsActive {true} // default set to true + , isDynamic{inIsDynamic} { // pipeline library initialization pipelineLibrary.Init(graphStorage->logicalDevice); @@ -368,6 +370,8 @@ namespace SHADE , nodeComputes{ std::move(rhs.nodeComputes) } , name { std::move(rhs.name) } , ISelfHandle{std::move(rhs)} + , dynamicIsActive {rhs.dynamicIsActive} + , isDynamic {rhs.isDynamic} { rhs.renderpass = {}; @@ -393,6 +397,8 @@ namespace SHADE spDeps = std::move(rhs.spDeps); nodeComputes = std::move(rhs.nodeComputes); name = std::move(rhs.name); + dynamicIsActive = rhs.dynamicIsActive; + isDynamic = rhs.isDynamic; rhs.renderpass = {}; @@ -805,6 +811,11 @@ namespace SHADE CreateFramebuffer(); } + void SHRenderGraphNode::SetDynamicActive(bool active) noexcept + { + dynamicIsActive = active; + } + /***************************************************************************/ /*! @@ -850,4 +861,9 @@ namespace SHADE return {}; } + bool SHRenderGraphNode::GetDynamicActive(void) const noexcept + { + return dynamicIsActive; + } + } \ No newline at end of file diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.h b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.h index b070b8fa..2877fdee 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.h @@ -80,6 +80,13 @@ namespace SHADE //! Whether or not the node has been configured already or not bool configured; + //! Whether or not the rendergraph should be executed. Should ONLY be used for dynamic + //! nodes that are independent from other nodes. + bool dynamicIsActive; + + //! True if the function is dynamic + bool isDynamic; + //! Manages batching for this RenderPass SHBatcher batcher; @@ -101,7 +108,7 @@ namespace SHADE /*-----------------------------------------------------------------------*/ /* CTORS AND DTORS */ /*-----------------------------------------------------------------------*/ - SHRenderGraphNode(std::string nodeName, Handle renderGraphStorage, std::vector attDescInitParams, std::vector> predecessors) noexcept; + SHRenderGraphNode(std::string nodeName, Handle renderGraphStorage, std::vector attDescInitParams, std::vector> predecessors, bool inIsDynamic = false) noexcept; SHRenderGraphNode(SHRenderGraphNode&& rhs) noexcept; SHRenderGraphNode& operator= (SHRenderGraphNode&& rhs) noexcept; @@ -123,11 +130,15 @@ namespace SHADE /*-----------------------------------------------------------------------*/ /* SETTERS AND GETTERS */ /*-----------------------------------------------------------------------*/ + void SetDynamicActive(bool active) noexcept; + Handle GetRenderpass(void) const noexcept; Handle GetSubpass(std::string_view subpassName) const noexcept; Handle GetResource (uint32_t resourceIndex) const noexcept; std::vector> const& GetResources (void) const noexcept; Handle GetNodeCompute (std::string nodeComputeName) const noexcept; + bool GetDynamicActive (void) const noexcept; + friend class SHRenderGraph; };