From e2ef32f130ba2788db492c213c31230b40b81a49 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Thu, 2 Mar 2023 15:29:24 +0800 Subject: [PATCH 1/3] Fixed Trajectory Rendering --- Assets/Shaders/Trajectory_VS.glsl | 2 +- Assets/Shaders/Trajectory_VS.shshaderb | Bin 1973 -> 1957 bytes SHADE_Engine/src/Common/SHAllComponents.h | 3 +- .../Inspector/SHEditorComponentView.hpp | 93 ++++++++++++++++++ .../MiddleEnd/Interface/SHGraphicsConstants.h | 3 +- .../MiddleEnd/Interface/SHGraphicsSystem.cpp | 6 +- .../SHTrajectoryRenderingSubSystem.cpp | 24 +++-- .../src/Serialization/SHSerialization.cpp | 3 + .../src/Serialization/SHYAMLConverters.h | 15 +++ 9 files changed, 136 insertions(+), 13 deletions(-) diff --git a/Assets/Shaders/Trajectory_VS.glsl b/Assets/Shaders/Trajectory_VS.glsl index 86be6b7e..1b4de7f7 100644 --- a/Assets/Shaders/Trajectory_VS.glsl +++ b/Assets/Shaders/Trajectory_VS.glsl @@ -32,5 +32,5 @@ void main() Out.uv = aUV; Out.color = aColor; - gl_Position = cameraData.projMat * aTransform * vec4(aPos, 1.0f); + gl_Position = cameraData.vpMat * aTransform * vec4(aPos, 1.0f); } \ No newline at end of file diff --git a/Assets/Shaders/Trajectory_VS.shshaderb b/Assets/Shaders/Trajectory_VS.shshaderb index 6f509f5c39101e9c796f0e8d0de035a74a9217ec..b7a0f9fb7b1ae8a837c85483252ddfbcd76e3637 100644 GIT binary patch delta 456 zcmX|-&q@MO6voe;85IH%7wOIh?2ndX+8+s`qE*|3pp6?hL4t+j0~quK*4Awg5Ycn^ z5I#rI@4HMo{5a=)=ey?~?|12=RB?-f`Ck~+$((Ii(R%aBeXfC=e5Nb6scd+c4xgqE z&*|7KXOSgequ|w*)v7@VH(ve?mu?o5ZX*Q{dm`H-x~x8@uUf~YRjCh%dC(}GZxPj# zF2Cwztwr8@NNx6V)ng~!75UoU2l>fN_wPU*if}HlR6Zb(L>GJ6Q zHt6m?9_`r4G{RczW}0@!_vnpBnW*J%t-xn?3>u&V>g!L;8LZw3XaRYy(W=B#&>L^T OCC{T;z8{|F4E_KYIU&UW delta 456 zcmX|-&q@MO6voe;@ehO{F4A2MSXr8*R#s37t=c9Ct=$9)6-*Cc;S-q8(5_8{&(TBl z9EHDcxHiL&bIy0Zd(XZ1y|^rv-ACTiFAS<=&Ngh*&gbR3>>+aenf$mdWusv-dVIcr zN*>Izma+J263kplt!)V5CYArfZ#Qj_7Lay*E27>b4}7G4d!1_DK2$;H=;4WoHITlp>*SjI#=Rn91LTn|kLI;N zvj%uHr{gukzjo|3oe|$SHJ*4;7r(VUzu75h11(Trhn};sdR@=~;M1& diff --git a/SHADE_Engine/src/Common/SHAllComponents.h b/SHADE_Engine/src/Common/SHAllComponents.h index 36b74853..ee900736 100644 --- a/SHADE_Engine/src/Common/SHAllComponents.h +++ b/SHADE_Engine/src/Common/SHAllComponents.h @@ -13,4 +13,5 @@ #include "Graphics/MiddleEnd/Interface/SHRenderable.h" #include "Physics/Interface/SHColliderComponent.h" #include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h" -#include "AudioSystem/SHAudioListenerComponent.h" \ No newline at end of file +#include "AudioSystem/SHAudioListenerComponent.h" +#include "Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h" diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp index af03ffa6..17b9a229 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp @@ -27,6 +27,8 @@ #include "Physics/Collision/Shapes/SHSphere.h" #include "../SHEditorWindowManager.h" #include "../AssetBrowser/SHAssetBrowser.h" +#include "Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderableComponent.h" + namespace SHADE { template @@ -679,4 +681,95 @@ namespace SHADE ImGui::PopID(); } + template<> + static void DrawComponent(SHTrajectoryRenderableComponent* component) + { + if (!component) + return; + + ImGui::PushID(SHFamilyID::GetID()); + + const auto componentType = rttr::type::get(*component); + + SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); + + ImGui::SameLine(); + if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen)) + { + DrawContextMenu(component); + Handle const& mesh = component->GetMesh(); + const auto MESH_NAME = SHResourceManager::GetAssetName(mesh).value_or(""); + SHEditorWidgets::DragDropReadOnlyField("Mesh", MESH_NAME, [component]() + { + Handle const& mesh = component->GetMesh(); + return SHResourceManager::GetAssetID(mesh).value_or(0); + }, + [component](AssetID const& id) + { + if (SHAssetManager::GetType(id) != AssetType::MESH) + { + SHLOG_WARNING("Attempted to assign non mesh asset to Renderable Mesh property!") + return; + } + component->SetMesh(SHResourceManager::LoadOrGet(id)); + SHResourceManager::FinaliseChanges(); + }, SHDragDrop::DRAG_RESOURCE); + + if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) + { + if (Handle const& mesh = component->GetMesh()) + { + AssetID assetID = SHResourceManager::GetAssetID(mesh).value_or(0); + SHEditorWindowManager::GetEditorWindow()->SetScrollTo(assetID); + } + } + + SHEditorWidgets::ColorPicker("Start Color", + [comp = component]() + { + SHVec4 newColor(comp->GetStartColor()); + newColor.w = comp->GetStartAlpha(); + return newColor; + }, + [comp = component](SHVec4 vec) + { + SHVec3 temp{vec.x, vec.y, vec.z}; + float a = vec.w; + comp->SetStartColor(temp); + comp->SetStartAlpha(a); + }); + + SHEditorWidgets::ColorPicker("End Color", + [comp = component]() + { + SHVec4 newColor(comp->GetEndColor()); + newColor.w = comp->GetEndAlpha(); + return newColor; + }, + [comp = component](SHVec4 vec) + { + SHVec3 temp{ vec.x, vec.y, vec.z }; + float a = vec.w; + comp->SetEndColor(temp); + comp->SetEndAlpha(a); + }); + + SHEditorWidgets::DragFloat("Color Evolve Rate", + [comp = component]() + { + return comp->GetColorEvolveRate(); + }, + [comp = component](float rate) + { + return comp->SetColorEvolveRate(rate); + }); + + } + else + { + DrawContextMenu(component); + } + ImGui::PopID(); + } + } diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h index 468cc0c7..d2fcb77e 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsConstants.h @@ -130,7 +130,7 @@ namespace SHADE static constexpr std::string_view GBUFFER_WRITE_VFX_SUBPASS = "G-Buffer Write With VFX"; static constexpr std::string_view UI_SUBPASS = "UI"; static constexpr std::string_view UI_TRANSLUCENT_SUBPASS = "UI Translucent"; - static constexpr std::string_view VFX_SUBPASS = "VFX"; + static constexpr std::string_view VFX_SUBPASS = "VFX Subpass"; static constexpr std::string_view OBJ_VFX_SUBPASS = "Object VFX Subpass No Depth"; static constexpr std::array USABLE_SUBPASSES = @@ -362,6 +362,7 @@ namespace SHADE */ /***************************************************************************/ static constexpr uint32_t TRAJECTORY_COLOR = 2; + static constexpr uint32_t TRAJECTORY_TRANSFORM = 3; static constexpr uint32_t CALCULATED_GLYPH_POSITION = 0; static constexpr uint32_t GLYPH_INDEX = 1; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 4681c4ae..e7f1ae68 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -337,7 +337,7 @@ namespace SHADE /* VFX PASS */ /*-----------------------------------------------------------------------*/ auto vfxPass = renderGraph->AddNode(SHGraphicsConstants::RenderGraphEntityNames::VFX_PASS.data(), { "Scene", "Depth Buffer" }, { SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data(), SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data() }); - auto vfxSubpass = vfxPass->AddSubpass("Vfx Subpass", worldViewport, worldRenderer); + auto vfxSubpass = vfxPass->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::VFX_SUBPASS.data(), worldViewport, worldRenderer); vfxSubpass->AddColorOutput("Scene"); vfxSubpass->AddDepthOutput("Depth Buffer"); vfxSubpass->AddExteriorDrawCalls([=](Handle cmdBuffer, Handle renderer, uint32_t frameIndex) @@ -485,8 +485,8 @@ namespace SHADE trajectoryRenderingSubSystem = resourceManager.Create(); - auto vfxNode = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::SCREEN_SPACE_PASS.data()); - trajectoryRenderingSubSystem->Init(device, vfxNode->GetRenderpass(), vfxNode->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::UI_SUBPASS), trajectoryVS, trajectoryFS); + auto vfxNode = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::VFX_PASS.data()); + trajectoryRenderingSubSystem->Init(device, vfxNode->GetRenderpass(), vfxNode->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::VFX_SUBPASS), trajectoryVS, trajectoryFS); SHGlobalDescriptorSets::SetLightingSubSystem(lightingSubSystem); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp index 61631925..cbf593d4 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.cpp @@ -68,6 +68,8 @@ namespace SHADE } pipeline->GetPipelineState().SetColorBlenState(colorBlendState); + + pipeline->ConstructPipeline(); } void SHTrajectoryRenderingSubSystem::Run(uint32_t frameIndex) noexcept @@ -75,12 +77,16 @@ namespace SHADE auto& comps = SHComponentManager::GetDense(); for (auto& comp : comps) { - comp.SetPositions(std::vector - { - SHVec3 {}, - SHVec3 {} - }); + //std::vector test{}; + //test.resize(10); + //float x = 0.0f; + //for (auto& vec : test) + //{ + // vec = SHVec3(x, 5.0f, 0.0f); + // x += 0.5f; + //} + //comp.SetPositions (test); // If has positions, feed data to buffer. if (comp.HasPositions()) { @@ -122,12 +128,13 @@ namespace SHADE transformData.push_back(trs); colorData.push_back(currentColor); + // evolve lerp value and clamp to 1 + lerpValue = std::min (1.0f, lerpValue + colorEvolveRate); + // evolve color currentColor = SHVec3::Lerp(startColor, endColor, lerpValue); currentColor.w = SHMath::Lerp (comp.GetStartAlpha(), comp.GetEndAlpha(), lerpValue); - // evolve lerp value and clamp to 1 - lerpValue = std::max (1.0f, lerpValue + colorEvolveRate); } // add draw data for this trajectory @@ -178,6 +185,9 @@ namespace SHADE // Bind color vertex buffer cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::TRAJECTORY_COLOR, colorBuffer, 0); + // Bind transform data + cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::TRAJECTORY_TRANSFORM, transformBuffer, 0); + // call draw call cmdBuffer->DrawMultiIndirect(drawDataBuffer, drawData.size()); diff --git a/SHADE_Engine/src/Serialization/SHSerialization.cpp b/SHADE_Engine/src/Serialization/SHSerialization.cpp index 13f5e36e..b6455935 100644 --- a/SHADE_Engine/src/Serialization/SHSerialization.cpp +++ b/SHADE_Engine/src/Serialization/SHSerialization.cpp @@ -247,6 +247,7 @@ namespace SHADE AddComponentToComponentNode(components, eid); AddComponentToComponentNode(components, eid); AddComponentToComponentNode(components, eid); + AddComponentToComponentNode(components, eid); node[ComponentsNode] = components; @@ -308,6 +309,7 @@ namespace SHADE AddComponentID(componentIDList, componentsNode); AddComponentID(componentIDList, componentsNode); AddComponentID(componentIDList, componentsNode); + AddComponentID(componentIDList, componentsNode); return componentIDList; } @@ -395,5 +397,6 @@ namespace SHADE SHSerializationHelper::InitializeComponentFromNode(componentsNode, eid); SHSerializationHelper::InitializeComponentFromNode(componentsNode, eid); SHSerializationHelper::InitializeComponentFromNode(componentsNode, eid); + SHSerializationHelper::InitializeComponentFromNode(componentsNode, eid); } } diff --git a/SHADE_Engine/src/Serialization/SHYAMLConverters.h b/SHADE_Engine/src/Serialization/SHYAMLConverters.h index 2c212e5f..ca0c0185 100644 --- a/SHADE_Engine/src/Serialization/SHYAMLConverters.h +++ b/SHADE_Engine/src/Serialization/SHYAMLConverters.h @@ -32,6 +32,8 @@ namespace YAML struct HasYAMLConv : std::true_type {}; template<> struct HasYAMLConv : std::true_type {}; + template<> + struct HasYAMLConv : std::true_type {}; template<> struct convert @@ -431,6 +433,8 @@ namespace YAML static constexpr std::string_view MESH_YAML_TAG = "Mesh"; static constexpr std::string_view START_COLOR_YAML_TAG = "Start Color"; static constexpr std::string_view END_COLOR_YAML_TAG = "End Color"; + static constexpr std::string_view START_ALPHA_YAML_TAG = "Start Alpha"; + static constexpr std::string_view END_ALPHA_YAML_TAG = "End Alpha"; static constexpr std::string_view COLOR_EVAL_RATE_YAML_TAG = "Color Eval Rate "; static YAML::Node encode(SHTrajectoryRenderableComponent const& rhs) @@ -438,7 +442,9 @@ namespace YAML YAML::Node node; node[MESH_YAML_TAG.data()] = SHResourceManager::GetAssetID(rhs.GetMesh()).value_or(0); node[START_COLOR_YAML_TAG.data()] = SHVec3(rhs.GetStartColor()); + node[START_ALPHA_YAML_TAG.data()] = rhs.GetStartAlpha(); node[END_COLOR_YAML_TAG.data()] = SHVec3(rhs.GetEndColor()); + node[END_ALPHA_YAML_TAG.data()] = rhs.GetEndAlpha(); node[COLOR_EVAL_RATE_YAML_TAG.data()] = rhs.GetColorEvolveRate(); return node; @@ -447,10 +453,19 @@ namespace YAML { if (node[MESH_YAML_TAG.data()].IsDefined()) rhs.SetMesh(SHResourceManager::LoadOrGet(node[MESH_YAML_TAG.data()].as())); + if (node[START_COLOR_YAML_TAG.data()].IsDefined()) rhs.SetStartColor(node[START_COLOR_YAML_TAG.data()].as()); + + if (node[START_ALPHA_YAML_TAG.data()].IsDefined()) + rhs.SetStartAlpha(node[START_ALPHA_YAML_TAG.data()].as()); + if (node[END_COLOR_YAML_TAG.data()].IsDefined()) rhs.SetEndColor(node[END_COLOR_YAML_TAG.data()].as()); + + if (node[END_ALPHA_YAML_TAG.data()].IsDefined()) + rhs.SetEndAlpha(node[END_ALPHA_YAML_TAG.data()].as()); + if (node[COLOR_EVAL_RATE_YAML_TAG.data()].IsDefined()) rhs.SetColorEvolveRate(node[COLOR_EVAL_RATE_YAML_TAG.data()].as()); -- 2.40.1 From e05e21ec5a3ef3a17caafde76ae306dcf5c3cebd Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Thu, 2 Mar 2023 15:49:28 +0800 Subject: [PATCH 2/3] Added text size for text renderable component --- .../EditorWindow/Inspector/SHEditorComponentView.hpp | 2 +- .../TextRendering/SHTextRenderableComponent.cpp | 12 ++++++++++++ .../TextRendering/SHTextRenderableComponent.h | 5 +++++ .../TextRendering/SHTextRenderingSubSystem.cpp | 7 +++++-- SHADE_Engine/src/Serialization/SHYAMLConverters.h | 8 +++++++- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp index 17b9a229..8adb45b5 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp @@ -601,7 +601,7 @@ namespace SHADE component->SetText(val); } ); - + SHEditorWidgets::DragVec3("Text Size", { "X", "Y", "Z" }, [&textComp = component]() {return textComp->GetTextSize();}, [&textComp = component](SHVec3 const& size) {textComp->SetTextSize(size); }); SHEditorWidgets::ColorPicker("Color", [&textComp = component]() {return textComp->GetColor(); }, [&textComp = component](SHVec4 const& newColor) {textComp->SetColor(newColor); }); } else diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.cpp index 3edf0983..5703a9c1 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.cpp @@ -29,6 +29,8 @@ namespace SHADE // Default white color. color = SHColour::WHITE; + + textSize = SHVec3::One; } void SHTextRenderableComponent::OnDestroy(void) @@ -66,6 +68,11 @@ namespace SHADE color = newColor; } + void SHTextRenderableComponent::SetTextSize(SHVec3 const& size) noexcept + { + textSize = size; + } + /***************************************************************************/ /*! @@ -92,6 +99,11 @@ namespace SHADE return color; } + SHVec3 const& SHTextRenderableComponent::GetTextSize(void) const noexcept + { + return textSize; + } + } namespace rttr diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h index 9d31cdd8..81d3a85f 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h @@ -40,6 +40,9 @@ namespace SHADE //! character position data for each letter in the text Handle charPositionDataBuffer; + //! Text size. Multiplied to TRS. + SHVec3 textSize; + void MakeDirty (void) noexcept; void Clean (void) noexcept; @@ -53,10 +56,12 @@ namespace SHADE void SetText (std::string_view newText) noexcept; void SetFont(Handle font) noexcept; void SetColor(SHColour const& newColor) noexcept; + void SetTextSize (SHVec3 const& size) noexcept; std::string const& GetText (void) const noexcept; Handle GetFont (void) const noexcept; SHColour const& GetColor (void) const noexcept; + SHVec3 const& GetTextSize (void) const noexcept; friend class SHTextRenderingSubSystem; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp index 9ab6106d..ff9168c9 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp @@ -210,10 +210,13 @@ namespace SHADE cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::CALCULATED_GLYPH_POSITION, comp.charPositionDataBuffer, 0); cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::GLYPH_INDEX, comp.indexingDataBuffer, 0); + auto const& textSize = comp.textSize; + SHMatrix textSizeScale{textSize.x, 0.0f, 0.0f, 0.0f, 0.0f, textSize.y, 0.0f, 0.0f, 0.0f, 0.0f, textSize.z, 0.0f}; + if (auto* uiComp = SHComponentManager::GetComponent_s(comp.GetEID())) - cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", uiComp->GetMatrix(), SH_PIPELINE_TYPE::GRAPHICS); + cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", textSizeScale * uiComp->GetMatrix(), SH_PIPELINE_TYPE::GRAPHICS); else - cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", transform->GetTRS(), SH_PIPELINE_TYPE::GRAPHICS); + cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", textSizeScale * transform->GetTRS(), SH_PIPELINE_TYPE::GRAPHICS); cmdBuffer->SetPushConstantVariable("TestPushConstant.eid", comp.GetEID(), SH_PIPELINE_TYPE::GRAPHICS); diff --git a/SHADE_Engine/src/Serialization/SHYAMLConverters.h b/SHADE_Engine/src/Serialization/SHYAMLConverters.h index ca0c0185..bd714fd3 100644 --- a/SHADE_Engine/src/Serialization/SHYAMLConverters.h +++ b/SHADE_Engine/src/Serialization/SHYAMLConverters.h @@ -357,6 +357,7 @@ namespace YAML static constexpr std::string_view TEXT_YAML_TAG = "Text"; static constexpr std::string_view FONT_YAML_TAG = "Font"; static constexpr std::string_view COLOR_YAML_TAG = "Color"; + static constexpr std::string_view TEXT_SIZE_YAML_TAG = "Text Size"; static YAML::Node encode(SHTextRenderableComponent const& rhs) { @@ -372,7 +373,8 @@ namespace YAML { node[FONT_YAML_TAG.data()] = 0; } - node[COLOR_YAML_TAG.data()] = SHVec4 (textColor); + node[COLOR_YAML_TAG.data()] = SHVec4(textColor); + node[TEXT_SIZE_YAML_TAG.data()] = rhs.GetTextSize(); return node; } static bool decode(YAML::Node const& node, SHTextRenderableComponent& rhs) @@ -395,6 +397,10 @@ namespace YAML { rhs.SetColor(node[COLOR_YAML_TAG.data()].as()); } + if (node[TEXT_SIZE_YAML_TAG.data()].IsDefined()) + { + rhs.SetTextSize(node[TEXT_SIZE_YAML_TAG.data()].as()); + } return true; } }; -- 2.40.1 From 61a877cee14ebb55ae8f4b26cc762e3e46461f47 Mon Sep 17 00:00:00 2001 From: Brandon Mak Date: Thu, 2 Mar 2023 16:04:22 +0800 Subject: [PATCH 3/3] Fixed bug texture loading - During mipmap transfer to GPU, height would sometimes be 0. Fixed it using std::max --- Assets/Shaders/UI_FS.glsl | 2 +- Assets/Shaders/UI_FS.shshaderb | Bin 2125 -> 2125 bytes .../src/Graphics/Images/SHVkImage.cpp | 2 +- .../MiddleEnd/Textures/SHTextureLibrary.h | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/Shaders/UI_FS.glsl b/Assets/Shaders/UI_FS.glsl index 30b59e48..3c66891b 100644 --- a/Assets/Shaders/UI_FS.glsl +++ b/Assets/Shaders/UI_FS.glsl @@ -37,7 +37,7 @@ layout(location = 1) out uint outEntityID; void main() { fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); - if (fragColor.a < 0.01f) + if (fragColor.a < 0.1f) { discard; } diff --git a/Assets/Shaders/UI_FS.shshaderb b/Assets/Shaders/UI_FS.shshaderb index 92f4ed4ece0ecf30a998c0cac1a7117aa46cd281..d734949d4a6a368e405562b731d7f6de5c8bffab 100644 GIT binary patch delta 17 YcmX>ra8_UgFB{9*Gd{MP1=(zv06OgjtN;K2 delta 17 YcmX>ra8_UgFB=Qjb!D5)f^0TS05e4d$^ZZW diff --git a/SHADE_Engine/src/Graphics/Images/SHVkImage.cpp b/SHADE_Engine/src/Graphics/Images/SHVkImage.cpp index 53703924..28870797 100644 --- a/SHADE_Engine/src/Graphics/Images/SHVkImage.cpp +++ b/SHADE_Engine/src/Graphics/Images/SHVkImage.cpp @@ -262,7 +262,7 @@ namespace SHADE copyRegions[i].imageSubresource.baseArrayLayer = 0; // TODO: Array textures not supported yet copyRegions[i].imageSubresource.layerCount = layerCount; copyRegions[i].imageOffset = vk::Offset3D{ 0,0,0 }; - copyRegions[i].imageExtent = vk::Extent3D{ width >> i, height >> i, 1 }; + copyRegions[i].imageExtent = vk::Extent3D{ std::max (1u, width >> i), std::max (1u, height >> i), 1 }; } cmdBufferHdl->CopyBufferToImage(stagingBuffer, vkImage, copyRegions); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h index bbc72a1a..e1c93349 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Textures/SHTextureLibrary.h @@ -71,7 +71,7 @@ namespace SHADE //! of the texture library would mean the recreation of the desc set that also //! involves the generic data, which is bad bad bad. Solution is to separate the //! 2 desc sets. - static constexpr uint32_t DEFAULT_MAX_TEXTURES = 2000; + static constexpr uint32_t DEFAULT_MAX_TEXTURES = 1000; /*-----------------------------------------------------------------------------*/ /* Usage Functions */ -- 2.40.1