From a67e65ff765c6fab0898ea9495145ea728dec4c2 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Mon, 30 Jan 2023 15:34:22 +0800 Subject: [PATCH 1/9] Made array for usable subpasses --- .../Graphics/MiddleEnd/Interface/SHGraphicsConstants.h | 8 ++++++++ .../src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h index b3945689..45f91ae6 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h @@ -13,6 +13,7 @@ of DigiPen Institute of Technology is prohibited. // STL Includes #include +#include namespace SHADE { @@ -114,7 +115,14 @@ namespace SHADE static constexpr std::string_view DEFERRED_COMPOSITE_COMPUTE = "Deferred Composite"; + static constexpr std::string_view GBUFFER_WRITE_SUBPASS = "G-Buffer Write"; + static constexpr std::string_view UI_SUBPASS = "UI"; + static constexpr std::array USABLE_SUBPASSES = + { + GBUFFER_WRITE_SUBPASS, + UI_SUBPASS + }; }; struct DescriptorSetBindings diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index c4990153..437dd9a8 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -231,7 +231,7 @@ namespace SHADE /*-----------------------------------------------------------------------*/ /* G-BUFFER SUBPASS INIT */ /*-----------------------------------------------------------------------*/ - auto gBufferSubpass = gBufferNode->AddSubpass("G-Buffer Write", worldViewport, worldRenderer); + auto gBufferSubpass = gBufferNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data(), worldViewport, worldRenderer); gBufferSubpass->AddColorOutput("Position"); gBufferSubpass->AddColorOutput("Entity ID"); gBufferSubpass->AddColorOutput("Light Layer Indices"); @@ -447,7 +447,7 @@ namespace SHADE defaultMaterial = AddMaterial ( defaultVertShader, defaultFragShader, - renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass("G-Buffer Write") + renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS) ); defaultMaterial->SetProperty("data.textureIndex", defaultTexture->TextureArrayIndex); } @@ -765,7 +765,7 @@ namespace SHADE auto const& EVENT_DATA = reinterpret_cast*>(eventPtr.get())->data; auto* lightComp = SHComponentManager::GetComponent(EVENT_DATA->lightEntity); std::string resourceName = "ShadowMap " + std::to_string(EVENT_DATA->lightEntity); - Handle companionSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass("G-Buffer Write"); + Handle companionSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS); if (EVENT_DATA->generateRenderer) { -- 2.40.1 From 8a4a469abf991059f0591cf60429fc09d091e15f Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Mon, 30 Jan 2023 15:52:42 +0800 Subject: [PATCH 2/9] Added ability to change subpass for a material and fixed typo for vertex shader in the material editor --- .../MaterialInspector/SHMaterialInspector.cpp | 38 ++++++++++++++++++- SHADE_Engine/src/Editor/SHEditorUI.h | 10 ++--- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp b/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp index 537cfc55..d382451d 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp @@ -1,8 +1,11 @@ #include "SHpch.h" + +#include +#include + #include "Serialization/SHSerializationHelper.hpp" #include "SHMaterialInspector.h" #include "Editor/SHImGuiHelpers.hpp" -#include #include "Assets/SHAssetManager.h" #include "Editor/IconsMaterialDesign.h" @@ -176,7 +179,7 @@ namespace SHADE const std::string VERT_SHADER_NAME = VERT_SHADER_INFO ? VERT_SHADER_INFO->name : "Unknown Shader"; isDirty |= SHEditorWidgets::DragDropReadOnlyField ( - "Fragment Shader", VERT_SHADER_NAME.data(), + "Vertex Shader", VERT_SHADER_NAME.data(), [this]() { return currentMatSpec->vertexShader; }, [this](const AssetID& id) { currentMatSpec->vertexShader = id; }, SHDragDrop::DRAG_RESOURCE @@ -191,6 +194,37 @@ namespace SHADE SHDragDrop::DRAG_RESOURCE ); + // Subpass + const auto& SP_NAMES = SHGraphicsConstants::RenderGraphEntityNames::USABLE_SUBPASSES; + ImGui::Text("Subpass"); + ImGui::SameLine(); + if (ImGui::BeginCombo("##", currentMatSpec->subpassName.data(), ImGuiComboFlags_None)) + { + for (const auto& NAME : SP_NAMES) + { + const bool IS_SELECTED = currentMatSpec->subpassName == NAME; + if (ImGui::Selectable(NAME.data(), IS_SELECTED)) + { + isDirty = true; + SHCommandManager::PerformCommand + ( + std::reinterpret_pointer_cast(std::make_shared> + ( + currentMatSpec->subpassName, + std::string(NAME), + [&](const std::string& newName){ currentMatSpec->subpassName = newName; } + )), + false + ); + } + if (IS_SELECTED) + { + ImGui::SetItemDefaultFocus(); + } + } + ImGui::EndCombo(); + } + // Load the shader to access it's data auto fragShader = SHResourceManager::LoadOrGet(currentMatSpec->fragShader); if (!fragShader) diff --git a/SHADE_Engine/src/Editor/SHEditorUI.h b/SHADE_Engine/src/Editor/SHEditorUI.h index cd87f46b..23cc2d1a 100644 --- a/SHADE_Engine/src/Editor/SHEditorUI.h +++ b/SHADE_Engine/src/Editor/SHEditorUI.h @@ -98,9 +98,9 @@ namespace SHADE static bool IsItemHovered(); /*-----------------------------------------------------------------------------*/ - /* ImGui Wrapper Functions - Menu */ - /*-----------------------------------------------------------------------------*/ - static bool BeginMenu(const std::string& label); + /* ImGui Wrapper Functions - Menu */ + /*-----------------------------------------------------------------------------*/ + static bool BeginMenu(const std::string& label); static bool BeginMenu(const std::string& label, const char* icon); static void EndMenu(); static void BeginTooltip(); @@ -164,8 +164,8 @@ namespace SHADE /// /// Text to display. /// True if button was pressed. - static bool Button(const std::string& title); - static bool Selectable(const std::string& label); + static bool Button(const std::string& title); + static bool Selectable(const std::string& label); static bool Selectable(const std::string& label, const char* icon); /// /// Creates a checkbox widget for boolean input. -- 2.40.1 From f8bde9fc359bb18bc2f2660c26a725038556d365 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Mon, 30 Jan 2023 16:35:12 +0800 Subject: [PATCH 3/9] Added map to retrieve usable subpasses --- .../src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp | 7 +++++-- .../src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 437dd9a8..12f8f318 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -240,6 +240,7 @@ namespace SHADE gBufferSubpass->AddColorOutput("Position World Space"); gBufferSubpass->AddDepthOutput("Depth Buffer", SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL); + usableSubpassesMapping.emplace (std::string (SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data()), gBufferSubpass); /*-----------------------------------------------------------------------*/ /* SSAO PASS AND DATA INIT */ @@ -318,7 +319,7 @@ namespace SHADE /* SCREEN SPACE PASS */ /*-----------------------------------------------------------------------*/ auto screenSpaceNode = renderGraph->AddNode(SHGraphicsConstants::RenderGraphEntityNames::SCREEN_SPACE_PASS.data(), {"Scene", "Entity ID"}, {SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data(), SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data(), SHGraphicsConstants::RenderGraphEntityNames::DEBUG_DRAW.data()}); - auto uiSubpass = screenSpaceNode->AddSubpass("UI", worldViewport, screenRenderer); + auto uiSubpass = screenSpaceNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::UI_SUBPASS.data(), worldViewport, screenRenderer); uiSubpass->AddColorOutput("Scene"); uiSubpass->AddColorOutput("Entity ID"); uiSubpass->AddExteriorDrawCalls([=](Handle cmdBuffer, Handle renderer, uint32_t frameIndex) @@ -326,6 +327,8 @@ namespace SHADE textRenderingSubSystem->Render(cmdBuffer, renderer, frameIndex); }); + usableSubpassesMapping.emplace(SHGraphicsConstants::RenderGraphEntityNames::UI_SUBPASS.data(), uiSubpass); + /*-----------------------------------------------------------------------*/ /* RENDER TO SWAPCHAIN IMAGE FOR PRESENT PASS */ /*-----------------------------------------------------------------------*/ @@ -420,7 +423,7 @@ namespace SHADE // initialize the text renderer auto uiNode = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::SCREEN_SPACE_PASS.data()); - textRenderingSubSystem->Init(device, uiNode->GetRenderpass(), uiNode->GetSubpass("UI"), descPool, textVS, textFS); + textRenderingSubSystem->Init(device, uiNode->GetRenderpass(), uiNode->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::UI_SUBPASS), descPool, textVS, textFS); SHGlobalDescriptorSets::SetLightingSubSystem(lightingSubSystem); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h index c736599f..11aaf337 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h @@ -399,6 +399,7 @@ namespace SHADE uint32_t GetCurrentFrameIndex(void) const noexcept { return renderContext.GetCurrentFrame(); } SHFontLibrary const& GetFontLibrary (void) const noexcept; const SHMeshLibrary& GetMeshLibrary() const noexcept { return meshLibrary; }; + std::unordered_map> const& GetUsableSubpasses(void) const noexcept {return usableSubpassesMapping;}; /*-----------------------------------------------------------------------------*/ /* Getters */ @@ -507,6 +508,8 @@ namespace SHADE uint32_t resizeHeight = 1; bool restoredFromMinimize = false; + std::unordered_map> usableSubpassesMapping{}; + /*---------------------------------------------------------------------------------*/ /* Helper Functions */ /*---------------------------------------------------------------------------------*/ -- 2.40.1 From c45c469c8e46506a23ab64d7aa0e4d49f41ee54d Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Mon, 30 Jan 2023 16:42:19 +0800 Subject: [PATCH 4/9] Change GetUsableSubpasses to GetUsableSubpass --- .../Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp | 10 ++++++++++ .../Graphics/MiddleEnd/Interface/SHGraphicsSystem.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 12f8f318..9874b706 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -1185,6 +1185,16 @@ namespace SHADE return fontLibrary; } + Handle const& SHGraphicsSystem::GetUsableSubpass(std::string subpassName) const noexcept + { + if (usableSubpassesMapping.contains(subpassName)) + { + return usableSubpassesMapping.at (subpassName); + } + else + return {}; + } + Handle SHGraphicsSystem::createDebugDrawPipeline(Handle renderPass, Handle subpass, bool filled, bool triMesh, bool instanced) { auto pipelineLayout = resourceManager.Create diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h index 11aaf337..bf283bc8 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h @@ -399,7 +399,7 @@ namespace SHADE uint32_t GetCurrentFrameIndex(void) const noexcept { return renderContext.GetCurrentFrame(); } SHFontLibrary const& GetFontLibrary (void) const noexcept; const SHMeshLibrary& GetMeshLibrary() const noexcept { return meshLibrary; }; - std::unordered_map> const& GetUsableSubpasses(void) const noexcept {return usableSubpassesMapping;}; + Handle const& GetUsableSubpass(std::string subpassName) const noexcept; /*-----------------------------------------------------------------------------*/ /* Getters */ -- 2.40.1 From 89b101f3e5386fa44ef178e7a63a575483d22ad1 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Mon, 30 Jan 2023 16:46:14 +0800 Subject: [PATCH 5/9] passed string by value dum dum brandon --- .../src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 9874b706..e84955d7 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -1185,7 +1185,7 @@ namespace SHADE return fontLibrary; } - Handle const& SHGraphicsSystem::GetUsableSubpass(std::string subpassName) const noexcept + Handle const& SHGraphicsSystem::GetUsableSubpass(std::string const& subpassName) const noexcept { if (usableSubpassesMapping.contains(subpassName)) { -- 2.40.1 From a3ca04535fbb6264549bb64698678093763ed884 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Mon, 30 Jan 2023 16:46:42 +0800 Subject: [PATCH 6/9] More changes --- .../src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp | 2 +- .../src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index e84955d7..6914df49 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -1185,7 +1185,7 @@ namespace SHADE return fontLibrary; } - Handle const& SHGraphicsSystem::GetUsableSubpass(std::string const& subpassName) const noexcept + Handle SHGraphicsSystem::GetUsableSubpass(std::string const& subpassName) const noexcept { if (usableSubpassesMapping.contains(subpassName)) { diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h index bf283bc8..86b233fd 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.h @@ -399,7 +399,7 @@ namespace SHADE uint32_t GetCurrentFrameIndex(void) const noexcept { return renderContext.GetCurrentFrame(); } SHFontLibrary const& GetFontLibrary (void) const noexcept; const SHMeshLibrary& GetMeshLibrary() const noexcept { return meshLibrary; }; - Handle const& GetUsableSubpass(std::string subpassName) const noexcept; + Handle GetUsableSubpass(std::string const& subpassName) const noexcept; /*-----------------------------------------------------------------------------*/ /* Getters */ -- 2.40.1 From c2aa067cc4403fc9d5ddb16a11b85dc39835c65f Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Mon, 30 Jan 2023 16:55:15 +0800 Subject: [PATCH 7/9] Fixed crash caused by loading incorrect renderpass for subpass replacement --- .../MaterialInspector/SHMaterialInspector.cpp | 16 +++++++++++----- .../src/Graphics/RenderGraph/SHSubpass.cpp | 2 +- .../src/Graphics/RenderGraph/SHSubpass.h | 2 +- SHADE_Engine/src/Resource/SHResourceManager.hpp | 10 ++-------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp b/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp index d382451d..adb1fe51 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/MaterialInspector/SHMaterialInspector.cpp @@ -92,11 +92,17 @@ namespace SHADE if (vertShader && fragShader && gfxSystem) { // - Retrieve pipeline from pipeline library - auto renderPass = gfxSystem->GetPrimaryRenderpass(); - auto subPass = renderPass->GetSubpass(currentMatSpec->subpassName); - auto pipeline = renderPass->GetOrCreatePipeline({ vertShader, fragShader }, subPass); - // - Set Pipeline - matHandle->SetPipeline(pipeline); + auto subPass = gfxSystem->GetUsableSubpass(currentMatSpec->subpassName); + if (subPass) + { + // Set Pipeline if valid + auto pipeline = subPass->GetParentNode()->GetOrCreatePipeline({vertShader, fragShader}, subPass); + matHandle->SetPipeline(pipeline); + } + else + { + SHLOG_ERROR("[SHMaterialInspector] Failed to find material subpass of type \"{}\"", currentMatSpec->subpassName); + } } } diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp index 5205b44d..96207d7a 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp @@ -474,7 +474,7 @@ namespace SHADE */ /***************************************************************************/ - Handle const& SHSubpass::GetParentNode(void) const noexcept + Handle SHSubpass::GetParentNode(void) const noexcept { return parentNode; } diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h index f84d4dee..811cc70c 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h @@ -159,7 +159,7 @@ namespace SHADE /*-----------------------------------------------------------------------*/ void SetCompanionSubpass (Handle companion, Handle pipeline) noexcept; - Handle const& GetParentNode(void) const noexcept; + Handle GetParentNode(void) const noexcept; SHSubPassIndex GetIndex() const noexcept; Handle GetSuperBatch(void) const noexcept; std::vector const& GetColorAttachmentReferences (void) const noexcept; diff --git a/SHADE_Engine/src/Resource/SHResourceManager.hpp b/SHADE_Engine/src/Resource/SHResourceManager.hpp index 51ee356a..8e2b3309 100644 --- a/SHADE_Engine/src/Resource/SHResourceManager.hpp +++ b/SHADE_Engine/src/Resource/SHResourceManager.hpp @@ -270,14 +270,8 @@ namespace SHADE return {}; } - // Grab subpass from worldRenderer - auto renderPass = gfxSystem->GetPrimaryRenderpass(); - if (!renderPass) - { - SHLOG_ERROR("[SHResourceManager] Failed to load material as RenderPass could not be found."); - return {}; - } - auto subPass = renderPass->GetSubpass(assetData.subpassName); + // Grab subpass + auto subPass = gfxSystem->GetUsableSubpass(assetData.subpassName); if (!subPass) { SHLOG_ERROR("[SHResourceManager] Failed to load material as SubPass could not be found."); -- 2.40.1 From e9452093f0eb6fc8b09491f0540e5bbc7dca9f9f Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Tue, 31 Jan 2023 15:17:40 +0800 Subject: [PATCH 8/9] Fixed UI --- Assets/Application.SHConfig | 2 +- Assets/Materials/UIMat_LoseScene.shmat | 2 +- Assets/Materials/UIMat_MainMenu.shmat | 2 +- Assets/Materials/UIMat_WinScene.shmat | 2 +- Assets/Shaders/UI_FS.glsl | 11 ++----- Assets/Shaders/UI_FS.shshaderb | Bin 2285 -> 1941 bytes SHADE_Engine/src/Camera/SHCameraSystem.cpp | 2 +- .../MiddleEnd/Interface/SHGraphicsSystem.cpp | 29 ++++++++---------- .../Graphics/RenderGraph/SHRenderGraph.cpp | 12 +++++++- .../src/Graphics/RenderGraph/SHRenderGraph.h | 2 +- 10 files changed, 31 insertions(+), 33 deletions(-) diff --git a/Assets/Application.SHConfig b/Assets/Application.SHConfig index ee5e42a8..5673556d 100644 --- a/Assets/Application.SHConfig +++ b/Assets/Application.SHConfig @@ -1,4 +1,4 @@ Start in Fullscreen: false -Starting Scene ID: 87244611 +Starting Scene ID: 97158628 Window Size: {x: 1920, y: 1080} Window Title: SHADE Engine \ No newline at end of file diff --git a/Assets/Materials/UIMat_LoseScene.shmat b/Assets/Materials/UIMat_LoseScene.shmat index b962f5ad..5be3677e 100644 --- a/Assets/Materials/UIMat_LoseScene.shmat +++ b/Assets/Materials/UIMat_LoseScene.shmat @@ -1,6 +1,6 @@ - VertexShader: 46580970 FragmentShader: 35983630 - SubPass: G-Buffer Write + SubPass: UI Properties: data.color: {x: 1, y: 1, z: 1, w: 1} data.textureIndex: 54324293 diff --git a/Assets/Materials/UIMat_MainMenu.shmat b/Assets/Materials/UIMat_MainMenu.shmat index 625021b0..0ca4c7a1 100644 --- a/Assets/Materials/UIMat_MainMenu.shmat +++ b/Assets/Materials/UIMat_MainMenu.shmat @@ -1,6 +1,6 @@ - VertexShader: 46580970 FragmentShader: 35983630 - SubPass: G-Buffer Write + SubPass: UI Properties: data.color: {x: 1, y: 1, z: 1, w: 1} data.textureIndex: 54429632 diff --git a/Assets/Materials/UIMat_WinScene.shmat b/Assets/Materials/UIMat_WinScene.shmat index b8d5b183..e9c36f65 100644 --- a/Assets/Materials/UIMat_WinScene.shmat +++ b/Assets/Materials/UIMat_WinScene.shmat @@ -1,6 +1,6 @@ - VertexShader: 46580970 FragmentShader: 35983630 - SubPass: G-Buffer Write + SubPass: UI Properties: data.color: {x: 1, y: 1, z: 1, w: 1} data.textureIndex: 57302694 diff --git a/Assets/Shaders/UI_FS.glsl b/Assets/Shaders/UI_FS.glsl index 0c4c526c..a28642f4 100644 --- a/Assets/Shaders/UI_FS.glsl +++ b/Assets/Shaders/UI_FS.glsl @@ -33,18 +33,11 @@ layout (std430, set = 2, binding = 0) buffer MaterialProperties // For mater MatPropData data[]; } MatProp; -layout(location = 0) out vec4 position; +layout(location = 0) out vec4 fragColor; layout(location = 1) out uint outEntityID; -layout(location = 2) out uint lightLayerIndices; -layout(location = 3) out vec4 normals; -layout(location = 4) out vec4 albedo; void main() { - position = In.vertPos; - normals = In.normal; - albedo = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); - + fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); outEntityID = In2.eid; - lightLayerIndices = In2.lightLayerIndex; } \ No newline at end of file diff --git a/Assets/Shaders/UI_FS.shshaderb b/Assets/Shaders/UI_FS.shshaderb index 703040e1a63c9c59d398cc68a6df7121a76c6b39..ce1dd7e9c0a416be4f198d797c9709fa254dd63e 100644 GIT binary patch literal 1941 zcmY+E+fEZv6o$97ML-b{0Tsmpo>4$VV`4NxCACQnM2vbj*|eK7I?UARl*l{yIO>ge zK9x5n{@)y+ZnC=8`qz2wJ&b=lZPHU3Sd?_ijF?gLFoVp584zMp{^LT%f9Cv`_=p)Y zJKOKQ&5!TAmg_cSzmr6<=Z7u#)eqa|j2TShYmJ@8ayMx$uRmHP^*K{YE0BB444bkz zbYT4u!?5VG=#FSbG%kPav|7^NfcS3(m*rV&cpGnDcwN`Au}z%U-M1|ld(rME*G#(q z`^coWyugO-o^3mCeQmX4o1c|uh&+rDMqw}X_oDc~`_i+4zvsJH_7Uv0t*u&P(`$A* zUN<=koEP|^^ICqaO8%jvR+=aG^TTG)YxO%+W}!$|*+P-rR4d}U)zOA}m8~f&s zMZIJ*O#I}i{>s#pgEu%Q;-GUU3#oRZ&r7GyYvm~JVlnqAFzjICeSY);rcdZNmOB8e zil}#9d{D#(L#|@)_;6~P0gO2OxdZwmccIfC2VeHb4A_vFEsHIsao^Ppe%FN;@{MD; zobIcCAM6aB`6gABy7P)BC-Sr;`mc&+RFiKPo%dhW?~pjY;7@a%or7J{_D96=Cx8Db z^jUeHkpaJ}lFy2xlY3O014eFiX6H;v9}};N$VG454YjB}CyBeHFZ{rrQ#OL@I%$sFp>h*wc`=5)7w2h;-3Y-Q~r>kk__(YZHzrsixe6IawI z?gRTZ;ndG&EvIiwYPut4zA2g6@Sz93BW4DNljF8H^{~+cI{%Z49`5EcG59ZwvqNUU zAAKdqu=AFQ#r{||sm*)f5cfw&MSMfQ%y&h^%S X15xqKQHS~0avXnlg#K6Cc_R7;_oT5} literal 2285 zcmY+FZF3Yw5XUFnU5Mc+h=7R14N*YRh%q3FP!)^RnX0o$8B2Y)HMt#<(ar9;yO$#0 zOMT-zKZ_rNH&prm&FzGxt2+JkpPufX-pkT|3nozS)aq$t=FFlwXP(Sl=AtovUnT16)Nqt;{`g&5 zyNRuAbL^ObJ$M~=Hfo)+heaX!tufPoO*o(EV;WuD8p4{YW@ocF+HH?VmRdW53ABAwd5*X=RaDgaUR5y!XG@zEbXeYz(& z?!}jg$^U`myqFJ_T!|zE1{$i;M3QshsSPG~v{$46#j5A){CoS6Ll24HjFCH+ON=sfkHUy(-riTJAU{7zsq&qROuxdV&;QET%?_`okp zf+yFq`sbSiiyujjvy#+9j2zg!E56IJ={ITZyRCgeHpF?}1Z=kk_JA59o;RX~SR;Eu z{F*lET}f&rN0*{~UC3(+fV(06JxOftzAg#jBR4iX2GRcwNpf@7vNUE*o%DpCI62u9 zV$0GKNo?}3NK$tqCO`H~F+OIqDw&8O=F4|TZv3-Y-+Ux}PE3p(*tc3Acie7u&c%6s z(uv=d&V93Y=$p@_LvaS{(#g-8lJ9{e{c=C|Ve|h6AMuBh;Jb15koW`jz+LPYgzu$1 z1IbPO<*hG@*$;N$v5?I3Z882QI>G*7NBm{!;MswQzakw!cy>;FX< zdcH5_9De#>r}2@48GkLNkC=mbf7ANG^Cs94|E+ZJaZcbLi}8c!jj&(o^&X1<2dFg4 A;s5{u diff --git a/SHADE_Engine/src/Camera/SHCameraSystem.cpp b/SHADE_Engine/src/Camera/SHCameraSystem.cpp index 6feece48..8b78045a 100644 --- a/SHADE_Engine/src/Camera/SHCameraSystem.cpp +++ b/SHADE_Engine/src/Camera/SHCameraSystem.cpp @@ -314,7 +314,7 @@ namespace SHADE camera.orthoProjMatrix(3, 3) = 1.0f; //camera.perspProjMatrix = SHMatrix::OrthographicLH(9.0f, 9.0f, 0.1f, 20.0f); - camera.orthoProjMatrix = SHMatrix::OrthographicRH(camera.GetWidth(), camera.GetHeight(), camera.GetNear(), camera.GetFar()); + //camera.orthoProjMatrix = SHMatrix::OrthographicLH(camera.GetWidth(), camera.GetHeight(), camera.GetNear(), camera.GetFar()); //camera.perspProjMatrix = SHMatrix::OrthographicLH(5.0f, 5.0f, 0.1f, 20.0f); //camera.projMatrix.Transpose(); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 6914df49..a416b149 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -127,12 +127,15 @@ namespace SHADE SHFreetypeInstance::Init(); - SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false); - SHAssetManager::CompileAsset("../../Assets/Shaders/SSAO_CS.glsl", false); - SHAssetManager::CompileAsset("../../Assets/Shaders/SSAOBlur_CS.glsl", false); - SHAssetManager::CompileAsset("../../Assets/Shaders/PureCopy_CS.glsl", false); - SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_VS.glsl", false); - SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_FS.glsl", false); + //SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false); + //SHAssetManager::CompileAsset("../../Assets/Shaders/SSAO_CS.glsl", false); + //SHAssetManager::CompileAsset("../../Assets/Shaders/SSAOBlur_CS.glsl", false); + //SHAssetManager::CompileAsset("../../Assets/Shaders/PureCopy_CS.glsl", false); + //SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_VS.glsl", false); + //SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_FS.glsl", false); + //SHAssetManager::CompileAsset("../../Assets/Shaders/UI_VS.glsl", false); + //SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false); + //SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false); // Load Built In Shaders static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet(VS_DEFAULT); @@ -418,7 +421,7 @@ namespace SHADE .addressMode = vk::SamplerAddressMode::eClampToBorder, }) ); - + textRenderingSubSystem = resourceManager.Create(); // initialize the text renderer @@ -567,7 +570,7 @@ namespace SHADE else renderer->UpdateData(frameIndex); #else - renderers[renIndex]->UpdateDataAndBind(frameIndex); + renderer->UpdateData(frameIndex); #endif } @@ -583,16 +586,8 @@ namespace SHADE renderGraph->Begin(frameIndex); auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex); - // Bind all the buffers required for meshes - for (auto& [buffer, bindingPoint] : MESH_DATA) - { - if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eVertexBuffer) - cmdBuffer->BindVertexBuffer(bindingPoint, buffer, 0); - else if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eIndexBuffer) - cmdBuffer->BindIndexBuffer(buffer, 0); - } - renderGraph->Execute(frameIndex, descPool); + renderGraph->Execute(frameIndex, descPool, MESH_DATA); renderGraph->End(frameIndex); graphicsQueue->SubmitCommandBuffer diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp index 74ea951a..c312535e 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.cpp @@ -565,7 +565,7 @@ namespace SHADE // TODO: The graph scope buffers were meant to bind vertex buffers and index buffers for meshes. Find a // better way to manage these - void SHRenderGraph::Execute(uint32_t frameIndex, Handle descPool) noexcept + void SHRenderGraph::Execute(uint32_t frameIndex, Handle descPool, const std::initializer_list, uint32_t>> MESH_DATA) noexcept { auto cmdBuffer = commandBuffers[frameIndex]; cmdBuffer->BeginLabeledSegment(name); @@ -577,6 +577,7 @@ namespace SHADE cmdBuffer->ForceSetPipelineLayout(batchingSystemData.dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE); auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); + for (auto& node : nodes) { @@ -585,6 +586,15 @@ namespace SHADE // bind static global data SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA)); + // Bind all the buffers required for meshes + for (auto& [buffer, bindingPoint] : MESH_DATA) + { + if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eVertexBuffer) + cmdBuffer->BindVertexBuffer(bindingPoint, buffer, 0); + else if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eIndexBuffer) + cmdBuffer->BindIndexBuffer(buffer, 0); + } + node->Execute(cmdBuffer, descPool, frameIndex); } } diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h index 5abcd6b6..0ae30015 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraph.h @@ -143,7 +143,7 @@ namespace SHADE void Generate (void) noexcept; void CheckForNodeComputes (void) noexcept; - void Execute (uint32_t frameIndex, Handle descPool) noexcept; + void Execute (uint32_t frameIndex, Handle descPool, const std::initializer_list, uint32_t>> MESH_DATA) noexcept; void Begin (uint32_t frameIndex) noexcept; void End (uint32_t frameIndex) noexcept; void FinaliseBatch (uint32_t frameIndex, Handle descPool); -- 2.40.1 From ea74f5ebf66883ac9efb708e6d87fff761f31bd2 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Tue, 31 Jan 2023 19:01:21 +0800 Subject: [PATCH 9/9] Fixed some errors in SHUISystem --- SHADE_Engine/src/UI/SHUISystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SHADE_Engine/src/UI/SHUISystem.cpp b/SHADE_Engine/src/UI/SHUISystem.cpp index c75af66f..9bd5ae43 100644 --- a/SHADE_Engine/src/UI/SHUISystem.cpp +++ b/SHADE_Engine/src/UI/SHUISystem.cpp @@ -182,7 +182,7 @@ namespace SHADE mousePos.x = x; mousePos.y = y; auto ws = SHSystemManager::GetSystem()->GetWindow()->GetWindowSize(); - windowSize = { ws.first,ws.second }; + windowSize = { static_cast(ws.first), static_cast(ws.second) }; mousePos /= windowSize; #endif @@ -300,7 +300,7 @@ namespace SHADE mousePos.x = x; mousePos.y = y; auto ws = SHSystemManager::GetSystem()->GetWindow()->GetWindowSize(); - windowSize = { ws.first,ws.second }; + windowSize = { static_cast(ws.first), static_cast(ws.second) }; mousePos /= windowSize; #endif -- 2.40.1