From 186ce699b17610b03c28a6401bc7e537592a76e9 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:14:32 +0000 Subject: [PATCH 001/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h index d5cd22191b..b1b3ae24cb 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h @@ -27,7 +27,5 @@ struct ERS_STRUCT_RendererSettings { int ShadowMapY_ = 2048; - // Indicate If Settings Have Changed - bool HaveSettingsChanged_ = false; }; \ No newline at end of file From fb6af3cdcc53449ca5a5ba5aaa3d9864798c592c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:16:20 +0000 Subject: [PATCH 002/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_RendererSettings.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h index b1b3ae24cb..5dbeba1bc6 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h @@ -26,6 +26,11 @@ struct ERS_STRUCT_RendererSettings { int ShadowMapX_ = 2048; int ShadowMapY_ = 2048; + // Set Shadow Filtering Type + + // Set Max Shadow Updates Per Frame + int MaxShadowUpdatesPerFrame = 20; + }; \ No newline at end of file From 6b2e575339a1254e810291ed3ccdf39e1fc3c8d9 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:16:54 +0000 Subject: [PATCH 003/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_ShadowFilteringType.cpp | 0 .../ERS_STRUCT_ShadowFilteringType.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.cpp create mode 100644 Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.cpp b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h new file mode 100644 index 0000000000..6a35855e7e --- /dev/null +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h @@ -0,0 +1,16 @@ +//======================================================================// +// This file is part of the BrainGenix-ERS Environment Rendering System // +//======================================================================// + +#pragma once + +// Standard Libraries (BG convention: use <> instead of "") +#include + +// Third-Party Libraries (BG convention: use <> instead of "") + +// Internal Libraries (BG convention: use <> instead of "") + + + +/ \ No newline at end of file From 45e63475893c1aac2969a6741c6b180db77f95ef Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:17:14 +0000 Subject: [PATCH 004/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_ShadowFilteringType.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h index 6a35855e7e..c58d05a70a 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h @@ -13,4 +13,8 @@ -/ \ No newline at end of file +struct ERS_STRUCT_ShadowFilteringType { + + + +} \ No newline at end of file From 9b13b225f645b3c3ba3d3ab126533fe0c61a9a0b Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:17:55 +0000 Subject: [PATCH 005/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_ShadowFilteringType.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h index c58d05a70a..e7b84b22ed 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h @@ -12,9 +12,15 @@ // Internal Libraries (BG convention: use <> instead of "") +enum ERS_ShadowFilteringType { + + + +} + struct ERS_STRUCT_ShadowFilteringType { - -} \ No newline at end of file + +}; \ No newline at end of file From bc68cf5369179536581d6761b312d428fdc76352 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:20:32 +0000 Subject: [PATCH 006/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_ShadowFilteringType.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h index e7b84b22ed..4994a21b9f 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h @@ -12,15 +12,19 @@ // Internal Libraries (BG convention: use <> instead of "") -enum ERS_ShadowFilteringType { +namespace ERS { - + namespace Renderer { -} + enum ShadowFilteringType { + ERS_NO_FILTERING, + ERS_PCF_FILTERING, + ERS_POISSON_SAMPLING, + ERS_STRATIFIED_POISSON_SAMPLING -struct ERS_STRUCT_ShadowFilteringType { + }; + } - -}; \ No newline at end of file +} \ No newline at end of file From 94989967ff46a739f293286e02e341bb54e5925a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:21:07 +0000 Subject: [PATCH 007/203] Implement Settings To Control Rendering (#220) --- .../Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt | 1 + ..._ShadowFilteringType.cpp => ERS_ENUM_ShadowFilteringType.cpp} | 0 ...RUCT_ShadowFilteringType.h => ERS_ENUM_ShadowFilteringType.h} | 0 3 files changed, 1 insertion(+) rename Source/Core/Structures/ERS_STRUCT_RendererSettings/{ERS_STRUCT_ShadowFilteringType.cpp => ERS_ENUM_ShadowFilteringType.cpp} (100%) rename Source/Core/Structures/ERS_STRUCT_RendererSettings/{ERS_STRUCT_ShadowFilteringType.h => ERS_ENUM_ShadowFilteringType.h} (100%) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt b/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt index e68c81a51f..333caa68f5 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt @@ -8,6 +8,7 @@ add_library(ERS_STRUCT_RendererSettings # Add Source Files (.cpp) "ERS_STRUCT_RendererSettings.cpp" + "ERS_" # Add Header Files (.h) "ERS_STRUCT_RendererSettings.h" diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.cpp b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.cpp similarity index 100% rename from Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.cpp rename to Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.cpp diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.h similarity index 100% rename from Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_ShadowFilteringType.h rename to Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.h From a2cdf244fe6ab36846b8b4fdb793c4a3af3208cc Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:21:49 +0000 Subject: [PATCH 008/203] Implement Settings To Control Rendering (#220) --- .../Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt | 3 ++- .../ERS_ENUM_ShadowFilteringType.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt b/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt index 333caa68f5..cf28376e37 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt @@ -8,10 +8,11 @@ add_library(ERS_STRUCT_RendererSettings # Add Source Files (.cpp) "ERS_STRUCT_RendererSettings.cpp" - "ERS_" + "ERS_ENUM_ShadowFilteringType.cpp" # Add Header Files (.h) "ERS_STRUCT_RendererSettings.h" + "ERS_ENUM_ShadowFilteringType.h" ${BACKWARD_ENABLE} ) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.cpp b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.cpp index e69de29bb2..2113253903 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.cpp +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.cpp @@ -0,0 +1,5 @@ +//======================================================================// +// This file is part of the BrainGenix-ERS Environment Rendering System // +//======================================================================// + +#include \ No newline at end of file From a7ab1b8a71fb1700391b6fbf47dc318d68ce20b6 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:23:21 +0000 Subject: [PATCH 009/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_RendererSettings.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h index 5dbeba1bc6..722eee66ea 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h @@ -13,7 +13,7 @@ // Third-Party Libraries (BG convention: use <> instead of "") // Internal Libraries (BG convention: use <> instead of "") - +#include /** @@ -27,9 +27,10 @@ struct ERS_STRUCT_RendererSettings { int ShadowMapY_ = 2048; // Set Shadow Filtering Type + ERS::Renderer::ShadowFilteringType ShadowFilteringType_ = ERS::Renderer::ERS_PCF_FILTERING; // Set Max Shadow Updates Per Frame - int MaxShadowUpdatesPerFrame = 20; + int MaxShadowUpdatesPerFrame_ = 20; From cc51bf53851cee6d251d604eac4ae838f843ebce Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:23:49 +0000 Subject: [PATCH 010/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h index 722eee66ea..a038f3c0d4 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h @@ -32,6 +32,4 @@ struct ERS_STRUCT_RendererSettings { // Set Max Shadow Updates Per Frame int MaxShadowUpdatesPerFrame_ = 20; - - }; \ No newline at end of file From 136daca3cd3aaf880ac977b4d7a374c1c49042f0 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:26:00 +0000 Subject: [PATCH 011/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index 4f281f06d2..c1c1d47611 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -108,6 +108,8 @@ void Widget_RenderingSettings::Draw() { ImGui::InputInt2("Depth Map Resolution", DepthMapResolution_); Apply = ImGui::Button("Apply"); + ImGui::InputInt("Max Shadow Updates Per Frame", &SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_); + if (Apply) { SystemUtils_->RendererSettings_->ShadowMapX_ = DepthMapResolution_[0]; SystemUtils_->RendererSettings_->ShadowMapY_ = DepthMapResolution_[1]; From 031da0ad6ccf12891a3e3a03a8fc489b7c2de4b0 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:26:47 +0000 Subject: [PATCH 012/203] Implement Settings To Control Rendering (#220) --- .../ERS_ENUM_ShadowUpdateMode.cpp | 5 ++++ .../ERS_ENUM_ShadowUpdateMode.h | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.cpp create mode 100644 Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.cpp b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.cpp new file mode 100644 index 0000000000..32270f38ef --- /dev/null +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.cpp @@ -0,0 +1,5 @@ +//======================================================================// +// This file is part of the BrainGenix-ERS Environment Rendering System // +//======================================================================// + +#include \ No newline at end of file diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h new file mode 100644 index 0000000000..acca69ec96 --- /dev/null +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h @@ -0,0 +1,30 @@ +//======================================================================// +// This file is part of the BrainGenix-ERS Environment Rendering System // +//======================================================================// + +#pragma once + +// Standard Libraries (BG convention: use <> instead of "") +#include + +// Third-Party Libraries (BG convention: use <> instead of "") + +// Internal Libraries (BG convention: use <> instead of "") + + +namespace ERS { + + namespace Renderer { + + enum ShadowUpdateMode { + + ERS_NO_FILTERING, + ERS_PCF_FILTERING, + ERS_POISSON_SAMPLING, + ERS_STRATIFIED_POISSON_SAMPLING + + }; + + } + +} \ No newline at end of file From 99cbd551d2189ed7d66ce547be66eee3f2ac15a3 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:27:16 +0000 Subject: [PATCH 013/203] Implement Settings To Control Rendering (#220) --- .../Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt b/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt index cf28376e37..7e66aac14a 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/CMakeLists.txt @@ -9,10 +9,13 @@ add_library(ERS_STRUCT_RendererSettings # Add Source Files (.cpp) "ERS_STRUCT_RendererSettings.cpp" "ERS_ENUM_ShadowFilteringType.cpp" + "ERS_ENUM_ShadowUpdateMode.cpp" + # Add Header Files (.h) "ERS_STRUCT_RendererSettings.h" "ERS_ENUM_ShadowFilteringType.h" + "ERS_ENUM_ShadowUpdateMode.h" ${BACKWARD_ENABLE} ) From 217f2875cd84ab54eebd7f548ab46b44d334e34e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:29:18 +0000 Subject: [PATCH 014/203] Implement Settings To Control Rendering (#220) --- .../ERS_ENUM_ShadowUpdateMode.h | 9 +++++---- .../ERS_STRUCT_RendererSettings.h | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h index acca69ec96..9252b5dc71 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h @@ -18,10 +18,11 @@ namespace ERS { enum ShadowUpdateMode { - ERS_NO_FILTERING, - ERS_PCF_FILTERING, - ERS_POISSON_SAMPLING, - ERS_STRATIFIED_POISSON_SAMPLING + ERS_NO_SHADOW_UPDATES, + ERS_RANDOM_SHADOW_UPDATES, + ERS_CONSECUTIVE_SHADOW_UPDATES, + ERS_DISTANCE_PRIORITIZED_SHADOW_UPDATES, + ERS_ALL_SHADOW_UPDATES }; diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h index a038f3c0d4..fc2276579a 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h @@ -26,10 +26,9 @@ struct ERS_STRUCT_RendererSettings { int ShadowMapX_ = 2048; int ShadowMapY_ = 2048; - // Set Shadow Filtering Type + // Set Shadow Update Settings ERS::Renderer::ShadowFilteringType ShadowFilteringType_ = ERS::Renderer::ERS_PCF_FILTERING; - // Set Max Shadow Updates Per Frame int MaxShadowUpdatesPerFrame_ = 20; }; \ No newline at end of file From be5858ac0c39a7ddc2463f9bd3af4578afec291f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:30:54 +0000 Subject: [PATCH 015/203] Implement Settings To Control Rendering (#220) --- .../ERS_ENUM_ShadowFilteringType.h | 8 ++++---- .../ERS_STRUCT_RendererSettings.h | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.h index 4994a21b9f..798072ba30 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.h @@ -18,10 +18,10 @@ namespace ERS { enum ShadowFilteringType { - ERS_NO_FILTERING, - ERS_PCF_FILTERING, - ERS_POISSON_SAMPLING, - ERS_STRATIFIED_POISSON_SAMPLING + ERS_SHADOW_FILTERING_NO_FILTERING, + ERS_SHADOW_FILTERING_PCF_FILTERING, + ERS_SHADOW_FILTERING_POISSON_SAMPLING, + ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING }; diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h index fc2276579a..e719ae89e4 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h @@ -14,6 +14,7 @@ // Internal Libraries (BG convention: use <> instead of "") #include +#include /** @@ -28,7 +29,7 @@ struct ERS_STRUCT_RendererSettings { // Set Shadow Update Settings ERS::Renderer::ShadowFilteringType ShadowFilteringType_ = ERS::Renderer::ERS_PCF_FILTERING; - + ERS::Renderer::ShadowUpdateMode ShadowUpdateMode_ = ERS::Renderer::ERS_ int MaxShadowUpdatesPerFrame_ = 20; }; \ No newline at end of file From e0141a26966c0006987aa5407b231d14f848b61d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:31:33 +0000 Subject: [PATCH 016/203] Implement Settings To Control Rendering (#220) --- .../ERS_ENUM_ShadowUpdateMode.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h index 9252b5dc71..c306f80446 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowUpdateMode.h @@ -18,11 +18,11 @@ namespace ERS { enum ShadowUpdateMode { - ERS_NO_SHADOW_UPDATES, - ERS_RANDOM_SHADOW_UPDATES, - ERS_CONSECUTIVE_SHADOW_UPDATES, - ERS_DISTANCE_PRIORITIZED_SHADOW_UPDATES, - ERS_ALL_SHADOW_UPDATES + ERS_SHADOW_UPDATE_MODE_DISABLED, + ERS_SHADOW_UPDATE_MODE_RANDOM, + ERS_SHADOW_UPDATE_MODE_CONSECUTIVE, + ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED, + ERS_SHADOW_UPDATE_MODE_ALL }; From ff0ea38f8afcd49b552e1d21966aea2c227c5a68 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:31:45 +0000 Subject: [PATCH 017/203] Implement Settings To Control Rendering (#220) --- .../ERS_ENUM_ShadowFilteringType.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.h index 798072ba30..da38374398 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_ENUM_ShadowFilteringType.h @@ -18,8 +18,8 @@ namespace ERS { enum ShadowFilteringType { - ERS_SHADOW_FILTERING_NO_FILTERING, - ERS_SHADOW_FILTERING_PCF_FILTERING, + ERS_SHADOW_FILTERING_DISABLED, + ERS_SHADOW_FILTERING_PCF, ERS_SHADOW_FILTERING_POISSON_SAMPLING, ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING From 0d01372bfec4a894401a76ae7ea1dcdfceed6d80 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:32:11 +0000 Subject: [PATCH 018/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h index e719ae89e4..b6b55c7302 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h @@ -28,8 +28,8 @@ struct ERS_STRUCT_RendererSettings { int ShadowMapY_ = 2048; // Set Shadow Update Settings - ERS::Renderer::ShadowFilteringType ShadowFilteringType_ = ERS::Renderer::ERS_PCF_FILTERING; - ERS::Renderer::ShadowUpdateMode ShadowUpdateMode_ = ERS::Renderer::ERS_ + ERS::Renderer::ShadowFilteringType ShadowFilteringType_ = ERS::Renderer::ERS_SHADOW_FILTERING_PCF; + ERS::Renderer::ShadowUpdateMode ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL; int MaxShadowUpdatesPerFrame_ = 20; }; \ No newline at end of file From 71828c282cb0dab589b58ce06c45ab65421b5fe8 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:42:05 +0000 Subject: [PATCH 019/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/CMakeLists.txt | 1 + .../Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Source/Core/Editor/Widgets/CMakeLists.txt b/Source/Core/Editor/Widgets/CMakeLists.txt index b362046ddb..147922d73a 100644 --- a/Source/Core/Editor/Widgets/CMakeLists.txt +++ b/Source/Core/Editor/Widgets/CMakeLists.txt @@ -50,6 +50,7 @@ target_link_libraries(Widgets ERS_STRUCT_HardwareInfo ERS_STRUCT_Scene ERS_STRUCT_ProjectUtils + ERS_STRUCT_RendererSettings ERS_SceneManager diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index c1c1d47611..accb45ff40 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -110,6 +110,13 @@ void Widget_RenderingSettings::Draw() { ImGui::InputInt("Max Shadow Updates Per Frame", &SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_); + + int SelectedShadowFiltering = 0; + + + + ImGui::Combo("Shadow Filtering", ) + if (Apply) { SystemUtils_->RendererSettings_->ShadowMapX_ = DepthMapResolution_[0]; SystemUtils_->RendererSettings_->ShadowMapY_ = DepthMapResolution_[1]; From ae2c57754f6ab3aad49d631ac5053e1c1559899d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:42:45 +0000 Subject: [PATCH 020/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h index ba3c2ea3df..62b570565c 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h @@ -16,6 +16,10 @@ // Internal Libraries (BG convention: use <> instead of "") #include +#include + +#include +#include From de7fc28bb7fb28e47d969d4ca57ab2566ac315dd Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:43:49 +0000 Subject: [PATCH 021/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index accb45ff40..d6063a19d1 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -103,6 +103,7 @@ void Widget_RenderingSettings::Draw() { ImGui::Separator(); ImGui::Spacing(); bool Apply = false; + ERS_STRUCT_RendererSettings* = SystemUtils_->RendererSettings_.get(); ImGui::InputInt2("Depth Map Resolution", DepthMapResolution_); From 25b5df547e673163f10c29fd2ce644996bcba579 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:44:58 +0000 Subject: [PATCH 022/203] Implement Settings To Control Rendering (#220) --- .../Widgets/GUI_Widget_RenderingSettings.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index d6063a19d1..e402975910 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -103,24 +103,27 @@ void Widget_RenderingSettings::Draw() { ImGui::Separator(); ImGui::Spacing(); bool Apply = false; - ERS_STRUCT_RendererSettings* = SystemUtils_->RendererSettings_.get(); + ERS_STRUCT_RendererSettings* Settings = SystemUtils_->RendererSettings_.get(); + int SelectedShadowFiltering = 0; + int SelectedShadowUpdates = 0; + + ImGui::InputInt2("Depth Map Resolution", DepthMapResolution_); Apply = ImGui::Button("Apply"); - ImGui::InputInt("Max Shadow Updates Per Frame", &SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_); + ImGui::InputInt("Max Shadow Updates Per Frame", &Settings->MaxShadowUpdatesPerFrame_); + - int SelectedShadowFiltering = 0; - ImGui::Combo("Shadow Filtering", ) if (Apply) { - SystemUtils_->RendererSettings_->ShadowMapX_ = DepthMapResolution_[0]; - SystemUtils_->RendererSettings_->ShadowMapY_ = DepthMapResolution_[1]; + Settings->ShadowMapX_ = DepthMapResolution_[0]; + Settings->ShadowMapY_ = DepthMapResolution_[1]; } From 4e4d1fc80dc59b18d8d0323d4b10bb87d37be1a9 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:49:00 +0000 Subject: [PATCH 023/203] Implement Settings To Control Rendering (#220) --- .../Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index e402975910..5e26569a37 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -107,7 +107,17 @@ void Widget_RenderingSettings::Draw() { int SelectedShadowFiltering = 0; int SelectedShadowUpdates = 0; - + if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_DISABLED) { + SelectedShadowFiltering = 0; + } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_PCF) { + SelectedShadowFiltering = 1; + } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_POISSON_SAMPLING) { + SelectedShadowFiltering = 2; + } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING) { + SelectedShadowFiltering = 3; + } + + ImGui::InputInt2("Depth Map Resolution", DepthMapResolution_); From 006db0e03551cd24870a1587e15416f9c4e0037d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:52:24 +0000 Subject: [PATCH 024/203] Implement Settings To Control Rendering (#220) --- .../Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index 5e26569a37..116b9db41d 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -117,6 +117,17 @@ void Widget_RenderingSettings::Draw() { SelectedShadowFiltering = 3; } + if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { + SelectedShadowUpdates = 0; + } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { + SelectedShadowUpdates = 1; + } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { + SelectedShadowUpdates = 2; + } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { + SelectedShadowUpdates = 3; + } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { + SelectedShadowUpdates = 4; + } From 4e1d7bc3e0fa3e0c3af4e8466d02b01ff7ed3d35 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:54:16 +0000 Subject: [PATCH 025/203] Implement Settings To Control Rendering (#220) --- .../Widgets/GUI_Widget_RenderingSettings.cpp | 22 ++++++++++++++----- .../Widgets/GUI_Widget_RenderingSettings.h | 3 ++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index 116b9db41d..5f498da778 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -104,8 +104,21 @@ void Widget_RenderingSettings::Draw() { ImGui::Spacing(); bool Apply = false; ERS_STRUCT_RendererSettings* Settings = SystemUtils_->RendererSettings_.get(); - int SelectedShadowFiltering = 0; - int SelectedShadowUpdates = 0; + + char* ShadowFilteringNames[] = { + "ERS_SHADOW_FILTERING_DISABLED", + "ERS_SHADOW_FILTERING_PCF", + "ERS_SHADOW_FILTERING_POISSON_SAMPLING", + "ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING" + }; + char* ShadowUpdateNames[] = { + "ERS_SHADOW_UPDATE_MODE_DISABLED", + "ERS_SHADOW_UPDATE_MODE_RANDOM", + "ERS_SHADOW_UPDATE_MODE_CONSECUTIVE", + "ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED", + "ERS_SHADOW_UPDATE_MODE_ALL" + }; + if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_DISABLED) { SelectedShadowFiltering = 0; @@ -137,10 +150,7 @@ void Widget_RenderingSettings::Draw() { ImGui::InputInt("Max Shadow Updates Per Frame", &Settings->MaxShadowUpdatesPerFrame_); - - - - ImGui::Combo("Shadow Filtering", ) + ImGui::Combo("Shadow Filtering", &SelectedShadowFiltering_, ShadowFilteringNames, 4); if (Apply) { Settings->ShadowMapX_ = DepthMapResolution_[0]; diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h index 62b570565c..e812805e2c 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h @@ -38,7 +38,8 @@ class Widget_RenderingSettings { // Variables To Store Input Data int DepthMapResolution_[2]; /**>Stores the value that the user is putting into the depth map input box*/ - + int SelectedShadowFiltering_ = 0; + int SelectedShadowUpdates_ = 0; public: From 9ee8575a33a77513c875ebc7bafa23f28a928d1f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:56:14 +0000 Subject: [PATCH 026/203] Implement Settings To Control Rendering (#220) --- .../Widgets/GUI_Widget_RenderingSettings.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index 5f498da778..f98961a788 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -121,25 +121,25 @@ void Widget_RenderingSettings::Draw() { if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_DISABLED) { - SelectedShadowFiltering = 0; + SelectedShadowFiltering_ = 0; } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_PCF) { - SelectedShadowFiltering = 1; + SelectedShadowFiltering_ = 1; } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_POISSON_SAMPLING) { - SelectedShadowFiltering = 2; + SelectedShadowFiltering_ = 2; } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING) { - SelectedShadowFiltering = 3; + SelectedShadowFiltering_ = 3; } if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { - SelectedShadowUpdates = 0; + SelectedShadowUpdates_ = 0; } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { - SelectedShadowUpdates = 1; + SelectedShadowUpdates_ = 1; } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { - SelectedShadowUpdates = 2; + SelectedShadowUpdates_ = 2; } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { - SelectedShadowUpdates = 3; + SelectedShadowUpdates_ = 3; } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { - SelectedShadowUpdates = 4; + SelectedShadowUpdates_ = 4; } From bf23537accd0ac36839d8cf1a9849e182d8b7aeb Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 22:57:26 +0000 Subject: [PATCH 027/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index f98961a788..f1004455cf 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -151,6 +151,8 @@ void Widget_RenderingSettings::Draw() { ImGui::Combo("Shadow Filtering", &SelectedShadowFiltering_, ShadowFilteringNames, 4); + ImGui::Combo("Shadow Update Mode", &SelectedShadowUpdates_, ShadowUpdateNames, 5); + if (Apply) { Settings->ShadowMapX_ = DepthMapResolution_[0]; From 7c0f6494dbe6f6462aa94c203ed52f754ae47ca4 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:01:06 +0000 Subject: [PATCH 028/203] Implement Settings To Control Rendering (#220) --- .../Widgets/GUI_Widget_RenderingSettings.cpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index f1004455cf..4c395a64b7 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -157,6 +157,31 @@ void Widget_RenderingSettings::Draw() { if (Apply) { Settings->ShadowMapX_ = DepthMapResolution_[0]; Settings->ShadowMapY_ = DepthMapResolution_[1]; + + + + if (SelectedShadowFiltering_ == 0) { + Settings->ShadowFilteringType_ = ERS::Renderer::ERS_SHADOW_FILTERING_DISABLED; + } else if (SelectedShadowFiltering_ == 1) { + Settings->ShadowFilteringType_ = ERS::Renderer::ERS_SHADOW_FILTERING_PCF; + } else if (SelectedShadowFiltering_ == 2) { + Settings->ShadowFilteringType_ = ERS::Renderer::ERS_SHADOW_FILTERING_POISSON_SAMPLING; + } else if (SelectedShadowFiltering_ == 3) { + Settings->ShadowFilteringType_ = ERS::Renderer::ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING; + } + + if (SelectedShadowUpdates_ == 0) { + Settings->ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED; + } else if (SelectedShadowUpdates_ == 1) { + Settings->ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM; + } else if (SelectedShadowUpdates_ == 2) { + Settings->ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE; + } else if (SelectedShadowUpdates_ == 3) { + Settings->ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED; + } else if (SelectedShadowUpdates_ == 4) { + Settings->ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL; + } + } From a51b626d3ee688cf7f3f81661eab2c7baf17a38f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:01:34 +0000 Subject: [PATCH 029/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index 4c395a64b7..5613b67b20 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -158,8 +158,6 @@ void Widget_RenderingSettings::Draw() { Settings->ShadowMapX_ = DepthMapResolution_[0]; Settings->ShadowMapY_ = DepthMapResolution_[1]; - - if (SelectedShadowFiltering_ == 0) { Settings->ShadowFilteringType_ = ERS::Renderer::ERS_SHADOW_FILTERING_DISABLED; } else if (SelectedShadowFiltering_ == 1) { From 9778a6b51f1b590704c3abe7e45b7a5314d3b508 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:03:02 +0000 Subject: [PATCH 030/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index 5613b67b20..8af428b988 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -105,13 +105,13 @@ void Widget_RenderingSettings::Draw() { bool Apply = false; ERS_STRUCT_RendererSettings* Settings = SystemUtils_->RendererSettings_.get(); - char* ShadowFilteringNames[] = { + const char* ShadowFilteringNames[] = { "ERS_SHADOW_FILTERING_DISABLED", "ERS_SHADOW_FILTERING_PCF", "ERS_SHADOW_FILTERING_POISSON_SAMPLING", "ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING" }; - char* ShadowUpdateNames[] = { + const char* ShadowUpdateNames[] = { "ERS_SHADOW_UPDATE_MODE_DISABLED", "ERS_SHADOW_UPDATE_MODE_RANDOM", "ERS_SHADOW_UPDATE_MODE_CONSECUTIVE", From 842f9a22f892b22ad3836e464a3e628b0874ac59 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:04:37 +0000 Subject: [PATCH 031/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index 8af428b988..79969173e5 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -143,17 +143,17 @@ void Widget_RenderingSettings::Draw() { } - + // Draw Buttons/Input Fields ImGui::InputInt2("Depth Map Resolution", DepthMapResolution_); - Apply = ImGui::Button("Apply"); ImGui::InputInt("Max Shadow Updates Per Frame", &Settings->MaxShadowUpdatesPerFrame_); - ImGui::Combo("Shadow Filtering", &SelectedShadowFiltering_, ShadowFilteringNames, 4); ImGui::Combo("Shadow Update Mode", &SelectedShadowUpdates_, ShadowUpdateNames, 5); + // Handle Apply Button + Apply = ImGui::Button("Apply"); if (Apply) { Settings->ShadowMapX_ = DepthMapResolution_[0]; Settings->ShadowMapY_ = DepthMapResolution_[1]; From 762625996eed7dde30c7c9af66608074267d6577 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:06:16 +0000 Subject: [PATCH 032/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h index e812805e2c..a6d1c11bbb 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.h @@ -43,7 +43,7 @@ class Widget_RenderingSettings { public: - bool Enabled_ = false; /** Date: Tue, 21 Jun 2022 23:08:37 +0000 Subject: [PATCH 033/203] Implement Settings To Control Rendering (#220) --- Source/Core/Renderer/ERS_CLASS_VisualRenderer/CMakeLists.txt | 1 + .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 1 + .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h | 3 +++ 3 files changed, 5 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/CMakeLists.txt b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/CMakeLists.txt index 2b314d4333..211a798187 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/CMakeLists.txt +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/CMakeLists.txt @@ -77,6 +77,7 @@ target_link_libraries(ERS_CLASS_VisualRenderer ERS_STRUCT_Scene ERS_STRUCT_ProjectUtils ERS_STRUCT_OpenGLDefaults + ERS_STRUCT_RendererSettings ) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index c617f7ed6b..2b317f9430 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -459,6 +459,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S // Check Settings CheckSettings(); + // Fix Offset (Peter Panning) glCullFace(GL_FRONT); diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h index 4e22d2820f..1c5640d08c 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h @@ -31,6 +31,9 @@ #include #include +#include +#include + #include From 4d3076c4ab005debf6f908c30dcf0510ad273218 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:11:03 +0000 Subject: [PATCH 034/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_DepthMaps.cpp | 90 ++++++++++--------- 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 2b317f9430..a6b4fa0b72 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -459,68 +459,74 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S // Check Settings CheckSettings(); + ERS::Renderer::ShadowUpdateMode UpdateMode = SystemUtils_->RendererSettings_->ShadowUpdateMode_; - // Fix Offset (Peter Panning) - glCullFace(GL_FRONT); + // Ensure That Shadows Aren't Supposed To Be Disabled + if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { - // Get Active Scene - ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); + // Fix Offset (Peter Panning) + glCullFace(GL_FRONT); - // Handle Directional Lights - for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { + // Get Active Scene + ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); - // Extract Struct - ERS_STRUCT_DirectionalLight* Light = ActiveScene->DirectionalLights[i].get(); + // Handle Directional Lights + for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { - // Check If Light Has DepthMap - if (!Light->DepthMap.Initialized) { - Light->DepthMap = GenerateDepthMap2D(); - } + // Extract Struct + ERS_STRUCT_DirectionalLight* Light = ActiveScene->DirectionalLights[i].get(); - // Render To Depth Map - UpdateDepthMap(Light, DepthShader); + // Check If Light Has DepthMap + if (!Light->DepthMap.Initialized) { + Light->DepthMap = GenerateDepthMap2D(); + } - } + // Render To Depth Map + UpdateDepthMap(Light, DepthShader); - // Handle Spot Lights - for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { + } - // Extract Struct - ERS_STRUCT_SpotLight* Light = ActiveScene->SpotLights[i].get(); + // Handle Spot Lights + for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { - // Check If Light Has DepthMap - if (!Light->DepthMap.Initialized) { - Light->DepthMap = GenerateDepthMap2D(); - } + // Extract Struct + ERS_STRUCT_SpotLight* Light = ActiveScene->SpotLights[i].get(); - // Render To Depth Map - UpdateDepthMap(Light, DepthShader); + // Check If Light Has DepthMap + if (!Light->DepthMap.Initialized) { + Light->DepthMap = GenerateDepthMap2D(); + } - } + // Render To Depth Map + UpdateDepthMap(Light, DepthShader); - // Handle Point Lights - glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); - glClear(GL_DEPTH_BUFFER_BIT); + } - for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { + // Handle Point Lights + glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); + glClear(GL_DEPTH_BUFFER_BIT); - // Extract Struct - ERS_STRUCT_PointLight* Light = ActiveScene->PointLights[i].get(); + for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { - // Check If Light Has DepthMap - if (!Light->DepthMap.Initialized) { - Light->DepthMap.DepthMapTextureIndex = AllocateDepthMapIndexCubemap(); - Light->DepthMap.Initialized = true; - } + // Extract Struct + ERS_STRUCT_PointLight* Light = ActiveScene->PointLights[i].get(); + + // Check If Light Has DepthMap + if (!Light->DepthMap.Initialized) { + Light->DepthMap.DepthMapTextureIndex = AllocateDepthMapIndexCubemap(); + Light->DepthMap.Initialized = true; + } - // Render To Depth Map - UpdateDepthMap(Light, CubemapDepthShader); + // Render To Depth Map + UpdateDepthMap(Light, CubemapDepthShader); - } + } - // Return To Normal Culling - glCullFace(GL_BACK); + // Return To Normal Culling + glCullFace(GL_BACK); + + } } \ No newline at end of file From d696ec61705cc86900ac3aee51df68b4a309883c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:12:18 +0000 Subject: [PATCH 035/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index a6b4fa0b72..5006f87faa 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -461,9 +461,11 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S ERS::Renderer::ShadowUpdateMode UpdateMode = SystemUtils_->RendererSettings_->ShadowUpdateMode_; + // Ensure That Shadows Aren't Supposed To Be Disabled if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { + // Fix Offset (Peter Panning) glCullFace(GL_FRONT); @@ -527,6 +529,8 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S // Return To Normal Culling glCullFace(GL_BACK); + + } } \ No newline at end of file From af9418fedb542c1c64deb4c415620e2868db0791 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:16:23 +0000 Subject: [PATCH 036/203] Implement Settings To Control Rendering (#220) --- .../Widgets/GUI_Widget_RenderingSettings.cpp | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index 79969173e5..b32aca5c0a 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -13,9 +13,31 @@ Widget_RenderingSettings::Widget_RenderingSettings(ERS_STRUCT_SystemUtils* Syste SystemUtils_->Logger_->Log("Setting Up Default Renderer Setting Input Fields", 3); SystemUtils_->Logger_->Log("Copying Shadow Map Resolution", 2); - DepthMapResolution_[0] = SystemUtils_->RendererSettings_->ShadowMapX_; - DepthMapResolution_[1] = SystemUtils_->RendererSettings_->ShadowMapY_; + ERS_STRUCT_RendererSettings* Settings = SystemUtils_->RendererSettings_.get(); + DepthMapResolution_[0] = Settings->ShadowMapX_; + DepthMapResolution_[1] = Settings->ShadowMapY_; + + if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_DISABLED) { + SelectedShadowFiltering_ = 0; + } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_PCF) { + SelectedShadowFiltering_ = 1; + } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_POISSON_SAMPLING) { + SelectedShadowFiltering_ = 2; + } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING) { + SelectedShadowFiltering_ = 3; + } + if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { + SelectedShadowUpdates_ = 0; + } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { + SelectedShadowUpdates_ = 1; + } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { + SelectedShadowUpdates_ = 2; + } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { + SelectedShadowUpdates_ = 3; + } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { + SelectedShadowUpdates_ = 4; + } } @@ -120,27 +142,6 @@ void Widget_RenderingSettings::Draw() { }; - if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_DISABLED) { - SelectedShadowFiltering_ = 0; - } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_PCF) { - SelectedShadowFiltering_ = 1; - } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_POISSON_SAMPLING) { - SelectedShadowFiltering_ = 2; - } else if (Settings->ShadowFilteringType_ == ERS::Renderer::ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING) { - SelectedShadowFiltering_ = 3; - } - - if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { - SelectedShadowUpdates_ = 0; - } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { - SelectedShadowUpdates_ = 1; - } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { - SelectedShadowUpdates_ = 2; - } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { - SelectedShadowUpdates_ = 3; - } else if (Settings->ShadowUpdateMode_ == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { - SelectedShadowUpdates_ = 4; - } // Draw Buttons/Input Fields From 7e83d2f822c8c7a8a366b2e92ff3017ae0cc102e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:19:25 +0000 Subject: [PATCH 037/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h | 3 +-- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h index 1c5640d08c..e8307e64e7 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h @@ -31,8 +31,7 @@ #include #include -#include -#include + #include diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index 16afd5586f..aa145e553d 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -30,6 +30,8 @@ #include #include +#include +#include /** From 17d0b6e3e8bc311279447b9d8d5c8227859e973f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:19:49 +0000 Subject: [PATCH 038/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 7 ------- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 5006f87faa..8ef709bec0 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -459,12 +459,8 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S // Check Settings CheckSettings(); - ERS::Renderer::ShadowUpdateMode UpdateMode = SystemUtils_->RendererSettings_->ShadowUpdateMode_; - // Ensure That Shadows Aren't Supposed To Be Disabled - if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { - // Fix Offset (Peter Panning) glCullFace(GL_FRONT); @@ -530,7 +526,4 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S glCullFace(GL_BACK); - - } - } \ No newline at end of file diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index cbbdd64115..afcaf30e38 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -26,9 +26,16 @@ ERS_CLASS_ShadowMaps::~ERS_CLASS_ShadowMaps() { void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader) { + ERS::Renderer::ShadowUpdateMode UpdateMode = SystemUtils_->RendererSettings_->ShadowUpdateMode_; + + + // Ensure That Shadows Aren't Supposed To Be Disabled + if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { + // Update All Depth Maps ERS_CLASS_DepthMaps_->UpdateDepthMaps(DepthMapShader, CubemapDepthShader); + } // Provide Depth Map Textures From b574613e3c5debe6f51c5a7b8bec7adccdd4030e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:20:27 +0000 Subject: [PATCH 039/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_DepthMaps.cpp | 87 +++++++++---------- 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 8ef709bec0..305c989256 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -456,74 +456,71 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_STRUCT_Shader* CubemapDepthShader) { - // Check Settings - CheckSettings(); - - // Fix Offset (Peter Panning) - glCullFace(GL_FRONT); + // Fix Offset (Peter Panning) + glCullFace(GL_FRONT); - // Get Active Scene - ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); + // Get Active Scene + ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); - // Handle Directional Lights - for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { + // Handle Directional Lights + for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { - // Extract Struct - ERS_STRUCT_DirectionalLight* Light = ActiveScene->DirectionalLights[i].get(); + // Extract Struct + ERS_STRUCT_DirectionalLight* Light = ActiveScene->DirectionalLights[i].get(); - // Check If Light Has DepthMap - if (!Light->DepthMap.Initialized) { - Light->DepthMap = GenerateDepthMap2D(); - } + // Check If Light Has DepthMap + if (!Light->DepthMap.Initialized) { + Light->DepthMap = GenerateDepthMap2D(); + } - // Render To Depth Map - UpdateDepthMap(Light, DepthShader); + // Render To Depth Map + UpdateDepthMap(Light, DepthShader); - } + } - // Handle Spot Lights - for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { + // Handle Spot Lights + for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { - // Extract Struct - ERS_STRUCT_SpotLight* Light = ActiveScene->SpotLights[i].get(); + // Extract Struct + ERS_STRUCT_SpotLight* Light = ActiveScene->SpotLights[i].get(); - // Check If Light Has DepthMap - if (!Light->DepthMap.Initialized) { - Light->DepthMap = GenerateDepthMap2D(); - } + // Check If Light Has DepthMap + if (!Light->DepthMap.Initialized) { + Light->DepthMap = GenerateDepthMap2D(); + } - // Render To Depth Map - UpdateDepthMap(Light, DepthShader); + // Render To Depth Map + UpdateDepthMap(Light, DepthShader); - } + } - // Handle Point Lights - glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); - glClear(GL_DEPTH_BUFFER_BIT); + // Handle Point Lights + glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); + glClear(GL_DEPTH_BUFFER_BIT); - for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { + for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { - // Extract Struct - ERS_STRUCT_PointLight* Light = ActiveScene->PointLights[i].get(); + // Extract Struct + ERS_STRUCT_PointLight* Light = ActiveScene->PointLights[i].get(); - // Check If Light Has DepthMap - if (!Light->DepthMap.Initialized) { - Light->DepthMap.DepthMapTextureIndex = AllocateDepthMapIndexCubemap(); - Light->DepthMap.Initialized = true; - } + // Check If Light Has DepthMap + if (!Light->DepthMap.Initialized) { + Light->DepthMap.DepthMapTextureIndex = AllocateDepthMapIndexCubemap(); + Light->DepthMap.Initialized = true; + } - // Render To Depth Map - UpdateDepthMap(Light, CubemapDepthShader); + // Render To Depth Map + UpdateDepthMap(Light, CubemapDepthShader); - } + } - // Return To Normal Culling - glCullFace(GL_BACK); + // Return To Normal Culling + glCullFace(GL_BACK); } \ No newline at end of file From 7ff3fe495828047402f8c6edfbd8d9a0ce78954e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:21:00 +0000 Subject: [PATCH 040/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h | 13 +++++++------ .../ERS_CLASS_ShadowMaps.cpp | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h index e8307e64e7..96b9dc9d13 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h @@ -84,11 +84,7 @@ class ERS_CLASS_DepthMaps { bool FreeDepthMapIndexCubemap(unsigned int Index); - /** - * @brief Checks the settings of the renderer against the current parameters. - * - */ - void CheckSettings(); + public: @@ -130,7 +126,12 @@ class ERS_CLASS_DepthMaps { */ ~ERS_CLASS_DepthMaps(); - + /** + * @brief Checks the settings of the renderer against the current parameters. + * + */ + void CheckSettings(); + /** * @brief Generates a depth map array (array texture), with the given width, height and number of layers. * diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index afcaf30e38..0cf685fbff 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -26,9 +26,14 @@ ERS_CLASS_ShadowMaps::~ERS_CLASS_ShadowMaps() { void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader) { + + ERS_CLASS_DepthMaps_-Setting + + ERS::Renderer::ShadowUpdateMode UpdateMode = SystemUtils_->RendererSettings_->ShadowUpdateMode_; + // Ensure That Shadows Aren't Supposed To Be Disabled if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { From 6d431fd1472e064945ff5f668ec4af7021e6ccd7 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:21:43 +0000 Subject: [PATCH 041/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 0cf685fbff..d18d1e1fd6 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -26,12 +26,10 @@ ERS_CLASS_ShadowMaps::~ERS_CLASS_ShadowMaps() { void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader) { - - ERS_CLASS_DepthMaps_-Setting - - + // Get Updated Info From Renderer Settings + ERS_CLASS_DepthMaps_->CheckSettings(); ERS::Renderer::ShadowUpdateMode UpdateMode = SystemUtils_->RendererSettings_->ShadowUpdateMode_; - + ERS::Renderer::ShadowFilteringType FilterMode = SystemUtils_->RendererSettings_->ShadowFilteringType_; // Ensure That Shadows Aren't Supposed To Be Disabled From e3c3b326da5650a38c20a18667b65b4cdeccd73b Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:23:21 +0000 Subject: [PATCH 042/203] Implement Settings To Control Rendering (#220) --- Source/Core/Structures/ERS_STRUCT_DepthMap/ERS_STRUCT_DepthMap.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Structures/ERS_STRUCT_DepthMap/ERS_STRUCT_DepthMap.h b/Source/Core/Structures/ERS_STRUCT_DepthMap/ERS_STRUCT_DepthMap.h index c1267f52a3..c69dc22188 100644 --- a/Source/Core/Structures/ERS_STRUCT_DepthMap/ERS_STRUCT_DepthMap.h +++ b/Source/Core/Structures/ERS_STRUCT_DepthMap/ERS_STRUCT_DepthMap.h @@ -30,5 +30,6 @@ struct ERS_STRUCT_DepthMap { glm::mat4 TransformationMatrix; /** Date: Tue, 21 Jun 2022 23:24:26 +0000 Subject: [PATCH 043/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_DepthMaps.cpp | 115 +++++++++--------- 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 305c989256..5eb70b97c5 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -378,79 +378,84 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_DirectionalLight* Light, ERS void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUCT_Shader* DepthShader) { + if (Light->DepthMap.ToBeUpdated) { - // Setup Variables - ERS_STRUCT_Scene* TargetScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); - float NearPlane, FarPlane; - NearPlane = 0.1f; - FarPlane = Light->MaxDistance; + // Setup Variables + ERS_STRUCT_Scene* TargetScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); + float NearPlane, FarPlane; + NearPlane = 0.1f; + FarPlane = Light->MaxDistance; - // Calculate Project, View, Space Matrices - float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - glm::mat4 ShadowProjection = glm::perspective(glm::radians(90.0f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source - - std::vector ShadowTransforms; - ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 1.0, 0.0, 0.0), glm::vec3(0.0,-1.0, 0.0))); - ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3(-1.0, 0.0, 0.0), glm::vec3(0.0,-1.0, 0.0))); - ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 0.0, 1.0, 0.0), glm::vec3(0.0, 0.0, 1.0))); - ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 0.0,-1.0, 0.0), glm::vec3(0.0, 0.0,-1.0))); - ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 0.0, 0.0, 1.0), glm::vec3(0.0,-1.0, 0.0))); - ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 0.0, 0.0,-1.0), glm::vec3(0.0,-1.0, 0.0))); + // Calculate Project, View, Space Matrices + float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; + glm::mat4 ShadowProjection = glm::perspective(glm::radians(90.0f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + + std::vector ShadowTransforms; + ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 1.0, 0.0, 0.0), glm::vec3(0.0,-1.0, 0.0))); + ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3(-1.0, 0.0, 0.0), glm::vec3(0.0,-1.0, 0.0))); + ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 0.0, 1.0, 0.0), glm::vec3(0.0, 0.0, 1.0))); + ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 0.0,-1.0, 0.0), glm::vec3(0.0, 0.0,-1.0))); + ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 0.0, 0.0, 1.0), glm::vec3(0.0,-1.0, 0.0))); + ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 0.0, 0.0,-1.0), glm::vec3(0.0,-1.0, 0.0))); - // Render All Sides - glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); + // Render All Sides + glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); - DepthShader->MakeActive(); + DepthShader->MakeActive(); - // Render With Depth Shader - for (unsigned int i = 0; i < ShadowTransforms.size(); i++) { - DepthShader->SetMat4(std::string("ShadowMatrices[") + std::to_string(i) + std::string("]"), ShadowTransforms[i]); - } + // Render With Depth Shader + for (unsigned int i = 0; i < ShadowTransforms.size(); i++) { + DepthShader->SetMat4(std::string("ShadowMatrices[") + std::to_string(i) + std::string("]"), ShadowTransforms[i]); + } - DepthShader->SetVec3("LightPos", Light->Pos); - DepthShader->SetFloat("FarPlane", Light->MaxDistance); - DepthShader->SetInt("ShadowMapLayer", Light->DepthMap.DepthMapTextureIndex); - Renderer_->RenderSceneNoTextures(TargetScene, DepthShader); + DepthShader->SetVec3("LightPos", Light->Pos); + DepthShader->SetFloat("FarPlane", Light->MaxDistance); + DepthShader->SetInt("ShadowMapLayer", Light->DepthMap.DepthMapTextureIndex); + Renderer_->RenderSceneNoTextures(TargetScene, DepthShader); + + } } void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT_Shader* DepthShader) { - // Check Settings - CheckSettings(); + if (Light->DepthMap.ToBeUpdated) { - // Setup Variables - glm::mat4* LightSpaceMatrixArray = &Light->DepthMap.TransformationMatrix; - ERS_STRUCT_Scene* TargetScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); - glm::mat4 ObjectProjection, ObjectView, ObjectSpace; - float NearPlane, FarPlane; - NearPlane = 0.1f; - FarPlane = Light->MaxDistance; - // Calculate Project, View, Space Matrices - float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - float FOV = glm::radians(130.0f);// * (0.01745329)); - ObjectProjection = glm::perspective(FOV, AspectRatio, NearPlane, FarPlane); // Perspective models regular light source - - // Re-Do Rotation - glm::vec3 XYZRotation = ERS_FUNCTION_ConvertRotationToFrontVector(Light->Rot); - glm::vec3 Front = glm::normalize(XYZRotation); - ObjectView = glm::lookAt(Light->Pos, Light->Pos+Front, glm::vec3(0.0f, 1.0f, 0.0f)); // Pos+Front - ObjectSpace = ObjectProjection * ObjectView; + // Setup Variables + glm::mat4* LightSpaceMatrixArray = &Light->DepthMap.TransformationMatrix; + ERS_STRUCT_Scene* TargetScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); + glm::mat4 ObjectProjection, ObjectView, ObjectSpace; + float NearPlane, FarPlane; + NearPlane = 0.1f; + FarPlane = Light->MaxDistance; - // Render With Depth Shader - DepthShader->MakeActive(); - DepthShader->SetMat4("LightSpaceMatrix", ObjectSpace); - *LightSpaceMatrixArray = ObjectSpace; + // Calculate Project, View, Space Matrices + float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; + float FOV = glm::radians(130.0f);// * (0.01745329)); + ObjectProjection = glm::perspective(FOV, AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + + // Re-Do Rotation + glm::vec3 XYZRotation = ERS_FUNCTION_ConvertRotationToFrontVector(Light->Rot); + glm::vec3 Front = glm::normalize(XYZRotation); + ObjectView = glm::lookAt(Light->Pos, Light->Pos+Front, glm::vec3(0.0f, 1.0f, 0.0f)); // Pos+Front + ObjectSpace = ObjectProjection * ObjectView; + + // Render With Depth Shader + DepthShader->MakeActive(); + DepthShader->SetMat4("LightSpaceMatrix", ObjectSpace); + *LightSpaceMatrixArray = ObjectSpace; + + glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); + glBindFramebuffer(GL_FRAMEBUFFER, Light->DepthMap.FrameBufferObjectID); + glClear(GL_DEPTH_BUFFER_BIT); + glActiveTexture(GL_TEXTURE0); + Renderer_->RenderSceneNoTextures(TargetScene, DepthShader); - glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); - glBindFramebuffer(GL_FRAMEBUFFER, Light->DepthMap.FrameBufferObjectID); - glClear(GL_DEPTH_BUFFER_BIT); - glActiveTexture(GL_TEXTURE0); - Renderer_->RenderSceneNoTextures(TargetScene, DepthShader); + } } From ca916196038a7c0563581d91192f41f5ea82b13f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:24:52 +0000 Subject: [PATCH 044/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 5eb70b97c5..2cccddf092 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -378,6 +378,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_DirectionalLight* Light, ERS void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUCT_Shader* DepthShader) { + // Only Update If Instructed To Do SO if (Light->DepthMap.ToBeUpdated) { // Setup Variables @@ -421,7 +422,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT_Shader* DepthShader) { - + // Only Update If Instructed To Do So if (Light->DepthMap.ToBeUpdated) { From 7178d2100847539e1a3d5a015645753fddf9012f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:25:53 +0000 Subject: [PATCH 045/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_DepthMaps.cpp | 62 +++++++++++-------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 2cccddf092..82f3a6ab80 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -338,40 +338,45 @@ ERS_STRUCT_DepthMap ERS_CLASS_DepthMaps::GenerateDepthMap2D(int Number, bool Log void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_DirectionalLight* Light, ERS_STRUCT_Shader* DepthShader) { - // Check Settings - CheckSettings(); + // Only Update If Instructed To Do SO + if (Light->DepthMap.ToBeUpdated) { - // Setup Variables - glm::mat4* LightSpaceMatrixArray = &Light->DepthMap.TransformationMatrix; - ERS_STRUCT_Scene* TargetScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); - glm::mat4 ObjectProjection, ObjectView, ObjectSpace; - float NearPlane = 0.1f, FarPlane = 15.0f; + // Setup Variables + glm::mat4* LightSpaceMatrixArray = &Light->DepthMap.TransformationMatrix; + ERS_STRUCT_Scene* TargetScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); + glm::mat4 ObjectProjection, ObjectView, ObjectSpace; + float NearPlane = 0.1f, FarPlane = 15.0f; - // Calculate Project, View, Space Matrices - ObjectProjection = glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, NearPlane, FarPlane); // ortho models directional light source + // Calculate Project, View, Space Matrices + ObjectProjection = glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, NearPlane, FarPlane); // ortho models directional light source - // Re-Do Rotation - glm::vec3 XYZRotation = ERS_FUNCTION_ConvertRotationToFrontVector(Light->Rot); + // Re-Do Rotation + glm::vec3 XYZRotation = ERS_FUNCTION_ConvertRotationToFrontVector(Light->Rot); - glm::vec3 Front = glm::normalize(XYZRotation); - ObjectView = glm::lookAt(Light->Pos, Light->Pos+Front, glm::vec3(0.0f, 1.0f, 0.0f)); // Pos+Front - ObjectSpace = ObjectProjection * ObjectView; + glm::vec3 Front = glm::normalize(XYZRotation); + ObjectView = glm::lookAt(Light->Pos, Light->Pos+Front, glm::vec3(0.0f, 1.0f, 0.0f)); // Pos+Front + ObjectSpace = ObjectProjection * ObjectView; - // Render With Depth Shader - DepthShader->MakeActive(); - DepthShader->SetMat4("LightSpaceMatrix", ObjectSpace); - *LightSpaceMatrixArray = ObjectSpace; + // Render With Depth Shader + DepthShader->MakeActive(); + DepthShader->SetMat4("LightSpaceMatrix", ObjectSpace); + *LightSpaceMatrixArray = ObjectSpace; - glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); - glBindFramebuffer(GL_FRAMEBUFFER, Light->DepthMap.FrameBufferObjectID); + glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); + glBindFramebuffer(GL_FRAMEBUFFER, Light->DepthMap.FrameBufferObjectID); - - glClear(GL_DEPTH_BUFFER_BIT); - glActiveTexture(GL_TEXTURE0); - Renderer_->RenderSceneNoTextures(TargetScene, DepthShader); + + glClear(GL_DEPTH_BUFFER_BIT); + glActiveTexture(GL_TEXTURE0); + Renderer_->RenderSceneNoTextures(TargetScene, DepthShader); + + glBindFramebuffer(GL_FRAMEBUFFER, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + // Reset After Updating + Light->DepthMap.ToBeUpdated = false; + + } } @@ -416,6 +421,9 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC DepthShader->SetInt("ShadowMapLayer", Light->DepthMap.DepthMapTextureIndex); Renderer_->RenderSceneNoTextures(TargetScene, DepthShader); + // Reset After Updating + Light->DepthMap.ToBeUpdated = false; + } } @@ -456,6 +464,10 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT glActiveTexture(GL_TEXTURE0); Renderer_->RenderSceneNoTextures(TargetScene, DepthShader); + + // Reset After Updating + Light->DepthMap.ToBeUpdated = false; + } } From b841fc3526eac0a3cee9c565f1a1c4485de9cb22 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:26:02 +0000 Subject: [PATCH 046/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 82f3a6ab80..9a941ad069 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -474,9 +474,6 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_STRUCT_Shader* CubemapDepthShader) { - - - // Fix Offset (Peter Panning) glCullFace(GL_FRONT); From 5d0f34c9ef4230efd45223cb72f23e68734fd0fe Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 21 Jun 2022 23:27:04 +0000 Subject: [PATCH 047/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index d18d1e1fd6..18011e0509 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -35,8 +35,8 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Ensure That Shadows Aren't Supposed To Be Disabled if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { - // Update All Depth Maps - ERS_CLASS_DepthMaps_->UpdateDepthMaps(DepthMapShader, CubemapDepthShader); + // Update All Depth Maps + ERS_CLASS_DepthMaps_->UpdateDepthMaps(DepthMapShader, CubemapDepthShader); } From 0de683489e2030b7ff4f50c45e192390c7fbfc26 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:03:43 +0000 Subject: [PATCH 048/203] Fix Shadow Issues With Point Lights --- .../ERS_CLASS_ShadowMaps.cpp | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 18011e0509..29d22bcf8b 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -32,15 +32,26 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E ERS::Renderer::ShadowFilteringType FilterMode = SystemUtils_->RendererSettings_->ShadowFilteringType_; - // Ensure That Shadows Aren't Supposed To Be Disabled - if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { + // Create List Of All Depth Maps + ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); + std::vector DepthMaps; + for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { + DepthMaps.push_back(&ActiveScene->DirectionalLights[i]->DepthMap); + } + for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { + DepthMaps.push_back(&ActiveScene->PointLights[i]->DepthMap); + } + for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { + DepthMaps.push_back(&ActiveScene->SpotLights[i]->DepthMap); + } - // Update All Depth Maps - ERS_CLASS_DepthMaps_->UpdateDepthMaps(DepthMapShader, CubemapDepthShader); + // Tell The Depth Map Update System Which Depth Maps To Update - } - // Provide Depth Map Textures - + //if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { + //} + + // Update All Depth Maps + ERS_CLASS_DepthMaps_->UpdateDepthMaps(DepthMapShader, CubemapDepthShader); } \ No newline at end of file From 706b77d4974666d0b724899138e00a4a7e72d6bd Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:05:04 +0000 Subject: [PATCH 049/203] Fix Shadow Issues With Point Lights --- .../ERS_CLASS_ShadowMaps.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 29d22bcf8b..a1a2bc61b9 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -46,10 +46,19 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } // Tell The Depth Map Update System Which Depth Maps To Update - - - //if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { - //} + if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { + + } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { + + } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { + + } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { + + } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { + + } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { + + } // Update All Depth Maps ERS_CLASS_DepthMaps_->UpdateDepthMaps(DepthMapShader, CubemapDepthShader); From 1e5825c2bf8d3fc93093a68ce5cb5774038aae13 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:05:58 +0000 Subject: [PATCH 050/203] Fix Shadow Issues With Point Lights --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index a1a2bc61b9..907f6c1a42 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -47,11 +47,11 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Tell The Depth Map Update System Which Depth Maps To Update if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { - - } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { - + // Do Nothing As All Updates Are Disabled } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { - + for (unsigned int i = 0; i < DepthMaps.size(); i++) { + DepthMaps[i]->ToBeUpdated = true; + } } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { From 5ce0e154207a19229704c232d625ab25c144c787 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:13:23 +0000 Subject: [PATCH 051/203] Fix Shadow Issues With Point Lights --- .../ERS_CLASS_ShadowMaps.cpp | 17 ++++++++++++++++- .../ERS_CLASS_ShadowMaps.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 907f6c1a42..0736a0064d 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -45,6 +45,11 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E DepthMaps.push_back(&ActiveScene->SpotLights[i]->DepthMap); } + // Exit Early If No Lights Exist + if (DepthMaps.size() == 0) { + return; + } + // Tell The Depth Map Update System Which Depth Maps To Update if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { // Do Nothing As All Updates Are Disabled @@ -53,7 +58,17 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E DepthMaps[i]->ToBeUpdated = true; } } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { - + for (unsigned int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { + + // Calculate The Current index, Wrap At End Of List Size + LastUpdateIndex_++; + if (LastUpdateIndex_ > DepthMaps.size() - 1) { + LastUpdateIndex_ = 0; + } + + DepthMaps[LastUpdateIndex_]->ToBeUpdated = true; + + } } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index aa145e553d..251a5c5d13 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -48,6 +48,7 @@ class ERS_CLASS_ShadowMaps { ERS_CLASS_MeshRenderer* Renderer_; /** Date: Wed, 22 Jun 2022 05:14:12 +0000 Subject: [PATCH 052/203] Fix Shadow Issues With Point Lights --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 0736a0064d..f5595a9dbc 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -55,7 +55,9 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Do Nothing As All Updates Are Disabled } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { for (unsigned int i = 0; i < DepthMaps.size(); i++) { + DepthMaps[i]->ToBeUpdated = true; + } } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { for (unsigned int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { From 92722a16e9e7b384243d16e501f5b1c45a9ef37a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:14:59 +0000 Subject: [PATCH 053/203] Fix Shadow Issues With Point Lights --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index f5595a9dbc..35e3e59937 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -60,7 +60,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { - for (unsigned int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { + for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { // Calculate The Current index, Wrap At End Of List Size LastUpdateIndex_++; From 140ee44d47b704e3a75bf807e7c7de09c0a9f29a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:17:27 +0000 Subject: [PATCH 054/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 35e3e59937..e26c198623 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -52,14 +52,18 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Tell The Depth Map Update System Which Depth Maps To Update if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { + std::cout<<"Disabled\n"; // Do Nothing As All Updates Are Disabled } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { + std::cout<<"All\n"; + for (unsigned int i = 0; i < DepthMaps.size(); i++) { DepthMaps[i]->ToBeUpdated = true; } } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { + std::cout<<"consec\n"; for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { // Calculate The Current index, Wrap At End Of List Size @@ -73,7 +77,9 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { + std::cout<<"random\n"; } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { + std::cout<<"prioritized\n"; } From 5312092bed3d50e8300b391a52fdfef01d94f31f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:18:47 +0000 Subject: [PATCH 055/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index b32aca5c0a..861c8f3ef6 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -152,7 +152,7 @@ void Widget_RenderingSettings::Draw() { ImGui::Combo("Shadow Filtering", &SelectedShadowFiltering_, ShadowFilteringNames, 4); ImGui::Combo("Shadow Update Mode", &SelectedShadowUpdates_, ShadowUpdateNames, 5); - + std::cout< Date: Wed, 22 Jun 2022 05:20:11 +0000 Subject: [PATCH 056/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index 861c8f3ef6..bb05767ea8 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -175,6 +175,7 @@ void Widget_RenderingSettings::Draw() { Settings->ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM; } else if (SelectedShadowUpdates_ == 2) { Settings->ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE; + std::cout<<"applied to consec\n"; } else if (SelectedShadowUpdates_ == 3) { Settings->ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED; } else if (SelectedShadowUpdates_ == 4) { From 7d11a09291787c8a215f73bfaa592cb456e891bf Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:22:34 +0000 Subject: [PATCH 057/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 2 -- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index bb05767ea8..6efdd07772 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -152,7 +152,6 @@ void Widget_RenderingSettings::Draw() { ImGui::Combo("Shadow Filtering", &SelectedShadowFiltering_, ShadowFilteringNames, 4); ImGui::Combo("Shadow Update Mode", &SelectedShadowUpdates_, ShadowUpdateNames, 5); - std::cout<ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM; } else if (SelectedShadowUpdates_ == 2) { Settings->ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE; - std::cout<<"applied to consec\n"; } else if (SelectedShadowUpdates_ == 3) { Settings->ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED; } else if (SelectedShadowUpdates_ == 4) { diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index e26c198623..735b888bf7 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -50,6 +50,8 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E return; } + std::cout<RendererSettings_->MaxShadowUpdatesPerFrame_< Date: Wed, 22 Jun 2022 05:23:44 +0000 Subject: [PATCH 058/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 735b888bf7..850bd85f05 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -50,13 +50,12 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E return; } - std::cout<RendererSettings_->MaxShadowUpdatesPerFrame_<ToBeUpdated = true; } - } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { + } else if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { std::cout<<"consec\n"; for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { @@ -77,10 +76,10 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E DepthMaps[LastUpdateIndex_]->ToBeUpdated = true; } - } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { + } else if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { std::cout<<"random\n"; - } else if (UpdateMode != ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { + } else if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { std::cout<<"prioritized\n"; } From a170a877e90f4cbf817933544c468be77b858eb6 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:25:24 +0000 Subject: [PATCH 059/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 850bd85f05..d6afac3e10 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -53,10 +53,8 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Tell The Depth Map Update System Which Depth Maps To Update if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { - std::cout<<"Disabled\n"; // Do Nothing As All Updates Are Disabled } else if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { - std::cout<<"All\n"; for (unsigned int i = 0; i < DepthMaps.size(); i++) { @@ -64,7 +62,6 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } } else if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { - std::cout<<"consec\n"; for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { // Calculate The Current index, Wrap At End Of List Size @@ -78,9 +75,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } } else if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { - std::cout<<"random\n"; } else if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { - std::cout<<"prioritized\n"; } From ca74d673ee94542f7478c00faa3d3f656eb2e64e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:25:44 +0000 Subject: [PATCH 060/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index d6afac3e10..3852765dcd 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -52,16 +52,16 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Tell The Depth Map Update System Which Depth Maps To Update - if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { + if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { // Do Nothing As All Updates Are Disabled - } else if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { + } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { for (unsigned int i = 0; i < DepthMaps.size(); i++) { DepthMaps[i]->ToBeUpdated = true; } - } else if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { + } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { // Calculate The Current index, Wrap At End Of List Size @@ -73,9 +73,9 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E DepthMaps[LastUpdateIndex_]->ToBeUpdated = true; } - } else if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { + } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { - } else if (UpdateMode = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { + } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { } From 2d36ea1ab4715d7f1927ed2330485d7cee9faac9 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:27:52 +0000 Subject: [PATCH 061/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 9a941ad069..0b08381db7 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -513,8 +513,8 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S } // Handle Point Lights - glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); - glClear(GL_DEPTH_BUFFER_BIT); + // glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); + // glClear(GL_DEPTH_BUFFER_BIT); for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { From ea5c31997b50818b21ea0dfb58c62b04b5334f35 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:31:57 +0000 Subject: [PATCH 062/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 0b08381db7..9a941ad069 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -513,8 +513,8 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S } // Handle Point Lights - // glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); - // glClear(GL_DEPTH_BUFFER_BIT); + glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); + glClear(GL_DEPTH_BUFFER_BIT); for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { From d6b8e6a38f433303a2cd38fa8b07876215dba39b Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:36:25 +0000 Subject: [PATCH 063/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 6 +++--- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 9a941ad069..22fe54368d 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -408,7 +408,10 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC // Render All Sides glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); + glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); + glClear(GL_DEPTH_BUFFER_BIT); + DepthShader->MakeActive(); // Render With Depth Shader @@ -513,9 +516,6 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S } // Handle Point Lights - glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); - glClear(GL_DEPTH_BUFFER_BIT); - for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { // Extract Struct diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h index 96b9dc9d13..9f03eb8551 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h @@ -88,11 +88,6 @@ class ERS_CLASS_DepthMaps { public: - - unsigned int TESTFBO; - unsigned int TESTCubemap; - - unsigned int DepthTextureArrayID_; /** Date: Wed, 22 Jun 2022 05:37:11 +0000 Subject: [PATCH 064/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 5 ++++- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 22fe54368d..7dded9c7e0 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -16,6 +16,7 @@ ERS_CLASS_DepthMaps::ERS_CLASS_DepthMaps(ERS_STRUCT_SystemUtils* SystemUtils, ER // Create Array Texture For Depth Maps RegenerateDepthMapTextureArray2D(16, SystemUtils_->RendererSettings_->ShadowMapX_, SystemUtils_->RendererSettings_->ShadowMapY_); RegenerateDepthMapTextureArrayCubemap(2); + glGenFramebuffers(1, &PointLightClearFBO_); } @@ -161,6 +162,8 @@ bool ERS_CLASS_DepthMaps::RegenerateDepthMapTextureArrayCubemap(int NumberOfText glGenFramebuffers(1, &CubemapFBO_); } + + SystemUtils_->Logger_->Log("Setting Up Cubemap Texture Array OpenGL Parameters", 4, LogEnabled); glGenTextures(1, &DepthTextureCubemapArrayID_); glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, DepthTextureCubemapArrayID_); @@ -411,7 +414,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); glClear(GL_DEPTH_BUFFER_BIT); - + DepthShader->MakeActive(); // Render With Depth Shader diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h index 9f03eb8551..7765ecd1fc 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h @@ -100,6 +100,7 @@ class ERS_CLASS_DepthMaps { unsigned int CubemapFBO_; + unsigned int PointLightClearFBO_; // !!FIXME!! // Replace above vector with instead pointers to struct list so we can keep track and automatically free, etc. From 4715517d6aeba27334c450d732f2fdf48c7393d8 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:37:18 +0000 Subject: [PATCH 065/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 7dded9c7e0..44594c482e 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -162,8 +162,6 @@ bool ERS_CLASS_DepthMaps::RegenerateDepthMapTextureArrayCubemap(int NumberOfText glGenFramebuffers(1, &CubemapFBO_); } - - SystemUtils_->Logger_->Log("Setting Up Cubemap Texture Array OpenGL Parameters", 4, LogEnabled); glGenTextures(1, &DepthTextureCubemapArrayID_); glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, DepthTextureCubemapArrayID_); From fc82804765e1ba24fd71c78d71ba013dadd6d9b2 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:42:16 +0000 Subject: [PATCH 066/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 44594c482e..a73f9cc786 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -409,9 +409,10 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC // Render All Sides glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); - glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); - glClear(GL_DEPTH_BUFFER_BIT); - + + // glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); + // glClear(GL_DEPTH_BUFFER_BIT); + glClearTexSubImage(DepthTextureCubemapArrayID_, 0, 0, 0, Light->DepthMap.DepthMapTextureIndex*6, DepthTextureArrayWidth_, DepthTextureArrayHeight_, 6, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); DepthShader->MakeActive(); From 5085b14bec1375b526e5f95f2f2ed5e7c7a7c67e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:48:21 +0000 Subject: [PATCH 067/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_DepthMaps.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index a73f9cc786..6d386386f5 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -412,7 +412,18 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC // glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); // glClear(GL_DEPTH_BUFFER_BIT); - glClearTexSubImage(DepthTextureCubemapArrayID_, 0, 0, 0, Light->DepthMap.DepthMapTextureIndex*6, DepthTextureArrayWidth_, DepthTextureArrayHeight_, 6, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); + glClearTexSubImage(DepthTextureCubemapArrayID_, // Texture To Clear + 0, // Mip Map Level + 0, // X Offset + 0, // Y Offset + Light->DepthMap.DepthMapTextureIndex, // Z Offset + DepthTextureArrayWidth_, + DepthTextureArrayHeight_, + 6, + GL_DEPTH_COMPONENT, + GL_FLOAT, + NULL + ); DepthShader->MakeActive(); From 6571579e0878a77e2cfc46b2c1600a2dc2f48a98 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:55:53 +0000 Subject: [PATCH 068/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_DepthMaps.cpp | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 6d386386f5..f762175d77 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -387,6 +387,12 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC // Only Update If Instructed To Do SO if (Light->DepthMap.ToBeUpdated) { + for (unsigned int i = 0; i < 6; i++) { + glBindFramebuffer(GL_FRAMEBUFFER, PointLightClearFBO_); + glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, DepthTextureCubemapArrayID_, 0, Light->DepthMap.DepthMapTextureIndex*6 + i); + glClear(GL_DEPTH_BUFFER_BIT); + } + // Setup Variables ERS_STRUCT_Scene* TargetScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); float NearPlane, FarPlane; @@ -407,23 +413,26 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC + + // Render All Sides glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); - - // glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); + glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); // glClear(GL_DEPTH_BUFFER_BIT); - glClearTexSubImage(DepthTextureCubemapArrayID_, // Texture To Clear - 0, // Mip Map Level - 0, // X Offset - 0, // Y Offset - Light->DepthMap.DepthMapTextureIndex, // Z Offset - DepthTextureArrayWidth_, - DepthTextureArrayHeight_, - 6, - GL_DEPTH_COMPONENT, - GL_FLOAT, - NULL - ); + // glClearTexSubImage(DepthTextureCubemapArrayID_, // Texture To Clear + // 0, // Mip Map Level + // 0, // X Offset + // 0, // Y Offset + // Light->DepthMap.DepthMapTextureIndex, // Z Offset + // DepthTextureArrayWidth_, // Texture Width + // DepthTextureArrayHeight_, // Texture Height + // 6, // Number Of Layers To Clear + // GL_DEPTH_COMPONENT, // Type OF Texture To Clear + // GL_FLOAT, // GL Internal Format + // NULL // Data To Put Back In + // ); + + DepthShader->MakeActive(); From 249cc142fbe376b9cce6123769db09ff71387417 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:58:22 +0000 Subject: [PATCH 069/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_DepthMaps.cpp | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index f762175d77..98ba6d8e9f 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -387,6 +387,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC // Only Update If Instructed To Do SO if (Light->DepthMap.ToBeUpdated) { + // Clear This Layer Of The Cubemap Array for (unsigned int i = 0; i < 6; i++) { glBindFramebuffer(GL_FRAMEBUFFER, PointLightClearFBO_); glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, DepthTextureCubemapArrayID_, 0, Light->DepthMap.DepthMapTextureIndex*6 + i); @@ -412,35 +413,13 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC ShadowTransforms.push_back(ShadowProjection * glm::lookAt(Light->Pos, Light->Pos + glm::vec3( 0.0, 0.0,-1.0), glm::vec3(0.0,-1.0, 0.0))); - - - // Render All Sides glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); glBindFramebuffer(GL_FRAMEBUFFER, CubemapFBO_); - // glClear(GL_DEPTH_BUFFER_BIT); - // glClearTexSubImage(DepthTextureCubemapArrayID_, // Texture To Clear - // 0, // Mip Map Level - // 0, // X Offset - // 0, // Y Offset - // Light->DepthMap.DepthMapTextureIndex, // Z Offset - // DepthTextureArrayWidth_, // Texture Width - // DepthTextureArrayHeight_, // Texture Height - // 6, // Number Of Layers To Clear - // GL_DEPTH_COMPONENT, // Type OF Texture To Clear - // GL_FLOAT, // GL Internal Format - // NULL // Data To Put Back In - // ); - - - DepthShader->MakeActive(); - - // Render With Depth Shader for (unsigned int i = 0; i < ShadowTransforms.size(); i++) { DepthShader->SetMat4(std::string("ShadowMatrices[") + std::to_string(i) + std::string("]"), ShadowTransforms[i]); } - DepthShader->SetVec3("LightPos", Light->Pos); DepthShader->SetFloat("FarPlane", Light->MaxDistance); DepthShader->SetInt("ShadowMapLayer", Light->DepthMap.DepthMapTextureIndex); From 7f09caca0801dd2cc09682b9c72311f62b8373e3 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:59:25 +0000 Subject: [PATCH 070/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 3852765dcd..e62cb228aa 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -74,7 +74,18 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { - + for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { + + // Calculate The Current index, Wrap At End Of List Size + LastUpdateIndex_++; + if (LastUpdateIndex_ > DepthMaps.size() - 1) { + LastUpdateIndex_ = 0; + } + + DepthMaps[LastUpdateIndex_]->ToBeUpdated = true; + + } + } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { } From 7f347bbc6a3988af7d2861a8e960495b12c09af8 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 05:59:41 +0000 Subject: [PATCH 071/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index 251a5c5d13..26a92c0b6a 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -9,6 +9,7 @@ #include #include #include +#include // Third-Party Libraries (BG convention: use <> instead of "") #include From 481a1d0fd0bfdd8e85045be7c0c60a94c55764bf Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:03:03 +0000 Subject: [PATCH 072/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index e62cb228aa..f4590e960f 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -74,16 +74,20 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { - for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { - // Calculate The Current index, Wrap At End Of List Size - LastUpdateIndex_++; - if (LastUpdateIndex_ > DepthMaps.size() - 1) { - LastUpdateIndex_ = 0; - } + // Setup Update Counter + int Updates = 0; - DepthMaps[LastUpdateIndex_]->ToBeUpdated = true; + // Loop Over All Lights Until Update Counter Is At Target Number Of Updates Per Frame + while (Updates < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_) { + for (unsigned int i = 0; i < DepthMaps.size(); i++) { + // Use Random Number Generator To Decide Which Lights To Update + if (rand() % 50 = 2) { + DepthMaps[LastUpdateIndex_]->ToBeUpdated = true; + Updates++; + } + } } } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { From fe85c250f493efa0a2ad63187fe1fb6c03704066 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:03:18 +0000 Subject: [PATCH 073/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index f4590e960f..e8e3b9a142 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -83,7 +83,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E for (unsigned int i = 0; i < DepthMaps.size(); i++) { // Use Random Number Generator To Decide Which Lights To Update - if (rand() % 50 = 2) { + if (rand() % 50 == 2) { DepthMaps[LastUpdateIndex_]->ToBeUpdated = true; Updates++; } From a4f384fe33fb79cf8d6154a712b1b72edb2e22b9 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:07:03 +0000 Subject: [PATCH 074/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index e8e3b9a142..000be1a311 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -75,19 +75,10 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { - // Setup Update Counter - int Updates = 0; - - // Loop Over All Lights Until Update Counter Is At Target Number Of Updates Per Frame - while (Updates < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_) { - for (unsigned int i = 0; i < DepthMaps.size(); i++) { - - // Use Random Number Generator To Decide Which Lights To Update - if (rand() % 50 == 2) { - DepthMaps[LastUpdateIndex_]->ToBeUpdated = true; - Updates++; - } - } + // Randomly Update The Light, Note: Updates Are Guarenteed To Be Less Than Max But Not Equal To That + for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { + int UpdateIndex = rand() % DepthMaps.size()-1; + DepthMaps[UpdateIndex]->ToBeUpdated = true; } } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { From 2e932165d4d74a199815b8b313d9427f19e6b2e0 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:07:21 +0000 Subject: [PATCH 075/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 000be1a311..aa6ffb03e8 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -79,6 +79,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { int UpdateIndex = rand() % DepthMaps.size()-1; DepthMaps[UpdateIndex]->ToBeUpdated = true; + std::cout< Date: Wed, 22 Jun 2022 06:07:58 +0000 Subject: [PATCH 076/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index aa6ffb03e8..a22d95b958 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -77,9 +77,10 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Randomly Update The Light, Note: Updates Are Guarenteed To Be Less Than Max But Not Equal To That for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { - int UpdateIndex = rand() % DepthMaps.size()-1; - DepthMaps[UpdateIndex]->ToBeUpdated = true; + int UpdateIndex = rand() % (DepthMaps.size()-1); std::cout<ToBeUpdated = true; } } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { From e5b05d060877661ddb757265b1b9ddcf1d62abfc Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:17:04 +0000 Subject: [PATCH 077/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index a22d95b958..8ef9cc1b73 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -77,7 +77,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Randomly Update The Light, Note: Updates Are Guarenteed To Be Less Than Max But Not Equal To That for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { - int UpdateIndex = rand() % (DepthMaps.size()-1); + int UpdateIndex = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); std::cout<ToBeUpdated = true; diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index 26a92c0b6a..9a80f1f8c8 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include // Third-Party Libraries (BG convention: use <> instead of "") #include @@ -49,6 +49,12 @@ class ERS_CLASS_ShadowMaps { ERS_CLASS_MeshRenderer* Renderer_; /** RandomNumberGenerator_; /** Date: Wed, 22 Jun 2022 06:17:29 +0000 Subject: [PATCH 078/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index 9a80f1f8c8..0fd0363411 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -50,11 +50,11 @@ class ERS_CLASS_ShadowMaps { std::mt19937 MersenneTwister_; /** RandomNumberGenerator_; /** RandomNumberGenerator_; /** Date: Wed, 22 Jun 2022 06:17:45 +0000 Subject: [PATCH 079/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index 0fd0363411..406998eba2 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -51,7 +51,7 @@ class ERS_CLASS_ShadowMaps { std::mt19937 MersenneTwister_; /** RandomNumberGenerator_; /** RandomNumberGenerator_; /** Date: Wed, 22 Jun 2022 06:18:17 +0000 Subject: [PATCH 080/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 1 + .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 8ef9cc1b73..dc55fcbfa8 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -14,6 +14,7 @@ ERS_CLASS_ShadowMaps::ERS_CLASS_ShadowMaps(ERS_STRUCT_SystemUtils* SystemUtils, SystemUtils_->Logger_->Log("Initializing Shadow Map Subsystem", 5); ERS_CLASS_DepthMaps_ = std::make_unique(SystemUtils_, ProjectUtils_, Renderer_); + MersenneTwister_.seed(RandomSeed_); } diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index 406998eba2..f7274ebe45 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -50,7 +50,7 @@ class ERS_CLASS_ShadowMaps { std::mt19937 MersenneTwister_; /** RandomNumberGenerator_; /** Date: Wed, 22 Jun 2022 06:22:54 +0000 Subject: [PATCH 081/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index dc55fcbfa8..844593c435 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -79,8 +79,6 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Randomly Update The Light, Note: Updates Are Guarenteed To Be Less Than Max But Not Equal To That for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { int UpdateIndex = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); - std::cout<ToBeUpdated = true; } From 4b51b610ab96d7b793536d6106c361ae98d4fc33 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:24:08 +0000 Subject: [PATCH 082/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 844593c435..5776d41dff 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -84,6 +84,8 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { + // + } // Update All Depth Maps From 04369b8ccd3f03ad860ec51029e10307d37c7eaf Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:25:41 +0000 Subject: [PATCH 083/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 3 ++- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 5776d41dff..333ffd99cd 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -84,7 +84,8 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { - // + // Create Map Of Indexes And Distances + } diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index f7274ebe45..ca694784c2 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -10,6 +10,7 @@ #include #include #include +#include // Third-Party Libraries (BG convention: use <> instead of "") #include From e9ce3d7619442c8c5f134d852c7489728a37de6a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:40:45 +0000 Subject: [PATCH 084/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 3 +++ .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 333ffd99cd..1fb70b075d 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -84,6 +84,9 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { + // We + glm::vec3 CameraPosition = + // Create Map Of Indexes And Distances diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index ca694784c2..1d16a4dfe9 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -89,7 +89,7 @@ class ERS_CLASS_ShadowMaps { * This function checks the scenemanger and other shared classes to get info about the scene. * */ - void UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader); + void UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader, glm::vec3 CameraPosition); }; \ No newline at end of file From 7d5b2a85174b3ac913b4d0e4c5e752ecb214395a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:46:22 +0000 Subject: [PATCH 085/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 1fb70b075d..a6910c7df6 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -25,7 +25,7 @@ ERS_CLASS_ShadowMaps::~ERS_CLASS_ShadowMaps() { } -void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader) { +void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader, glm::vec3 CameraPosition) { // Get Updated Info From Renderer Settings ERS_CLASS_DepthMaps_->CheckSettings(); @@ -36,14 +36,18 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Create List Of All Depth Maps ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); std::vector DepthMaps; - for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { - DepthMaps.push_back(&ActiveScene->DirectionalLights[i]->DepthMap); - } + std::vector LightPositions; + // for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { + // DepthMaps.push_back(&ActiveScene->DirectionalLights[i]->DepthMap); + // LightPositions.push_back(ActiveScene->DirectionalLights[i]->Pos); + // } for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { DepthMaps.push_back(&ActiveScene->PointLights[i]->DepthMap); + LightPositions.push_back(ActiveScene->PointLights[i]->Pos); } for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { DepthMaps.push_back(&ActiveScene->SpotLights[i]->DepthMap); + LightPositions.push_back(ActiveScene->SpotLights[i]->Pos); } // Exit Early If No Lights Exist @@ -84,11 +88,13 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { - // We - glm::vec3 CameraPosition = - // Create Map Of Indexes And Distances - + std::map LightDistances; + + for (unsigned int i = 0; i < DepthMaps.size(); i++) { + float Distance = glm::distance + } + } From 9be1924f97d7c03aba2ef1842332898eb316a4d9 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:50:36 +0000 Subject: [PATCH 086/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 79 ++++++++++--------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index a6910c7df6..c219ca5c54 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -33,14 +33,12 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E ERS::Renderer::ShadowFilteringType FilterMode = SystemUtils_->RendererSettings_->ShadowFilteringType_; + + // Create List Of All Depth Maps ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); std::vector DepthMaps; std::vector LightPositions; - // for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { - // DepthMaps.push_back(&ActiveScene->DirectionalLights[i]->DepthMap); - // LightPositions.push_back(ActiveScene->DirectionalLights[i]->Pos); - // } for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { DepthMaps.push_back(&ActiveScene->PointLights[i]->DepthMap); LightPositions.push_back(ActiveScene->PointLights[i]->Pos); @@ -50,54 +48,63 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E LightPositions.push_back(ActiveScene->SpotLights[i]->Pos); } - // Exit Early If No Lights Exist - if (DepthMaps.size() == 0) { - return; + // All Directional Lights Will Be Updated + for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { + ActiveScene->DirectionalLights[i]->DepthMap.ToBeUpdated = true; + } + - // Tell The Depth Map Update System Which Depth Maps To Update - if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { - // Do Nothing As All Updates Are Disabled - } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { + // Skip Handling An Update If No Lights Are To Be Updated Here + if (DepthMaps.size() != 0) { - for (unsigned int i = 0; i < DepthMaps.size(); i++) { + // Tell The Depth Map Update System Which Depth Maps To Update + if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { + // Do Nothing As All Updates Are Disabled + } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL) { - DepthMaps[i]->ToBeUpdated = true; + for (unsigned int i = 0; i < DepthMaps.size(); i++) { - } - } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { - for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { + DepthMaps[i]->ToBeUpdated = true; - // Calculate The Current index, Wrap At End Of List Size - LastUpdateIndex_++; - if (LastUpdateIndex_ > DepthMaps.size() - 1) { - LastUpdateIndex_ = 0; } + } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { + for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { - DepthMaps[LastUpdateIndex_]->ToBeUpdated = true; + // Calculate The Current index, Wrap At End Of List Size + LastUpdateIndex_++; + if (LastUpdateIndex_ > DepthMaps.size() - 1) { + LastUpdateIndex_ = 0; + } - } - } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { + DepthMaps[LastUpdateIndex_]->ToBeUpdated = true; - // Randomly Update The Light, Note: Updates Are Guarenteed To Be Less Than Max But Not Equal To That - for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { - int UpdateIndex = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); - DepthMaps[UpdateIndex]->ToBeUpdated = true; - } + } + } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { - } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { - - // Create Map Of Indexes And Distances - std::map LightDistances; + // Randomly Update The Light, Note: Updates Are Guarenteed To Be Less Than Max But Not Equal To That + for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { + int UpdateIndex = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); + DepthMaps[UpdateIndex]->ToBeUpdated = true; + } - for (unsigned int i = 0; i < DepthMaps.size(); i++) { - float Distance = glm::distance - } + } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { + + // Create Map Of Indexes And Distances + std::map LightDistances; + for (unsigned int i = 0; i < DepthMaps.size(); i++) { + float Distance = glm::distance(CameraPosition, LightPositions[i]); + LightDistances[i] = Distance; + } + for (unsigned int i = 0; i UpdateDepthMaps(DepthMapShader, CubemapDepthShader); From 5f12f72560d094d3b726cb160f79c6b01b336cbf Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:53:08 +0000 Subject: [PATCH 087/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp index 8fb67a638a..8423b5d9c0 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -81,8 +81,9 @@ void ERS_CLASS_VisualRenderer::UpdateViewports(float DeltaTime, ERS_CLASS_SceneM // Generate Shadows //DepthMapShader_ = Shaders_[ERS_FUNCTION_FindShaderByName(std::string("Preview Shader"), &Shaders_)].get(); - ShadowMaps_->UpdateShadowMaps(DepthMapShader_, CubemapDepthShader_); - + if (Viewports_.size() > 0) { + ShadowMaps_->UpdateShadowMaps(DepthMapShader_, CubemapDepthShader_, Viewports_[0]->Camera->Position_); + } // Setup Vars glEnable(GL_DEPTH_TEST); From c50e16bbd2b513cd33a8681b2cfb992ea15078cf Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 06:57:29 +0000 Subject: [PATCH 088/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index c219ca5c54..bf662f6737 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -98,6 +98,20 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E LightDistances[i] = Distance; } + // Sort Based On Value In Acending Order + typedef std::pair pair; + std::sort(LightDistances.begin(), LightDistances.end(), + [](const pair &l, const pair &r) + { + if (l.second != r.second) { + return l.second < r.second; + } + + return l.first < r.first; + }); + + + for (unsigned int i = 0; i Date: Wed, 22 Jun 2022 06:57:54 +0000 Subject: [PATCH 089/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index bf662f6737..819d8b3df4 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -99,7 +99,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } // Sort Based On Value In Acending Order - typedef std::pair pair; + typedef std::pair pair; std::sort(LightDistances.begin(), LightDistances.end(), [](const pair &l, const pair &r) { @@ -110,7 +110,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E return l.first < r.first; }); - + for (unsigned int i = 0; i Date: Wed, 22 Jun 2022 07:00:54 +0000 Subject: [PATCH 090/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 819d8b3df4..0fa38819af 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -98,17 +98,6 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E LightDistances[i] = Distance; } - // Sort Based On Value In Acending Order - typedef std::pair pair; - std::sort(LightDistances.begin(), LightDistances.end(), - [](const pair &l, const pair &r) - { - if (l.second != r.second) { - return l.second < r.second; - } - - return l.first < r.first; - }); From 6358d115954e96ff8b9241b71f879532edbdb3d7 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 07:02:23 +0000 Subject: [PATCH 091/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 0fa38819af..d8600db350 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -95,7 +95,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E std::map LightDistances; for (unsigned int i = 0; i < DepthMaps.size(); i++) { float Distance = glm::distance(CameraPosition, LightPositions[i]); - LightDistances[i] = Distance; + LightDistances.insert(std::make_pair(i, Distance)); } From 971b3bb8c23a503b5376f48d6e4ed682fcad9c97 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 07:07:00 +0000 Subject: [PATCH 092/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index d8600db350..13ac5344ff 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -92,7 +92,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { // Create Map Of Indexes And Distances - std::map LightDistances; + std::multimap> LightDistances; for (unsigned int i = 0; i < DepthMaps.size(); i++) { float Distance = glm::distance(CameraPosition, LightPositions[i]); LightDistances.insert(std::make_pair(i, Distance)); From ac529e512ff2e501f58d66466c190ac3b399725d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 07:07:48 +0000 Subject: [PATCH 093/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 13ac5344ff..7052b3d580 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -101,8 +101,8 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E - for (unsigned int i = 0; i Date: Wed, 22 Jun 2022 07:09:44 +0000 Subject: [PATCH 094/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 7052b3d580..0aa7c7f3c5 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -92,17 +92,20 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { // Create Map Of Indexes And Distances - std::multimap> LightDistances; + std::map LightDistances; for (unsigned int i = 0; i < DepthMaps.size(); i++) { float Distance = glm::distance(CameraPosition, LightPositions[i]); - LightDistances.insert(std::make_pair(i, Distance)); + LightDistances.insert(std::make_pair(Distance, i)); } + std::map SortedLightDistances; + for (auto const& Entry : LightDistances) { + SortedLightDistances.insert(std::make_pair(Entry.second, Entry.first)); + } - - for (auto const& entry : LightDistances) { - std::cout< Date: Wed, 22 Jun 2022 07:10:54 +0000 Subject: [PATCH 095/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 0aa7c7f3c5..1ddb525767 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -100,13 +100,14 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E std::map SortedLightDistances; for (auto const& Entry : LightDistances) { + std::cout< Date: Wed, 22 Jun 2022 07:13:55 +0000 Subject: [PATCH 096/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 1ddb525767..909e9b971c 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -100,14 +100,13 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E std::map SortedLightDistances; for (auto const& Entry : LightDistances) { - std::cout< Date: Wed, 22 Jun 2022 07:14:02 +0000 Subject: [PATCH 097/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 909e9b971c..4801997046 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -100,7 +100,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E std::map SortedLightDistances; for (auto const& Entry : LightDistances) { - SortedLightDistances[Entry.second] = Entry.first); + SortedLightDistances[Entry.second] = Entry.first]; } From 3a77ceec1257f1acb5fb3cc5a9965554be8a092f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 07:15:50 +0000 Subject: [PATCH 098/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 4801997046..3ea35b4b7d 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -98,14 +98,14 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E LightDistances.insert(std::make_pair(Distance, i)); } - std::map SortedLightDistances; + std::vector SortedLightDistances; for (auto const& Entry : LightDistances) { - SortedLightDistances[Entry.second] = Entry.first]; + SortedLightDistances.push_back(Entry.second); } for (unsigned int i = 0; i Date: Wed, 22 Jun 2022 07:22:39 +0000 Subject: [PATCH 099/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 3ea35b4b7d..b60b3ea176 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -70,7 +70,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { - for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { + for (i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { // Calculate The Current index, Wrap At End Of List Size LastUpdateIndex_++; @@ -84,14 +84,14 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_RANDOM) { // Randomly Update The Light, Note: Updates Are Guarenteed To Be Less Than Max But Not Equal To That - for (unsigned int i = 0; i < (unsigned int)SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { + for (int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { int UpdateIndex = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); DepthMaps[UpdateIndex]->ToBeUpdated = true; } } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED) { - // Create Map Of Indexes And Distances + // Create Sorted List Of Light Indexes Based On Distance std::map LightDistances; for (unsigned int i = 0; i < DepthMaps.size(); i++) { float Distance = glm::distance(CameraPosition, LightPositions[i]); @@ -104,9 +104,11 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } - for (unsigned int i = 0; i RendererSettings_->MaxShadowUpdatesPerFrame_) { + DepthMaps[SortedLightDistances[i]]->ToBeUpdated = true; } + } From 83d9b551e1c65fa41e52be9b9bc091f185e26da2 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 07:23:03 +0000 Subject: [PATCH 100/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index b60b3ea176..e8a39ea5ae 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -105,7 +105,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Mark Lights To Be Updated - for (int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_) { + for (int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { DepthMaps[SortedLightDistances[i]]->ToBeUpdated = true; } From 3c4660128ed8b9f5ac8f05a6d6f4a8da752df31a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 07:23:24 +0000 Subject: [PATCH 101/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index e8a39ea5ae..fc9174eaf1 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -70,7 +70,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } } else if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_CONSECUTIVE) { - for (i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { + for (int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { // Calculate The Current index, Wrap At End Of List Size LastUpdateIndex_++; From 34e10b7603eb1f4fe1235bc5013dd39a4f2ce393 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 07:50:46 +0000 Subject: [PATCH 102/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index fc9174eaf1..389054ab39 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -106,7 +106,11 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Mark Lights To Be Updated for (int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { - DepthMaps[SortedLightDistances[i]]->ToBeUpdated = true; + unsigned int DepthMapIndex = SortedLightDistances[i]; + if (RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1) == i) { + SystemUtils = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); + } + DepthMaps[]->ToBeUpdated = true; } From 1534459df83037675eb66921c082e9151084b5f9 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 07:51:11 +0000 Subject: [PATCH 103/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 389054ab39..d89ed2aa92 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -108,9 +108,9 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E for (int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { unsigned int DepthMapIndex = SortedLightDistances[i]; if (RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1) == i) { - SystemUtils = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); + DepthMapIndex = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); } - DepthMaps[]->ToBeUpdated = true; + DepthMaps[DepthMapIndex]->ToBeUpdated = true; } From 23eda759c1c5f44d0ff03392f7e7341299512bb3 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 07:55:03 +0000 Subject: [PATCH 104/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h index b6b55c7302..f8bc5e9bf2 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h @@ -29,7 +29,7 @@ struct ERS_STRUCT_RendererSettings { // Set Shadow Update Settings ERS::Renderer::ShadowFilteringType ShadowFilteringType_ = ERS::Renderer::ERS_SHADOW_FILTERING_PCF; - ERS::Renderer::ShadowUpdateMode ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_ALL; - int MaxShadowUpdatesPerFrame_ = 20; + ERS::Renderer::ShadowUpdateMode ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED; + int MaxShadowUpdatesPerFrame_ = 5; }; \ No newline at end of file From 3a161efa90b8917e7620e864a1a27e2cfa69e01c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 07:56:35 +0000 Subject: [PATCH 105/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index d89ed2aa92..4670b9d9f9 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -107,7 +107,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Mark Lights To Be Updated for (int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { unsigned int DepthMapIndex = SortedLightDistances[i]; - if (RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1) == i) { + if ((unsigned int)RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1) == i) { DepthMapIndex = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); } DepthMaps[DepthMapIndex]->ToBeUpdated = true; From 7ffc8a9b3040364387e78a014995f416f321ecdb Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 21:43:44 +0000 Subject: [PATCH 106/203] Implement Settings To Control Rendering (#220) --- .../Structures/ERS_STRUCT_Model/ERS_STRUCT_Model.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/Core/Structures/ERS_STRUCT_Model/ERS_STRUCT_Model.h b/Source/Core/Structures/ERS_STRUCT_Model/ERS_STRUCT_Model.h index 6b03c62047..ee71c68129 100644 --- a/Source/Core/Structures/ERS_STRUCT_Model/ERS_STRUCT_Model.h +++ b/Source/Core/Structures/ERS_STRUCT_Model/ERS_STRUCT_Model.h @@ -46,6 +46,14 @@ struct ERS_STRUCT_Model { long AssetID; + + // Shadows Information + bool CastDynamicShadows_ = true; /** Date: Wed, 22 Jun 2022 21:53:24 +0000 Subject: [PATCH 107/203] Implement Settings To Control Rendering (#220) --- .../Widgets/GUI_Widget_ObjectProperties.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 9b1fd572ae..808e2098fe 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -181,6 +181,30 @@ void Widget_ObjectProperties::Draw() { } + } else if (SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SceneObjects_[SelectedSceneObject].Type_ == std::string("Model")) { + + unsigned long Index = SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SceneObjects_[SelectedSceneObject].Index_; + if (ImGui::CollapsingHeader("Model Settings", ImGuiTreeNodeFlags_DefaultOpen)) { + + // Get Current Model + ERS_STRUCT_Model* Model = SceneManager_->Scenes_[SceneManager_->ActiveScene_]->Models[Index].get(); + + ImGui::Checkbox("Casts Dynamic Shadows", &Model->CastDynamicShadows_); + ImGui::SameLine(); + ImGui::HelpMarker("Indicates if this model will cast shadows in dynamic lights. Avoid using this whenever possible due to performance related issues."); + + + ImGui::Checkbox("Casts Static Shadows", &Model->CastStaticShadows_); + ImGui::SameLine(); + ImGui::HelpMarker("Indicates if this model will cast shadows in static lights."); + + ImGui::Checkbox("Receive Shadows", &Model->ReceiveShadows_); + ImGui::SameLine(); + ImGui::HelpMarker("Allow this model to have shadows cast upon it by other objects as well as itself."); + + + } + } From b04889321b121581e59fe3ae4346f1eec2a425a7 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 21:53:31 +0000 Subject: [PATCH 108/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 808e2098fe..9462703c1e 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -193,7 +193,6 @@ void Widget_ObjectProperties::Draw() { ImGui::SameLine(); ImGui::HelpMarker("Indicates if this model will cast shadows in dynamic lights. Avoid using this whenever possible due to performance related issues."); - ImGui::Checkbox("Casts Static Shadows", &Model->CastStaticShadows_); ImGui::SameLine(); ImGui::HelpMarker("Indicates if this model will cast shadows in static lights."); From 24a1c3638253ffbadf5e695926436a6a62d3eede Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 21:54:45 +0000 Subject: [PATCH 109/203] Implement Settings To Control Rendering (#220) --- ...UNCTION_MeshTransparencySortNoTextures.cpp | 32 +++++++++++++++++++ ..._FUNCTION_MeshTransparencySortNoTextures.h | 28 ++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp create mode 100644 Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.h diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp new file mode 100644 index 0000000000..9cb432bc5d --- /dev/null +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp @@ -0,0 +1,32 @@ +//======================================================================// +// This file is part of the BrainGenix-ERS Environment Rendering System // +//======================================================================// + +#include + + +void ERS_FUNCTION_MeshTransparencySort(std::vector* OpaqueMeshes, std::vector* TransparentMeshes, ERS_STRUCT_Scene* Scene) { + + + for (unsigned long i = 0; i < Scene->Models.size(); i++) { + + ERS_STRUCT_Model *Model = Scene->Models[i].get(); + glm::mat4 ModelMatrix = Model->GetMat4(); + if (Model->FullyReady && Model->Enabled) { + for (unsigned int i = 0; i < Model->Meshes.size(); i++) { + + ERS_STRUCT_Mesh* Mesh = &Model->Meshes[i]; + Mesh->ModelMatrix = ModelMatrix; + if (Mesh->HasTransparency_) { + TransparentMeshes->push_back(Mesh); + } else { + OpaqueMeshes->push_back(Mesh); + } + + } + } + + } + + +} \ No newline at end of file diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.h new file mode 100644 index 0000000000..dfd6680230 --- /dev/null +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.h @@ -0,0 +1,28 @@ +//======================================================================// +// This file is part of the BrainGenix-ERS Environment Rendering System // +//======================================================================// + +#pragma once + + +// Standard Libraries (BG convention: use <> instead of "") +#include +#include + +// Third-Party Libraries (BG convention: use <> instead of "") + +// Internal Libraries (BG convention: use <> instead of "") +#include + +#include +#include + + +/** + * @brief Sorts the meshes in the given scene into the opaque and transparent meshes vectors. Also updates the "model" mat4 in the mesh. + * + * @param OpaqueMeshes + * @param TransparentMeshes + * @param Scene + */ +void ERS_FUNCTION_MeshTransparencySort(std::vector* OpaqueMeshes, std::vector* TransparentMeshes, ERS_STRUCT_Scene* Scene); \ No newline at end of file From ac44774588e2c1ad697392139af95c05647de716 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 21:54:57 +0000 Subject: [PATCH 110/203] Implement Settings To Control Rendering (#220) --- .../ERS_FUNCTION_MeshTransparencySortNoTextures.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp index 9cb432bc5d..3e6b2df3e4 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp @@ -2,10 +2,10 @@ // This file is part of the BrainGenix-ERS Environment Rendering System // //======================================================================// -#include +#include -void ERS_FUNCTION_MeshTransparencySort(std::vector* OpaqueMeshes, std::vector* TransparentMeshes, ERS_STRUCT_Scene* Scene) { +void ERS_FUNCTION_MeshTransparencySortNoTextures(std::vector* OpaqueMeshes, std::vector* TransparentMeshes, ERS_STRUCT_Scene* Scene) { for (unsigned long i = 0; i < Scene->Models.size(); i++) { From 06571580476afb3dc34c8f019ccfb10424d00836 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 21:55:05 +0000 Subject: [PATCH 111/203] Implement Settings To Control Rendering (#220) --- .../ERS_FUNCTION_MeshTransparencySortNoTextures.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.h index dfd6680230..906027983c 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.h @@ -25,4 +25,4 @@ * @param TransparentMeshes * @param Scene */ -void ERS_FUNCTION_MeshTransparencySort(std::vector* OpaqueMeshes, std::vector* TransparentMeshes, ERS_STRUCT_Scene* Scene); \ No newline at end of file +void ERS_FUNCTION_MeshTransparencySortNoTextures(std::vector* OpaqueMeshes, std::vector* TransparentMeshes, ERS_STRUCT_Scene* Scene); \ No newline at end of file From 7aada439a1a92bf45fd1c12a03a2c41a132918c3 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 21:57:23 +0000 Subject: [PATCH 112/203] Implement Settings To Control Rendering (#220) --- Source/Core/Renderer/ERS_CLASS_VisualRenderer/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/CMakeLists.txt b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/CMakeLists.txt index 211a798187..b8b192e166 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/CMakeLists.txt +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/CMakeLists.txt @@ -23,6 +23,8 @@ add_library(ERS_CLASS_VisualRenderer "ERS_FUNCTION_DrawMeshNoTextures.cpp" "ERS_FUNCTION_ResetMeshTexture.cpp" "ERS_FUNCTION_ConvertRotationToFrontVector.cpp" + "ERS_FUNCTION_MeshTransparencySortNoTextures.cpp" + # Add Header Files (.h) @@ -42,6 +44,8 @@ add_library(ERS_CLASS_VisualRenderer "ERS_FUNCTION_DrawMeshNoTextures.h" "ERS_FUNCTION_ResetMeshTexture.h" "ERS_FUNCTION_ConvertRotationToFrontVector.h" + "ERS_FUNCTION_MeshTransparencySortNoTextures.h" + From f92de923ec6ffda8b15d0b1df28dbf0ea435f4f7 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 21:58:35 +0000 Subject: [PATCH 113/203] Implement Settings To Control Rendering (#220) --- .../ERS_FUNCTION_MeshTransparencySortNoTextures.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp index 3e6b2df3e4..da42b30f7f 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_MeshTransparencySortNoTextures.cpp @@ -12,7 +12,7 @@ void ERS_FUNCTION_MeshTransparencySortNoTextures(std::vector* ERS_STRUCT_Model *Model = Scene->Models[i].get(); glm::mat4 ModelMatrix = Model->GetMat4(); - if (Model->FullyReady && Model->Enabled) { + if (Model->FullyReady && Model->Enabled && Model->CastDynamicShadows_) { for (unsigned int i = 0; i < Model->Meshes.size(); i++) { ERS_STRUCT_Mesh* Mesh = &Model->Meshes[i]; From 66bf4f9ba0f7bc93f42111481744cf8743748455 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 21:59:18 +0000 Subject: [PATCH 114/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_MeshRenderer.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_MeshRenderer.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_MeshRenderer.h index 5da5dfda21..8da83f3c92 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_MeshRenderer.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_MeshRenderer.h @@ -29,6 +29,7 @@ #include #include +#include #include #include From 47559afef4e8fc614ad9d1e87dc0e0282c6e2deb Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 21:59:42 +0000 Subject: [PATCH 115/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_MeshRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_MeshRenderer.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_MeshRenderer.cpp index 3e216d9a2c..bc8c03f0b2 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_MeshRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_MeshRenderer.cpp @@ -66,7 +66,7 @@ void ERS_CLASS_MeshRenderer::RenderSceneNoTextures(ERS_STRUCT_Scene* Scene, ERS_ // Sort Into Pesh Categories std::vector OpaqueMeshes; std::vector TransparentMeshes; - ERS_FUNCTION_MeshTransparencySort(&OpaqueMeshes, &TransparentMeshes, Scene); + ERS_FUNCTION_MeshTransparencySortNoTextures(&OpaqueMeshes, &TransparentMeshes, Scene); // Draw All Opaque Meshes for (unsigned long i = 0; i < OpaqueMeshes.size(); i++) { From 32eca5079b3d6e98cb4c8293d8b349fdd3b7459a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 22:06:01 +0000 Subject: [PATCH 116/203] Implement Settings To Control Rendering (#220) --- Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h b/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h index bdced242be..139e0f4033 100644 --- a/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h +++ b/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h @@ -68,6 +68,11 @@ struct ERS_STRUCT_Mesh { std::vector TextureNames; /** Date: Wed, 22 Jun 2022 22:08:17 +0000 Subject: [PATCH 117/203] Implement Settings To Control Rendering (#220) --- Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp | 1 + Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp b/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp index 7453d9f150..1f974e7d41 100644 --- a/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp +++ b/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp @@ -233,6 +233,7 @@ void ERS_CLASS_ModelLoader::ProcessGPU(std::shared_ptr Model) int TextureIndex = Model->Meshes[i].TextureReferences_[Index]; + if (TextureIndex == -1) { SystemUtils_->Logger_->Log("Failed To Find Corresponding Texture", 8); Model->Meshes[i].TextureIDs.push_back(-1); diff --git a/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h b/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h index 139e0f4033..7481f1a8ff 100644 --- a/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h +++ b/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h @@ -69,9 +69,9 @@ struct ERS_STRUCT_Mesh { // Handle Shadow Configuration - bool CastDynamicShadows_ = true; /** Date: Wed, 22 Jun 2022 22:08:46 +0000 Subject: [PATCH 118/203] Implement Settings To Control Rendering (#220) --- Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h b/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h index 7481f1a8ff..52a9010d5a 100644 --- a/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h +++ b/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h @@ -69,9 +69,9 @@ struct ERS_STRUCT_Mesh { // Handle Shadow Configuration - bool *CastDynamicShadows_ = true; /** Date: Wed, 22 Jun 2022 22:10:09 +0000 Subject: [PATCH 119/203] Implement Settings To Control Rendering (#220) --- Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp b/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp index 1f974e7d41..ab934fb9fe 100644 --- a/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp +++ b/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp @@ -233,6 +233,10 @@ void ERS_CLASS_ModelLoader::ProcessGPU(std::shared_ptr Model) int TextureIndex = Model->Meshes[i].TextureReferences_[Index]; + // Set Shadow Configuration Pointers + Model->Meshes[i].CastDynamicShadows_ = &Model->CastDynamicShadows_; + Model->Meshes[i].CastStaticShadows_ = &Model->CastStaticShadows_; + Model->Meshes[i].ReceiveShadows_ = &Model->ReceiveShadows_; if (TextureIndex == -1) { SystemUtils_->Logger_->Log("Failed To Find Corresponding Texture", 8); From 2d7a2da9a3f1c60f29086559b1c96b63cdf796c2 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 22:11:13 +0000 Subject: [PATCH 120/203] Implement Settings To Control Rendering (#220) --- Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h b/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h index 52a9010d5a..e160c5f25d 100644 --- a/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h +++ b/Source/Core/Structures/ERS_STRUCT_Mesh/ERS_STRUCT_Mesh.h @@ -69,9 +69,9 @@ struct ERS_STRUCT_Mesh { // Handle Shadow Configuration - bool* CastDynamicShadows_ = true; /** Date: Wed, 22 Jun 2022 22:14:42 +0000 Subject: [PATCH 121/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp index b6eb2205e1..03d9a9d327 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp @@ -103,6 +103,9 @@ void ERS_FUNCTION_DrawMesh(ERS_STRUCT_Mesh* Mesh, ERS_STRUCT_OpenGLDefaults* Ope Shader->SetBool("HasMetalness", HasMetalness); Shader->SetBool("HasNormals", HasNormals); Shader->SetBool("HasShininess", HasShininess); + + // Shadow Control Uniforms + Shader->SetBool("ReceiveShadows_", *Mesh->ReceiveShadows_); From 731780592d70c3c46c271d29349766f1bc53bea9 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 22:15:41 +0000 Subject: [PATCH 122/203] Implement Settings To Control Rendering (#220) --- Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp index 35db10cfd5..50aec77930 100644 --- a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp +++ b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp @@ -113,6 +113,11 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo } + // Load Shadow Configuration + if (SceneDataNode[i]["CastsDynamicShadows"]) { + + } + } else if (AssetType == std::string("DirectionalLight")) { From ad39f96846f06aed5bc6d3b5a4f2ca296dbdbae9 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 22:17:12 +0000 Subject: [PATCH 123/203] Implement Settings To Control Rendering (#220) --- .../Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp index 50aec77930..55052fc064 100644 --- a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp +++ b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp @@ -114,8 +114,16 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo // Load Shadow Configuration - if (SceneDataNode[i]["CastsDynamicShadows"]) { - + if (SceneDataNode[i]["CastDynamicShadows"]) { + Scene.Models[CurrentSize-1]->CastDynamicShadows_ = SceneDataNode[i]["CastDynamicShadows"].as(); + } + + if (SceneDataNode[i]["CastStaticShadows"]) { + Scene.Models[CurrentSize-1]->CastStaticShadows_ = SceneDataNode[i]["CastStaticShadows"].as(); + } + + if (SceneDataNode[i]["ReceiveShadows"]) { + Scene.Models[CurrentSize-1]->ReceiveShadows_ = SceneDataNode[i]["ReceiveShadows"].as(); } From b7676d303acd5c1deba62df265d6ac9aa877ee58 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 22:18:20 +0000 Subject: [PATCH 124/203] Implement Settings To Control Rendering (#220) --- Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp index d71da83906..00b232c234 100644 --- a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp +++ b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp @@ -84,6 +84,11 @@ std::string SceneWriter::ProcessScene(ERS_STRUCT_Scene* InputScene) { Output << YAML::Key << "FlipTextures" << YAML::Value << InputScene->Models[i]->FlipTextures; + Output << YAML::Key << "CastDynamicShadows" << YAML::Value << InputScene->Models[i]->CastDynamicShadows_; + Output << YAML::Key << "CastStaticShadows" << YAML::Value << InputScene->Models[i]->CastStaticShadows_; + Output << YAML::Key << "ReceiveShadows" << YAML::Value << InputScene->Models[i]->ReceiveShadows_; + + Output< Date: Wed, 22 Jun 2022 22:20:32 +0000 Subject: [PATCH 125/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp index 03d9a9d327..65e46d25fb 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp @@ -105,6 +105,8 @@ void ERS_FUNCTION_DrawMesh(ERS_STRUCT_Mesh* Mesh, ERS_STRUCT_OpenGLDefaults* Ope Shader->SetBool("HasShininess", HasShininess); // Shadow Control Uniforms + Shader->SetBool("CastDynamicShadows_", *Mesh->CastDynamicShadows_); + Shader->SetBool("CastStaticShadows_", *Mesh->CastStaticShadows_); Shader->SetBool("ReceiveShadows_", *Mesh->ReceiveShadows_); From 4bd24cc36fc536886b0e61f6e521f30254ad408b Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 22:21:18 +0000 Subject: [PATCH 126/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp | 1 + .../Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp index 65e46d25fb..3544c9efca 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp @@ -109,6 +109,7 @@ void ERS_FUNCTION_DrawMesh(ERS_STRUCT_Mesh* Mesh, ERS_STRUCT_OpenGLDefaults* Ope Shader->SetBool("CastStaticShadows_", *Mesh->CastStaticShadows_); Shader->SetBool("ReceiveShadows_", *Mesh->ReceiveShadows_); + // Draw Mesh diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.h index c823265541..65928994c7 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.h @@ -19,6 +19,8 @@ #include #include +#include + /** From f5447dd549992e921a707852e4e98fc03c613f4e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 22:24:21 +0000 Subject: [PATCH 127/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer.cpp | 14 ++++++++++++++ .../ERS_FUNCTION_DrawMesh.cpp | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp index 8423b5d9c0..914457e841 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -751,6 +751,20 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in } + // Set Shadow Filter Info + int ShadowFilterType = 0; + ERS::Renderer::ShadowFilteringType ShadowFilterEnum = SystemUtils_->RendererSettings_->ShadowFilteringType_; + + if (ShadowFilterEnum == ERS::Renderer::ERS_SHADOW_FILTERING_DISABLED) { + ShadowFilterType = 0; + } else if (ShadowFilterEnum == ERS::Renderer::ERS_SHADOW_FILTERING_PCF) { + ShadowFilterType = 1; + } else if (ShadowFilterEnum == ERS::Renderer::ERS_SHADOW_FILTERING_POISSON_SAMPLING) { + ShadowFilterType = 2; + } else if (ShadowFilterEnum == ERS::Renderer::ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING) { + ShadowFilterType = 3; + } + ActiveShader->SetFloat("Shinyness", 32.0f); diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp index 3544c9efca..4f25bfd0ea 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp @@ -109,7 +109,7 @@ void ERS_FUNCTION_DrawMesh(ERS_STRUCT_Mesh* Mesh, ERS_STRUCT_OpenGLDefaults* Ope Shader->SetBool("CastStaticShadows_", *Mesh->CastStaticShadows_); Shader->SetBool("ReceiveShadows_", *Mesh->ReceiveShadows_); - + // Draw Mesh From 87536f626c42e685f9d94dd62638aebc08e59831 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 22:24:54 +0000 Subject: [PATCH 128/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp index 914457e841..e1a2cceba7 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -754,7 +754,6 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in // Set Shadow Filter Info int ShadowFilterType = 0; ERS::Renderer::ShadowFilteringType ShadowFilterEnum = SystemUtils_->RendererSettings_->ShadowFilteringType_; - if (ShadowFilterEnum == ERS::Renderer::ERS_SHADOW_FILTERING_DISABLED) { ShadowFilterType = 0; } else if (ShadowFilterEnum == ERS::Renderer::ERS_SHADOW_FILTERING_PCF) { @@ -764,6 +763,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in } else if (ShadowFilterEnum == ERS::Renderer::ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING) { ShadowFilterType = 3; } + ActiveShader->SetInt("ShadowFilterType_", ShadowFilterType); ActiveShader->SetFloat("Shinyness", 32.0f); From 63dee55e73ecd7243e148a6654a085e18fcd764d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 22:25:10 +0000 Subject: [PATCH 129/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.h | 2 ++ .../Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.h index 6f7d66b9aa..3cbffe4bf0 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.h @@ -48,6 +48,8 @@ #include #include +#include + /** * @brief Handles viewport creation/deletion/rendering/updating. * diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.h index 65928994c7..f582fe1350 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.h @@ -19,7 +19,6 @@ #include #include -#include From af8c3a4755ccf93c0b3e01661f5a7ab75b825fb3 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 22:27:46 +0000 Subject: [PATCH 130/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 4670b9d9f9..28d18846bf 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -107,7 +107,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Mark Lights To Be Updated for (int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { unsigned int DepthMapIndex = SortedLightDistances[i]; - if ((unsigned int)RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1) == i) { + if ((long)RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1) == (long)i) { DepthMapIndex = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); } DepthMaps[DepthMapIndex]->ToBeUpdated = true; From 85042c04a0447554aded53c06701804a9fb0001b Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 22:31:21 +0000 Subject: [PATCH 131/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 53 ++++++++++++------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 1921731ca7..74549e59e6 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -112,6 +112,9 @@ uniform bool HasNormals; uniform bool HasShininess; +// Get Shadow Configuration Information +uniform bool ReceiveShadows_; + // Get Lighting Info uniform int NumberDirectionalLights; uniform int NumberPointLights; @@ -205,6 +208,13 @@ float ShadowPCFRandom(float Bias, vec3 ProjCoords, int Index, float CurrentDepth float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) { + + // If Shadows Are Not Enabled, Exit Early + if (!ReceiveShadows_) { + return 1.0f; + } + + vec4 fragPosLightSpace = LightSpaceMatrix * vec4(Object.FragPos, 1.0f); // perform perspective divide @@ -239,7 +249,31 @@ float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) } +float ShadowCalculation(STRUCT_PointLight Light) +{ + // If Shadows Are Not Enabled, Exit Early + if (!ReceiveShadows_) { + return 1.0f; + } + + // get vector between fragment position and light position + vec3 fragToLight = Object.FragPos - Light.Position; + + // ise the fragment to light vector to sample from the depth map + float closestDepth = texture(DepthMapCubeArray, vec4(fragToLight, Light.DepthCubemapIndex)).r; + // it is currently in linear range between [0,1], let's re-transform it back to original depth value + closestDepth *= Light.MaxDistance; + // now get current linear depth as the length between the fragment and light position + float currentDepth = length(fragToLight); + // test for shadows + float bias = 0.05; // we use a much larger bias since depth is now in [near_plane, far_plane] range + float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0; + // display closestDepth as debug (to visualize depth cubemap) + // FragColor = vec4(vec3(closestDepth / Light.MaxDistance), 1.0); + + return 1.0f - shadow; +} @@ -378,25 +412,7 @@ STRUCT_SampledData SetSampledData() { -float ShadowCalculation(STRUCT_PointLight Light) -{ - // get vector between fragment position and light position - vec3 fragToLight = Object.FragPos - Light.Position; - // ise the fragment to light vector to sample from the depth map - float closestDepth = texture(DepthMapCubeArray, vec4(fragToLight, Light.DepthCubemapIndex)).r; - // it is currently in linear range between [0,1], let's re-transform it back to original depth value - closestDepth *= Light.MaxDistance; - // now get current linear depth as the length between the fragment and light position - float currentDepth = length(fragToLight); - // test for shadows - float bias = 0.05; // we use a much larger bias since depth is now in [near_plane, far_plane] range - float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0; - // display closestDepth as debug (to visualize depth cubemap) - // FragColor = vec4(vec3(closestDepth / Light.MaxDistance), 1.0); - - return 1.0f - shadow; -} vec3 PBRPointLight(STRUCT_PointLight Light, vec3 ViewDir, vec3 Reflectance, STRUCT_SampledData Model) { @@ -619,5 +635,6 @@ void main() { + From 18b64f9d627bee64e4ef4c7c9a59b8feb6dac919 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 23:08:52 +0000 Subject: [PATCH 132/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 75 ++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 74549e59e6..60e9219015 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -114,6 +114,7 @@ uniform bool HasShininess; // Get Shadow Configuration Information uniform bool ReceiveShadows_; +uniform int ShadowFilterType_; // Get Lighting Info uniform int NumberDirectionalLights; @@ -228,7 +229,7 @@ float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) float currentDepth = projCoords.z; // check whether current frag pos is in shadow vec3 LightDir = normalize(LightPos - Object.FragPos); - float Bias = max(0.00 * (1.0 - dot(Object.Normal, LightDir)), 0.00025); + float Bias = max(0.00 * (1.0 - dot(Object.Normal, LightDir)), 0.0025); //float Shadow = currentDepth - Bias > closestDepth ? 1.0 : 0.0; float Shadow = ShadowPCF(Bias, projCoords, Index, currentDepth, 2); @@ -249,6 +250,76 @@ float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) } +float ShadowCalculation(STRUCT_SpotLight Light) +{ + + // If Shadows Are Not Enabled, Exit Early + if (!ReceiveShadows_) { + return 1.0f; + } + + + vec4 fragPosLightSpace = Light.LightSpaceMatrix * vec4(Object.FragPos, 1.0f); + + // perform perspective divide + vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w; + // transform to [0,1] range + projCoords = projCoords * 0.5f + 0.5; + + // get closest depth value from light's perspective (using [0,1] range fragPosLight as coords) + float closestDepth = texture(DepthMapArray, vec3(projCoords.xy, Light.DepthMapIndex)).r; + // get depth of current fragment from light's perspective + float currentDepth = projCoords.z; + // check whether current frag pos is in shadow + vec3 LightDir = normalize(Light.Position - Object.FragPos); + + int TextureSize = textureSize(DepthMapArray, 0).x; + float BiasMax = 1.0f; + + if (TextureSize == 512) { + BiasMax = 0.003; + } else if (TextureSize == 1024) { + BiasMax = 0.0015; + } else if (TextureSize == 2048) { + BiasMax = 0.00075; + } else if (TextureSize == 4096) { + BiasMax = 0.00045; + } else if (TextureSize == 8192) { + BiasMax = 0.00025; + } else if (TextureSize == 16384) { + BiasMax = 0.00015; + } + + float Bias = max(0.00 * (1.0 - dot(Object.Normal, LightDir)), BiasMax);//0.00225); + + + // Select Correct Filter Based On Selection Uniform + float Shadow; + if (ShadowFilterType_ == 0) { // No Filtering + Shadow = currentDepth - Bias > closestDepth ? 1.0 : 0.0; + } else if (ShadowFilterType_ == 1) { + Shadow = ShadowPCF(Bias, projCoords, Light.DepthMapIndex, currentDepth, 2); + } else { + return 0.0f; // Return Failure, All Black) + } + + //float Shadow = ShadowPCFRandom(Bias, projCoords, Index, currentDepth, 1); + + if (projCoords.z > 1.0) { + Shadow = 0.0f; + } + + if (Shadow > 1.0f) { + Shadow = 1.0f; + } else if (Shadow < 0.0f) { + Shadow = 0.0f; + } + + + return 1.0f - Shadow; +} + + float ShadowCalculation(STRUCT_PointLight Light) { @@ -510,7 +581,7 @@ vec3 PBRSpotLight(STRUCT_SpotLight Light, vec3 ViewDir, vec3 Reflectance, STRUCT } // add to outgoing radiance Lo - return ((kD * Model.Albedo.rgb / PI + specular) * radiance * NdotL * Intensity) * ShadowCalculation(Light.LightSpaceMatrix, Light.Direction, Light.DepthMapIndex); // note that we already multiplied the BRDF by the Fresnel (kS) so we won't multiply by kS again + return ((kD * Model.Albedo.rgb / PI + specular) * radiance * NdotL * Intensity) * ShadowCalculation(Light); // note that we already multiplied the BRDF by the Fresnel (kS) so we won't multiply by kS again } From 53924a5e948b71fb188eefee527662cd2586af47 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 23:12:38 +0000 Subject: [PATCH 133/203] Implement Settings To Control Rendering (#220) --- Source/EditorAssets/Projects/DefaultProject/10041.ERS | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 60e9219015..878bcd89a4 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -273,9 +273,10 @@ float ShadowCalculation(STRUCT_SpotLight Light) // check whether current frag pos is in shadow vec3 LightDir = normalize(Light.Position - Object.FragPos); - int TextureSize = textureSize(DepthMapArray, 0).x; - float BiasMax = 1.0f; + // Generate Shadow Map Bias + int TextureSize = textureSize(DepthMapArray, 0).x; + float BiasMax = 0.0005f; if (TextureSize == 512) { BiasMax = 0.003; } else if (TextureSize == 1024) { From e47c3630c1648fcdb2adce0b6f04bba9d071dc26 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 23:15:19 +0000 Subject: [PATCH 134/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 28d18846bf..73ffdad38f 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -107,7 +107,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Mark Lights To Be Updated for (int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { unsigned int DepthMapIndex = SortedLightDistances[i]; - if ((long)RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1) == (long)i) { + if ((signed long)RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1) == (signed long)i) { DepthMapIndex = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); } DepthMaps[DepthMapIndex]->ToBeUpdated = true; From 8d97aa4d51cf7769117f241a05dfe326d5416794 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 23:18:33 +0000 Subject: [PATCH 135/203] Implement Settings To Control Rendering (#220) --- .../EditorAssets/Projects/DefaultProject/10041.ERS | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 878bcd89a4..283b8fa305 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -277,17 +277,17 @@ float ShadowCalculation(STRUCT_SpotLight Light) // Generate Shadow Map Bias int TextureSize = textureSize(DepthMapArray, 0).x; float BiasMax = 0.0005f; - if (TextureSize == 512) { + if (TextureSize <= 512) { BiasMax = 0.003; - } else if (TextureSize == 1024) { + } else if (TextureSize <= 1024) { BiasMax = 0.0015; - } else if (TextureSize == 2048) { + } else if (TextureSize <= 2048) { BiasMax = 0.00075; - } else if (TextureSize == 4096) { + } else if (TextureSize <= 4096) { BiasMax = 0.00045; - } else if (TextureSize == 8192) { + } else if (TextureSize <= 8192) { BiasMax = 0.00025; - } else if (TextureSize == 16384) { + } else if (TextureSize <= 16384) { BiasMax = 0.00015; } @@ -708,5 +708,6 @@ void main() { + From ec2ba4a94a42c1129462c3a391eccedd4289eeff Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 23:28:18 +0000 Subject: [PATCH 136/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 73ffdad38f..0979599e6b 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -107,7 +107,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Mark Lights To Be Updated for (int i = 0; i < SystemUtils_->RendererSettings_->MaxShadowUpdatesPerFrame_; i++) { unsigned int DepthMapIndex = SortedLightDistances[i]; - if ((signed long)RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1) == (signed long)i) { + if ((signed long)RandomNumberGenerator_(MersenneTwister_) % (signed long)(DepthMaps.size()-1) == (signed long)i) { DepthMapIndex = RandomNumberGenerator_(MersenneTwister_) % (DepthMaps.size()-1); } DepthMaps[DepthMapIndex]->ToBeUpdated = true; From 0e6c8f8071f9ec2f0d6c6ddf0a9fbc3de4fbbf01 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Wed, 22 Jun 2022 23:34:01 +0000 Subject: [PATCH 137/203] Implement Settings To Control Rendering (#220) --- Source/EditorAssets/Projects/DefaultProject/10041.ERS | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 283b8fa305..4083b37cb8 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -282,13 +282,13 @@ float ShadowCalculation(STRUCT_SpotLight Light) } else if (TextureSize <= 1024) { BiasMax = 0.0015; } else if (TextureSize <= 2048) { - BiasMax = 0.00075; + BiasMax = 0.001; } else if (TextureSize <= 4096) { - BiasMax = 0.00045; + BiasMax = 0.00075; } else if (TextureSize <= 8192) { - BiasMax = 0.00025; + BiasMax = 0.00045; } else if (TextureSize <= 16384) { - BiasMax = 0.00015; + BiasMax = 0.00025; } float Bias = max(0.00 * (1.0 - dot(Object.Normal, LightDir)), BiasMax);//0.00225); @@ -709,5 +709,6 @@ void main() { + From 96e6c0a9a249f05c539ee3dbc4b85f0d2cb541d5 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 00:19:22 +0000 Subject: [PATCH 138/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10040.ERS | 3 ++ .../Projects/DefaultProject/10041.ERS | 45 ++++++++++++------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10040.ERS b/Source/EditorAssets/Projects/DefaultProject/10040.ERS index cf0e79dec9..a49eb8a919 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10040.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10040.ERS @@ -16,6 +16,7 @@ out VS_OUT { vec3 TangentViewPos; vec3 TangentFragPos; vec3 Normal; // Used when no normal map is available; + //vec4 FragPosLightSpace; } Object; @@ -68,3 +69,5 @@ void main() + + diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 4083b37cb8..8c8c084e17 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -12,6 +12,7 @@ in VS_OUT { vec3 TangentViewPos; vec3 TangentFragPos; vec3 Normal; // Used when normal texture not present + //vec4 FragPosLightSpace; } Object; @@ -159,7 +160,7 @@ float random(vec3 seed, int i){ } -float ShadowPCF(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { +float PCFSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { float shadow = 0.0; vec2 texelSize = 1.0 / textureSize(DepthMapArray, 0).xy; @@ -178,9 +179,7 @@ float ShadowPCF(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int } - -float ShadowPCFRandom(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { - +float StratifiedPoissonSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { float shadow = 0.0f; vec2 texelSize = 1.0f / textureSize(DepthMapArray, 0).xy; @@ -193,18 +192,32 @@ float ShadowPCFRandom(float Bias, vec3 ProjCoords, int Index, float CurrentDepth float pcfDepth = texture(DepthMapArray, vec3(TexCoords2D + PoissonDisk[index]/700.0f, Index)).r; //pcfDepth = texture(DepthMapArray, vec3(TexCoords2D, Index)).r; shadow += CurrentDepth - Bias > pcfDepth ? 1.0f : 0.0f; - - - - } + } } shadow /= (SampleSize*2)*(SampleSize*2); - - return shadow; } +float PoissonSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { + + float shadow = 0.0f; + vec2 texelSize = 1.0f / textureSize(DepthMapArray, 0).xy; + + for(int x = -SampleSize; x <= SampleSize; ++x) + { + for(int y = -SampleSize; y <= SampleSize; ++y) + { + vec2 TexCoords2D = ProjCoords.xy + (vec2(x, y) * texelSize); + int index = int(x*y)%16; + float pcfDepth = texture(DepthMapArray, vec3(TexCoords2D + PoissonDisk[index]/700.0f, Index)).r; + shadow += CurrentDepth - Bias > pcfDepth ? 1.0f : 0.0f; + } + } + shadow /= (SampleSize*2)*(SampleSize*2); + return shadow; + +} float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) @@ -232,7 +245,7 @@ float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) float Bias = max(0.00 * (1.0 - dot(Object.Normal, LightDir)), 0.0025); //float Shadow = currentDepth - Bias > closestDepth ? 1.0 : 0.0; - float Shadow = ShadowPCF(Bias, projCoords, Index, currentDepth, 2); + float Shadow = PCFSampler(Bias, projCoords, Index, currentDepth, 2); //float Shadow = ShadowPCFRandom(Bias, projCoords, Index, currentDepth, 1); if (projCoords.z > 1.0) { @@ -298,14 +311,16 @@ float ShadowCalculation(STRUCT_SpotLight Light) float Shadow; if (ShadowFilterType_ == 0) { // No Filtering Shadow = currentDepth - Bias > closestDepth ? 1.0 : 0.0; - } else if (ShadowFilterType_ == 1) { - Shadow = ShadowPCF(Bias, projCoords, Light.DepthMapIndex, currentDepth, 2); + } else if (ShadowFilterType_ == 1) { // PCF Filtering + Shadow = PCFSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, 2); + } else if (ShadowFilterType_ == 2) { // Poisson Filtering + Shadow = PoissonSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, 2); + } else if (ShadowFilterType_ == 3) { + Shadow = StratifiedPoissonSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, 2); } else { return 0.0f; // Return Failure, All Black) } - //float Shadow = ShadowPCFRandom(Bias, projCoords, Index, currentDepth, 1); - if (projCoords.z > 1.0) { Shadow = 0.0f; } From 865ecfde163a7b2bd3c9b821a1ed788627e0d9e3 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 00:20:30 +0000 Subject: [PATCH 139/203] Implement Settings To Control Rendering (#220) --- Source/EditorAssets/Projects/DefaultProject/10041.ERS | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 8c8c084e17..e733897bda 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -116,6 +116,7 @@ uniform bool HasShininess; // Get Shadow Configuration Information uniform bool ReceiveShadows_; uniform int ShadowFilterType_; +uniform int ShadowFilterKernelSize_; // Get Lighting Info uniform int NumberDirectionalLights; @@ -312,11 +313,11 @@ float ShadowCalculation(STRUCT_SpotLight Light) if (ShadowFilterType_ == 0) { // No Filtering Shadow = currentDepth - Bias > closestDepth ? 1.0 : 0.0; } else if (ShadowFilterType_ == 1) { // PCF Filtering - Shadow = PCFSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, 2); + Shadow = PCFSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, ShadowFilterKernelSize_); } else if (ShadowFilterType_ == 2) { // Poisson Filtering - Shadow = PoissonSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, 2); + Shadow = PoissonSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, ShadowFilterKernelSize_); } else if (ShadowFilterType_ == 3) { - Shadow = StratifiedPoissonSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, 2); + Shadow = StratifiedPoissonSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, ShadowFilterKernelSize_); } else { return 0.0f; // Return Failure, All Black) } From 4b1c7138c9afcb5d88ba6f0e4a1f443446fc9734 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 00:21:08 +0000 Subject: [PATCH 140/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h index f8bc5e9bf2..7e93725282 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h @@ -31,5 +31,6 @@ struct ERS_STRUCT_RendererSettings { ERS::Renderer::ShadowFilteringType ShadowFilteringType_ = ERS::Renderer::ERS_SHADOW_FILTERING_PCF; ERS::Renderer::ShadowUpdateMode ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED; int MaxShadowUpdatesPerFrame_ = 5; + int ShadowFilterKernelSize_ = 2; }; \ No newline at end of file From 3376c9193d8af29ddcd68eb0348e3464317293e4 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 00:21:52 +0000 Subject: [PATCH 141/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp index e1a2cceba7..02174f90c9 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -764,6 +764,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ShadowFilterType = 3; } ActiveShader->SetInt("ShadowFilterType_", ShadowFilterType); + ActiveShader->SetInt("ShadowFilterKernelSize_", SystemUtils_->RendererSettings_->ShadowFilterKernelSize_); + ActiveShader->SetFloat("Shinyness", 32.0f); From 41913a9c6c9c683d67566e2fef7d9231eb9c8bc7 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 00:23:58 +0000 Subject: [PATCH 142/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp index 6efdd07772..f8cd4df228 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_RenderingSettings.cpp @@ -148,6 +148,7 @@ void Widget_RenderingSettings::Draw() { ImGui::InputInt2("Depth Map Resolution", DepthMapResolution_); ImGui::InputInt("Max Shadow Updates Per Frame", &Settings->MaxShadowUpdatesPerFrame_); + ImGui::InputInt("Shadow Filter Kernel Size", &Settings->ShadowFilterKernelSize_); ImGui::Combo("Shadow Filtering", &SelectedShadowFiltering_, ShadowFilteringNames, 4); ImGui::Combo("Shadow Update Mode", &SelectedShadowUpdates_, ShadowUpdateNames, 5); From c1f0704fe3f83784affdc7b5f6c467004a54b93c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 01:10:17 +0000 Subject: [PATCH 143/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/3.ERS | 187 ++++++++++++++++-- 1 file changed, 176 insertions(+), 11 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/3.ERS b/Source/EditorAssets/Projects/DefaultProject/3.ERS index d3be522eee..dd447c8254 100644 --- a/Source/EditorAssets/Projects/DefaultProject/3.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/3.ERS @@ -15,6 +15,9 @@ SceneData: AssetScaleY: 0.0199999996 AssetScaleZ: 0.0199999996 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 1: @@ -31,6 +34,9 @@ SceneData: AssetScaleY: 0.0199999996 AssetScaleZ: 0.0199999996 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 2: @@ -47,6 +53,9 @@ SceneData: AssetScaleY: 0.0199999996 AssetScaleZ: 0.0199999996 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 3: @@ -63,6 +72,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 4: @@ -79,6 +91,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 5: @@ -95,6 +110,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 6: @@ -111,6 +129,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 7: @@ -127,6 +148,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 8: @@ -143,6 +167,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 9: @@ -159,6 +186,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 10: @@ -175,6 +205,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 11: @@ -191,6 +224,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 12: @@ -207,6 +243,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 13: @@ -223,6 +262,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 14: @@ -239,6 +281,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 15: @@ -255,6 +300,9 @@ SceneData: AssetScaleY: 0.00311163021 AssetScaleZ: 0.00311163021 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 16: @@ -271,6 +319,9 @@ SceneData: AssetScaleY: 0.00280800601 AssetScaleZ: 0.00280800601 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 17: @@ -287,6 +338,9 @@ SceneData: AssetScaleY: 0.00280800601 AssetScaleZ: 0.00280800601 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 18: @@ -303,6 +357,9 @@ SceneData: AssetScaleY: 0.00280800601 AssetScaleZ: 0.00280800601 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 19: @@ -319,6 +376,9 @@ SceneData: AssetScaleY: 0.00990002044 AssetScaleZ: 0.00990002137 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 20: @@ -335,6 +395,9 @@ SceneData: AssetScaleY: 0.00736923702 AssetScaleZ: 0.00736923702 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 21: @@ -351,6 +414,9 @@ SceneData: AssetScaleY: 0.00736923702 AssetScaleZ: 0.00736923702 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 22: @@ -367,6 +433,9 @@ SceneData: AssetScaleY: 0.00736923702 AssetScaleZ: 0.00736923702 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 23: @@ -383,6 +452,9 @@ SceneData: AssetScaleY: 0.00800004043 AssetScaleZ: 0.00800004043 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 24: @@ -399,6 +471,9 @@ SceneData: AssetScaleY: 0.00800004043 AssetScaleZ: 0.00800004043 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 25: @@ -415,6 +490,9 @@ SceneData: AssetScaleY: 0.000735000009 AssetScaleZ: 0.000735000067 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 26: @@ -431,6 +509,9 @@ SceneData: AssetScaleY: 0.000735000009 AssetScaleZ: 0.000735000067 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 27: @@ -447,6 +528,9 @@ SceneData: AssetScaleY: 0.000735000009 AssetScaleZ: 0.000735000067 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 28: @@ -463,6 +547,9 @@ SceneData: AssetScaleY: 0.000735000009 AssetScaleZ: 0.000735000067 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 29: @@ -479,6 +566,9 @@ SceneData: AssetScaleY: 0.000735000009 AssetScaleZ: 0.000735000067 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 30: @@ -495,6 +585,9 @@ SceneData: AssetScaleY: 0.00380000775 AssetScaleZ: 0.00380000775 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 31: @@ -511,6 +604,9 @@ SceneData: AssetScaleY: 0.00793306623 AssetScaleZ: 0.00694000022 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 32: @@ -527,6 +623,9 @@ SceneData: AssetScaleY: 0.0082000168 AssetScaleZ: 0.0082000168 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 33: @@ -543,6 +642,9 @@ SceneData: AssetScaleY: 0.0082000168 AssetScaleZ: 0.0082000168 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 34: @@ -559,6 +661,9 @@ SceneData: AssetScaleY: 0.00832000002 AssetScaleZ: 0.00728000002 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 35: @@ -575,6 +680,9 @@ SceneData: AssetScaleY: 0.00380000775 AssetScaleZ: 0.00380000775 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 36: @@ -591,6 +699,9 @@ SceneData: AssetScaleY: 0.00293800584 AssetScaleZ: 0.00293800584 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 37: @@ -607,6 +718,9 @@ SceneData: AssetScaleY: 0.00293800584 AssetScaleZ: 0.00293800584 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 38: @@ -623,6 +737,9 @@ SceneData: AssetScaleY: 0.00736923702 AssetScaleZ: 0.00736923702 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 39: @@ -639,6 +756,9 @@ SceneData: AssetScaleY: 0.00736923702 AssetScaleZ: 0.00736923702 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 40: @@ -655,6 +775,9 @@ SceneData: AssetScaleY: 0.00293800584 AssetScaleZ: 0.00293800584 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 41: @@ -671,6 +794,9 @@ SceneData: AssetScaleY: 0.00293800584 AssetScaleZ: 0.00293800584 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 42: @@ -687,6 +813,9 @@ SceneData: AssetScaleY: 0.00280800601 AssetScaleZ: 0.00280800601 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 43: @@ -703,6 +832,9 @@ SceneData: AssetScaleY: 0.00280800601 AssetScaleZ: 0.00280800601 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 44: @@ -719,6 +851,9 @@ SceneData: AssetScaleY: 0.00280800601 AssetScaleZ: 0.00280800601 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 45: @@ -735,6 +870,9 @@ SceneData: AssetScaleY: 0.00280800601 AssetScaleZ: 0.00280800601 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 46: @@ -751,6 +889,9 @@ SceneData: AssetScaleY: 0.00280800601 AssetScaleZ: 0.00280800601 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 47: @@ -767,6 +908,9 @@ SceneData: AssetScaleY: 0.00990002044 AssetScaleZ: 0.00990002137 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 48: @@ -783,6 +927,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 49: @@ -799,6 +946,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 50: @@ -815,6 +965,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 51: @@ -831,6 +984,9 @@ SceneData: AssetScaleY: 0.0100000501 AssetScaleZ: 0.0100000501 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 52: @@ -847,6 +1003,9 @@ SceneData: AssetScaleY: 0.0199999996 AssetScaleZ: 0.0199999996 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 53: @@ -863,6 +1022,9 @@ SceneData: AssetScaleY: 0.0199999996 AssetScaleZ: 0.0199999996 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 54: @@ -879,6 +1041,9 @@ SceneData: AssetScaleY: 0.0199999996 AssetScaleZ: 0.0199999996 FlipTextures: true + CastDynamicShadows: true + CastStaticShadows: true + ReceiveShadows: true AttachedScripts: {} 55: @@ -995,8 +1160,8 @@ SceneData: PosY: 1.5959357 PosZ: 6.00342846 RotX: 209.56749 - RotY: 59.9117813 - RotZ: 160.184723 + RotY: 59.9117851 + RotZ: 165.184708 Intensity: 25 MaxDistance: 10 CutOff: 103 @@ -1027,12 +1192,12 @@ SceneData: ColorRed: 1 ColorGreen: 1 ColorBlue: 1 - PosX: -0.849999964 - PosY: 1.5 + PosX: -0.74999994 + PosY: 1.60000002 PosZ: -4.8931241 - RotX: 47.6549835 - RotY: 47.9395943 - RotZ: 4.55612373 + RotX: 48.318615 + RotY: 52.9613876 + RotZ: 10.0683851 Intensity: 25 MaxDistance: 10 CutOff: 95 @@ -1045,12 +1210,12 @@ SceneData: ColorRed: 1 ColorGreen: 1 ColorBlue: 1 - PosX: 2.97785139 + PosX: 2.87785149 PosY: 1.5 PosZ: -4.70444107 - RotX: 4.07153368 - RotY: 59.641552 - RotZ: 250.978882 + RotX: 11.295084 + RotY: 50.5678635 + RotZ: 239.557556 Intensity: 25 MaxDistance: 15 CutOff: 77 From 1b7e5b9439e6a6a68e67c26f4ee891523d1d67a7 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 02:36:54 +0000 Subject: [PATCH 144/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h index 7e93725282..376d45ae17 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h @@ -28,7 +28,7 @@ struct ERS_STRUCT_RendererSettings { int ShadowMapY_ = 2048; // Set Shadow Update Settings - ERS::Renderer::ShadowFilteringType ShadowFilteringType_ = ERS::Renderer::ERS_SHADOW_FILTERING_PCF; + ERS::Renderer::ShadowFilteringType ShadowFilteringType_ = ERS::Renderer::ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING; ERS::Renderer::ShadowUpdateMode ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED; int MaxShadowUpdatesPerFrame_ = 5; int ShadowFilterKernelSize_ = 2; From dd90fc3622f8ebd985761ce95be039326c1960d2 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 02:37:53 +0000 Subject: [PATCH 145/203] Implement Settings To Control Rendering (#220) --- .../Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h index 4bd67dbd27..e208f5d516 100644 --- a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h +++ b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h @@ -25,6 +25,8 @@ struct ERS_STRUCT_DirectionalLight { float Intensity; /** Date: Thu, 23 Jun 2022 02:38:08 +0000 Subject: [PATCH 146/203] Implement Settings To Control Rendering (#220) --- Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_PointLight.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_PointLight.h b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_PointLight.h index 0a881b979b..65cd00df11 100644 --- a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_PointLight.h +++ b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_PointLight.h @@ -31,4 +31,6 @@ struct ERS_STRUCT_PointLight { ERS_STRUCT_DepthMap DepthMap; /** Date: Thu, 23 Jun 2022 02:38:19 +0000 Subject: [PATCH 147/203] Implement Settings To Control Rendering (#220) --- Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h index c87301664c..b161d1b4eb 100644 --- a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h +++ b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h @@ -35,4 +35,6 @@ struct ERS_STRUCT_SpotLight { ERS_STRUCT_DepthMap DepthMap; /** Date: Thu, 23 Jun 2022 02:41:40 +0000 Subject: [PATCH 148/203] Implement Settings To Control Rendering (#220) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 9462703c1e..2ed089056e 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -142,6 +142,9 @@ void Widget_ObjectProperties::Draw() { ImGui::SameLine(); ImGui::HelpMarker("Sets the distance after which the scene is no longer affected by this light source."); + ImGui::Checkbox("Cast Shadows", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->CastsShadows_); + ImGui::SameLine(); + ImGui::HelpMarker("Allows or disallows this light from creating shadows on the scene."); } From 81480fe9b5b7f61ea6a99519e2c2c62c9da53289 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 02:42:25 +0000 Subject: [PATCH 149/203] Implement Settings To Control Rendering (#220) --- .../Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 2ed089056e..22a08e4b66 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -116,7 +116,9 @@ void Widget_ObjectProperties::Draw() { ImGui::SameLine(); ImGui::HelpMarker("Sets the distance after which the scene is no longer affected by this light source."); - + ImGui::Checkbox("Cast Shadows", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->CastsShadows_); + ImGui::SameLine(); + ImGui::HelpMarker("Allows or disallows this light from creating shadows on the scene."); } @@ -182,6 +184,10 @@ void Widget_ObjectProperties::Draw() { ImGui::SameLine(); ImGui::HelpMarker("Sets the angle at which the outer cone begins to roll off. This angle sets the inner cone which is unaffected by rolloff. Rolloff occurs in the area between the outer and inner cone (this angle)."); + ImGui::Checkbox("Cast Shadows", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CastsShadows_); + ImGui::SameLine(); + ImGui::HelpMarker("Allows or disallows this light from creating shadows on the scene."); + } } else if (SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SceneObjects_[SelectedSceneObject].Type_ == std::string("Model")) { From 1c72caf52311c3b484a6b55302968ca86c22f701 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 02:43:39 +0000 Subject: [PATCH 150/203] Implement Settings To Control Rendering (#220) --- .../Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp index 55052fc064..38e2d706b6 100644 --- a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp +++ b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp @@ -162,6 +162,11 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo SceneDataNode[i]["RotZ"].as() ); + + if (SceneDataNode[i]["CastShadows"]) { + Scene.DirectionalLights[LightIndex]->CastsShadows_ = SceneDataNode[i]["CastShadows"].as(); + } + // Load Attached Scripts if (SceneDataNode[i]["AttachedScripts"]) { YAML::Node Scripts = SceneDataNode[i]["AttachedScripts"]; @@ -199,6 +204,10 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo SceneDataNode[i]["PosZ"].as() ); + if (SceneDataNode[i]["CastShadows"]) { + Scene.PointLights[LightIndex]->CastsShadows_ = SceneDataNode[i]["CastShadows"].as(); + } + // Load Attached Scripts if (SceneDataNode[i]["AttachedScripts"]) { YAML::Node Scripts = SceneDataNode[i]["AttachedScripts"]; @@ -247,6 +256,10 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo ); + if (SceneDataNode[i]["CastShadows"]) { + Scene.SpotLights[LightIndex]->CastsShadows_ = SceneDataNode[i]["CastShadows"].as(); + } + // Load Attached Scripts if (SceneDataNode[i]["AttachedScripts"]) { YAML::Node Scripts = SceneDataNode[i]["AttachedScripts"]; From 016d92912a89be27ad0fda91d42d114419a4aa43 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 02:45:32 +0000 Subject: [PATCH 151/203] Implement Settings To Control Rendering (#220) --- Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp index 00b232c234..5f02295f88 100644 --- a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp +++ b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp @@ -128,6 +128,8 @@ std::string SceneWriter::ProcessScene(ERS_STRUCT_Scene* InputScene) { Output << YAML::Key << "Intensity" << YAML::Value << InputScene->DirectionalLights[i]->Intensity; Output << YAML::Key << "MaxDistance" << YAML::Value << InputScene->DirectionalLights[i]->MaxDistance; + Output << YAML::Key << "CastShadows" << YAML::Value << InputScene->DirectionalLights[i]->CastsShadows_; + Output<PointLights[i]->Intensity; Output << YAML::Key << "MaxDistance" << YAML::Value << InputScene->PointLights[i]->MaxDistance; + Output << YAML::Key << "CastShadows" << YAML::Value << InputScene->PointLights[i]->CastsShadows_; + Output<SpotLights[i]->Rolloff; + Output << YAML::Key << "CastShadows" << YAML::Value << InputScene->SpotLights[i]->CastsShadows_; + + + Output<SpotLights[i]->AttachedScriptIndexes_.size(); x++) { From 4f35771e5449a6a4f412adc7647e722e223f3d6e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 02:47:13 +0000 Subject: [PATCH 152/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 0979599e6b..1f2be47062 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -40,17 +40,23 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E std::vector DepthMaps; std::vector LightPositions; for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { - DepthMaps.push_back(&ActiveScene->PointLights[i]->DepthMap); - LightPositions.push_back(ActiveScene->PointLights[i]->Pos); + if (ActiveScene->PointLights[i]->CastsShadows_) { + DepthMaps.push_back(&ActiveScene->PointLights[i]->DepthMap); + LightPositions.push_back(ActiveScene->PointLights[i]->Pos); + } } for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { - DepthMaps.push_back(&ActiveScene->SpotLights[i]->DepthMap); - LightPositions.push_back(ActiveScene->SpotLights[i]->Pos); + if (ActiveScene->SpotLights[i]->CastsShadows_) { + DepthMaps.push_back(&ActiveScene->SpotLights[i]->DepthMap); + LightPositions.push_back(ActiveScene->SpotLights[i]->Pos); + } } // All Directional Lights Will Be Updated for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { - ActiveScene->DirectionalLights[i]->DepthMap.ToBeUpdated = true; + if (ActiveScene->DirectionalLights[i]->CastsShadows_) { + ActiveScene->DirectionalLights[i]->DepthMap.ToBeUpdated = true; + } } From 9b15acc4233ded3b0a32ec34cef8cf81adbb7513 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 02:59:21 +0000 Subject: [PATCH 153/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 5 +---- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 98ba6d8e9f..329f6b3912 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -490,10 +490,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S // Extract Struct ERS_STRUCT_DirectionalLight* Light = ActiveScene->DirectionalLights[i].get(); - // Check If Light Has DepthMap - if (!Light->DepthMap.Initialized) { - Light->DepthMap = GenerateDepthMap2D(); - } + // Render To Depth Map UpdateDepthMap(Light, DepthShader); diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 1f2be47062..6e8d7e4d84 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -55,6 +55,12 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // All Directional Lights Will Be Updated for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { if (ActiveScene->DirectionalLights[i]->CastsShadows_) { + + // Check If Light Has DepthMap + if (!ActiveScene->DirectionalLights[i]->DepthMap.Initialized) { + ActiveScene->DirectionalLights[i]->DepthMap = ERS_CLASS_DepthMaps_->GenerateDepthMap2D(); + } + ActiveScene->DirectionalLights[i]->DepthMap.ToBeUpdated = true; } From de757bf997b811c196b0011c0107be7479448a8f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 02:59:34 +0000 Subject: [PATCH 154/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 6e8d7e4d84..1ca9241947 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -41,6 +41,12 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E std::vector LightPositions; for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { if (ActiveScene->PointLights[i]->CastsShadows_) { + + // Check If Light Has DepthMap + if (!ActiveScene->PointLights[i]->DepthMap.Initialized) { + ActiveScene->PointLights[i]->DepthMap = ERS_CLASS_DepthMaps_->GenerateDepthMap2D(); + } + DepthMaps.push_back(&ActiveScene->PointLights[i]->DepthMap); LightPositions.push_back(ActiveScene->PointLights[i]->Pos); } From a119f8bcf2ca2e03fe621196c5ef6fd3221088ba Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:00:00 +0000 Subject: [PATCH 155/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 329f6b3912..4b1db34f61 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -490,10 +490,10 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S // Extract Struct ERS_STRUCT_DirectionalLight* Light = ActiveScene->DirectionalLights[i].get(); - - // Render To Depth Map - UpdateDepthMap(Light, DepthShader); + if (Light->CastsShadows_) { + UpdateDepthMap(Light, DepthShader); + } } From 58e266589388e0ea7ca5f08200d8598341e26cbf Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:00:15 +0000 Subject: [PATCH 156/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 4b1db34f61..a6d321a04a 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -509,7 +509,9 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S } // Render To Depth Map - UpdateDepthMap(Light, DepthShader); + if (Light->CastsShadows_) { + UpdateDepthMap(Light, DepthShader); + } } @@ -526,7 +528,9 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S } // Render To Depth Map - UpdateDepthMap(Light, CubemapDepthShader); + if (Light->CastsShadows_) { + UpdateDepthMap(Light, CubemapDepthShader); + } } From 8fe01a1c2b0b3610138d4172e65b072dd2a2446a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:00:25 +0000 Subject: [PATCH 157/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index a6d321a04a..00d23ec4c3 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -521,12 +521,6 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S // Extract Struct ERS_STRUCT_PointLight* Light = ActiveScene->PointLights[i].get(); - // Check If Light Has DepthMap - if (!Light->DepthMap.Initialized) { - Light->DepthMap.DepthMapTextureIndex = AllocateDepthMapIndexCubemap(); - Light->DepthMap.Initialized = true; - } - // Render To Depth Map if (Light->CastsShadows_) { UpdateDepthMap(Light, CubemapDepthShader); From f4a1e51b0b41254bc0f9384a549bbfa231303b40 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:00:31 +0000 Subject: [PATCH 158/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 00d23ec4c3..056696a916 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -503,11 +503,6 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader, ERS_S // Extract Struct ERS_STRUCT_SpotLight* Light = ActiveScene->SpotLights[i].get(); - // Check If Light Has DepthMap - if (!Light->DepthMap.Initialized) { - Light->DepthMap = GenerateDepthMap2D(); - } - // Render To Depth Map if (Light->CastsShadows_) { UpdateDepthMap(Light, DepthShader); From ee1ad6a4f16b4906fa123e93938170fbd0226934 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:03:35 +0000 Subject: [PATCH 159/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 1ca9241947..068fa09635 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -53,6 +53,14 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { if (ActiveScene->SpotLights[i]->CastsShadows_) { + + + // Check If Light Has DepthMap + if (!ActiveScene->SpotLights[i]->DepthMap.Initialized) { + ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex = ERS_CLASS_DepthMaps_->AllocateDepthMapIndexCubemap(); + ActiveScene->SpotLights[i]->DepthMap.Initialized = true; + } + DepthMaps.push_back(&ActiveScene->SpotLights[i]->DepthMap); LightPositions.push_back(ActiveScene->SpotLights[i]->Pos); } From 78f431f8d23700ec8c53ab49068817ea3f95f9f4 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:04:00 +0000 Subject: [PATCH 160/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_DepthMaps.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h index 7765ecd1fc..408be92878 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h @@ -66,13 +66,7 @@ class ERS_CLASS_DepthMaps { unsigned int DepthMapAllocationChunkSize_ = 16; /** Date: Thu, 23 Jun 2022 03:04:51 +0000 Subject: [PATCH 161/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp index 02174f90c9..525e88bafa 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -744,6 +744,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetFloat((UniformName + std::string(".MaxDistance")).c_str(), ActiveScene->SpotLights[i]->MaxDistance); + ActiveShader->SetBool((UniformName + std::string(".CastsShadows")).c_str(), ActiveScene->SpotLights[i]->CastsShadows_); + ActiveShader->SetInt((UniformName + std::string(".DepthMapIndex")).c_str(), ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex); ActiveShader->SetMat4((UniformName + std::string(".LightSpaceMatrix")).c_str(), ActiveScene->SpotLights[i]->DepthMap.TransformationMatrix); From c247aac744ba12790e846e45a6f036814c35c0ef Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:05:24 +0000 Subject: [PATCH 162/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp index 525e88bafa..9e5e5f51aa 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -678,6 +678,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetFloat((UniformName + std::string(".MaxDistance")).c_str(), ActiveScene->DirectionalLights[i]->MaxDistance); + ActiveShader->SetBool((UniformName + std::string(".CastsShadows")).c_str(), ActiveScene->DirectionalLights[i]->CastsShadows_); + ActiveShader->SetInt((UniformName + std::string(".DepthMapIndex")).c_str(), ActiveScene->DirectionalLights[i]->DepthMap.DepthMapTextureIndex); ActiveShader->SetMat4((UniformName + std::string(".LightSpaceMatrix")).c_str(), ActiveScene->DirectionalLights[i]->DepthMap.TransformationMatrix); @@ -695,7 +697,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->PointLights[i]->Color); ActiveShader->SetFloat((UniformName + std::string(".MaxDistance")).c_str(), ActiveScene->PointLights[i]->MaxDistance); - + + ActiveShader->SetBool((UniformName + std::string(".CastsShadows")).c_str(), ActiveScene->PointLights[i]->CastsShadows_); ActiveShader->SetInt((UniformName + std::string(".DepthCubemapIndex")).c_str(), ActiveScene->PointLights[i]->DepthMap.DepthMapTextureIndex); From c5e231ec2263a1fa4a90149061d6cadc649f4725 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:06:45 +0000 Subject: [PATCH 163/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 068fa09635..4614f8a470 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -30,9 +30,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Get Updated Info From Renderer Settings ERS_CLASS_DepthMaps_->CheckSettings(); ERS::Renderer::ShadowUpdateMode UpdateMode = SystemUtils_->RendererSettings_->ShadowUpdateMode_; - ERS::Renderer::ShadowFilteringType FilterMode = SystemUtils_->RendererSettings_->ShadowFilteringType_; - - + //ERS::Renderer::ShadowFilteringType FilterMode = SystemUtils_->RendererSettings_->ShadowFilteringType_; // Create List Of All Depth Maps From 099b0cd1c4da64a3d6fd8656d840bae612f84b27 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:15:03 +0000 Subject: [PATCH 164/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 136 +++++++++--------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index e733897bda..77aee946af 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -135,88 +135,88 @@ uniform float Gamma_; const float PI = 3.14159265358979; vec2 PoissonDisk[16] = vec2[]( - vec2( -0.94201624, -0.39906216 ), - vec2( 0.94558609, -0.76890725 ), - vec2( -0.094184101, -0.92938870 ), - vec2( 0.34495938, 0.29387760 ), - vec2( -0.91588581, 0.45771432 ), - vec2( -0.81544232, -0.87912464 ), - vec2( -0.38277543, 0.27676845 ), - vec2( 0.97484398, 0.75648379 ), - vec2( 0.44323325, -0.97511554 ), - vec2( 0.53742981, -0.47373420 ), - vec2( -0.26496911, -0.41893023 ), - vec2( 0.79197514, 0.19090188 ), - vec2( -0.24188840, 0.99706507 ), - vec2( -0.81409955, 0.91437590 ), - vec2( 0.19984126, 0.78641367 ), - vec2( 0.14383161, -0.14100790 ) +vec2( -0.94201624, -0.39906216 ), +vec2( 0.94558609, -0.76890725 ), +vec2( -0.094184101, -0.92938870 ), +vec2( 0.34495938, 0.29387760 ), +vec2( -0.91588581, 0.45771432 ), +vec2( -0.81544232, -0.87912464 ), +vec2( -0.38277543, 0.27676845 ), +vec2( 0.97484398, 0.75648379 ), +vec2( 0.44323325, -0.97511554 ), +vec2( 0.53742981, -0.47373420 ), +vec2( -0.26496911, -0.41893023 ), +vec2( 0.79197514, 0.19090188 ), +vec2( -0.24188840, 0.99706507 ), +vec2( -0.81409955, 0.91437590 ), +vec2( 0.19984126, 0.78641367 ), +vec2( 0.14383161, -0.14100790 ) ); float random(vec3 seed, int i){ - vec4 seed4 = vec4(seed,i); - float dot_product = dot(seed4, vec4(12.9898,78.233,45.164,94.673)); - return fract(sin(dot_product) * 43758.5453); + vec4 seed4 = vec4(seed,i); + float dot_product = dot(seed4, vec4(12.9898,78.233,45.164,94.673)); + return fract(sin(dot_product) * 43758.5453); } float PCFSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { float shadow = 0.0; - vec2 texelSize = 1.0 / textureSize(DepthMapArray, 0).xy; - for(int x = -SampleSize; x <= SampleSize; ++x) - { - for(int y = -SampleSize; y <= SampleSize; ++y) - { + vec2 texelSize = 1.0 / textureSize(DepthMapArray, 0).xy; + for(int x = -SampleSize; x <= SampleSize; ++x) + { + for(int y = -SampleSize; y <= SampleSize; ++y) + { vec2 TexCoords2D = ProjCoords.xy + (vec2(x, y) * texelSize); - float pcfDepth = texture(DepthMapArray, vec3(TexCoords2D, Index)).r; - shadow += CurrentDepth - Bias > pcfDepth ? 1.0 : 0.0; - } - } - shadow /= (SampleSize*2)*(SampleSize*2); + float pcfDepth = texture(DepthMapArray, vec3(TexCoords2D, Index)).r; + shadow += CurrentDepth - Bias > pcfDepth ? 1.0 : 0.0; + } + } + shadow /= (SampleSize*2)*(SampleSize*2); - return shadow; + return shadow; } float StratifiedPoissonSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { float shadow = 0.0f; - vec2 texelSize = 1.0f / textureSize(DepthMapArray, 0).xy; + vec2 texelSize = 1.0f / textureSize(DepthMapArray, 0).xy; - for(int x = -SampleSize; x <= SampleSize; ++x) - { - for(int y = -SampleSize; y <= SampleSize; ++y) - { + for(int x = -SampleSize; x <= SampleSize; ++x) + { + for(int y = -SampleSize; y <= SampleSize; ++y) + { vec2 TexCoords2D = ProjCoords.xy + (vec2(x, y) * texelSize); int index = int(16.0f*random(floor(gl_FragCoord.yxz*1000.0f), x*y))%16; - float pcfDepth = texture(DepthMapArray, vec3(TexCoords2D + PoissonDisk[index]/700.0f, Index)).r; - //pcfDepth = texture(DepthMapArray, vec3(TexCoords2D, Index)).r; - shadow += CurrentDepth - Bias > pcfDepth ? 1.0f : 0.0f; - } - } - shadow /= (SampleSize*2)*(SampleSize*2); - return shadow; + float pcfDepth = texture(DepthMapArray, vec3(TexCoords2D + PoissonDisk[index]/700.0f, Index)).r; + //pcfDepth = texture(DepthMapArray, vec3(TexCoords2D, Index)).r; + shadow += CurrentDepth - Bias > pcfDepth ? 1.0f : 0.0f; + } + } + shadow /= (SampleSize*2)*(SampleSize*2); + return shadow; } float PoissonSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { float shadow = 0.0f; - vec2 texelSize = 1.0f / textureSize(DepthMapArray, 0).xy; + vec2 texelSize = 1.0f / textureSize(DepthMapArray, 0).xy; - for(int x = -SampleSize; x <= SampleSize; ++x) - { - for(int y = -SampleSize; y <= SampleSize; ++y) - { + for(int x = -SampleSize; x <= SampleSize; ++x) + { + for(int y = -SampleSize; y <= SampleSize; ++y) + { vec2 TexCoords2D = ProjCoords.xy + (vec2(x, y) * texelSize); int index = int(x*y)%16; - float pcfDepth = texture(DepthMapArray, vec3(TexCoords2D + PoissonDisk[index]/700.0f, Index)).r; - shadow += CurrentDepth - Bias > pcfDepth ? 1.0f : 0.0f; - } - } - shadow /= (SampleSize*2)*(SampleSize*2); - return shadow; + float pcfDepth = texture(DepthMapArray, vec3(TexCoords2D + PoissonDisk[index]/700.0f, Index)).r; + shadow += CurrentDepth - Bias > pcfDepth ? 1.0f : 0.0f; + } + } + shadow /= (SampleSize*2)*(SampleSize*2); + return shadow; } @@ -226,7 +226,7 @@ float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) // If Shadows Are Not Enabled, Exit Early if (!ReceiveShadows_) { - return 1.0f; + return 1.0f; } @@ -253,11 +253,11 @@ float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) Shadow = 0.0f; } - if (Shadow > 1.0f) { - Shadow = 1.0f; - } else if (Shadow < 0.0f) { - Shadow = 0.0f; - } + if (Shadow > 1.0f) { + Shadow = 1.0f; + } else if (Shadow < 0.0f) { + Shadow = 0.0f; + } return 1.0f - Shadow; @@ -269,7 +269,7 @@ float ShadowCalculation(STRUCT_SpotLight Light) // If Shadows Are Not Enabled, Exit Early if (!ReceiveShadows_) { - return 1.0f; + return 1.0f; } @@ -326,11 +326,11 @@ float ShadowCalculation(STRUCT_SpotLight Light) Shadow = 0.0f; } - if (Shadow > 1.0f) { - Shadow = 1.0f; - } else if (Shadow < 0.0f) { - Shadow = 0.0f; - } + if (Shadow > 1.0f) { + Shadow = 1.0f; + } else if (Shadow < 0.0f) { + Shadow = 0.0f; + } return 1.0f - Shadow; @@ -342,7 +342,7 @@ float ShadowCalculation(STRUCT_PointLight Light) // If Shadows Are Not Enabled, Exit Early if (!ReceiveShadows_) { - return 1.0f; + return 1.0f; } // get vector between fragment position and light position @@ -371,7 +371,7 @@ vec3 GetNormalFromMap(sampler2D Normal) { // Ensure That Textures Are Present/Valid, If Not, Provide Fallback vec3 SampledColor = texture(Normal, Object.TexCoords).xyz; if (!HasNormals || (SampledColor == vec3(0.0f))) { - SampledColor = vec3(0.5f, 0.5f, 1.0f); + SampledColor = vec3(0.5f, 0.5f, 1.0f); } // Use Texture Data To Calculate Normal Data @@ -683,7 +683,7 @@ void main() { vec4 Color = Ambient + vec4(Lo, Model.Albedo.a); - // Add Emissive Texture + // Add Emissive Texture if (HasEmissive) { Color.rgb += Model.Emissive; } From c84b68ae9875b138922aea32a397ad804c3d8224 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:16:23 +0000 Subject: [PATCH 165/203] Implement Settings To Control Rendering (#220) --- Source/EditorAssets/Projects/DefaultProject/10041.ERS | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 77aee946af..5a28329bf9 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -27,6 +27,8 @@ struct STRUCT_DirectionalLight { float MaxDistance; int DepthMapIndex; mat4 LightSpaceMatrix; + + bool CastsShadows; }; @@ -43,6 +45,8 @@ struct STRUCT_PointLight { float MaxDistance; int DepthCubemapIndex; + + bool CastsShadows; }; @@ -65,6 +69,8 @@ struct STRUCT_SpotLight { int DepthMapIndex; mat4 LightSpaceMatrix; + + bool CastsShadows; }; @@ -225,7 +231,7 @@ float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) { // If Shadows Are Not Enabled, Exit Early - if (!ReceiveShadows_) { + if (!ReceiveShadows_ || !Light.CastsShadows) { return 1.0f; } @@ -268,7 +274,7 @@ float ShadowCalculation(STRUCT_SpotLight Light) { // If Shadows Are Not Enabled, Exit Early - if (!ReceiveShadows_) { + if (!ReceiveShadows_ || !Light.CastsShadows) { return 1.0f; } From ac3f80630a80cb7cd510a9eddf057732a10273f3 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:18:54 +0000 Subject: [PATCH 166/203] Implement Settings To Control Rendering (#220) --- Source/EditorAssets/Projects/DefaultProject/10041.ERS | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 5a28329bf9..eec7fc5da3 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -130,7 +130,7 @@ uniform int NumberPointLights; uniform int NumberSpotLights; uniform STRUCT_DirectionalLight DirectionalLights[2]; uniform STRUCT_PointLight PointLights[42]; -uniform STRUCT_SpotLight SpotLights[64]; +uniform STRUCT_SpotLight SpotLights[56]; // Gamma Correction Info uniform bool GammaCorrectionEnabled_; @@ -231,7 +231,7 @@ float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) { // If Shadows Are Not Enabled, Exit Early - if (!ReceiveShadows_ || !Light.CastsShadows) { + if (!ReceiveShadows_) { return 1.0f; } @@ -347,7 +347,7 @@ float ShadowCalculation(STRUCT_PointLight Light) { // If Shadows Are Not Enabled, Exit Early - if (!ReceiveShadows_) { + if (!ReceiveShadows_ || !Light.CastsShadows) { return 1.0f; } @@ -732,5 +732,6 @@ void main() { + From 4cc5fb532b965113ffe967dd7bc141603894eae7 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:22:00 +0000 Subject: [PATCH 167/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 4614f8a470..353706857b 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -81,7 +81,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Skip Handling An Update If No Lights Are To Be Updated Here - if (DepthMaps.size() != 0) { + if (DepthMaps.size() >= 1) { // Tell The Depth Map Update System Which Depth Maps To Update if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { @@ -140,7 +140,11 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } + } else { // Handle Edge Case Where One Light Breaks The Random Number Generator + DepthMaps[0]->ToBeUpdated = true; } + + // Update All Depth Maps ERS_CLASS_DepthMaps_->UpdateDepthMaps(DepthMapShader, CubemapDepthShader); From 621ee9af8a0f6ce5cfeacd634f7d7016f42a3d39 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:22:53 +0000 Subject: [PATCH 168/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 353706857b..f5c331894b 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -140,7 +140,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } - } else { // Handle Edge Case Where One Light Breaks The Random Number Generator + } else if (DepthMaps.size() == 1) { // Handle Edge Case Where One Light Breaks The Random Number Generator DepthMaps[0]->ToBeUpdated = true; } From bd4ed44ae5961a37cd4c81b23bc026c93eccb40c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:26:19 +0000 Subject: [PATCH 169/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index f5c331894b..ee91c4ca7b 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -81,7 +81,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Skip Handling An Update If No Lights Are To Be Updated Here - if (DepthMaps.size() >= 1) { + if (DepthMaps.size() > 1) { // Tell The Depth Map Update System Which Depth Maps To Update if (UpdateMode == ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISABLED) { From df1fdf386d9e8ac138c777c2ba12d48f8de5deb4 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 03:35:15 +0000 Subject: [PATCH 170/203] Implement Settings To Control Rendering (#220) --- Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h index b161d1b4eb..a5a1f20f3b 100644 --- a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h +++ b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h @@ -35,6 +35,6 @@ struct ERS_STRUCT_SpotLight { ERS_STRUCT_DepthMap DepthMap; /** Date: Thu, 23 Jun 2022 03:37:52 +0000 Subject: [PATCH 171/203] Implement Settings To Control Rendering (#220) --- Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_PointLight.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_PointLight.h b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_PointLight.h index 65cd00df11..a7d8dae7e4 100644 --- a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_PointLight.h +++ b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_PointLight.h @@ -31,6 +31,6 @@ struct ERS_STRUCT_PointLight { ERS_STRUCT_DepthMap DepthMap; /** Date: Thu, 23 Jun 2022 03:38:01 +0000 Subject: [PATCH 172/203] Implement Settings To Control Rendering (#220) --- .../Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h index e208f5d516..596446ba3e 100644 --- a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h +++ b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h @@ -24,8 +24,8 @@ struct ERS_STRUCT_DirectionalLight { glm::vec3 Color; /** Date: Thu, 23 Jun 2022 04:08:47 +0000 Subject: [PATCH 173/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index ee91c4ca7b..a2b769283b 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -42,9 +42,12 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Check If Light Has DepthMap if (!ActiveScene->PointLights[i]->DepthMap.Initialized) { - ActiveScene->PointLights[i]->DepthMap = ERS_CLASS_DepthMaps_->GenerateDepthMap2D(); + ActiveScene->PointLights[i]->DepthMap.DepthMapTextureIndex = ERS_CLASS_DepthMaps_->AllocateDepthMapIndexCubemap(); + ActiveScene->PointLights[i]->DepthMap.Initialized = true; } + + DepthMaps.push_back(&ActiveScene->PointLights[i]->DepthMap); LightPositions.push_back(ActiveScene->PointLights[i]->Pos); } @@ -52,11 +55,9 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { if (ActiveScene->SpotLights[i]->CastsShadows_) { - // Check If Light Has DepthMap if (!ActiveScene->SpotLights[i]->DepthMap.Initialized) { - ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex = ERS_CLASS_DepthMaps_->AllocateDepthMapIndexCubemap(); - ActiveScene->SpotLights[i]->DepthMap.Initialized = true; + ActiveScene->SpotLights[i]->DepthMap = ERS_CLASS_DepthMaps_->GenerateDepthMap2D(); } DepthMaps.push_back(&ActiveScene->SpotLights[i]->DepthMap); From f7ec09e037b0d394816f4ea28bddf42ce67d48a0 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 04:10:59 +0000 Subject: [PATCH 174/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_DepthMaps.h | 20 ++++++++++--------- .../ERS_CLASS_ShadowMaps.cpp | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h index 408be92878..04dd098f37 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h @@ -68,15 +68,7 @@ class ERS_CLASS_DepthMaps { - /** - * @brief Deallocates an index from the depth map texture array. - * @param Index - * @return true - * @return false - */ - bool FreeDepthMapIndex2D(unsigned int Index); - bool FreeDepthMapIndexCubemap(unsigned int Index); - + @@ -122,6 +114,16 @@ class ERS_CLASS_DepthMaps { * */ void CheckSettings(); + + + /** + * @brief Deallocates an index from the depth map texture array. + * @param Index + * @return true + * @return false + */ + bool FreeDepthMapIndex2D(unsigned int Index); + bool FreeDepthMapIndexCubemap(unsigned int Index); /** diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index a2b769283b..88d17b1f80 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -50,6 +50,8 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E DepthMaps.push_back(&ActiveScene->PointLights[i]->DepthMap); LightPositions.push_back(ActiveScene->PointLights[i]->Pos); + } else if (ActiveScene->PointLights[i]->DepthMap.Initialized) { + ERS_CLASS_DepthMaps_-> } } for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { From 98e0688bf24ff3a91ff2514671d9a577dd070d8e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 04:13:04 +0000 Subject: [PATCH 175/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 88d17b1f80..ff5f0013bc 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -50,8 +50,12 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E DepthMaps.push_back(&ActiveScene->PointLights[i]->DepthMap); LightPositions.push_back(ActiveScene->PointLights[i]->Pos); + } else if (ActiveScene->PointLights[i]->DepthMap.Initialized) { - ERS_CLASS_DepthMaps_-> + + // Free The Light Index If Not Enabled + ERS_CLASS_DepthMaps_->FreeDepthMapIndexCubemap(ActiveScene->PointLights[i]->DepthMap.DepthMapTextureIndex); + ActiveScene->PointLights[i]->DepthMap.Initialized = false; } } for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { @@ -64,6 +68,12 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E DepthMaps.push_back(&ActiveScene->SpotLights[i]->DepthMap); LightPositions.push_back(ActiveScene->SpotLights[i]->Pos); + + } else if (ActiveScene->SpotLights[i]->DepthMap.Initialized) { + + // Free The Light Index If Not Enabled + ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex); + ActiveScene->SpotLights[i]->DepthMap.Initialized = false; } } @@ -77,6 +87,11 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } ActiveScene->DirectionalLights[i]->DepthMap.ToBeUpdated = true; + } else if (ActiveScene->DirectionalLights[i]->DepthMap.Initialized) { + + // Free The Light Index If Not Enabled + ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->DirectionalLights[i]->DepthMap.DepthMapTextureIndex); + ActiveScene->DirectionalLights[i]->DepthMap.Initialized = false; } } From 2a5be0f243ec14b6ebc090ccbc4e1df8e2103ff2 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 04:20:51 +0000 Subject: [PATCH 176/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 36 +++++++++++-------- .../ERS_CLASS_ShadowMaps.h | 8 +++++ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index ff5f0013bc..03c01c11d6 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -24,19 +24,10 @@ ERS_CLASS_ShadowMaps::~ERS_CLASS_ShadowMaps() { } +void ERS_CLASS_ShadowMaps::GetDepthMaps(std::vector* DepthMaps, std::vector* LightPositions) { -void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader, glm::vec3 CameraPosition) { - - // Get Updated Info From Renderer Settings - ERS_CLASS_DepthMaps_->CheckSettings(); - ERS::Renderer::ShadowUpdateMode UpdateMode = SystemUtils_->RendererSettings_->ShadowUpdateMode_; - //ERS::Renderer::ShadowFilteringType FilterMode = SystemUtils_->RendererSettings_->ShadowFilteringType_; - - - // Create List Of All Depth Maps ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); - std::vector DepthMaps; - std::vector LightPositions; + for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { if (ActiveScene->PointLights[i]->CastsShadows_) { @@ -48,8 +39,8 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E - DepthMaps.push_back(&ActiveScene->PointLights[i]->DepthMap); - LightPositions.push_back(ActiveScene->PointLights[i]->Pos); + DepthMaps->push_back(&ActiveScene->PointLights[i]->DepthMap); + LightPositions->push_back(ActiveScene->PointLights[i]->Pos); } else if (ActiveScene->PointLights[i]->DepthMap.Initialized) { @@ -66,8 +57,8 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E ActiveScene->SpotLights[i]->DepthMap = ERS_CLASS_DepthMaps_->GenerateDepthMap2D(); } - DepthMaps.push_back(&ActiveScene->SpotLights[i]->DepthMap); - LightPositions.push_back(ActiveScene->SpotLights[i]->Pos); + DepthMaps->push_back(&ActiveScene->SpotLights[i]->DepthMap); + LightPositions->push_back(ActiveScene->SpotLights[i]->Pos); } else if (ActiveScene->SpotLights[i]->DepthMap.Initialized) { @@ -96,6 +87,21 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } +} + +void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader, glm::vec3 CameraPosition) { + + // Get Updated Info From Renderer Settings + ERS_CLASS_DepthMaps_->CheckSettings(); + ERS::Renderer::ShadowUpdateMode UpdateMode = SystemUtils_->RendererSettings_->ShadowUpdateMode_; + //ERS::Renderer::ShadowFilteringType FilterMode = SystemUtils_->RendererSettings_->ShadowFilteringType_; + + + // Create List Of All Depth Maps + std::vector DepthMaps; + std::vector LightPositions; + + // Skip Handling An Update If No Lights Are To Be Updated Here diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index 1d16a4dfe9..bf84634e1d 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -59,6 +59,14 @@ class ERS_CLASS_ShadowMaps { unsigned int LastUpdateIndex_ = 0; /*** DepthMaps, std::vector* LightPositions); + public: From 1c058df4441876331f87b77fab442e98068f229a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 04:21:40 +0000 Subject: [PATCH 177/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 03c01c11d6..348c3551a7 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -100,7 +100,7 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Create List Of All Depth Maps std::vector DepthMaps; std::vector LightPositions; - + GetDepthMaps(&DepthMaps, &LightPositions); From b1b3d283c73094028aa59e79eee5c48a2d25e699 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 04:24:43 +0000 Subject: [PATCH 178/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index bf84634e1d..5eb6eb6dbe 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -67,6 +67,14 @@ class ERS_CLASS_ShadowMaps { */ void GetDepthMaps(std::vector* DepthMaps, std::vector* LightPositions); + /** + * @brief Determines which depth maps should be updated, and also deallocates those on lights that are no longer being used. + * + * @param DepthMaps + * @param LightPositions + */ + void PrioritizeDepthMaps(std::vector* DepthMaps, std::vector* LightPositions); + public: From f42f66a68cdec5d712ad1562cf202b0d658697b5 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 04:26:14 +0000 Subject: [PATCH 179/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 31 ++++++++++++------- .../ERS_CLASS_ShadowMaps.h | 2 +- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 348c3551a7..6e00301d8b 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -89,20 +89,11 @@ void ERS_CLASS_ShadowMaps::GetDepthMaps(std::vector* Depth } -void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader, glm::vec3 CameraPosition) { - - // Get Updated Info From Renderer Settings - ERS_CLASS_DepthMaps_->CheckSettings(); - ERS::Renderer::ShadowUpdateMode UpdateMode = SystemUtils_->RendererSettings_->ShadowUpdateMode_; - //ERS::Renderer::ShadowFilteringType FilterMode = SystemUtils_->RendererSettings_->ShadowFilteringType_; +void ERS_CLASS_ShadowMaps::PrioritizeDepthMaps(std::vector DepthMaps, std::vector LightPositions, glm::vec3 CameraPosition) { - // Create List Of All Depth Maps - std::vector DepthMaps; - std::vector LightPositions; - GetDepthMaps(&DepthMaps, &LightPositions); + ERS::Renderer::ShadowUpdateMode UpdateMode = SystemUtils_->RendererSettings_->ShadowUpdateMode_; - // Skip Handling An Update If No Lights Are To Be Updated Here if (DepthMaps.size() > 1) { @@ -169,6 +160,24 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E } +} + +void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader, glm::vec3 CameraPosition) { + + // Get Updated Info From Renderer Settings + ERS_CLASS_DepthMaps_->CheckSettings(); + //ERS::Renderer::ShadowFilteringType FilterMode = SystemUtils_->RendererSettings_->ShadowFilteringType_; + + + // Create List Of All Depth Maps + std::vector DepthMaps; + std::vector LightPositions; + GetDepthMaps(&DepthMaps, &LightPositions); + + + + + // Update All Depth Maps ERS_CLASS_DepthMaps_->UpdateDepthMaps(DepthMapShader, CubemapDepthShader); diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index 5eb6eb6dbe..f51160d940 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -73,7 +73,7 @@ class ERS_CLASS_ShadowMaps { * @param DepthMaps * @param LightPositions */ - void PrioritizeDepthMaps(std::vector* DepthMaps, std::vector* LightPositions); + void PrioritizeDepthMaps(std::vector DepthMaps, std::vector LightPositions, glm::vec3 CameraPosition); public: From d30a0a417eb73b93b45413a71f6c179006dabe46 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 04:26:44 +0000 Subject: [PATCH 180/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 6e00301d8b..c781474bde 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -166,17 +166,12 @@ void ERS_CLASS_ShadowMaps::UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, E // Get Updated Info From Renderer Settings ERS_CLASS_DepthMaps_->CheckSettings(); - //ERS::Renderer::ShadowFilteringType FilterMode = SystemUtils_->RendererSettings_->ShadowFilteringType_; - - // Create List Of All Depth Maps + // Handle Updating Depth Maps std::vector DepthMaps; std::vector LightPositions; GetDepthMaps(&DepthMaps, &LightPositions); - - - - + PrioritizeDepthMaps(DepthMaps, LightPositions, CameraPosition); // Update All Depth Maps ERS_CLASS_DepthMaps_->UpdateDepthMaps(DepthMapShader, CubemapDepthShader); From de8d044213b383c19d5e0860f050d291f25b7f50 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 04:29:39 +0000 Subject: [PATCH 181/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index 056696a916..e52cee19c3 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -209,13 +209,17 @@ bool ERS_CLASS_DepthMaps::RegenerateDepthMapTextureArrayCubemap(int NumberOfText bool ERS_CLASS_DepthMaps::FreeDepthMapIndex2D(unsigned int Index) { + SystemUtils_->Logger_->Log(std::string("Freeing 2D Array Depth Map Index '") + std::to_string(Index) + std::string("'"), 4); + // Sanity Check if (Index > DepthMapTexturesAlreadyAllocated_.size() - 1) { + SystemUtils_->Logger_->Log(std::string("Cannot Free Invalid 2D Array Depth Map Index '") + std::to_string(Index) + std::string("', Index Out Of Range"), 9); return false; // Indicate Failure, Out Of Range } // DeAllocate From Array DepthMapTexturesAlreadyAllocated_[Index] = -1; + SystemUtils_->Logger_->Log(std::string("Deallocated 2D Array Depth Map Index '") + std::to_string(Index) + std::string("'"), 3); return true; } From 10110db577bc9d933c72f9b9de58493e81ac8400 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 04:30:17 +0000 Subject: [PATCH 182/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp index e52cee19c3..276ea1f1b3 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -226,13 +226,17 @@ bool ERS_CLASS_DepthMaps::FreeDepthMapIndex2D(unsigned int Index) { bool ERS_CLASS_DepthMaps::FreeDepthMapIndexCubemap(unsigned int Index) { + SystemUtils_->Logger_->Log(std::string("Freeing Cubemap Array Depth Map Index '") + std::to_string(Index) + std::string("'"), 4); + // Sanity Check if (Index > DepthMapTexturesCubemapAlreadyAllocated_.size() - 1) { + SystemUtils_->Logger_->Log(std::string("Cannot Free Invalid Cubemap Array Depth Map Index '") + std::to_string(Index) + std::string("', Index Out Of Range"), 9); return false; // Indicate Failure, Out Of Range } // DeAllocate From Array - DepthMapTexturesCubemapAlreadyAllocated_[Index] = -1; //ERS_STRUCT_CubemapFBOIndexes(); + DepthMapTexturesCubemapAlreadyAllocated_[Index] = -1; + SystemUtils_->Logger_->Log(std::string("Deallocated Cubemap Array Depth Map Index '") + std::to_string(Index) + std::string("'"), 3); return true; } From c0f4e530119b11fb348ffa5e438515741a38b473 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 04:50:37 +0000 Subject: [PATCH 183/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index c781474bde..8bb028777b 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -22,6 +22,38 @@ ERS_CLASS_ShadowMaps::~ERS_CLASS_ShadowMaps() { SystemUtils_->Logger_->Log("Viewport Overlay Subsystem Destructor Invoked", 6); + // Iterate Over All Depth Maps, And Dellocate It + SystemUtils_->Logger_->Log("Deallocating All Depth Map Indices", 5); + ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); + + for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { + + if (ActiveScene->PointLights[i]->DepthMap.Initialized) { + ERS_CLASS_DepthMaps_->FreeDepthMapIndexCubemap(ActiveScene->PointLights[i]->DepthMap.DepthMapTextureIndex); + ActiveScene->PointLights[i]->DepthMap.Initialized = false; + } + + } + + for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { + + if (ActiveScene->SpotLights[i]->DepthMap.Initialized) { + ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex); + ActiveScene->SpotLights[i]->DepthMap.Initialized = false; + } + + } + + for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { + + if (ActiveScene->DirectionalLights[i]->DepthMap.Initialized) { + ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->DirectionalLights[i]->DepthMap.DepthMapTextureIndex); + ActiveScene->DirectionalLights[i]->DepthMap.Initialized = false; + } + + } + + } void ERS_CLASS_ShadowMaps::GetDepthMaps(std::vector* DepthMaps, std::vector* LightPositions) { From 7ba4e9db5c86bc9cfcf5575deecaee61946ac2a4 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 04:51:31 +0000 Subject: [PATCH 184/203] Implement Settings To Control Rendering (#220) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 8bb028777b..5958d5c1e7 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -52,6 +52,7 @@ ERS_CLASS_ShadowMaps::~ERS_CLASS_ShadowMaps() { } } + SystemUtils_->Logger_->Log("Finished Dallocating All Depth Map Indices", 4); } From 4178d6f3ff937d83cf27286dea2cfb92131a6bc2 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 05:01:14 +0000 Subject: [PATCH 185/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index 5958d5c1e7..a1a512b696 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -22,37 +22,37 @@ ERS_CLASS_ShadowMaps::~ERS_CLASS_ShadowMaps() { SystemUtils_->Logger_->Log("Viewport Overlay Subsystem Destructor Invoked", 6); - // Iterate Over All Depth Maps, And Dellocate It - SystemUtils_->Logger_->Log("Deallocating All Depth Map Indices", 5); - ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); + // // Iterate Over All Depth Maps, And Dellocate It + // SystemUtils_->Logger_->Log("Deallocating All Depth Map Indices", 5); + // ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); - for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { + // for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { - if (ActiveScene->PointLights[i]->DepthMap.Initialized) { - ERS_CLASS_DepthMaps_->FreeDepthMapIndexCubemap(ActiveScene->PointLights[i]->DepthMap.DepthMapTextureIndex); - ActiveScene->PointLights[i]->DepthMap.Initialized = false; - } + // if (ActiveScene->PointLights[i]->DepthMap.Initialized) { + // ERS_CLASS_DepthMaps_->FreeDepthMapIndexCubemap(ActiveScene->PointLights[i]->DepthMap.DepthMapTextureIndex); + // ActiveScene->PointLights[i]->DepthMap.Initialized = false; + // } - } + // } - for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { + // for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { - if (ActiveScene->SpotLights[i]->DepthMap.Initialized) { - ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex); - ActiveScene->SpotLights[i]->DepthMap.Initialized = false; - } + // if (ActiveScene->SpotLights[i]->DepthMap.Initialized) { + // ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex); + // ActiveScene->SpotLights[i]->DepthMap.Initialized = false; + // } - } + // } - for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { + // for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { - if (ActiveScene->DirectionalLights[i]->DepthMap.Initialized) { - ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->DirectionalLights[i]->DepthMap.DepthMapTextureIndex); - ActiveScene->DirectionalLights[i]->DepthMap.Initialized = false; - } + // if (ActiveScene->DirectionalLights[i]->DepthMap.Initialized) { + // ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->DirectionalLights[i]->DepthMap.DepthMapTextureIndex); + // ActiveScene->DirectionalLights[i]->DepthMap.Initialized = false; + // } - } - SystemUtils_->Logger_->Log("Finished Dallocating All Depth Map Indices", 4); + // } + // SystemUtils_->Logger_->Log("Finished Dallocating All Depth Map Indices", 4); } From 4ff0104c01fef1f2bd4d877557b379d0a40c2e1c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 05:12:16 +0000 Subject: [PATCH 186/203] Implement Settings To Control Rendering (#220) --- .../ERS_CLASS_ShadowMaps.cpp | 47 ++++++++++--------- .../ERS_CLASS_ShadowMaps.h | 7 +++ 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp index a1a512b696..72e6f8a866 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.cpp @@ -22,38 +22,41 @@ ERS_CLASS_ShadowMaps::~ERS_CLASS_ShadowMaps() { SystemUtils_->Logger_->Log("Viewport Overlay Subsystem Destructor Invoked", 6); - // // Iterate Over All Depth Maps, And Dellocate It - // SystemUtils_->Logger_->Log("Deallocating All Depth Map Indices", 5); - // ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); +} - // for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { +void ERS_CLASS_ShadowMaps::DeallocateLightMaps() { - // if (ActiveScene->PointLights[i]->DepthMap.Initialized) { - // ERS_CLASS_DepthMaps_->FreeDepthMapIndexCubemap(ActiveScene->PointLights[i]->DepthMap.DepthMapTextureIndex); - // ActiveScene->PointLights[i]->DepthMap.Initialized = false; - // } + // Iterate Over All Depth Maps, And Dellocate It + SystemUtils_->Logger_->Log("Deallocating All Depth Map Indices", 5); + ERS_STRUCT_Scene* ActiveScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); - // } + for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { - // for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { + if (ActiveScene->PointLights[i]->DepthMap.Initialized) { + ERS_CLASS_DepthMaps_->FreeDepthMapIndexCubemap(ActiveScene->PointLights[i]->DepthMap.DepthMapTextureIndex); + ActiveScene->PointLights[i]->DepthMap.Initialized = false; + } - // if (ActiveScene->SpotLights[i]->DepthMap.Initialized) { - // ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex); - // ActiveScene->SpotLights[i]->DepthMap.Initialized = false; - // } + } - // } + for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { - // for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { + if (ActiveScene->SpotLights[i]->DepthMap.Initialized) { + ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex); + ActiveScene->SpotLights[i]->DepthMap.Initialized = false; + } - // if (ActiveScene->DirectionalLights[i]->DepthMap.Initialized) { - // ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->DirectionalLights[i]->DepthMap.DepthMapTextureIndex); - // ActiveScene->DirectionalLights[i]->DepthMap.Initialized = false; - // } + } + + for (unsigned int i = 0; i < ActiveScene->DirectionalLights.size(); i++) { - // } - // SystemUtils_->Logger_->Log("Finished Dallocating All Depth Map Indices", 4); + if (ActiveScene->DirectionalLights[i]->DepthMap.Initialized) { + ERS_CLASS_DepthMaps_->FreeDepthMapIndex2D(ActiveScene->DirectionalLights[i]->DepthMap.DepthMapTextureIndex); + ActiveScene->DirectionalLights[i]->DepthMap.Initialized = false; + } + } + SystemUtils_->Logger_->Log("Finished Dallocating All Depth Map Indices", 4); } diff --git a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h index f51160d940..5960b70fa5 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_ShadowMaps.h @@ -108,4 +108,11 @@ class ERS_CLASS_ShadowMaps { void UpdateShadowMaps(ERS_STRUCT_Shader* DepthMapShader, ERS_STRUCT_Shader* CubemapDepthShader, glm::vec3 CameraPosition); + /** + * @brief Deallocates all + * + */ + void DeallocateLightMaps(); + + }; \ No newline at end of file From d302144d3d87f6c33a078f32c469d1a7626d852a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 05:31:14 +0000 Subject: [PATCH 187/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index eec7fc5da3..5ca37901fc 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -361,8 +361,27 @@ float ShadowCalculation(STRUCT_PointLight Light) // now get current linear depth as the length between the fragment and light position float currentDepth = length(fragToLight); // test for shadows - float bias = 0.05; // we use a much larger bias since depth is now in [near_plane, far_plane] range - float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0; + + // Generate Shadow Map Bias + int TextureSize = textureSize(DepthMapCubeArray, 0).x; + float BiasMax = 0.005f; + if (TextureSize <= 512) { + BiasMax = 0.075; + } else if (TextureSize <= 1024) { + BiasMax = 0.05; + } else if (TextureSize <= 2048) { + BiasMax = 0.03; + } else if (TextureSize <= 4096) { + BiasMax = 0.02; + } else if (TextureSize <= 8192) { + BiasMax = 0.015; + } else if (TextureSize <= 16384) { + BiasMax = 0.01; + } + + float Bias = max(0.00 * (1.0 - dot(Object.Normal, normalize(fragToLight))), BiasMax); + + float shadow = currentDepth - Bias > closestDepth ? 1.0 : 0.0; // display closestDepth as debug (to visualize depth cubemap) // FragColor = vec4(vec3(closestDepth / Light.MaxDistance), 1.0); @@ -733,5 +752,6 @@ void main() { + From d90f7ca58caa6764e1846da53d2b8e5fdef712ec Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 07:43:39 +0000 Subject: [PATCH 188/203] Implement Settings To Control Rendering (#220) --- .../Loader/ERS_SceneLoader/ERS_SceneLoader.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp index 38e2d706b6..e1b34f7e8b 100644 --- a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp +++ b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp @@ -298,6 +298,23 @@ void ERS_CLASS_SceneLoader::AddModel(ERS_STRUCT_Scene* Scene, long AssetID) { Scene->Models[CurrentSize-1]->Name = std::string("Loading..."); Scene->Models[CurrentSize-1]->FlipTextures = true; + + // Process Texture References, Setup Meshes + ERS_STRUCT_Model* Model = Scene->Models[CurrentSize-1].get(); + for (unsigned long i = 0; i < Model->Meshes.size(); i++) { + for (unsigned long Index = 0; Index < Model->Meshes[i].TextureReferences_.size(); Index++) { // IF TEXTURES DONT WORK, CHECK HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + int TextureIndex = Model->Meshes[i].TextureReferences_[Index]; + + // Set Shadow Configuration Pointers + Model->Meshes[i].CastDynamicShadows_ = &Model->CastDynamicShadows_; + Model->Meshes[i].CastStaticShadows_ = &Model->CastStaticShadows_; + Model->Meshes[i].ReceiveShadows_ = &Model->ReceiveShadows_; + + } + } + + ModelLoader_->AddModelToLoadingQueue(AssetID, Scene->Models[CurrentSize-1], Scene->Models[CurrentSize-1]->FlipTextures); From 6dce252dca2e3bb34bbaf95fbb4ca06c8cc00ac6 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 07:46:40 +0000 Subject: [PATCH 189/203] Implement Settings To Control Rendering (#220) --- .../Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp index e1b34f7e8b..6ecbfc6ba6 100644 --- a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp +++ b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp @@ -302,16 +302,13 @@ void ERS_CLASS_SceneLoader::AddModel(ERS_STRUCT_Scene* Scene, long AssetID) { // Process Texture References, Setup Meshes ERS_STRUCT_Model* Model = Scene->Models[CurrentSize-1].get(); for (unsigned long i = 0; i < Model->Meshes.size(); i++) { - for (unsigned long Index = 0; Index < Model->Meshes[i].TextureReferences_.size(); Index++) { // IF TEXTURES DONT WORK, CHECK HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - int TextureIndex = Model->Meshes[i].TextureReferences_[Index]; - // Set Shadow Configuration Pointers - Model->Meshes[i].CastDynamicShadows_ = &Model->CastDynamicShadows_; - Model->Meshes[i].CastStaticShadows_ = &Model->CastStaticShadows_; - Model->Meshes[i].ReceiveShadows_ = &Model->ReceiveShadows_; + // Set Shadow Configuration Pointers + Model->Meshes[i].CastDynamicShadows_ = &Model->CastDynamicShadows_; + Model->Meshes[i].CastStaticShadows_ = &Model->CastStaticShadows_; + Model->Meshes[i].ReceiveShadows_ = &Model->ReceiveShadows_; - } + } From 347c5de5714c6a5068877bf208e39ece00a983f6 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 07:47:07 +0000 Subject: [PATCH 190/203] Implement Settings To Control Rendering (#220) --- .../Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp b/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp index ab934fb9fe..22f4dbb6e8 100644 --- a/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp +++ b/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp @@ -229,15 +229,17 @@ void ERS_CLASS_ModelLoader::ProcessGPU(std::shared_ptr Model) // Process Texture References, Setup Meshes for (unsigned long i = 0; i < Model->Meshes.size(); i++) { + + // Set Shadow Configuration Pointers + Model->Meshes[i].CastDynamicShadows_ = &Model->CastDynamicShadows_; + Model->Meshes[i].CastStaticShadows_ = &Model->CastStaticShadows_; + Model->Meshes[i].ReceiveShadows_ = &Model->ReceiveShadows_; + + for (unsigned long Index = 0; Index < Model->Meshes[i].TextureReferences_.size(); Index++) { // IF TEXTURES DONT WORK, CHECK HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! int TextureIndex = Model->Meshes[i].TextureReferences_[Index]; - // Set Shadow Configuration Pointers - Model->Meshes[i].CastDynamicShadows_ = &Model->CastDynamicShadows_; - Model->Meshes[i].CastStaticShadows_ = &Model->CastStaticShadows_; - Model->Meshes[i].ReceiveShadows_ = &Model->ReceiveShadows_; - if (TextureIndex == -1) { SystemUtils_->Logger_->Log("Failed To Find Corresponding Texture", 8); Model->Meshes[i].TextureIDs.push_back(-1); From 8ddad8b7794447540b4ed1ff952e27b7ca9ed231 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 08:59:26 +0000 Subject: [PATCH 191/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10040.ERS | 4 + .../Projects/DefaultProject/10041.ERS | 137 ++++++++++++------ 2 files changed, 97 insertions(+), 44 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10040.ERS b/Source/EditorAssets/Projects/DefaultProject/10040.ERS index a49eb8a919..a7604b2c1f 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10040.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10040.ERS @@ -71,3 +71,7 @@ void main() + + + + diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 5ca37901fc..14799ca935 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -159,6 +159,14 @@ vec2( 0.19984126, 0.78641367 ), vec2( 0.14383161, -0.14100790 ) ); +vec3 SampleOffsetDirections[20] = vec3[] +( + vec3( 1, 1, 1), vec3( 1, -1, 1), vec3(-1, -1, 1), vec3(-1, 1, 1), + vec3( 1, 1, -1), vec3( 1, -1, -1), vec3(-1, -1, -1), vec3(-1, 1, -1), + vec3( 1, 1, 0), vec3( 1, -1, 0), vec3(-1, -1, 0), vec3(-1, 1, 0), + vec3( 1, 0, 1), vec3(-1, 0, 1), vec3( 1, 0, -1), vec3(-1, 0, -1), + vec3( 0, 1, 1), vec3( 0, -1, 1), vec3( 0, -1, -1), vec3( 0, 1, -1) +); float random(vec3 seed, int i){ vec4 seed4 = vec4(seed,i); @@ -186,6 +194,30 @@ float PCFSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int } +float PCFSamplerCubemap(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, float ViewDistance, int SampleSize) { + + float shadow = 0.0; + + float samples = SampleSize; + float offset = 0.025; + for(float x = -offset; x < offset; x += offset / (samples * 0.5)) + { + for(float y = -offset; y < offset; y += offset / (samples * 0.5)) + { + for(float z = -offset; z < offset; z += offset / (samples * 0.5)) + { + float closestDepth = texture(DepthMapCubeArray, vec4(TexCoords3D + vec3(x, y, z), Index)).r; // use lightdir to lookup cubemap + closestDepth *= ViewDistance; // Undo mapping [0;1] + if(BiasedCurrentDepth > closestDepth) + shadow += 1.0; + } + } + } + shadow /= (samples * samples * samples); + + return shadow; +} + float StratifiedPoissonSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { float shadow = 0.0f; vec2 texelSize = 1.0f / textureSize(DepthMapArray, 0).xy; @@ -227,6 +259,65 @@ float PoissonSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, } +float ShadowCalculation(STRUCT_PointLight Light) +{ + + // If Shadows Are Not Enabled, Exit Early + if (!ReceiveShadows_ || !Light.CastsShadows) { + return 1.0f; + } + + // get vector between fragment position and light position + vec3 fragToLight = Object.FragPos - Light.Position; + + // ise the fragment to light vector to sample from the depth map + float closestDepth = texture(DepthMapCubeArray, vec4(fragToLight, Light.DepthCubemapIndex)).r; + // it is currently in linear range between [0,1], let's re-transform it back to original depth value + closestDepth *= Light.MaxDistance; + // now get current linear depth as the length between the fragment and light position + float currentDepth = length(fragToLight); + // test for shadows + + // Generate Shadow Map Bias + int TextureSize = textureSize(DepthMapCubeArray, 0).x; + float BiasMax = 0.005f; + if (TextureSize <= 512) { + BiasMax = 0.075; + } else if (TextureSize <= 1024) { + BiasMax = 0.05; + } else if (TextureSize <= 2048) { + BiasMax = 0.03; + } else if (TextureSize <= 4096) { + BiasMax = 0.02; + } else if (TextureSize <= 8192) { + BiasMax = 0.015; + } else if (TextureSize <= 16384) { + BiasMax = 0.01; + } + + float Bias = max(0.00 * (1.0 - dot(Object.Normal, normalize(fragToLight))), BiasMax); + + + // Select Correct Filter Based On Selection Uniform + float Shadow; + if (ShadowFilterType_ == 0) { // No Filtering + Shadow = currentDepth - Bias > closestDepth ? 1.0 : 0.0; + } else if (ShadowFilterType_ == 1) { // PCF Filtering + Shadow = PCFSamplerCubemap(currentDepth-Bias, fragToLight, Light.DepthCubemapIndex, Light.MaxDistance, ShadowFilterKernelSize_); + } else if (ShadowFilterType_ == 2) { // Poisson Filtering + //Shadow = PoissonSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, ShadowFilterKernelSize_); + } else if (ShadowFilterType_ == 3) { + //Shadow = StratifiedPoissonSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, ShadowFilterKernelSize_); + } else { + return 0.0f; // Return Failure, All Black) + } + + // display closestDepth as debug (to visualize depth cubemap) + // FragColor = vec4(vec3(closestDepth / Light.MaxDistance), 1.0); + + return 1.0f - Shadow; +} + float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) { @@ -343,50 +434,6 @@ float ShadowCalculation(STRUCT_SpotLight Light) } -float ShadowCalculation(STRUCT_PointLight Light) -{ - - // If Shadows Are Not Enabled, Exit Early - if (!ReceiveShadows_ || !Light.CastsShadows) { - return 1.0f; - } - - // get vector between fragment position and light position - vec3 fragToLight = Object.FragPos - Light.Position; - - // ise the fragment to light vector to sample from the depth map - float closestDepth = texture(DepthMapCubeArray, vec4(fragToLight, Light.DepthCubemapIndex)).r; - // it is currently in linear range between [0,1], let's re-transform it back to original depth value - closestDepth *= Light.MaxDistance; - // now get current linear depth as the length between the fragment and light position - float currentDepth = length(fragToLight); - // test for shadows - - // Generate Shadow Map Bias - int TextureSize = textureSize(DepthMapCubeArray, 0).x; - float BiasMax = 0.005f; - if (TextureSize <= 512) { - BiasMax = 0.075; - } else if (TextureSize <= 1024) { - BiasMax = 0.05; - } else if (TextureSize <= 2048) { - BiasMax = 0.03; - } else if (TextureSize <= 4096) { - BiasMax = 0.02; - } else if (TextureSize <= 8192) { - BiasMax = 0.015; - } else if (TextureSize <= 16384) { - BiasMax = 0.01; - } - - float Bias = max(0.00 * (1.0 - dot(Object.Normal, normalize(fragToLight))), BiasMax); - - float shadow = currentDepth - Bias > closestDepth ? 1.0 : 0.0; - // display closestDepth as debug (to visualize depth cubemap) - // FragColor = vec4(vec3(closestDepth / Light.MaxDistance), 1.0); - - return 1.0f - shadow; -} @@ -752,6 +799,8 @@ void main() { + + From 1b02dd625b873d9411d920debd7e9567b3af2737 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 12:07:57 +0000 Subject: [PATCH 192/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 14799ca935..661777b321 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -159,6 +159,25 @@ vec2( 0.19984126, 0.78641367 ), vec2( 0.14383161, -0.14100790 ) ); +vec3 Poisson3D[16] = vec3[] ( +vec3(0.7439873218536399, -0.541186283808202, 0.17664264608175007), +vec3(-0.275775456801057, -0.32272001542150996, 0.68133261147887), +vec3(0.44897621078416994, -0.467917730100453, -0.659653108566999), +vec3(-0.847784673329443, 0.028283810708670032, -0.400656977668405), +vec3(-0.727825771085918, -0.283869738690555, 0.08675202075392008), +vec3(-0.452855029609054, 0.66060589626431, 0.7711005629971599), +vec3(0.61847387859598, -0.33074145298451196, 0.51381932664663), +vec3(0.35371939232573, 0.3825031747110199, -0.18291005725040999), +vec3(0.08679201826453009, 0.61422011069953, -0.5682788607664411), +vec3(-0.733357671182603, 0.78749090107158, 0.42277105059474995), +vec3(0.58986698603258, -0.422245749272406, 0.42315440950914995), +vec3(-0.081056734547019, -0.26176304789259996, 0.33600588003173004), +vec3(-0.158656360581517, -0.436631633434445, 0.09938938915729989), +vec3(-0.534419173840433, 0.81530744861811, 0.26251380564645), +vec3(0.7347787003964199, -0.17376213055103995, -0.05371918901801098), +vec3(0.59472335595638, 0.43984056729822996, -0.564682560041547) +); + vec3 SampleOffsetDirections[20] = vec3[] ( vec3( 1, 1, 1), vec3( 1, -1, 1), vec3(-1, -1, 1), vec3(-1, 1, 1), @@ -218,6 +237,36 @@ float PCFSamplerCubemap(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, f return shadow; } + +float PoissonSamplerCube(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, float ViewDistance, int SampleSize) { + + float shadow = 0.0; + + float samples = SampleSize; + float offset = 0.025; + int PoissonIndex = 0; + for(float x = -offset; x < offset; x += offset / (samples * 0.5)) + { + for(float y = -offset; y < offset; y += offset / (samples * 0.5)) + { + for(float z = -offset; z < offset; z += offset / (samples * 0.5)) + { + PoissonIndex++; + vec3 PoissonOffset = vec3(Poisson3D[PoissonIndex%16]/75.0f); + float closestDepth = texture(DepthMapCubeArray, vec4(TexCoords3D + PoissonOffset, Index)).r; + closestDepth *= ViewDistance; + if(BiasedCurrentDepth > closestDepth) + shadow += 1.0; + } + } + } + shadow /= (samples * samples * samples); + + return shadow; + +} + + float StratifiedPoissonSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { float shadow = 0.0f; vec2 texelSize = 1.0f / textureSize(DepthMapArray, 0).xy; @@ -226,6 +275,7 @@ float StratifiedPoissonSampler(float Bias, vec3 ProjCoords, int Index, float Cur { for(int y = -SampleSize; y <= SampleSize; ++y) { + vec2 TexCoords2D = ProjCoords.xy + (vec2(x, y) * texelSize); int index = int(16.0f*random(floor(gl_FragCoord.yxz*1000.0f), x*y))%16; float pcfDepth = texture(DepthMapArray, vec3(TexCoords2D + PoissonDisk[index]/700.0f, Index)).r; @@ -259,6 +309,7 @@ float PoissonSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, } + float ShadowCalculation(STRUCT_PointLight Light) { @@ -305,7 +356,7 @@ float ShadowCalculation(STRUCT_PointLight Light) } else if (ShadowFilterType_ == 1) { // PCF Filtering Shadow = PCFSamplerCubemap(currentDepth-Bias, fragToLight, Light.DepthCubemapIndex, Light.MaxDistance, ShadowFilterKernelSize_); } else if (ShadowFilterType_ == 2) { // Poisson Filtering - //Shadow = PoissonSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, ShadowFilterKernelSize_); + Shadow = PoissonSamplerCube(currentDepth-Bias, fragToLight, Light.DepthCubemapIndex, Light.MaxDistance, ShadowFilterKernelSize_); } else if (ShadowFilterType_ == 3) { //Shadow = StratifiedPoissonSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, ShadowFilterKernelSize_); } else { From 518997394e159fb51aaff5cb6bdbd2ce91c0d1d8 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 12:09:14 +0000 Subject: [PATCH 193/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 661777b321..da871dfff8 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -238,6 +238,26 @@ float PCFSamplerCubemap(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, f } +float PoissonSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { + + float shadow = 0.0f; + vec2 texelSize = 1.0f / textureSize(DepthMapArray, 0).xy; + + for(int x = -SampleSize; x <= SampleSize; ++x) + { + for(int y = -SampleSize; y <= SampleSize; ++y) + { + vec2 TexCoords2D = ProjCoords.xy + (vec2(x, y) * texelSize); + int index = int(x*y)%16; + float pcfDepth = texture(DepthMapArray, vec3(TexCoords2D + PoissonDisk[index]/700.0f, Index)).r; + shadow += CurrentDepth - Bias > pcfDepth ? 1.0f : 0.0f; + } + } + shadow /= (SampleSize*2)*(SampleSize*2); + return shadow; + +} + float PoissonSamplerCube(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, float ViewDistance, int SampleSize) { float shadow = 0.0; @@ -288,25 +308,6 @@ float StratifiedPoissonSampler(float Bias, vec3 ProjCoords, int Index, float Cur } -float PoissonSampler(float Bias, vec3 ProjCoords, int Index, float CurrentDepth, int SampleSize) { - - float shadow = 0.0f; - vec2 texelSize = 1.0f / textureSize(DepthMapArray, 0).xy; - - for(int x = -SampleSize; x <= SampleSize; ++x) - { - for(int y = -SampleSize; y <= SampleSize; ++y) - { - vec2 TexCoords2D = ProjCoords.xy + (vec2(x, y) * texelSize); - int index = int(x*y)%16; - float pcfDepth = texture(DepthMapArray, vec3(TexCoords2D + PoissonDisk[index]/700.0f, Index)).r; - shadow += CurrentDepth - Bias > pcfDepth ? 1.0f : 0.0f; - } - } - shadow /= (SampleSize*2)*(SampleSize*2); - return shadow; - -} From 99dde32a23780eef58cc3ec3a889ad2ca4e01eec Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 12:22:06 +0000 Subject: [PATCH 194/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index da871dfff8..5dd930f741 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -308,7 +308,33 @@ float StratifiedPoissonSampler(float Bias, vec3 ProjCoords, int Index, float Cur } +float StratifiedPoissonSamplerCube(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, float ViewDistance, int SampleSize) { + float shadow = 0.0; + + float samples = SampleSize; + float offset = 0.025; + for(float x = -offset; x < offset; x += offset / (samples * 0.5)) + { + for(float y = -offset; y < offset; y += offset / (samples * 0.5)) + { + for(float z = -offset; z < offset; z += offset / (samples * 0.5)) + { + + int PoissonIndex = int(16.0f*random(floor(gl_FragCoord.yxz*1000.0f), int(10.0f*x*y*z)))%16; + vec3 PoissonOffset = vec3(Poisson3D[PoissonIndex%16]/250.0f); + float closestDepth = texture(DepthMapCubeArray, vec4(TexCoords3D + PoissonOffset, Index)).r; + closestDepth *= ViewDistance; + if(BiasedCurrentDepth > closestDepth) + shadow += 1.0; + } + } + } + shadow /= (samples * samples * samples); + + return shadow; + +} float ShadowCalculation(STRUCT_PointLight Light) @@ -359,7 +385,7 @@ float ShadowCalculation(STRUCT_PointLight Light) } else if (ShadowFilterType_ == 2) { // Poisson Filtering Shadow = PoissonSamplerCube(currentDepth-Bias, fragToLight, Light.DepthCubemapIndex, Light.MaxDistance, ShadowFilterKernelSize_); } else if (ShadowFilterType_ == 3) { - //Shadow = StratifiedPoissonSampler(Bias, projCoords, Light.DepthMapIndex, currentDepth, ShadowFilterKernelSize_); + Shadow = StratifiedPoissonSamplerCube(currentDepth-Bias, fragToLight, Light.DepthCubemapIndex, Light.MaxDistance, ShadowFilterKernelSize_); } else { return 0.0f; // Return Failure, All Black) } From fab98332a0ebf44ed52e9e9b8c83c7ee7d186337 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 12:31:43 +0000 Subject: [PATCH 195/203] Implement Settings To Control Rendering (#220) --- Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp b/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp index 22f4dbb6e8..2050e5c071 100644 --- a/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp +++ b/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp @@ -145,6 +145,11 @@ void ERS_CLASS_ModelLoader::AddModelToLoadingQueue(long AssetID, std::shared_ptr } +// Todo: cubemap shaders running too many times +// if needed, make one shader per filter technique and have it autogenerate multiple shaders +// just general performance improvements, such as rendering shadows on lower quality models, and adding static shadows. + + void ERS_CLASS_ModelLoader::ProcessGPU(std::shared_ptr Model) { From 19c713f946b5802d209089bb97f74bf1c964e06e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 23:05:42 +0000 Subject: [PATCH 196/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 5dd930f741..ec74a9dbd9 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -217,6 +217,7 @@ float PCFSamplerCubemap(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, f float shadow = 0.0; + /** float samples = SampleSize; float offset = 0.025; for(float x = -offset; x < offset; x += offset / (samples * 0.5)) @@ -234,6 +235,21 @@ float PCFSamplerCubemap(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, f } shadow /= (samples * samples * samples); + **/ + + + int samples = SampleSize*SampleSize; + //float viewDistance = length(viewPos - fragPos); + float diskRadius = 0.01f;//(1.0 + (viewDistance / far_plane)) / 25.0; + for(int i = 0; i < samples; ++i) + { + float closestDepth = texture(DepthMapCubeArray, vec4(TexCoords3D + SampleOffsetDirections[i] * diskRadius, Index)).r; + closestDepth *= ViewDistance; // undo mapping [0;1] + if(BiasedCurrentDepth > closestDepth) + shadow += 1.0; + } + shadow /= float(samples); + return shadow; } @@ -262,6 +278,7 @@ float PoissonSamplerCube(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, float shadow = 0.0; + /** float samples = SampleSize; float offset = 0.025; int PoissonIndex = 0; @@ -280,7 +297,20 @@ float PoissonSamplerCube(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, } } } - shadow /= (samples * samples * samples); + shadow /= (samples * samples * samples);**/ + + int samples = SampleSize*SampleSize*SampleSize; + for(int i = 0; i < samples; ++i) + { + + vec3 PoissonOffset = vec3(Poisson3D[i%16]/150.0f); + float closestDepth = texture(DepthMapCubeArray, vec4(TexCoords3D + PoissonOffset, Index)).r; + closestDepth *= ViewDistance; // undo mapping [0;1] + if(BiasedCurrentDepth > closestDepth) + shadow += 1.0; + } + shadow /= float(samples); + return shadow; @@ -880,5 +910,6 @@ void main() { + From 4f536e36341401e71fd24daf71c4c8ca57509d65 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 23:06:01 +0000 Subject: [PATCH 197/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index ec74a9dbd9..9d810ac61d 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -217,26 +217,6 @@ float PCFSamplerCubemap(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, f float shadow = 0.0; - /** - float samples = SampleSize; - float offset = 0.025; - for(float x = -offset; x < offset; x += offset / (samples * 0.5)) - { - for(float y = -offset; y < offset; y += offset / (samples * 0.5)) - { - for(float z = -offset; z < offset; z += offset / (samples * 0.5)) - { - float closestDepth = texture(DepthMapCubeArray, vec4(TexCoords3D + vec3(x, y, z), Index)).r; // use lightdir to lookup cubemap - closestDepth *= ViewDistance; // Undo mapping [0;1] - if(BiasedCurrentDepth > closestDepth) - shadow += 1.0; - } - } - } - shadow /= (samples * samples * samples); - - **/ - int samples = SampleSize*SampleSize; //float viewDistance = length(viewPos - fragPos); From 88a43d7732f57014a4e1361dd4e44310dfb1a04c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 23:08:48 +0000 Subject: [PATCH 198/203] Implement Settings To Control Rendering (#220) --- Source/EditorAssets/Projects/DefaultProject/10041.ERS | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 9d810ac61d..5c0f3fc8ee 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -217,9 +217,7 @@ float PCFSamplerCubemap(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, f float shadow = 0.0; - - int samples = SampleSize*SampleSize; - //float viewDistance = length(viewPos - fragPos); + int samples = SampleSize*SampleSize*SampleSize; float diskRadius = 0.01f;//(1.0 + (viewDistance / far_plane)) / 25.0; for(int i = 0; i < samples; ++i) { From 0b856c349dd6f0e47c9e969648d6146fb67b955c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 23:09:09 +0000 Subject: [PATCH 199/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 5c0f3fc8ee..d11a67053c 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -256,27 +256,6 @@ float PoissonSamplerCube(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, float shadow = 0.0; - /** - float samples = SampleSize; - float offset = 0.025; - int PoissonIndex = 0; - for(float x = -offset; x < offset; x += offset / (samples * 0.5)) - { - for(float y = -offset; y < offset; y += offset / (samples * 0.5)) - { - for(float z = -offset; z < offset; z += offset / (samples * 0.5)) - { - PoissonIndex++; - vec3 PoissonOffset = vec3(Poisson3D[PoissonIndex%16]/75.0f); - float closestDepth = texture(DepthMapCubeArray, vec4(TexCoords3D + PoissonOffset, Index)).r; - closestDepth *= ViewDistance; - if(BiasedCurrentDepth > closestDepth) - shadow += 1.0; - } - } - } - shadow /= (samples * samples * samples);**/ - int samples = SampleSize*SampleSize*SampleSize; for(int i = 0; i < samples; ++i) { From df6209e22d50416ef9f3e3d426c806e963f6a424 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 23:10:59 +0000 Subject: [PATCH 200/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index d11a67053c..83781c49f6 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -299,6 +299,7 @@ float StratifiedPoissonSamplerCube(float BiasedCurrentDepth, vec3 TexCoords3D, i float shadow = 0.0; + /** float samples = SampleSize; float offset = 0.025; for(float x = -offset; x < offset; x += offset / (samples * 0.5)) @@ -318,6 +319,24 @@ float StratifiedPoissonSamplerCube(float BiasedCurrentDepth, vec3 TexCoords3D, i } } shadow /= (samples * samples * samples); + + **/ + + + int samples = SampleSize*SampleSize*SampleSize; + for(int i = 0; i < samples; ++i) + { + int PoissonIndex = int(16.0f*random(floor(gl_FragCoord.yxz*1000.0f), int(i)))%16; + vec3 PoissonOffset = vec3(Poisson3D[PoissonIndex]/150.0f); + float closestDepth = texture(DepthMapCubeArray, vec4(TexCoords3D + PoissonOffset, Index)).r; + closestDepth *= ViewDistance; // undo mapping [0;1] + if(BiasedCurrentDepth > closestDepth) + shadow += 1.0; + } + shadow /= float(samples); + + + return shadow; return shadow; From ce965ce5ece7fa1a97010189a547c70ebb091877 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Thu, 23 Jun 2022 23:35:04 +0000 Subject: [PATCH 201/203] Implement Settings To Control Rendering (#220) --- .../Projects/DefaultProject/10041.ERS | 33 +++---------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 83781c49f6..93fa987074 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -217,7 +217,7 @@ float PCFSamplerCubemap(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, f float shadow = 0.0; - int samples = SampleSize*SampleSize*SampleSize; + int samples = SampleSize*SampleSize; float diskRadius = 0.01f;//(1.0 + (viewDistance / far_plane)) / 25.0; for(int i = 0; i < samples; ++i) { @@ -256,7 +256,9 @@ float PoissonSamplerCube(float BiasedCurrentDepth, vec3 TexCoords3D, int Index, float shadow = 0.0; - int samples = SampleSize*SampleSize*SampleSize; + int samples = SampleSize*SampleSize; + + for(int i = 0; i < samples; ++i) { @@ -299,31 +301,7 @@ float StratifiedPoissonSamplerCube(float BiasedCurrentDepth, vec3 TexCoords3D, i float shadow = 0.0; - /** - float samples = SampleSize; - float offset = 0.025; - for(float x = -offset; x < offset; x += offset / (samples * 0.5)) - { - for(float y = -offset; y < offset; y += offset / (samples * 0.5)) - { - for(float z = -offset; z < offset; z += offset / (samples * 0.5)) - { - - int PoissonIndex = int(16.0f*random(floor(gl_FragCoord.yxz*1000.0f), int(10.0f*x*y*z)))%16; - vec3 PoissonOffset = vec3(Poisson3D[PoissonIndex%16]/250.0f); - float closestDepth = texture(DepthMapCubeArray, vec4(TexCoords3D + PoissonOffset, Index)).r; - closestDepth *= ViewDistance; - if(BiasedCurrentDepth > closestDepth) - shadow += 1.0; - } - } - } - shadow /= (samples * samples * samples); - - **/ - - - int samples = SampleSize*SampleSize*SampleSize; + int samples = SampleSize*SampleSize; for(int i = 0; i < samples; ++i) { int PoissonIndex = int(16.0f*random(floor(gl_FragCoord.yxz*1000.0f), int(i)))%16; @@ -338,7 +316,6 @@ float StratifiedPoissonSamplerCube(float BiasedCurrentDepth, vec3 TexCoords3D, i return shadow; - return shadow; } From 3e1d09c1a2964f4c4c591e4c3f63921b6e0f089b Mon Sep 17 00:00:00 2001 From: datacrystals Date: Fri, 24 Jun 2022 01:53:48 +0000 Subject: [PATCH 202/203] Implement Settings To Control Rendering (#220) --- .../ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h index 376d45ae17..7470012b55 100644 --- a/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h +++ b/Source/Core/Structures/ERS_STRUCT_RendererSettings/ERS_STRUCT_RendererSettings.h @@ -31,6 +31,6 @@ struct ERS_STRUCT_RendererSettings { ERS::Renderer::ShadowFilteringType ShadowFilteringType_ = ERS::Renderer::ERS_SHADOW_FILTERING_STRATIFIED_POISSON_SAMPLING; ERS::Renderer::ShadowUpdateMode ShadowUpdateMode_ = ERS::Renderer::ERS_SHADOW_UPDATE_MODE_DISTANCE_PRIORITIZED; int MaxShadowUpdatesPerFrame_ = 5; - int ShadowFilterKernelSize_ = 2; + int ShadowFilterKernelSize_ = 1; }; \ No newline at end of file From 564a23ea9af5bfc07a083e85db9c4e99816bdc08 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Fri, 24 Jun 2022 01:56:49 +0000 Subject: [PATCH 203/203] Implement Settings To Control Rendering (#220) --- Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp b/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp index 2050e5c071..8ef3a6595f 100644 --- a/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp +++ b/Source/Core/Loader/ERS_ModelLoader/ERS_ModelLoader.cpp @@ -145,10 +145,6 @@ void ERS_CLASS_ModelLoader::AddModelToLoadingQueue(long AssetID, std::shared_ptr } -// Todo: cubemap shaders running too many times -// if needed, make one shader per filter technique and have it autogenerate multiple shaders -// just general performance improvements, such as rendering shadows on lower quality models, and adding static shadows. - void ERS_CLASS_ModelLoader::ProcessGPU(std::shared_ptr Model) {