From 3ca21dce8a2aedfa592927d092d99ae248c21bbe Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 01:44:49 +0000 Subject: [PATCH 001/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp | 2 -- 1 file changed, 2 deletions(-) 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 90198f398c..37bd986877 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp @@ -13,7 +13,6 @@ void ERS_FUNCTION_DrawMesh(ERS_STRUCT_Mesh* Mesh, ERS_STRUCT_OpenGLDefaults* Ope unsigned int DiffuseHandle = 1; unsigned int DisplacementHandle = 1; unsigned int EmissiveHandle = 1; - unsigned int HeightHandle = 1; unsigned int MetalnessHandle = 1; unsigned int NormalsHandle = 1; unsigned int ShininessHandle = 1; @@ -27,7 +26,6 @@ void ERS_FUNCTION_DrawMesh(ERS_STRUCT_Mesh* Mesh, ERS_STRUCT_OpenGLDefaults* Ope ERS_FUNCTION_ResetMeshTexture("texture_diffuse1", 2, ShaderProgram, ResetTexID); ERS_FUNCTION_ResetMeshTexture("texture_displacement1", 3, ShaderProgram, ResetTexID); ERS_FUNCTION_ResetMeshTexture("texture_emissive1", 4, ShaderProgram, ResetTexID); - ERS_FUNCTION_ResetMeshTexture("texture_height1", 5, ShaderProgram, ResetTexID); ERS_FUNCTION_ResetMeshTexture("texture_metalness1", 6, ShaderProgram, ResetTexID); ERS_FUNCTION_ResetMeshTexture("texture_normals1", 7, ShaderProgram, ResetTexID); ERS_FUNCTION_ResetMeshTexture("texture_shininess1", 8, ShaderProgram, ResetTexID); From f17691d81cd932c13a2e95fe6f65a61c54da4ad4 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 01:45:22 +0000 Subject: [PATCH 002/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 37bd986877..b6eb2205e1 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_FUNCTION_DrawMesh.cpp @@ -26,9 +26,9 @@ void ERS_FUNCTION_DrawMesh(ERS_STRUCT_Mesh* Mesh, ERS_STRUCT_OpenGLDefaults* Ope ERS_FUNCTION_ResetMeshTexture("texture_diffuse1", 2, ShaderProgram, ResetTexID); ERS_FUNCTION_ResetMeshTexture("texture_displacement1", 3, ShaderProgram, ResetTexID); ERS_FUNCTION_ResetMeshTexture("texture_emissive1", 4, ShaderProgram, ResetTexID); - ERS_FUNCTION_ResetMeshTexture("texture_metalness1", 6, ShaderProgram, ResetTexID); - ERS_FUNCTION_ResetMeshTexture("texture_normals1", 7, ShaderProgram, ResetTexID); - ERS_FUNCTION_ResetMeshTexture("texture_shininess1", 8, ShaderProgram, ResetTexID); + ERS_FUNCTION_ResetMeshTexture("texture_metalness1", 5, ShaderProgram, ResetTexID); + ERS_FUNCTION_ResetMeshTexture("texture_normals1", 6, ShaderProgram, ResetTexID); + ERS_FUNCTION_ResetMeshTexture("texture_shininess1", 7, ShaderProgram, ResetTexID); From 11a30e576c528874a8176fe0abe334177286cd31 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 01:47:57 +0000 Subject: [PATCH 003/121] Implement Spot Light Shadows (#217) --- Source/EditorAssets/DefaultLayout/imgui.ini | 44 ++++++++++++--------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/Source/EditorAssets/DefaultLayout/imgui.ini b/Source/EditorAssets/DefaultLayout/imgui.ini index d0815f6139..5c8f805498 100644 --- a/Source/EditorAssets/DefaultLayout/imgui.ini +++ b/Source/EditorAssets/DefaultLayout/imgui.ini @@ -93,7 +93,7 @@ Collapsed=0 [Window][DockSpaceViewport_11111111] Pos=0,20 -Size=1920,1156 +Size=3408,1354 Collapsed=0 [Window][TestWindow2] @@ -127,20 +127,20 @@ Collapsed=0 DockId=0x00000001,1 [Window][Framerate Graph] -Pos=428,20 -Size=832,227 +Pos=601,20 +Size=1566,227 Collapsed=0 DockId=0x00000015,0 [Window][Object Properties] -Pos=428,711 -Size=459,465 +Pos=601,809 +Size=459,565 Collapsed=0 DockId=0x00000014,0 [Window][Scene Tree] -Pos=428,249 -Size=459,230 +Pos=601,249 +Size=459,279 Collapsed=0 DockId=0x00000001,0 @@ -161,14 +161,14 @@ Size=266,318 Collapsed=0 [Window][Frame Latency Graph] -Pos=1262,20 -Size=658,227 +Pos=2169,20 +Size=1239,227 Collapsed=0 DockId=0x00000016,0 [Window][Viewport 1] -Pos=889,249 -Size=1031,927 +Pos=1062,249 +Size=2346,1125 Collapsed=0 DockId=0x00000017,0 @@ -190,16 +190,16 @@ Size=589,466 Collapsed=0 [Window][Asset Explorer] -Pos=428,481 -Size=459,228 +Pos=601,530 +Size=459,277 Collapsed=0 DockId=0x00000002,0 [Window][Shader Editor] -Pos=0,271 -Size=599,436 +Pos=0,20 +Size=599,952 Collapsed=0 -DockId=0x00000019,0 +DockId=0x0000001F,0 [Window][Shader Tools] Pos=0,709 @@ -235,6 +235,12 @@ Pos=60,60 Size=435,273 Collapsed=0 +[Window][Compiler Log] +Pos=0,974 +Size=599,400 +Collapsed=0 +DockId=0x00000020,0 + [Table][0x0B04C00B,4] RefScale=14 Column 0 Sort=0v @@ -252,7 +258,7 @@ RefScale=14 Column 0 Sort=0v [Docking][Data] -DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,20 Size=1920,1156 Split=X +DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,20 Size=3408,1354 Split=X DockNode ID=0x0000001A Parent=0x8B93E3BD SizeRef=426,1156 Split=Y DockNode ID=0x0000001C Parent=0x0000001A SizeRef=600,200 Selected=0x02DF5741 DockNode ID=0x0000001D Parent=0x0000001A SizeRef=600,198 Selected=0xA5B8BA00 @@ -260,7 +266,9 @@ DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,20 Size=1920,115 DockNode ID=0x0000000B Parent=0x0000001E SizeRef=599,982 Split=Y DockNode ID=0x0000000F Parent=0x0000000B SizeRef=600,200 Split=Y Selected=0x919FD48C DockNode ID=0x00000018 Parent=0x0000000F SizeRef=599,249 Selected=0x734C7367 - DockNode ID=0x00000019 Parent=0x0000000F SizeRef=599,436 Selected=0x919FD48C + DockNode ID=0x00000019 Parent=0x0000000F SizeRef=599,436 Split=Y Selected=0x919FD48C + DockNode ID=0x0000001F Parent=0x00000019 SizeRef=599,952 Selected=0x919FD48C + DockNode ID=0x00000020 Parent=0x00000019 SizeRef=599,400 Selected=0x9B2665CA DockNode ID=0x00000010 Parent=0x0000000B SizeRef=600,198 Selected=0xECC4EA8D DockNode ID=0x00000011 Parent=0x0000001E SizeRef=1319,982 Split=Y DockNode ID=0x0000000C Parent=0x00000011 SizeRef=3440,227 Split=X Selected=0x31F26B5E From 63aae5897b8173e45ea4517278fef3dc4796552a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:16:09 +0000 Subject: [PATCH 004/121] Implement Spot Light Shadows (#217) --- .../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 cf4c7d8b29..527ee01f67 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), ActiveScene->SpotLights[i]->CutOff); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - ActiveScene->SpotLights[i]->CutOff); ActiveShader->SetFloat((UniformName + std::string(".OuterCutOff")).c_str(), ActiveScene->SpotLights[i]->OuterCutOff); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From d71d4f0e459887ab7a528feae6bd306152cc23e3 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:18:55 +0000 Subject: [PATCH 005/121] Implement Spot Light Shadows (#217) --- .../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 527ee01f67..15ed05672c 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - ActiveScene->SpotLights[i]->CutOff); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 3.1415))); ActiveShader->SetFloat((UniformName + std::string(".OuterCutOff")).c_str(), ActiveScene->SpotLights[i]->OuterCutOff); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 31c161c48321149cd148cbe0007319b9c88d83ff Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:21:53 +0000 Subject: [PATCH 006/121] Implement Spot Light Shadows (#217) --- .../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 15ed05672c..f06e23b5e4 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -711,7 +711,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 3.1415))); - ActiveShader->SetFloat((UniformName + std::string(".OuterCutOff")).c_str(), ActiveScene->SpotLights[i]->OuterCutOff); + ActiveShader->SetFloat((UniformName + std::string(".OuterCutOff")).c_str(), (ActiveScene->SpotLights[i]->OuterCutOff * (0.01745329 / 3.1415))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From c0eeed4146bf22b997f0f38ad1ec910a2152dfca Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:26:48 +0000 Subject: [PATCH 007/121] Implement Spot Light Shadows (#217) --- .../Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h | 1 + Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_PointLight.h | 1 + Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h | 1 + 3 files changed, 3 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 a6818d63ec..c16902c30a 100644 --- a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h +++ b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_DirectionalLight.h @@ -23,6 +23,7 @@ struct ERS_STRUCT_DirectionalLight { glm::vec3 Color; /** AttachedScriptIndexes_; /** AttachedScriptIndexes_; /** Date: Sun, 12 Jun 2022 02:27:26 +0000 Subject: [PATCH 008/121] Implement Spot Light Shadows (#217) --- .../Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 f3ccd17e7d..cf3ea4a762 100644 --- a/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h +++ b/Source/Core/Structures/ERS_STRUCT_Light/ERS_STRUCT_SpotLight.h @@ -25,8 +25,8 @@ struct ERS_STRUCT_SpotLight { std::vector AttachedScriptIndexes_; /** Date: Sun, 12 Jun 2022 02:28:19 +0000 Subject: [PATCH 009/121] Implement Spot Light Shadows (#217) --- Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp index e3ea5ef382..194fed4b19 100644 --- a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp +++ b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp @@ -134,6 +134,10 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo Scene.DirectionalLights[LightIndex]->Intensity = SceneDataNode[i]["Intensity"].as(); } + if (SceneDataNode[i]["MaxDistance"]) { + Scene.DirectionalLights[LightIndex]->MaxDistance = SceneDataNode[i]["MaxDistance"].as(); + } + Scene.DirectionalLights[LightIndex]->Pos = glm::vec3( SceneDataNode[i]["PosX"].as(), SceneDataNode[i]["PosY"].as(), From a5864827db9654f49db6e65fa1da3e33a8866c9c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:28:54 +0000 Subject: [PATCH 010/121] Implement Spot Light Shadows (#217) --- Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp index 194fed4b19..1c2768ffcf 100644 --- a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp +++ b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp @@ -167,6 +167,9 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo if (SceneDataNode[i]["Intensity"]) { Scene.PointLights[LightIndex]->Intensity = SceneDataNode[i]["Intensity"].as(); } + if (SceneDataNode[i]["MaxDistance"]) { + Scene.PointLights[LightIndex]->MaxDistance = SceneDataNode[i]["MaxDistance"].as(); + } if (SceneDataNode[i]["ColorRed"] && SceneDataNode[i]["ColorGreen"] && SceneDataNode[i]["ColorBlue"]) { From e3c373f4f0548202e3b29f2794a350ef523f3132 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:29:30 +0000 Subject: [PATCH 011/121] Implement Spot Light Shadows (#217) --- Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp index 1c2768ffcf..55f2c92f53 100644 --- a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp +++ b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp @@ -206,7 +206,7 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo Scene.SpotLights[LightIndex]->Intensity = SceneDataNode[i]["Intensity"].as(); } Scene.SpotLights[LightIndex]->CutOff = SceneDataNode[i]["CutOff"].as(); - Scene.SpotLights[LightIndex]->OuterCutOff = SceneDataNode[i]["OuterCutOff"].as(); + Scene.SpotLights[LightIndex]->Rolloff = SceneDataNode[i]["RollOff"].as(); if (SceneDataNode[i]["ColorRed"] && SceneDataNode[i]["ColorGreen"] && SceneDataNode[i]["ColorBlue"]) { Scene.SpotLights[LightIndex]->Color = glm::vec3( From 4ac7fe2867008efeef2a3b42f583cfe007815343 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:29:48 +0000 Subject: [PATCH 012/121] Implement Spot Light Shadows (#217) --- Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp index 55f2c92f53..7606eeb760 100644 --- a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp +++ b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp @@ -205,6 +205,9 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo if (SceneDataNode[i]["Intensity"]) { Scene.SpotLights[LightIndex]->Intensity = SceneDataNode[i]["Intensity"].as(); } + if (SceneDataNode[i]["MaxDistance"]) { + Scene.SpotLights[LightIndex]->MaxDistance = SceneDataNode[i]["MaxDistance"].as(); + } Scene.SpotLights[LightIndex]->CutOff = SceneDataNode[i]["CutOff"].as(); Scene.SpotLights[LightIndex]->Rolloff = SceneDataNode[i]["RollOff"].as(); From cd587f1d3d30b68abd64a3ae1c44651f3dc1334d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:31:50 +0000 Subject: [PATCH 013/121] Implement Spot Light Shadows (#217) --- Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp index 3cee067e95..f258981fba 100644 --- a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp +++ b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp @@ -121,6 +121,7 @@ std::string SceneWriter::ProcessScene(ERS_STRUCT_Scene* InputScene) { Output << YAML::Key << "RotZ" << YAML::Value << InputScene->DirectionalLights[i]->Rot[2]; Output << YAML::Key << "Intensity" << YAML::Value << InputScene->DirectionalLights[i]->Intensity; + Output << YAML::Key << "MaxDistance" << YAML::Value << InputScene->DirectionalLights[i]->MaxDistance; Output< Date: Sun, 12 Jun 2022 02:32:11 +0000 Subject: [PATCH 014/121] Implement Spot Light Shadows (#217) --- Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp index f258981fba..bf500f0742 100644 --- a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp +++ b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp @@ -158,6 +158,7 @@ std::string SceneWriter::ProcessScene(ERS_STRUCT_Scene* InputScene) { Output << YAML::Key << "Intensity" << YAML::Value << InputScene->PointLights[i]->Intensity; + Output << YAML::Key << "MaxDistance" << YAML::Value << InputScene->PointLights[i]->MaxDistance; Output< Date: Sun, 12 Jun 2022 02:32:31 +0000 Subject: [PATCH 015/121] Implement Spot Light Shadows (#217) --- Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp index bf500f0742..f280a6fbc5 100644 --- a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp +++ b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp @@ -199,6 +199,7 @@ std::string SceneWriter::ProcessScene(ERS_STRUCT_Scene* InputScene) { Output << YAML::Key << "Intensity" << YAML::Value << InputScene->SpotLights[i]->Intensity; + Output << YAML::Key << "MaxDistance" << YAML::Value << InputScene->SpotLights[i]->MaxDistance; Output << YAML::Key << "CutOff" << YAML::Value << InputScene->SpotLights[i]->CutOff; Output << YAML::Key << "OuterCutOff" << YAML::Value << InputScene->SpotLights[i]->OuterCutOff; From 220a80f6bdd6f5762641c1ac5e98c805cedba6ac Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:32:53 +0000 Subject: [PATCH 016/121] Implement Spot Light Shadows (#217) --- Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp index f280a6fbc5..d71da83906 100644 --- a/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp +++ b/Source/Core/Writers/ERS_SceneWriter/ERS_SceneWriter.cpp @@ -202,7 +202,7 @@ std::string SceneWriter::ProcessScene(ERS_STRUCT_Scene* InputScene) { Output << YAML::Key << "MaxDistance" << YAML::Value << InputScene->SpotLights[i]->MaxDistance; Output << YAML::Key << "CutOff" << YAML::Value << InputScene->SpotLights[i]->CutOff; - Output << YAML::Key << "OuterCutOff" << YAML::Value << InputScene->SpotLights[i]->OuterCutOff; + Output << YAML::Key << "RollOff" << YAML::Value << InputScene->SpotLights[i]->Rolloff; Output< Date: Sun, 12 Jun 2022 02:36:48 +0000 Subject: [PATCH 017/121] Implement Spot Light Shadows (#217) --- .../Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 92d7aaaed8..9059247104 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -100,12 +100,12 @@ void Widget_ObjectProperties::Draw() { ImGui::HelpMarker("Sets the brightness of the light source, increase this for a brighter light."); - ImGui::DragFloat("Cutoff", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff, 0.01f); + ImGui::DragFloat("Cutoff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff, 0.01f); ImGui::SameLine(); - ImGui::HelpMarker("Set the inner circle cutoff point. Will start to attenuate outside of this circle."); - ImGui::DragFloat("Outer Cutoff", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->OuterCutOff, 0.01f); + ImGui::HelpMarker("Specifies the angle of the spot light's outer cone."); + ImGui::DragFloat("Rolloff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff, 0.01f); ImGui::SameLine(); - ImGui::HelpMarker("Sets the outer circle at which attenuation ends. Everything outside this circle is unaffected by the light."); + 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)."); } From 1c3d486c24ba31b7036c64eb2909d077ccbc5b7d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:37:02 +0000 Subject: [PATCH 018/121] Implement Spot Light Shadows (#217) --- .../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 f06e23b5e4..67b57fc3f7 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -711,7 +711,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 3.1415))); - ActiveShader->SetFloat((UniformName + std::string(".OuterCutOff")).c_str(), (ActiveScene->SpotLights[i]->OuterCutOff * (0.01745329 / 3.1415))); + ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 3.1415))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 8ce35baa3f604fb12bd9007f81da9da2ecb8e75d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:41:02 +0000 Subject: [PATCH 019/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 9059247104..cd174c68a7 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -30,7 +30,11 @@ void Widget_ObjectProperties::Draw() { // LocRotScale Properties if (ImGui::CollapsingHeader("Physical Parameters", ImGuiTreeNodeFlags_DefaultOpen)) { + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1.0f, 0.1f, 0.1f, 1.0f)); ImGui::DragFloat3("Location", (float*)glm::value_ptr(Cursors3D_->Pos_), 0.05f); + ImGui::PopStyleColor(); + ImGui::DragFloat3("Rotation", (float*)glm::value_ptr(Cursors3D_->Rot_), 0.05f);// FIXME: MAKE ROLL OVER TO 180 Degrees? ImGui::DragFloat3("Scale", (float*)glm::value_ptr(Cursors3D_->Scale_), 0.05f, 0.0f, 65535.0f); } From 609161974a413c85319c489d28f51ec91da27dee Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:42:12 +0000 Subject: [PATCH 020/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_PythonInterpreterIntegration.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp index 8d1acd06f9..ce5225384f 100644 --- a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp +++ b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp @@ -193,6 +193,7 @@ bool ERS_CLASS_PythonInterpreterIntegration::ExecutePointLightScript(std::string PointLightModule.attr("PointLightColorB") = PointLight->Color.b; PointLightModule.attr("PointLightIntensity") = PointLight->Intensity; + PointLightModule.attr("PointLightMaxDistance") = PointLight->MaxDistance; // Get Local Dict @@ -289,6 +290,13 @@ bool ERS_CLASS_PythonInterpreterIntegration::ExecutePointLightScript(std::string ErrorMessageString->push_back("PointLight Intensity CAST_ERROR"); } + try { + PointLight->Intensity = PointLightModule.attr("PointLightMaxDistance").cast(); + } catch (pybind11::cast_error const&) { + ErrorMessageString->push_back("PointLight MaxDistance CAST_ERROR"); + } + + // Return Status return true; From eddccbf8a0a43fc3e8df9b86465ef0b61cf0a97d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:42:39 +0000 Subject: [PATCH 021/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_PythonInterpreterIntegration.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp index ce5225384f..91b5e9c611 100644 --- a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp +++ b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp @@ -325,6 +325,7 @@ bool ERS_CLASS_PythonInterpreterIntegration::ExecuteDirectionalLightScript(std:: DirectionalLightModule.attr("DirectionalLightColorB") = DirectionalLight->Color.b; DirectionalLightModule.attr("DirectionalLightIntensity") = DirectionalLight->Intensity; + DirectionalLightModule.attr("DirectionalLightMaxDistance") = DirectionalLight->MaxDistance; // Get Local Dict pybind11::dict Locals = DirectionalLightModule.attr("__dict__"); From a74606a915c12b20d1e435176706da4981067a31 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:42:56 +0000 Subject: [PATCH 022/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_PythonInterpreterIntegration.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp index 91b5e9c611..56b5095ae9 100644 --- a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp +++ b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp @@ -432,6 +432,13 @@ bool ERS_CLASS_PythonInterpreterIntegration::ExecuteDirectionalLightScript(std:: ErrorMessageString->push_back("DirectionalLight Intensity CAST_ERROR"); } + try { + DirectionalLight->Intensity = DirectionalLightModule.attr("DirectionalLightMaxDistance").cast(); + } catch (pybind11::cast_error const&) { + ErrorMessageString->push_back("DirectionalLight MaxDistance CAST_ERROR"); + } + + // Return Status return true; From b54e4b61e80b7b736c5409a884014483bf82e963 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:43:40 +0000 Subject: [PATCH 023/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_PythonInterpreterIntegration.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp index 56b5095ae9..5dfad10d69 100644 --- a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp +++ b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp @@ -467,9 +467,10 @@ bool ERS_CLASS_PythonInterpreterIntegration::ExecuteSpotLightScript(std::string SpotLightModule.attr("SpotLightColorB") = SpotLight->Color.b; SpotLightModule.attr("SpotLightIntensity") = SpotLight->Intensity; + SpotLightModule.attr("SpotLightMaxDistance") = SpotLight->MaxDistance; SpotLightModule.attr("SpotLightCutoff") = SpotLight->CutOff; - SpotLightModule.attr("SpotLightOuterCutoff") = SpotLight->OuterCutOff; + SpotLightModule.attr("SpotLightRolloff") = SpotLight->Rolloff; // Get Local Dict From c39503d5a0651033f914422a085af537a1a38dc7 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:44:18 +0000 Subject: [PATCH 024/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_PythonInterpreterIntegration.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp index 5dfad10d69..0f8a54b016 100644 --- a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp +++ b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp @@ -578,9 +578,17 @@ bool ERS_CLASS_PythonInterpreterIntegration::ExecuteSpotLightScript(std::string } + try { + SpotLight->Intensity = SpotLightModule.attr("SpotLightRolloff").cast(); + } catch (pybind11::cast_error const&) { + ErrorMessageString->push_back("SpotLight Rolloff CAST_ERROR"); + } + + + try { SpotLight->CutOff = SpotLightModule.attr("SpotLightCutoff").cast(); - SpotLight->OuterCutOff = SpotLightModule.attr("SpotLightOuterCutoff").cast(); + SpotLight->Rolloff = SpotLightModule.attr("SpotLightRolloff").cast(); } catch (pybind11::cast_error const&) { ErrorMessageString->push_back("SpotLight Cutoff CAST_ERROR"); } From 5c7008ac4ce66b4d32d6fc721be5ec6684691db8 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:49:40 +0000 Subject: [PATCH 025/121] Implement Spot Light Shadows (#217) --- .../ERS_SceneManager/ERS_SceneManager.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Source/Core/Manager/ERS_SceneManager/ERS_SceneManager.cpp b/Source/Core/Manager/ERS_SceneManager/ERS_SceneManager.cpp index 1d189097e5..f76649919e 100644 --- a/Source/Core/Manager/ERS_SceneManager/ERS_SceneManager.cpp +++ b/Source/Core/Manager/ERS_SceneManager/ERS_SceneManager.cpp @@ -120,10 +120,11 @@ void ERS_CLASS_SceneManager::AddPointLight() { std::shared_ptr Light = std::make_shared(); Light->UserDefinedName = "New Point Light"; - Light->Color = glm::vec3(0.0f); - + Light->Color = glm::vec3(1.0f); Light->Intensity = 1.0f; + Light->MaxDistance = 20.0f; + Scenes_[ActiveScene_]->PointLights.push_back(Light); Scenes_[ActiveScene_]->IndexSceneObjects(); @@ -135,7 +136,12 @@ void ERS_CLASS_SceneManager::AddDirectionalLight() { std::shared_ptr Light = std::make_shared(); Light->UserDefinedName = "New Directional Light"; - Light->Color = glm::vec3(0.0f); + Light->Color = glm::vec3(1.0f); + + Light->Intensity = 5.0f; + + Light->MaxDistance = 100.0f; + Scenes_[ActiveScene_]->DirectionalLights.push_back(Light); @@ -148,13 +154,14 @@ void ERS_CLASS_SceneManager::AddSpotLight() { std::shared_ptr Light = std::make_shared(); Light->UserDefinedName = "New Spot Light"; - Light->Color = glm::vec3(0.0f); + Light->Color = glm::vec3(1.0f); Light->Intensity = 1.0f; + Light->MaxDistance = 20.0f; - Light->CutOff = 0.970f; - Light->OuterCutOff = 0.960f; + Light->CutOff = 45.0f; + Light->Rolloff = 10.0f; Scenes_[ActiveScene_]->SpotLights.push_back(Light); Scenes_[ActiveScene_]->IndexSceneObjects(); From 2927453d11d4830bef6d4ccc7e776491a70f5f39 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:52:15 +0000 Subject: [PATCH 026/121] Implement Spot Light Shadows (#217) --- Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp index 7606eeb760..35db10cfd5 100644 --- a/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp +++ b/Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp @@ -209,8 +209,10 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo Scene.SpotLights[LightIndex]->MaxDistance = SceneDataNode[i]["MaxDistance"].as(); } Scene.SpotLights[LightIndex]->CutOff = SceneDataNode[i]["CutOff"].as(); - Scene.SpotLights[LightIndex]->Rolloff = SceneDataNode[i]["RollOff"].as(); + if (SceneDataNode[i]["RollOff"]) { + Scene.SpotLights[LightIndex]->Rolloff = SceneDataNode[i]["RollOff"].as(); + } if (SceneDataNode[i]["ColorRed"] && SceneDataNode[i]["ColorGreen"] && SceneDataNode[i]["ColorBlue"]) { Scene.SpotLights[LightIndex]->Color = glm::vec3( SceneDataNode[i]["ColorRed"].as(), From 853f30946170e5604cfe505f63b535093900855d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:54:52 +0000 Subject: [PATCH 027/121] Implement Spot Light Shadows (#217) --- 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 5fb3d1c33e..8e90b8925b 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -461,8 +461,8 @@ vec3 PBRSpotLight(STRUCT_SpotLight Light, vec3 ViewDir, vec3 Reflectance, STRUCT // Calculate Spot Intensity float Theta = dot(normalize(Light.Position - Object.FragPos), normalize(-Light.Direction)); - float Epsilon = Light.CutOff - Light.OuterCutOff; - float Intensity = clamp((Theta - Light.OuterCutOff) / Epsilon, 0.0f, 1.0f); + float Epsilon = Light.OuterCutOff; + float Intensity = clamp((Theta - Light.CutOff) / Epsilon, 0.0f, 1.0f); if (GammaCorrectionEnabled_) { Intensity = pow(Intensity, Gamma_*Gamma_); @@ -615,3 +615,4 @@ void main() { + From f0a52c4afdb590dd52bc77b6a40751766ddeaa7d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 02:58:37 +0000 Subject: [PATCH 028/121] Implement Spot Light Shadows (#217) --- Source/EditorAssets/Projects/DefaultProject/10041.ERS | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 8e90b8925b..1b44494cd9 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -23,6 +23,7 @@ struct STRUCT_DirectionalLight { // Light Color Parameters vec3 Color; float Intensity; + float MaxDistance; int DepthMapIndex; mat4 LightSpaceMatrix; @@ -38,6 +39,7 @@ struct STRUCT_PointLight { // Light Rolloff Parameters float Intensity; + float MaxDistance; int DepthMapIndex; mat4 LightSpaceMatrix; @@ -55,10 +57,11 @@ struct STRUCT_SpotLight { // Light Rolloff Parameters float Intensity; + float MaxDistance; // Spotlight Parameters float CutOff; - float OuterCutOff; + float RollOff; int DepthMapIndex; mat4 LightSpaceMatrix; @@ -113,7 +116,7 @@ uniform bool HasShininess; uniform int NumberDirectionalLights; uniform int NumberPointLights; uniform int NumberSpotLights; -uniform STRUCT_DirectionalLight DirectionalLights[10]; +uniform STRUCT_DirectionalLight DirectionalLights[2]; uniform STRUCT_PointLight PointLights[64]; uniform STRUCT_SpotLight SpotLights[32]; @@ -461,7 +464,7 @@ vec3 PBRSpotLight(STRUCT_SpotLight Light, vec3 ViewDir, vec3 Reflectance, STRUCT // Calculate Spot Intensity float Theta = dot(normalize(Light.Position - Object.FragPos), normalize(-Light.Direction)); - float Epsilon = Light.OuterCutOff; + float Epsilon = Light.RollOff; float Intensity = clamp((Theta - Light.CutOff) / Epsilon, 0.0f, 1.0f); if (GammaCorrectionEnabled_) { From ce391849f4606d149ab43256732c98eb3d459c19 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:01:51 +0000 Subject: [PATCH 029/121] Implement Spot Light Shadows (#217) --- .../Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index cd174c68a7..fda20198b8 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -59,10 +59,13 @@ void Widget_ObjectProperties::Draw() { FloatToVec(Color, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Color); - ImGui::DragFloat("Intensity", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Intensity, 0.01f); + ImGui::DragFloat("Intensity", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Intensity, 0.25f); ImGui::SameLine(); ImGui::HelpMarker("Sets the brightness of the light source, increase this for a brighter light."); + ImGui::DragFloat("MaxDistance", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->MaxDistance, 0.5f); + + } @@ -79,7 +82,7 @@ void Widget_ObjectProperties::Draw() { FloatToVec(Color, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->Color); - ImGui::DragFloat("Intensity", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->Intensity, 0.01f); + ImGui::DragFloat("Intensity", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->Intensity, 0.25f); ImGui::SameLine(); ImGui::HelpMarker("Sets the brightness of the light source, increase this for a brighter light."); @@ -99,15 +102,15 @@ void Widget_ObjectProperties::Draw() { FloatToVec(Color, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Color); - ImGui::DragFloat("Intensity", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Intensity, 0.01f); + ImGui::DragFloat("Intensity", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Intensity, 0.25f); ImGui::SameLine(); ImGui::HelpMarker("Sets the brightness of the light source, increase this for a brighter light."); - ImGui::DragFloat("Cutoff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff, 0.01f); + ImGui::DragFloat("Cutoff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff, 1.0f); ImGui::SameLine(); ImGui::HelpMarker("Specifies the angle of the spot light's outer cone."); - ImGui::DragFloat("Rolloff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff, 0.01f); + ImGui::DragFloat("Rolloff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff, 0.5f); 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)."); From 582502a493f8c626e9b6984ebe5dc6c03f3028d2 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:02:22 +0000 Subject: [PATCH 030/121] Implement Spot Light Shadows (#217) --- 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 fda20198b8..ff661973d4 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -64,6 +64,9 @@ void Widget_ObjectProperties::Draw() { ImGui::HelpMarker("Sets the brightness of the light source, increase this for a brighter light."); ImGui::DragFloat("MaxDistance", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->MaxDistance, 0.5f); + ImGui::SameLine(); + ImGui::HelpMarker("Sets the distance after which the scene is no longer affected by this light source."); + From 7e9831306f6cf9916bf9e7d3c51c3b9f1806cb6d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:02:32 +0000 Subject: [PATCH 031/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index ff661973d4..26d08bf801 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -89,6 +89,10 @@ void Widget_ObjectProperties::Draw() { ImGui::SameLine(); ImGui::HelpMarker("Sets the brightness of the light source, increase this for a brighter light."); + ImGui::DragFloat("MaxDistance", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->MaxDistance, 0.5f); + ImGui::SameLine(); + ImGui::HelpMarker("Sets the distance after which the scene is no longer affected by this light source."); + } From 84438dd875c35696d13354239a8fb337012e9e64 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:02:43 +0000 Subject: [PATCH 032/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 26d08bf801..0b389a7852 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -113,6 +113,10 @@ void Widget_ObjectProperties::Draw() { ImGui::SameLine(); ImGui::HelpMarker("Sets the brightness of the light source, increase this for a brighter light."); + ImGui::DragFloat("MaxDistance", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->MaxDistance, 0.5f); + ImGui::SameLine(); + ImGui::HelpMarker("Sets the distance after which the scene is no longer affected by this light source."); + ImGui::DragFloat("Cutoff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff, 1.0f); ImGui::SameLine(); From 3a3cfd291aec4126c2713bf861553a62bde2d04a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:06:28 +0000 Subject: [PATCH 033/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 0b389a7852..e706542175 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -31,7 +31,7 @@ void Widget_ObjectProperties::Draw() { // LocRotScale Properties if (ImGui::CollapsingHeader("Physical Parameters", ImGuiTreeNodeFlags_DefaultOpen)) { - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1.0f, 0.1f, 0.1f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.8f, 0.1f, 0.1f, 1.0f)); ImGui::DragFloat3("Location", (float*)glm::value_ptr(Cursors3D_->Pos_), 0.05f); ImGui::PopStyleColor(); From c19c359017ac3949778af2237bd6380ead831c43 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:10:29 +0000 Subject: [PATCH 034/121] Implement Spot Light Shadows (#217) --- .../Widgets/GUI_Widget_ObjectProperties.cpp | 17 ++++++++++++++++- .../Widgets/GUI_Widget_ObjectProperties.h | 10 ++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index e706542175..db3913e6a2 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -17,6 +17,21 @@ Widget_ObjectProperties::~Widget_ObjectProperties() { } +glm::vec3 Widget_ObjectProperties::XYZDragFloat(std::string Name, glm::vec3 Input, float SnapAmount) { + + // Convert Input To Values + float X, Y, Z; + X = Input.x; + Y = Input.y; + Z = Input.z; + + // Draw Three Colored Boxes + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.7f, 0.1f, 0.1f, 1.0f)); + ImGui::DragFloat3("Location", (float*)glm::value_ptr(Cursors3D_->Pos_), SnapAmount); + ImGui::PopStyleColor(); + +} + void Widget_ObjectProperties::Draw() { if (Enabled_) { @@ -31,7 +46,7 @@ void Widget_ObjectProperties::Draw() { // LocRotScale Properties if (ImGui::CollapsingHeader("Physical Parameters", ImGuiTreeNodeFlags_DefaultOpen)) { - ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.8f, 0.1f, 0.1f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.7f, 0.1f, 0.1f, 1.0f)); ImGui::DragFloat3("Location", (float*)glm::value_ptr(Cursors3D_->Pos_), 0.05f); ImGui::PopStyleColor(); diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.h b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.h index c15be2facb..8e51b4e6d4 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.h +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.h @@ -59,6 +59,16 @@ class Widget_ObjectProperties { */ void FloatToVec(float* In, glm::vec3* Out); + /** + * @brief Draws a color coded drag float element. + * + * @param Name + * @param Value + * @param SnapAmount + * @return glm::vec3 + */ + glm::vec3 XYZDragFloat(std::string Name, glm::vec3 Value, float SnapAmount = 0.1f); + public: From ff6109ad72a5e390a90f54d7618c5bf4ee09c98a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:11:46 +0000 Subject: [PATCH 035/121] Implement Spot Light Shadows (#217) --- .../Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index db3913e6a2..6ca18ff8ca 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -27,9 +27,20 @@ glm::vec3 Widget_ObjectProperties::XYZDragFloat(std::string Name, glm::vec3 Inpu // Draw Three Colored Boxes ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.7f, 0.1f, 0.1f, 1.0f)); - ImGui::DragFloat3("Location", (float*)glm::value_ptr(Cursors3D_->Pos_), SnapAmount); + ImGui::DragFloat(nullptr, &X, SnapAmount); ImGui::PopStyleColor(); + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.1f, 0.7f, 0.1f, 1.0f)); + ImGui::DragFloat(nullptr, &Y, SnapAmount); + ImGui::PopStyleColor(); + + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.1f, 0.7f, 1.0f)); + ImGui::DragFloat(nullptr, &Z, SnapAmount); + ImGui::PopStyleColor(); + + // Return Value + return glm::vec3(X, Y, Z); + } void Widget_ObjectProperties::Draw() { From 99b6459e55ebe4647ac23ba2c73119a5a1d26473 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:12:17 +0000 Subject: [PATCH 036/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 6ca18ff8ca..832b40e050 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -29,14 +29,20 @@ glm::vec3 Widget_ObjectProperties::XYZDragFloat(std::string Name, glm::vec3 Inpu ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.7f, 0.1f, 0.1f, 1.0f)); ImGui::DragFloat(nullptr, &X, SnapAmount); ImGui::PopStyleColor(); + ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.1f, 0.7f, 0.1f, 1.0f)); ImGui::DragFloat(nullptr, &Y, SnapAmount); ImGui::PopStyleColor(); + ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.1f, 0.7f, 1.0f)); ImGui::DragFloat(nullptr, &Z, SnapAmount); ImGui::PopStyleColor(); + ImGui::SameLine(); + + // Draw Label + ImGui::Text(Name.c_str()); // Return Value return glm::vec3(X, Y, Z); From cce1d4334f550f37e43e1da959b6f7c4c6695cc5 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:13:13 +0000 Subject: [PATCH 037/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 832b40e050..c0cfbd98e7 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -63,9 +63,10 @@ void Widget_ObjectProperties::Draw() { // LocRotScale Properties if (ImGui::CollapsingHeader("Physical Parameters", ImGuiTreeNodeFlags_DefaultOpen)) { - ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.7f, 0.1f, 0.1f, 1.0f)); - ImGui::DragFloat3("Location", (float*)glm::value_ptr(Cursors3D_->Pos_), 0.05f); - ImGui::PopStyleColor(); + // ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.7f, 0.1f, 0.1f, 1.0f)); + // ImGui::DragFloat3("Location", (float*)glm::value_ptr(Cursors3D_->Pos_), 0.05f); + // ImGui::PopStyleColor(); + Cursors3D_->Pos_ = XYZDragFloat("Position", Cursors3D_->Pos_); ImGui::DragFloat3("Rotation", (float*)glm::value_ptr(Cursors3D_->Rot_), 0.05f);// FIXME: MAKE ROLL OVER TO 180 Degrees? ImGui::DragFloat3("Scale", (float*)glm::value_ptr(Cursors3D_->Scale_), 0.05f, 0.0f, 65535.0f); From a72a71a27c0c9dabd2946813214b3c79f70ea002 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:14:11 +0000 Subject: [PATCH 038/121] Implement Spot Light Shadows (#217) --- .../Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index c0cfbd98e7..c1cee36cf4 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -27,22 +27,22 @@ glm::vec3 Widget_ObjectProperties::XYZDragFloat(std::string Name, glm::vec3 Inpu // Draw Three Colored Boxes ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.7f, 0.1f, 0.1f, 1.0f)); - ImGui::DragFloat(nullptr, &X, SnapAmount); + ImGui::DragFloat("", &X, SnapAmount); ImGui::PopStyleColor(); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.1f, 0.7f, 0.1f, 1.0f)); - ImGui::DragFloat(nullptr, &Y, SnapAmount); + ImGui::DragFloat("", &Y, SnapAmount); ImGui::PopStyleColor(); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.1f, 0.7f, 1.0f)); - ImGui::DragFloat(nullptr, &Z, SnapAmount); + ImGui::DragFloat("", &Z, SnapAmount); ImGui::PopStyleColor(); ImGui::SameLine(); // Draw Label - ImGui::Text(Name.c_str()); + ImGui::Text("%s", Name.c_str()); // Return Value return glm::vec3(X, Y, Z); From 7789cdf640102d3e336206e227512fd3ee540e30 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:17:55 +0000 Subject: [PATCH 039/121] Implement Spot Light Shadows (#217) --- .../Widgets/GUI_Widget_ObjectProperties.cpp | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index c1cee36cf4..67d6d50f77 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -25,24 +25,36 @@ glm::vec3 Widget_ObjectProperties::XYZDragFloat(std::string Name, glm::vec3 Inpu Y = Input.y; Z = Input.z; - // Draw Three Colored Boxes - ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.7f, 0.1f, 0.1f, 1.0f)); - ImGui::DragFloat("", &X, SnapAmount); - ImGui::PopStyleColor(); - ImGui::SameLine(); - - ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.1f, 0.7f, 0.1f, 1.0f)); - ImGui::DragFloat("", &Y, SnapAmount); - ImGui::PopStyleColor(); - ImGui::SameLine(); - - ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.1f, 0.7f, 1.0f)); - ImGui::DragFloat("", &Z, SnapAmount); - ImGui::PopStyleColor(); - ImGui::SameLine(); - - // Draw Label - ImGui::Text("%s", Name.c_str()); + // Format Table + if (ImGui::BeginTable("##Table_%s", Name.c_str(), 4)) { + + ImGui::TableNextRow(); + + // Draw Three Colored Boxes + ImGui::TableNextColumn(); + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.7f, 0.1f, 0.1f, 1.0f)); + ImGui::DragFloat("", &X, SnapAmount); + ImGui::PopStyleColor(); + //ImGui::SameLine(); + + ImGui::TableNextColumn(); + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.1f, 0.7f, 0.1f, 1.0f)); + ImGui::DragFloat("", &Y, SnapAmount); + ImGui::PopStyleColor(); + //ImGui::SameLine(); + + ImGui::TableNextColumn(); + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.1f, 0.7f, 1.0f)); + ImGui::DragFloat("", &Z, SnapAmount); + ImGui::PopStyleColor(); + //ImGui::SameLine(); + + // Draw Label + ImGui::TableNextColumn(); + ImGui::Text("%s", Name.c_str()); + + } + ImGui::EndTable(); // Return Value return glm::vec3(X, Y, Z); From c17c2f0cb966e2ec1639555280c76d3d772a6b26 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:18:17 +0000 Subject: [PATCH 040/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 67d6d50f77..2b3781b9fe 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -26,7 +26,7 @@ glm::vec3 Widget_ObjectProperties::XYZDragFloat(std::string Name, glm::vec3 Inpu Z = Input.z; // Format Table - if (ImGui::BeginTable("##Table_%s", Name.c_str(), 4)) { + if (ImGui::BeginTable(Name.c_str(), 4)) { ImGui::TableNextRow(); From f6cbccf730efaeb9a9e2031f6866a596b0276a1a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:20:27 +0000 Subject: [PATCH 041/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 2b3781b9fe..432f815a6e 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -26,7 +26,8 @@ glm::vec3 Widget_ObjectProperties::XYZDragFloat(std::string Name, glm::vec3 Inpu Z = Input.z; // Format Table - if (ImGui::BeginTable(Name.c_str(), 4)) { + ImGuiTableFlags TableFlags = ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoBordersInBody; + if (ImGui::BeginTable(Name.c_str(), 4, TableFlags)) { ImGui::TableNextRow(); From eb926937c9abd0ac54e101d491daa926fe35d60e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:21:36 +0000 Subject: [PATCH 042/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 432f815a6e..855f233b8a 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -26,7 +26,7 @@ glm::vec3 Widget_ObjectProperties::XYZDragFloat(std::string Name, glm::vec3 Inpu Z = Input.z; // Format Table - ImGuiTableFlags TableFlags = ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoBordersInBody; + ImGuiTableFlags TableFlags = ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingFixedFit; if (ImGui::BeginTable(Name.c_str(), 4, TableFlags)) { ImGui::TableNextRow(); From ff07ec307dc64fd19924638a98adce8062f6d68c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:22:58 +0000 Subject: [PATCH 043/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 855f233b8a..b2cc5896f6 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -26,7 +26,7 @@ glm::vec3 Widget_ObjectProperties::XYZDragFloat(std::string Name, glm::vec3 Inpu Z = Input.z; // Format Table - ImGuiTableFlags TableFlags = ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingFixedFit; + ImGuiTableFlags TableFlags = ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingStretchProp; if (ImGui::BeginTable(Name.c_str(), 4, TableFlags)) { ImGui::TableNextRow(); From 7d9d93ba22b808188ccc9a41663d728eb195a9eb Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:24:16 +0000 Subject: [PATCH 044/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index b2cc5896f6..855f233b8a 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -26,7 +26,7 @@ glm::vec3 Widget_ObjectProperties::XYZDragFloat(std::string Name, glm::vec3 Inpu Z = Input.z; // Format Table - ImGuiTableFlags TableFlags = ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingStretchProp; + ImGuiTableFlags TableFlags = ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingFixedFit; if (ImGui::BeginTable(Name.c_str(), 4, TableFlags)) { ImGui::TableNextRow(); From 3916aac093084e4f95656560f0a9889ed89eeb3e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:24:47 +0000 Subject: [PATCH 045/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 855f233b8a..1225d606fe 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -26,7 +26,7 @@ glm::vec3 Widget_ObjectProperties::XYZDragFloat(std::string Name, glm::vec3 Inpu Z = Input.z; // Format Table - ImGuiTableFlags TableFlags = ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingFixedFit; + ImGuiTableFlags TableFlags = ImGuiTableFlags_NoPadInnerX | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingFixedSame; if (ImGui::BeginTable(Name.c_str(), 4, TableFlags)) { ImGui::TableNextRow(); From 069742ccae5824b46f3088a386d279e43284708d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:31:21 +0000 Subject: [PATCH 046/121] Implement Spot Light Shadows (#217) --- .../ImGuizmo/example/imgui_widgets.cpp | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/Third-Party/ImGuizmo/example/imgui_widgets.cpp b/Third-Party/ImGuizmo/example/imgui_widgets.cpp index 46d2174feb..802eb5887e 100644 --- a/Third-Party/ImGuizmo/example/imgui_widgets.cpp +++ b/Third-Party/ImGuizmo/example/imgui_widgets.cpp @@ -2421,6 +2421,44 @@ bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data return value_changed; } + +bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, float Color[], const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + bool value_changed = false; + BeginGroup(); + PushID(label); + PushMultiItemsWidths(components, CalcItemWidth()); + size_t type_size = GDataTypeInfo[data_type].Size; + for (int i = 0; i < components; i++) + { + PushID(i); + if (i > 0) + SameLine(0, g.Style.ItemInnerSpacing.x); + PushStyleColor(ImGuiCol_FrameBg, ImVec4(Color[i*3], Color[i*3]+1, Color[i*3]+2, 1.0f)); + value_changed |= DragScalar("", data_type, p_data, v_speed, p_min, p_max, format, flags); + PopStyleColor(); + PopID(); + PopItemWidth(); + p_data = (void*)((char*)p_data + type_size); + } + PopID(); + + const char* label_end = FindRenderedTextEnd(label); + if (label != label_end) + { + SameLine(0, g.Style.ItemInnerSpacing.x); + TextEx(label, label_end); + } + + EndGroup(); + return value_changed; +} + bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, flags); @@ -2436,6 +2474,11 @@ bool ImGui::DragFloat3(const char* label, float v[3], float v_speed, float v_min return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, flags); } +bool ImGui::DragFloat3(const char* label, float v[3], float v_speed, float colors[9], float v_min, float v_max, const char* format, ImGuiSliderFlags flags) +{ + return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, colors, &v_min, &v_max, format, flags); +} + bool ImGui::DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, flags); From 7a71ba00955ac839d28ec5e58edf6ff0df3b6c96 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:33:40 +0000 Subject: [PATCH 047/121] Implement Spot Light Shadows (#217) --- .../Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 10 ++++++++-- Third-Party/ImGuizmo/example/imgui.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 1225d606fe..caf42f5842 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -77,9 +77,15 @@ void Widget_ObjectProperties::Draw() { if (ImGui::CollapsingHeader("Physical Parameters", ImGuiTreeNodeFlags_DefaultOpen)) { // ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.7f, 0.1f, 0.1f, 1.0f)); - // ImGui::DragFloat3("Location", (float*)glm::value_ptr(Cursors3D_->Pos_), 0.05f); + float Colors[9] = { + 0.7f, 0.1f, 0.1f, + 0.1f, 0.7f, 0.1f, + 0.1f, 0.1f, 0.7f + }; + + ImGui::DragFloat3("Location", (float*)glm::value_ptr(Cursors3D_->Pos_), 0.05f, Colors); // ImGui::PopStyleColor(); - Cursors3D_->Pos_ = XYZDragFloat("Position", Cursors3D_->Pos_); + //Cursors3D_->Pos_ = XYZDragFloat("Position", Cursors3D_->Pos_); ImGui::DragFloat3("Rotation", (float*)glm::value_ptr(Cursors3D_->Rot_), 0.05f);// FIXME: MAKE ROLL OVER TO 180 Degrees? ImGui::DragFloat3("Scale", (float*)glm::value_ptr(Cursors3D_->Scale_), 0.05f, 0.0f, 65535.0f); diff --git a/Third-Party/ImGuizmo/example/imgui.h b/Third-Party/ImGuizmo/example/imgui.h index 06a610d408..dd855d8ff0 100644 --- a/Third-Party/ImGuizmo/example/imgui.h +++ b/Third-Party/ImGuizmo/example/imgui.h @@ -515,6 +515,7 @@ namespace ImGui IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float colors[9], float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // MODIFIED BY ERS DEV TEAM TO ALLOW FOR RGB COLORD DRAG FLOAT IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, ImGuiSliderFlags flags = 0); IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound From faf1695ecce1dd1b946eefb34f51f678dfb08fdb Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:34:47 +0000 Subject: [PATCH 048/121] Implement Spot Light Shadows (#217) --- Third-Party/ImGuizmo/example/imgui.h | 1 - Third-Party/imgui/imgui.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Third-Party/ImGuizmo/example/imgui.h b/Third-Party/ImGuizmo/example/imgui.h index dd855d8ff0..06a610d408 100644 --- a/Third-Party/ImGuizmo/example/imgui.h +++ b/Third-Party/ImGuizmo/example/imgui.h @@ -515,7 +515,6 @@ namespace ImGui IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); - IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float colors[9], float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // MODIFIED BY ERS DEV TEAM TO ALLOW FOR RGB COLORD DRAG FLOAT IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, ImGuiSliderFlags flags = 0); IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound diff --git a/Third-Party/imgui/imgui.h b/Third-Party/imgui/imgui.h index 88a61ae33b..464717709a 100644 --- a/Third-Party/imgui/imgui.h +++ b/Third-Party/imgui/imgui.h @@ -550,6 +550,7 @@ namespace ImGui IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float colors[9], float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // MODIFIED BY ERS DEV TEAM TO ALLOW FOR RGB COLORD DRAG FLOAT IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, ImGuiSliderFlags flags = 0); IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound From 6613ec40c19c4587692ec898443346704be815ce Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:35:47 +0000 Subject: [PATCH 049/121] Implement Spot Light Shadows (#217) --- Third-Party/imgui/imgui_widgets.cpp | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Third-Party/imgui/imgui_widgets.cpp b/Third-Party/imgui/imgui_widgets.cpp index d67fa3f443..3497c9b547 100644 --- a/Third-Party/imgui/imgui_widgets.cpp +++ b/Third-Party/imgui/imgui_widgets.cpp @@ -2503,6 +2503,43 @@ bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data return value_changed; } +bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, float Color[], const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) +{ + ImGuiWindow* window = GetCurrentWindow(); + if (window->SkipItems) + return false; + + ImGuiContext& g = *GImGui; + bool value_changed = false; + BeginGroup(); + PushID(label); + PushMultiItemsWidths(components, CalcItemWidth()); + size_t type_size = GDataTypeInfo[data_type].Size; + for (int i = 0; i < components; i++) + { + PushID(i); + if (i > 0) + SameLine(0, g.Style.ItemInnerSpacing.x); + PushStyleColor(ImGuiCol_FrameBg, ImVec4(Color[i*3], Color[i*3]+1, Color[i*3]+2, 1.0f)); + value_changed |= DragScalar("", data_type, p_data, v_speed, p_min, p_max, format, flags); + PopStyleColor(); + PopID(); + PopItemWidth(); + p_data = (void*)((char*)p_data + type_size); + } + PopID(); + + const char* label_end = FindRenderedTextEnd(label); + if (label != label_end) + { + SameLine(0, g.Style.ItemInnerSpacing.x); + TextEx(label, label_end); + } + + EndGroup(); + return value_changed; +} + bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, flags); @@ -2518,6 +2555,11 @@ bool ImGui::DragFloat3(const char* label, float v[3], float v_speed, float v_min return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, flags); } +bool ImGui::DragFloat3(const char* label, float v[3], float v_speed, float colors[9], float v_min, float v_max, const char* format, ImGuiSliderFlags flags) +{ + return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, colors, &v_min, &v_max, format, flags); +} + bool ImGui::DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, flags); From 0ac0808ef350587e13a7bd817f3c37577d77517d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:37:32 +0000 Subject: [PATCH 050/121] Implement Spot Light Shadows (#217) --- Third-Party/imgui/imgui.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Third-Party/imgui/imgui.h b/Third-Party/imgui/imgui.h index 464717709a..37dfe91084 100644 --- a/Third-Party/imgui/imgui.h +++ b/Third-Party/imgui/imgui.h @@ -550,7 +550,7 @@ namespace ImGui IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); - IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float colors[9], float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // MODIFIED BY ERS DEV TEAM TO ALLOW FOR RGB COLORD DRAG FLOAT + IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed, float colors[9], float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // MODIFIED BY ERS DEV TEAM TO ALLOW FOR RGB COLORD DRAG FLOAT IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, ImGuiSliderFlags flags = 0); IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound From 5dfa2d9b4797d5b0d544e94eaea18bbc65c041de Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:38:25 +0000 Subject: [PATCH 051/121] Implement Spot Light Shadows (#217) --- Third-Party/imgui/imgui.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Third-Party/imgui/imgui.h b/Third-Party/imgui/imgui.h index 37dfe91084..4c78711a8a 100644 --- a/Third-Party/imgui/imgui.h +++ b/Third-Party/imgui/imgui.h @@ -560,6 +560,8 @@ namespace ImGui IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", const char* format_max = NULL, ImGuiSliderFlags flags = 0); IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0); IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0); + IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, float colors[], const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0); // MODIFIED BY ERS TEAM + // Widgets: Regular Sliders // - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped by default and can go off-bounds. Use ImGuiSliderFlags_AlwaysClamp to always clamp. From 8f010cd522dd5514ea13e775a4d73e2bbc10a9d6 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:40:55 +0000 Subject: [PATCH 052/121] Implement Spot Light Shadows (#217) --- Third-Party/imgui/imgui_widgets.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Third-Party/imgui/imgui_widgets.cpp b/Third-Party/imgui/imgui_widgets.cpp index 3497c9b547..0c0795dfe1 100644 --- a/Third-Party/imgui/imgui_widgets.cpp +++ b/Third-Party/imgui/imgui_widgets.cpp @@ -2502,7 +2502,7 @@ bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data EndGroup(); return value_changed; } - +#include bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, float Color[], const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) { ImGuiWindow* window = GetCurrentWindow(); @@ -2521,6 +2521,7 @@ bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data if (i > 0) SameLine(0, g.Style.ItemInnerSpacing.x); PushStyleColor(ImGuiCol_FrameBg, ImVec4(Color[i*3], Color[i*3]+1, Color[i*3]+2, 1.0f)); + std::cout< Date: Sun, 12 Jun 2022 03:41:33 +0000 Subject: [PATCH 053/121] Implement Spot Light Shadows (#217) --- Third-Party/imgui/imgui.h | 3 +++ Third-Party/imgui/imgui_widgets.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Third-Party/imgui/imgui.h b/Third-Party/imgui/imgui.h index 4c78711a8a..c5af4bd141 100644 --- a/Third-Party/imgui/imgui.h +++ b/Third-Party/imgui/imgui.h @@ -132,6 +132,8 @@ Index of this file: #pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead #endif +#include + //----------------------------------------------------------------------------- // [SECTION] Forward declarations and basic types //----------------------------------------------------------------------------- @@ -563,6 +565,7 @@ namespace ImGui IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, float colors[], const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0); // MODIFIED BY ERS TEAM + // Widgets: Regular Sliders // - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped by default and can go off-bounds. Use ImGuiSliderFlags_AlwaysClamp to always clamp. // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. diff --git a/Third-Party/imgui/imgui_widgets.cpp b/Third-Party/imgui/imgui_widgets.cpp index 0c0795dfe1..81411ceea6 100644 --- a/Third-Party/imgui/imgui_widgets.cpp +++ b/Third-Party/imgui/imgui_widgets.cpp @@ -2502,7 +2502,7 @@ bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data EndGroup(); return value_changed; } -#include + bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, float Color[], const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) { ImGuiWindow* window = GetCurrentWindow(); From 359bc066f1d254ad03e6e8447308436b2a533e25 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:42:44 +0000 Subject: [PATCH 054/121] Implement Spot Light Shadows (#217) --- Third-Party/imgui/imgui.h | 3 --- Third-Party/imgui/imgui_widgets.cpp | 4 +--- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Third-Party/imgui/imgui.h b/Third-Party/imgui/imgui.h index c5af4bd141..4c78711a8a 100644 --- a/Third-Party/imgui/imgui.h +++ b/Third-Party/imgui/imgui.h @@ -132,8 +132,6 @@ Index of this file: #pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead #endif -#include - //----------------------------------------------------------------------------- // [SECTION] Forward declarations and basic types //----------------------------------------------------------------------------- @@ -565,7 +563,6 @@ namespace ImGui IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, float colors[], const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0); // MODIFIED BY ERS TEAM - // Widgets: Regular Sliders // - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped by default and can go off-bounds. Use ImGuiSliderFlags_AlwaysClamp to always clamp. // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. diff --git a/Third-Party/imgui/imgui_widgets.cpp b/Third-Party/imgui/imgui_widgets.cpp index 81411ceea6..69cebdf721 100644 --- a/Third-Party/imgui/imgui_widgets.cpp +++ b/Third-Party/imgui/imgui_widgets.cpp @@ -2502,7 +2502,6 @@ bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data EndGroup(); return value_changed; } - bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, float Color[], const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) { ImGuiWindow* window = GetCurrentWindow(); @@ -2520,8 +2519,7 @@ bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data PushID(i); if (i > 0) SameLine(0, g.Style.ItemInnerSpacing.x); - PushStyleColor(ImGuiCol_FrameBg, ImVec4(Color[i*3], Color[i*3]+1, Color[i*3]+2, 1.0f)); - std::cout< Date: Sun, 12 Jun 2022 03:44:44 +0000 Subject: [PATCH 055/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index caf42f5842..5059fdaef0 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -84,11 +84,8 @@ void Widget_ObjectProperties::Draw() { }; ImGui::DragFloat3("Location", (float*)glm::value_ptr(Cursors3D_->Pos_), 0.05f, Colors); - // ImGui::PopStyleColor(); - //Cursors3D_->Pos_ = XYZDragFloat("Position", Cursors3D_->Pos_); - - ImGui::DragFloat3("Rotation", (float*)glm::value_ptr(Cursors3D_->Rot_), 0.05f);// FIXME: MAKE ROLL OVER TO 180 Degrees? - ImGui::DragFloat3("Scale", (float*)glm::value_ptr(Cursors3D_->Scale_), 0.05f, 0.0f, 65535.0f); + ImGui::DragFloat3("Rotation", (float*)glm::value_ptr(Cursors3D_->Rot_), 0.05f, Colors); + ImGui::DragFloat3("Scale", (float*)glm::value_ptr(Cursors3D_->Scale_), 0.05f, Colors, 0.0f, 65535.0f); } // Handle Extra Options For Lights From bdc8d497390a9bb6b228b798802fa980113a3f9c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:48:18 +0000 Subject: [PATCH 056/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 5059fdaef0..fb2ea8937a 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -167,10 +167,10 @@ void Widget_ObjectProperties::Draw() { ImGui::HelpMarker("Sets the distance after which the scene is no longer affected by this light source."); - ImGui::DragFloat("Cutoff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff, 1.0f); + ImGui::DragFloat("Cutoff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff, 1.0f, 0.0f, 120.0f); ImGui::SameLine(); ImGui::HelpMarker("Specifies the angle of the spot light's outer cone."); - ImGui::DragFloat("Rolloff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff, 0.5f); + ImGui::DragFloat("Rolloff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff, 0.5f, 0.0f, SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff); 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)."); From c45f2331a5642363f5f7becc91cb815f7a75ab02 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:48:52 +0000 Subject: [PATCH 057/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index fb2ea8937a..e1add4a1a7 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -170,7 +170,10 @@ void Widget_ObjectProperties::Draw() { ImGui::DragFloat("Cutoff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff, 1.0f, 0.0f, 120.0f); ImGui::SameLine(); ImGui::HelpMarker("Specifies the angle of the spot light's outer cone."); - ImGui::DragFloat("Rolloff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff, 0.5f, 0.0f, SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff); + ImGui::DragFloat("Rolloff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff, 0.5f, 0.0f); + if (SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff < SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff) { + SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff = SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff; + } 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)."); From 66b03c624b9277daecaddf7e3fc3bc3b399d2995 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 03:50:36 +0000 Subject: [PATCH 058/121] Implement Spot Light Shadows (#217) --- Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index e1add4a1a7..5b777cb462 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -173,6 +173,8 @@ void Widget_ObjectProperties::Draw() { ImGui::DragFloat("Rolloff Angle", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff, 0.5f, 0.0f); if (SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff < SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff) { SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff = SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff; + } else if (SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff < 0.0f) { + SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Rolloff = 0.0f; } 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)."); From 99c2053afbcc6937c084cca2a28bb40172b26a4e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:09:03 +0000 Subject: [PATCH 059/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_DepthMaps.cpp | 95 ++++++++++++++++++- 1 file changed, 94 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 722ddd87d7..f9898c305a 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -211,7 +211,50 @@ void ERS_CLASS_DepthMaps::CheckSettings() { } -void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_DepthMap* Target, ERS_STRUCT_Shader* DepthShader, glm::vec3 Pos, glm::vec3 Rot, bool Orthogonal, glm::mat4* LightSpaceMatrix) { +void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_DirectionalLight* Light, ERS_STRUCT_Shader* DepthShader, glm::mat4* LightSpaceMatrix) { + + + // Check Settings + CheckSettings(); + + // Setup Variables + 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 + + + // 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); + + if (LightSpaceMatrix != nullptr) { + *LightSpaceMatrix = ObjectSpace; + } + + glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); + glBindFramebuffer(GL_FRAMEBUFFER, Light->DepthMap.FrameBufferObjectID); + + + glClear(GL_DEPTH_BUFFER_BIT); + glActiveTexture(GL_TEXTURE0); + Renderer_->RenderSceneNoTextures(TargetScene, DepthShader); + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + +} + +void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUCT_Shader* DepthShader, glm::mat4* LightSpaceMatrix) { // Check Settings @@ -258,6 +301,56 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_DepthMap* Target, ERS_STRUCT } + +void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT_Shader* DepthShader, glm::mat4* LightSpaceMatrix) { + + + // Check Settings + CheckSettings(); + + // Setup Variables + 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 + if (Orthogonal) { + ObjectProjection = glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, NearPlane, FarPlane); // ortho models directional light source + } else { + float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; + ObjectProjection = glm::perspective(glm::radians(110.0f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + } + + // Re-Do Rotation + glm::vec3 XYZRotation = ERS_FUNCTION_ConvertRotationToFrontVector(Rot); + + glm::vec3 Front = glm::normalize(XYZRotation); + ObjectView = glm::lookAt(Pos, 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); + + if (LightSpaceMatrix != nullptr) { + *LightSpaceMatrix = ObjectSpace; + } + + glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); + glBindFramebuffer(GL_FRAMEBUFFER, Target->FrameBufferObjectID); + + + glClear(GL_DEPTH_BUFFER_BIT); + glActiveTexture(GL_TEXTURE0); + Renderer_->RenderSceneNoTextures(TargetScene, DepthShader); + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + +} + + + void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { From 9268dd89966a06783a659832bb298ac8a6921150 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:18:12 +0000 Subject: [PATCH 060/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_DepthMaps.cpp | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 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 f9898c305a..c46dcbc6d8 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -266,18 +266,16 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC float NearPlane = 0.1f, FarPlane = 15.0f; // Calculate Project, View, Space Matrices - if (Orthogonal) { - ObjectProjection = glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, NearPlane, FarPlane); // ortho models directional light source - } else { - float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - ObjectProjection = glm::perspective(glm::radians(110.0f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source - } + + float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; + ObjectProjection = glm::perspective(glm::radians(110.0f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + // Re-Do Rotation - glm::vec3 XYZRotation = ERS_FUNCTION_ConvertRotationToFrontVector(Rot); + glm::vec3 XYZRotation = ERS_FUNCTION_ConvertRotationToFrontVector(Light->Rot); glm::vec3 Front = glm::normalize(XYZRotation); - ObjectView = glm::lookAt(Pos, Pos+Front, glm::vec3(0.0f, 1.0f, 0.0f)); // Pos+Front + 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 @@ -289,7 +287,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC } glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); - glBindFramebuffer(GL_FRAMEBUFFER, Target->FrameBufferObjectID); + glBindFramebuffer(GL_FRAMEBUFFER, Light->DepthMap.FrameBufferObjectID); glClear(GL_DEPTH_BUFFER_BIT); @@ -314,18 +312,16 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT float NearPlane = 0.1f, FarPlane = 15.0f; // Calculate Project, View, Space Matrices - if (Orthogonal) { - ObjectProjection = glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, NearPlane, FarPlane); // ortho models directional light source - } else { - float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - ObjectProjection = glm::perspective(glm::radians(110.0f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source - } + + float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; + ObjectProjection = glm::perspective(glm::radians(110.0f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + // Re-Do Rotation - glm::vec3 XYZRotation = ERS_FUNCTION_ConvertRotationToFrontVector(Rot); + glm::vec3 XYZRotation = ERS_FUNCTION_ConvertRotationToFrontVector(Light->Rot); glm::vec3 Front = glm::normalize(XYZRotation); - ObjectView = glm::lookAt(Pos, Pos+Front, glm::vec3(0.0f, 1.0f, 0.0f)); // Pos+Front + 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 @@ -337,7 +333,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT } glViewport(0, 0, DepthTextureArrayWidth_, DepthTextureArrayHeight_); - glBindFramebuffer(GL_FRAMEBUFFER, Target->FrameBufferObjectID); + glBindFramebuffer(GL_FRAMEBUFFER, Light->DepthMap.FrameBufferObjectID); glClear(GL_DEPTH_BUFFER_BIT); From 3133cd03e2da18f6cc4d364b162ce9ed6a8a62cb Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:19:16 +0000 Subject: [PATCH 061/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 1a0809a62e..bd4ccd85f8 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.h @@ -156,6 +156,8 @@ class ERS_CLASS_DepthMaps { * @param Scale * @param Orthogonal Use Orthogonal for directional lights and perspective for everything else */ - void UpdateDepthMap(ERS_STRUCT_DepthMap* Target, ERS_STRUCT_Shader* DepthShader, glm::vec3 Pos, glm::vec3 Rot, bool Orthogonal = true, glm::mat4* LightSpaceMatrix = nullptr); + void UpdateDepthMap(ERS_STRUCT_DirectionalLight* Light, ERS_STRUCT_Shader* DepthShader, glm::mat4* LightSpaceMatrix = nullptr); + void UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUCT_Shader* DepthShader, glm::mat4* LightSpaceMatrix = nullptr); + void UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT_Shader* DepthShader, glm::mat4* LightSpaceMatrix = nullptr); }; \ No newline at end of file From c452c06c185ebb6d006e4013ad03a5561382d8f4 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:21:50 +0000 Subject: [PATCH 062/121] Implement Spot Light Shadows (#217) --- .../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 c46dcbc6d8..a83408a3bb 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -369,7 +369,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { // Render To Depth Map glm::mat4* LightSpaceMatrix = new glm::mat4(); - UpdateDepthMap(&Light->DepthMap, DepthShader, Light->Pos, Light->Rot, true, LightSpaceMatrix); + UpdateDepthMap(&Light, DepthShader, LightSpaceMatrix); Light->LightSpaceMatrix = *LightSpaceMatrix; } @@ -387,7 +387,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { // Render To Depth Map glm::mat4* LightSpaceMatrix = new glm::mat4(); - UpdateDepthMap(&Light->DepthMap, DepthShader, Light->Pos, Light->Rot, true, LightSpaceMatrix); + UpdateDepthMap(&Light, DepthShader, LightSpaceMatrix); Light->LightSpaceMatrix = *LightSpaceMatrix; } @@ -405,7 +405,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { // Render To Depth Map glm::mat4* LightSpaceMatrix = new glm::mat4(); - UpdateDepthMap(&Light->DepthMap, DepthShader, Light->Pos, Light->Pos, true, LightSpaceMatrix); // set this to false later, debugging + UpdateDepthMap(&Light, DepthShader, LightSpaceMatrix); // set this to false later, debugging Light->LightSpaceMatrix = *LightSpaceMatrix; } From 74d876118c2d363f3873995096b9e36c8b483257 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:22:39 +0000 Subject: [PATCH 063/121] Implement Spot Light Shadows (#217) --- .../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 a83408a3bb..e335ef2d1d 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -369,7 +369,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { // Render To Depth Map glm::mat4* LightSpaceMatrix = new glm::mat4(); - UpdateDepthMap(&Light, DepthShader, LightSpaceMatrix); + UpdateDepthMap(Light, DepthShader, LightSpaceMatrix); Light->LightSpaceMatrix = *LightSpaceMatrix; } @@ -387,7 +387,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { // Render To Depth Map glm::mat4* LightSpaceMatrix = new glm::mat4(); - UpdateDepthMap(&Light, DepthShader, LightSpaceMatrix); + UpdateDepthMap(Light, DepthShader, LightSpaceMatrix); Light->LightSpaceMatrix = *LightSpaceMatrix; } @@ -405,7 +405,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { // Render To Depth Map glm::mat4* LightSpaceMatrix = new glm::mat4(); - UpdateDepthMap(&Light, DepthShader, LightSpaceMatrix); // set this to false later, debugging + UpdateDepthMap(Light, DepthShader, LightSpaceMatrix); // set this to false later, debugging Light->LightSpaceMatrix = *LightSpaceMatrix; } From df16c780a67d869e34a0a6702f67b7f81ae5bfb6 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:23:43 +0000 Subject: [PATCH 064/121] Implement Spot Light Shadows (#217) --- .../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 e335ef2d1d..97726fe4de 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -272,10 +272,10 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC // Re-Do Rotation - glm::vec3 XYZRotation = ERS_FUNCTION_ConvertRotationToFrontVector(Light->Rot); + //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 + //glm::vec3 Front = glm::normalize(XYZRotation); + ObjectView = glm::lookAt(Light->Pos, Light->Pos, glm::vec3(0.0f, 1.0f, 0.0f)); // Pos+Front ObjectSpace = ObjectProjection * ObjectView; // Render With Depth Shader From b9b2d6b068da4c8acf13e2316e5e0c385f06028a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:37:16 +0000 Subject: [PATCH 065/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 3 +-- 1 file changed, 1 insertion(+), 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 97726fe4de..ac64ef761c 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -299,7 +299,6 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_PointLight* Light, ERS_STRUC } - void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT_Shader* DepthShader, glm::mat4* LightSpaceMatrix) { @@ -314,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - ObjectProjection = glm::perspective(glm::radians(110.0f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + ObjectProjection = glm::perspective(glm::radians(Light->CutOff + 20.0f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source // Re-Do Rotation From ae2122af87543a266312c9e2767839210133c6e1 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:42:03 +0000 Subject: [PATCH 066/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 ac64ef761c..3815bfc9b3 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - ObjectProjection = glm::perspective(glm::radians(Light->CutOff + 20.0f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + ObjectProjection = glm::perspective(glm::radians(Light->CutOff), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source // Re-Do Rotation From 2363a90cc3a192e2ff8053dd743e18f3b7636bc1 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:45:36 +0000 Subject: [PATCH 067/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 3815bfc9b3..5e7b8bd834 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - ObjectProjection = glm::perspective(glm::radians(Light->CutOff), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + ObjectProjection = glm::perspective(glm::radians(Light->CutOff * 1.5), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source // Re-Do Rotation From 45730913ebf2081a8569d9e18f54995b38766111 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:46:16 +0000 Subject: [PATCH 068/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 5e7b8bd834..3815bfc9b3 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - ObjectProjection = glm::perspective(glm::radians(Light->CutOff * 1.5), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + ObjectProjection = glm::perspective(glm::radians(Light->CutOff), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source // Re-Do Rotation From 48cb9ca7f06cb667c4d50e0e9340e1002c1db91a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:46:29 +0000 Subject: [PATCH 069/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 3815bfc9b3..df6e00476a 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - ObjectProjection = glm::perspective(glm::radians(Light->CutOff), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + ObjectProjection = glm::perspective(glm::radians(Light->CutOff * 1.5f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source // Re-Do Rotation From 5ee863bc499044ce29ea43e7a8deea5a4044e560 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 05:48:14 +0000 Subject: [PATCH 070/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 df6e00476a..3815bfc9b3 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - ObjectProjection = glm::perspective(glm::radians(Light->CutOff * 1.5f), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + ObjectProjection = glm::perspective(glm::radians(Light->CutOff), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source // Re-Do Rotation From c6709024093ef2a07ca613f402ca44b09d4d756f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 06:06:47 +0000 Subject: [PATCH 071/121] Implement Spot Light Shadows (#217) --- .../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 67b57fc3f7..a8dde05e4d 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -679,7 +679,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetInt((UniformName + std::string(".DepthMapIndex")).c_str(), ActiveScene->DirectionalLights[i]->DepthMap.DepthMapTextureIndex); ActiveShader->SetMat4((UniformName + std::string(".LightSpaceMatrix")).c_str(), ActiveScene->DirectionalLights[i]->LightSpaceMatrix); - + } // Point Lights From 48a7c6e6986c64be3790c41c336263e356d222fe Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 06:07:18 +0000 Subject: [PATCH 072/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 4 ++-- 1 file changed, 2 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 a8dde05e4d..62e834e964 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,8 +710,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 3.1415))); - ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 3.1415))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 2))); + ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 2))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From ecadbb92f953671b73104d1ee2115e8b35030a32 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 06:14:24 +0000 Subject: [PATCH 073/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 4 ++-- 1 file changed, 2 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 62e834e964..8dafa6aea4 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,8 +710,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 2))); - ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 2))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 4))); + ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 4))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 6ba623611e29f767061a8beace8a76c67ebe42fa Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 07:27:12 +0000 Subject: [PATCH 074/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 4 ++-- 1 file changed, 2 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 8dafa6aea4..9f6e11fe8e 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,8 +710,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 4))); - ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 4))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (glm::radians(ActiveScene->SpotLights[i]->CutOff))); + ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From c9a98833ac814c85ef603dd26d387d905e28044c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 07:29:37 +0000 Subject: [PATCH 075/121] Implement Spot Light Shadows (#217) --- .../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 9f6e11fe8e..bdc38ce89b 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (glm::radians(ActiveScene->SpotLights[i]->CutOff))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (glm::radians(ActiveScene->SpotLights[i]->CutOff))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 42b09feaa37a5e42101366eb1d3978e360098bd0 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 07:31:45 +0000 Subject: [PATCH 076/121] Implement Spot Light Shadows (#217) --- .../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 bdc38ce89b..10af954ba0 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (glm::radians(ActiveScene->SpotLights[i]->CutOff))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - glm::radians(ActiveScene->SpotLights[i]->CutOff))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From e248c2dca10ea27059264d7f44fc9a3844e348eb Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 07:53:45 +0000 Subject: [PATCH 077/121] Implement Spot Light Shadows (#217) --- .../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 10af954ba0..2cb806fff7 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - glm::radians(ActiveScene->SpotLights[i]->CutOff))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - glm::radians(ActiveScene->SpotLights[i]->CutOff + 180))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 14a9ab9827851f7662bde8b464e29f4cce9bacb7 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 07:55:08 +0000 Subject: [PATCH 078/121] Implement Spot Light Shadows (#217) --- .../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 2cb806fff7..6dd0b16501 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - glm::radians(ActiveScene->SpotLights[i]->CutOff + 180))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - cos(glm::radians(ActiveScene->SpotLights[i]->CutOff)))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 43ae360beb13a3f161f72e85ac22059bc31ff692 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 07:56:43 +0000 Subject: [PATCH 079/121] Implement Spot Light Shadows (#217) --- .../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 6dd0b16501..e79e2e5eaa 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - cos(glm::radians(ActiveScene->SpotLights[i]->CutOff)))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - cos(glm::radians(ActiveScene->SpotLights[i]->CutOff + 90)))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From cfa9beb7a3dd73e0a1479d5a7f446947ede14f0a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 07:58:19 +0000 Subject: [PATCH 080/121] Implement Spot Light Shadows (#217) --- .../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 e79e2e5eaa..10af954ba0 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - cos(glm::radians(ActiveScene->SpotLights[i]->CutOff + 90)))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - glm::radians(ActiveScene->SpotLights[i]->CutOff))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From d59fed990ba7ac901f0cc5ab18f26da44c182e5c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:07:25 +0000 Subject: [PATCH 081/121] Implement Spot Light Shadows (#217) --- .../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 10af954ba0..3faf041ccf 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - glm::radians(ActiveScene->SpotLights[i]->CutOff))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), ( glm::radians(ActiveScene->SpotLights[i]->CutOff))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 5c5d82a8ebb8d8ae9d2c2df085f5bac449123cb7 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:27:38 +0000 Subject: [PATCH 082/121] Implement Spot Light Shadows (#217) --- .../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 3faf041ccf..10af954ba0 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), ( glm::radians(ActiveScene->SpotLights[i]->CutOff))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - glm::radians(ActiveScene->SpotLights[i]->CutOff))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 73ac0d13ed7fd84f6866971794dd0031ab3d8207 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:28:47 +0000 Subject: [PATCH 083/121] Implement Spot Light Shadows (#217) --- .../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 10af954ba0..3b5a534e00 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - glm::radians(ActiveScene->SpotLights[i]->CutOff))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - (glm::radians(ActiveScene->SpotLights[i]->CutOff) * 6.36))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From ef6d9669ceb5e74028cf41cba1fcaa18f1cc258e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:29:53 +0000 Subject: [PATCH 084/121] Implement Spot Light Shadows (#217) --- .../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 3b5a534e00..70898bdebc 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - (glm::radians(ActiveScene->SpotLights[i]->CutOff) * 6.36))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - (glm::radians(ActiveScene->SpotLights[i]->CutOff)))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From ac06b43af558b1a10479e95efbf54138a5fff9db Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:31:29 +0000 Subject: [PATCH 085/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 4 ++-- 1 file changed, 2 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 70898bdebc..8dafa6aea4 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,8 +710,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), (1.0f - (glm::radians(ActiveScene->SpotLights[i]->CutOff)))); - ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 4))); + ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 4))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 47440733e8000ae72832819a9cbaac3626803123 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:33:18 +0000 Subject: [PATCH 086/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 4 ++-- 1 file changed, 2 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 8dafa6aea4..802c67527b 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,8 +710,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 4))); - ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 4))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - ((ActiveScene->SpotLights[i]->CutOff + 25.0f) * (0.01745329 / 5))); + ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 5))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 0fb8c74fb9e82a6a816572255577e5db1f2aba79 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:34:11 +0000 Subject: [PATCH 087/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 4 ++-- 1 file changed, 2 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 802c67527b..03c0de4134 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,8 +710,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - ((ActiveScene->SpotLights[i]->CutOff + 25.0f) * (0.01745329 / 5))); - ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 5))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - ((ActiveScene->SpotLights[i]->CutOff + 25.0f) * (0.01745329 / 3.1415))); + ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 3.1415))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 0185a6dc2e9dd6ba06dac14a8263f7d5dc2b0bdc Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:35:38 +0000 Subject: [PATCH 088/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 4 ++-- 1 file changed, 2 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 03c0de4134..67b57fc3f7 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -679,7 +679,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetInt((UniformName + std::string(".DepthMapIndex")).c_str(), ActiveScene->DirectionalLights[i]->DepthMap.DepthMapTextureIndex); ActiveShader->SetMat4((UniformName + std::string(".LightSpaceMatrix")).c_str(), ActiveScene->DirectionalLights[i]->LightSpaceMatrix); - + } // Point Lights @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - ((ActiveScene->SpotLights[i]->CutOff + 25.0f) * (0.01745329 / 3.1415))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 3.1415))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 3.1415))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 241d351f6dc124ad2ee2cfc2eefbb095461c322d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:35:52 +0000 Subject: [PATCH 089/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 3815bfc9b3..782b083bc0 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - ObjectProjection = glm::perspective(glm::radians(Light->CutOff), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + ObjectProjection = glm::perspective(Light->CutOff* (0.01745329 / 3.1415), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source // Re-Do Rotation From be9d588c7faa31e1c603a7f1045971a685a7012e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:36:37 +0000 Subject: [PATCH 090/121] Implement Spot Light Shadows (#217) --- .../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 782b083bc0..71e982185f 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,8 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - ObjectProjection = glm::perspective(Light->CutOff* (0.01745329 / 3.1415), AspectRatio, NearPlane, FarPlane); // Perspective models regular light source + float FOV = (Light->CutOff * (0.01745329 / 3.1415)); + ObjectProjection = glm::perspective(FOV, AspectRatio, NearPlane, FarPlane); // Perspective models regular light source // Re-Do Rotation From 8b6a7aa3952135ff93c982fa7d7f263e8989459c Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:37:47 +0000 Subject: [PATCH 091/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 71e982185f..4e41883ef2 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - float FOV = (Light->CutOff * (0.01745329 / 3.1415)); + float FOV = (Light->CutOff * (0.01745329)); ObjectProjection = glm::perspective(FOV, AspectRatio, NearPlane, FarPlane); // Perspective models regular light source From 54e5397385e12a72f5032b916dbfaf95a3bc469e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:42:06 +0000 Subject: [PATCH 092/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 4e41883ef2..cf3dd936d4 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - float FOV = (Light->CutOff * (0.01745329)); + float FOV = glm::radians(Light->CutOff);// * (0.01745329)); ObjectProjection = glm::perspective(FOV, AspectRatio, NearPlane, FarPlane); // Perspective models regular light source From f89797af5e3b64be2f5aa625387d4402b6a0bf32 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:43:04 +0000 Subject: [PATCH 093/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 cf3dd936d4..1b7aaccd7f 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - float FOV = glm::radians(Light->CutOff);// * (0.01745329)); + float FOV = glm::radians(Light->CutOff) * 2;// * (0.01745329)); ObjectProjection = glm::perspective(FOV, AspectRatio, NearPlane, FarPlane); // Perspective models regular light source From 925b403b679773d5ab263becefd557de1b0b76f4 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:44:44 +0000 Subject: [PATCH 094/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 1b7aaccd7f..53b0c65630 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - float FOV = glm::radians(Light->CutOff) * 2;// * (0.01745329)); + float FOV = glm::radians(130.0f);// * (0.01745329)); ObjectProjection = glm::perspective(FOV, AspectRatio, NearPlane, FarPlane); // Perspective models regular light source From 9d7f5330e64a02c19ec360be4d1acf09033bd1eb Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:46:03 +0000 Subject: [PATCH 095/121] Implement Spot Light Shadows (#217) --- .../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 67b57fc3f7..cbddd079c1 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 3.1415))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - glm::radians(ActiveScene->SpotLights[i]->CutOff));// * (0.01745329 / 3.1415))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 3.1415))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 590f1a8757bc0d4a355ffa95c5bf758a90252d6b Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:47:43 +0000 Subject: [PATCH 096/121] Implement Spot Light Shadows (#217) --- .../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 cbddd079c1..1499e27845 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - glm::radians(ActiveScene->SpotLights[i]->CutOff));// * (0.01745329 / 3.1415))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 6.28))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 3.1415))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 610fade415111a39e80ec859364dfb8185203148 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:50:11 +0000 Subject: [PATCH 097/121] Implement Spot Light Shadows (#217) --- .../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 1499e27845..0c52ceb23f 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 6.28))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 5))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 3.1415))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 61ee8ba5b75a3c2b0f8cd604a20e40a39d5a53e4 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:51:11 +0000 Subject: [PATCH 098/121] Implement Spot Light Shadows (#217) --- .../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 0c52ceb23f..5ea89d2cab 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -710,7 +710,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Position")).c_str(), ActiveScene->SpotLights[i]->Pos); ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); - ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 5))); + ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 4))); ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 3.1415))); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); From 1d64f1acc41d0bbdcff3ad5d54fab981e500881e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 08:54:22 +0000 Subject: [PATCH 099/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 2 +- .../ERS_CLASS_PythonInterpreterIntegration.cpp | 2 +- 2 files changed, 2 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 5ea89d2cab..6fdd1f456f 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -711,7 +711,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Direction")).c_str(), ERS_FUNCTION_ConvertRotationToFrontVector(ActiveScene->SpotLights[i]->Rot)); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->SpotLights[i]->Intensity); ActiveShader->SetFloat((UniformName + std::string(".CutOff")).c_str(), 1.0f - (ActiveScene->SpotLights[i]->CutOff * (0.01745329 / 4))); - ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), (ActiveScene->SpotLights[i]->Rolloff * (0.01745329 / 3.1415))); + ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); diff --git a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp index 0f8a54b016..ad1ffbe8d0 100644 --- a/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp +++ b/Source/Core/Script/ERS_CLASS_PythonInterpreterIntegration/ERS_CLASS_PythonInterpreterIntegration.cpp @@ -579,7 +579,7 @@ bool ERS_CLASS_PythonInterpreterIntegration::ExecuteSpotLightScript(std::string try { - SpotLight->Intensity = SpotLightModule.attr("SpotLightRolloff").cast(); + SpotLight->Rolloff = SpotLightModule.attr("SpotLightRolloff").cast(); } catch (pybind11::cast_error const&) { ErrorMessageString->push_back("SpotLight Rolloff CAST_ERROR"); } From a5ba24daa80533e056ba1a8d154d9e838d1dc0bc Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 09:18:49 +0000 Subject: [PATCH 100/121] Implement Spot Light Shadows (#217) --- .../Widgets/GUI_Widget_ObjectProperties.cpp | 28 +++++++++++-------- .../Projects/DefaultProject/10041.ERS | 15 ++++++---- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp index 5b777cb462..9b1fd572ae 100644 --- a/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp +++ b/Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp @@ -205,24 +205,30 @@ void Widget_ObjectProperties::Draw() { for (unsigned long i = 0; i < ScriptIndices_->size(); i++) { - std::string ScriptName = ProjectUtils_->ProjectManager_->Project_.Scripts[(*ScriptIndices_)[i]].Name_; - bool Selected = i==(unsigned long)ScriptIndex_; - if (ImGui::Selectable(ScriptName.c_str(), &Selected)) { - ScriptIndex_ = i; - } + unsigned int Index = (*ScriptIndices_)[i]; - // Context Menu - if (ImGui::BeginPopupContextItem()) { + if (Index < ProjectUtils_->ProjectManager_->Project_.Scripts.size()) { - if (ImGui::MenuItem("Remove Script")) { - ScriptIndices_->erase(ScriptIndices_->begin() + i); + std::string ScriptName = ProjectUtils_->ProjectManager_->Project_.Scripts[Index].Name_; + bool Selected = i==(unsigned long)ScriptIndex_; + if (ImGui::Selectable(ScriptName.c_str(), &Selected)) { + ScriptIndex_ = i; } - ImGui::EndPopup(); - } + // Context Menu + if (ImGui::BeginPopupContextItem()) { + + if (ImGui::MenuItem("Remove Script")) { + ScriptIndices_->erase(ScriptIndices_->begin() + i); + } + + ImGui::EndPopup(); + } + + } } diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 1b44494cd9..74a0f74410 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -219,10 +219,10 @@ 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.005); + float Bias = max(0.00 * (1.0 - dot(Object.Normal, LightDir)), 0.00025); + - //float Shadow = currentDepth - Bias > closestDepth ? 1.0 : 0.0; //float Shadow = 0.0f; @@ -250,9 +250,9 @@ float ShadowCalculation(mat4 LightSpaceMatrix, vec3 LightPos, int Index) **/ - - - float Shadow = ShadowPCFRandom(Bias, projCoords, Index, currentDepth, 1); + //float Shadow = currentDepth - Bias > closestDepth ? 1.0 : 0.0; + float Shadow = ShadowPCF(Bias, projCoords, Index, currentDepth, 2); + //float Shadow = ShadowPCFRandom(Bias, projCoords, Index, currentDepth, 1); @@ -464,7 +464,7 @@ vec3 PBRSpotLight(STRUCT_SpotLight Light, vec3 ViewDir, vec3 Reflectance, STRUCT // Calculate Spot Intensity float Theta = dot(normalize(Light.Position - Object.FragPos), normalize(-Light.Direction)); - float Epsilon = Light.RollOff; + float Epsilon = (Light.RollOff); float Intensity = clamp((Theta - Light.CutOff) / Epsilon, 0.0f, 1.0f); if (GammaCorrectionEnabled_) { @@ -619,3 +619,6 @@ void main() { + + + From dc71fd419f6739175512fa2666ad7ba95923bc73 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 09:19:14 +0000 Subject: [PATCH 101/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 53b0c65630..64bd4c0fbb 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - float FOV = glm::radians(130.0f);// * (0.01745329)); + float FOV = glm::radians(Light->CutOff * 1.1);// * (0.01745329)); ObjectProjection = glm::perspective(FOV, AspectRatio, NearPlane, FarPlane); // Perspective models regular light source From 946a3b8bf60be6c8234dd955fc6527c98d71d46b Mon Sep 17 00:00:00 2001 From: datacrystals Date: Sun, 12 Jun 2022 09:22:16 +0000 Subject: [PATCH 102/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 64bd4c0fbb..53b0c65630 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -313,7 +313,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Calculate Project, View, Space Matrices float AspectRatio = DepthTextureArrayWidth_ / DepthTextureArrayHeight_; - float FOV = glm::radians(Light->CutOff * 1.1);// * (0.01745329)); + float FOV = glm::radians(130.0f);// * (0.01745329)); ObjectProjection = glm::perspective(FOV, AspectRatio, NearPlane, FarPlane); // Perspective models regular light source From 2dc8bb68ce0beb44636015f7175b733bf845feac Mon Sep 17 00:00:00 2001 From: datacrystals Date: Mon, 13 Jun 2022 05:10:21 +0000 Subject: [PATCH 103/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 1 - 1 file changed, 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 53b0c65630..7406e2b7ec 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -341,7 +341,6 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT Renderer_->RenderSceneNoTextures(TargetScene, DepthShader); glBindFramebuffer(GL_FRAMEBUFFER, 0); - } From c569b523aa19940b02a53c2455240afe46381669 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Mon, 13 Jun 2022 05:12:15 +0000 Subject: [PATCH 104/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 4 ++++ 1 file changed, 4 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 6fdd1f456f..c3a19a4edb 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -677,6 +677,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->DirectionalLights[i]->Color); ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->DirectionalLights[i]->Intensity); + ActiveShader->SetFloat((UniformName + std::string(".MaxDistance")).c_str(), ActiveScene->DirectionalLights[i]->MaxDistance); + ActiveShader->SetInt((UniformName + std::string(".DepthMapIndex")).c_str(), ActiveScene->DirectionalLights[i]->DepthMap.DepthMapTextureIndex); ActiveShader->SetMat4((UniformName + std::string(".LightSpaceMatrix")).c_str(), ActiveScene->DirectionalLights[i]->LightSpaceMatrix); @@ -693,6 +695,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->PointLights[i]->Intensity); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->PointLights[i]->Color); + + ActiveShader->SetInt((UniformName + std::string(".DepthMapIndex")).c_str(), ActiveScene->PointLights[i]->DepthMap.DepthMapTextureIndex); ActiveShader->SetMat4((UniformName + std::string(".LightSpaceMatrix")).c_str(), ActiveScene->PointLights[i]->LightSpaceMatrix); From ef70c1681cb431c1984d1fd28cac0a247e492b96 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Mon, 13 Jun 2022 05:12:28 +0000 Subject: [PATCH 105/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 3 ++- 1 file changed, 2 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 c3a19a4edb..68d04e8d70 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -695,8 +695,9 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetFloat((UniformName + std::string(".Intensity")).c_str(), ActiveScene->PointLights[i]->Intensity); 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->SetInt((UniformName + std::string(".DepthMapIndex")).c_str(), ActiveScene->PointLights[i]->DepthMap.DepthMapTextureIndex); ActiveShader->SetMat4((UniformName + std::string(".LightSpaceMatrix")).c_str(), ActiveScene->PointLights[i]->LightSpaceMatrix); From 420cd131b491733b36ad6d5b68776bb6e9755277 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Mon, 13 Jun 2022 05:12:41 +0000 Subject: [PATCH 106/121] Implement Spot Light Shadows (#217) --- .../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 68d04e8d70..15f4a35ab9 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -719,6 +719,8 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetFloat((UniformName + std::string(".RollOff")).c_str(), glm::radians(ActiveScene->SpotLights[i]->Rolloff)); ActiveShader->SetVec3((UniformName + std::string(".Color")).c_str(), ActiveScene->SpotLights[i]->Color); + ActiveShader->SetFloat((UniformName + std::string(".MaxDistance")).c_str(), ActiveScene->SpotLights[i]->MaxDistance); + ActiveShader->SetInt((UniformName + std::string(".DepthMapIndex")).c_str(), ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex); ActiveShader->SetMat4((UniformName + std::string(".LightSpaceMatrix")).c_str(), ActiveScene->SpotLights[i]->LightSpaceMatrix); From 08250dd2d3d4c67bd288e006d8022b5b59368de0 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Mon, 13 Jun 2022 05:29:26 +0000 Subject: [PATCH 107/121] Implement Spot Light Shadows (#217) --- Source/EditorAssets/Projects/DefaultProject/10041.ERS | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/10041.ERS b/Source/EditorAssets/Projects/DefaultProject/10041.ERS index 74a0f74410..1ac8151cae 100644 --- a/Source/EditorAssets/Projects/DefaultProject/10041.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/10041.ERS @@ -474,8 +474,8 @@ vec3 PBRSpotLight(STRUCT_SpotLight Light, vec3 ViewDir, vec3 Reflectance, STRUCT // calculate per-light radiance vec3 L = normalize(Light.Position - Object.WorldPos); vec3 H = normalize(ViewDir + L); - float distance = length(Light.Position - Object.WorldPos); - float attenuation = 1.0 / (distance * distance); + float LightDistance = length(Light.Position - Object.WorldPos); + float attenuation = 1.0 / (LightDistance * LightDistance); vec3 radiance = Light.Color * Light.Intensity * attenuation; // Cook-Torrance BRDF @@ -500,6 +500,12 @@ vec3 PBRSpotLight(STRUCT_SpotLight Light, vec3 ViewDir, vec3 Reflectance, STRUCT // scale light by NdotL float NdotL = max(dot(Model.Normal, L), 0.0); + + // Check Distance, And Roll Off According To Max Distance + float DistanceToEnd = Light.MaxDistance - LightDistance; + if (DistanceToEnd < 1.0f) { + Intensity = clamp(Intensity * (DistanceToEnd), 0.0f, 1.0f); + } // add to outgoing radiance Lo return (kD * Model.Albedo.rgb / PI + specular) * radiance * NdotL * Intensity; // note that we already multiplied the BRDF by the Fresnel (kS) so we won't multiply by kS again @@ -622,3 +628,4 @@ void main() { + From cb2de27b98184856f2303ec4864f5d7146c76c3e Mon Sep 17 00:00:00 2001 From: datacrystals Date: Mon, 13 Jun 2022 05:31:21 +0000 Subject: [PATCH 108/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 5 +++-- 1 file changed, 3 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 7406e2b7ec..168fefcbaf 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -308,10 +308,11 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT // Setup Variables ERS_STRUCT_Scene* TargetScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); glm::mat4 ObjectProjection, ObjectView, ObjectSpace; - float NearPlane = 0.1f, FarPlane = 15.0f; + float NearPlane, FarPlane; + NearPlane = 0.001f; + 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 From ab7ed98d2945c354a54b71a5cf08d8eac6d34486 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Mon, 13 Jun 2022 05:33:33 +0000 Subject: [PATCH 109/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 168fefcbaf..a0efa4d31e 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -309,7 +309,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMap(ERS_STRUCT_SpotLight* Light, ERS_STRUCT ERS_STRUCT_Scene* TargetScene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get(); glm::mat4 ObjectProjection, ObjectView, ObjectSpace; float NearPlane, FarPlane; - NearPlane = 0.001f; + NearPlane = 0.1f; FarPlane = Light->MaxDistance; // Calculate Project, View, Space Matrices From cb02107dbbd049416d7810d5317d4e4ff23c131a Mon Sep 17 00:00:00 2001 From: datacrystals Date: Mon, 13 Jun 2022 20:03:51 +0000 Subject: [PATCH 110/121] Implement Spot Light Shadows (#217) --- .../Projects/DefaultProject/3.ERS | 69 +++++++++++-------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/Source/EditorAssets/Projects/DefaultProject/3.ERS b/Source/EditorAssets/Projects/DefaultProject/3.ERS index f98c2c609b..a89ba5b637 100644 --- a/Source/EditorAssets/Projects/DefaultProject/3.ERS +++ b/Source/EditorAssets/Projects/DefaultProject/3.ERS @@ -891,6 +891,7 @@ SceneData: PosY: 1.70000005 PosZ: 6.0999999 Intensity: 1 + MaxDistance: 0 AttachedScripts: {} 56: @@ -903,6 +904,7 @@ SceneData: PosY: 1.70000005 PosZ: 6.0999999 Intensity: 1 + MaxDistance: 0 AttachedScripts: {} 57: @@ -915,6 +917,7 @@ SceneData: PosY: 1.70000005 PosZ: 6.0999999 Intensity: 1 + MaxDistance: 0 AttachedScripts: {} 58: @@ -927,6 +930,7 @@ SceneData: PosY: 1.70000005 PosZ: 6.0999999 Intensity: 1 + MaxDistance: 0 AttachedScripts: {} 59: @@ -939,6 +943,7 @@ SceneData: PosY: 1.70000005 PosZ: 6.0999999 Intensity: 1 + MaxDistance: 0 AttachedScripts: {} 60: @@ -951,6 +956,7 @@ SceneData: PosY: 1.70000005 PosZ: 6.0999999 Intensity: 1 + MaxDistance: 0 AttachedScripts: {} 61: @@ -963,6 +969,7 @@ SceneData: PosY: 1.70000005 PosZ: 6.0999999 Intensity: 1 + MaxDistance: 0 AttachedScripts: {} 62: @@ -975,6 +982,7 @@ SceneData: PosY: 1.70000005 PosZ: 6.0999999 Intensity: 1 + MaxDistance: 0 AttachedScripts: {} 63: @@ -983,15 +991,16 @@ SceneData: ColorRed: 1 ColorGreen: 1 ColorBlue: 1 - PosX: -0.930386484 + PosX: -0.730386496 PosY: 1.5959357 PosZ: 6.00342846 - RotX: 18.4778862 - RotY: -15.6467848 - RotZ: -7.83750677 + RotX: 209.56749 + RotY: 59.9117813 + RotZ: 160.184723 Intensity: 25 - CutOff: 0.910000026 - OuterCutOff: 0.75999999 + MaxDistance: 10 + CutOff: 103 + RollOff: 11.5 AttachedScripts: {} 64: @@ -1000,15 +1009,16 @@ SceneData: ColorRed: 1 ColorGreen: 1 ColorBlue: 1 - PosX: -0.949999988 + PosX: -0.649999976 PosY: 1.5 PosZ: 1 - RotX: 14.6964588 - RotY: -8.51486015 - RotZ: -3.0760181 + RotX: 199.196381 + RotY: 58.3953362 + RotZ: 185.813049 Intensity: 25 - CutOff: 0.910000026 - OuterCutOff: 0.75999999 + MaxDistance: 15 + CutOff: 120 + RollOff: 16 AttachedScripts: {} 65: @@ -1017,15 +1027,16 @@ SceneData: ColorRed: 1 ColorGreen: 1 ColorBlue: 1 - PosX: -0.949999988 + PosX: -0.849999964 PosY: 1.5 PosZ: -4.8931241 - RotX: 14.7390451 - RotY: -6.51885748 - RotZ: -1.36448181 + RotX: 47.6549835 + RotY: 47.9395943 + RotZ: 4.55612373 Intensity: 25 - CutOff: 0.910000026 - OuterCutOff: 0.75999999 + MaxDistance: 10 + CutOff: 95 + RollOff: 7 AttachedScripts: {} 66: @@ -1037,12 +1048,13 @@ SceneData: PosX: 2.97785139 PosY: 1.5 PosZ: -4.70444107 - RotX: -35.5486069 - RotY: -20.949976 - RotZ: 8.76933765 + RotX: 4.07153368 + RotY: 59.641552 + RotZ: 250.978882 Intensity: 25 - CutOff: 0.910000026 - OuterCutOff: 0.75999999 + MaxDistance: 15 + CutOff: 77 + RollOff: 6 AttachedScripts: {} 67: @@ -1054,11 +1066,12 @@ SceneData: PosX: 2.97785139 PosY: 1.5 PosZ: 1.07611871 - RotX: -34.3861809 - RotY: -30.3114014 - RotZ: 12.0187654 + RotX: 71.6560745 + RotY: 347.370728 + RotZ: 322.172424 Intensity: 25 - CutOff: 0.910000026 - OuterCutOff: 0.75999999 + MaxDistance: 10 + CutOff: 80 + RollOff: 9 AttachedScripts: {} \ No newline at end of file From 731e88fd5976df6fb890af2a45505c792463453d Mon Sep 17 00:00:00 2001 From: datacrystals Date: Mon, 13 Jun 2022 21:30:56 +0000 Subject: [PATCH 111/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_DepthMaps.cpp | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 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 a0efa4d31e..b93267c97e 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -356,23 +356,23 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { // 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 = GenerateDepthMap(); - } + // // Check If Light Has DepthMap + // if (!Light->DepthMap.Initialized) { + // Light->DepthMap = GenerateDepthMap(); + // } - // Render To Depth Map - glm::mat4* LightSpaceMatrix = new glm::mat4(); - UpdateDepthMap(Light, DepthShader, LightSpaceMatrix); - Light->LightSpaceMatrix = *LightSpaceMatrix; + // // Render To Depth Map + // glm::mat4* LightSpaceMatrix = new glm::mat4(); + // UpdateDepthMap(Light, DepthShader, LightSpaceMatrix); + // Light->LightSpaceMatrix = *LightSpaceMatrix; - } + // } // Handle Spot Lights for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { @@ -392,23 +392,23 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { } - // Handle Point Lights - for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { + // // Handle Point Lights + // 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 = GenerateDepthMap(); - } + // // Check If Light Has DepthMap + // if (!Light->DepthMap.Initialized) { + // Light->DepthMap = GenerateDepthMap(); + // } - // Render To Depth Map - glm::mat4* LightSpaceMatrix = new glm::mat4(); - UpdateDepthMap(Light, DepthShader, LightSpaceMatrix); // set this to false later, debugging - Light->LightSpaceMatrix = *LightSpaceMatrix; + // // Render To Depth Map + // glm::mat4* LightSpaceMatrix = new glm::mat4(); + // UpdateDepthMap(Light, DepthShader, LightSpaceMatrix); // set this to false later, debugging + // Light->LightSpaceMatrix = *LightSpaceMatrix; - } + // } // Return To Normal Culling From 09caaff740af261384653c3bd34089cf65363bce Mon Sep 17 00:00:00 2001 From: datacrystals Date: Mon, 13 Jun 2022 21:38:28 +0000 Subject: [PATCH 112/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 1 + 1 file changed, 1 insertion(+) 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 15f4a35ab9..fa175db02f 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp @@ -725,6 +725,7 @@ void ERS_CLASS_VisualRenderer::UpdateShader(int ShaderIndex, float DeltaTime, in ActiveShader->SetInt((UniformName + std::string(".DepthMapIndex")).c_str(), ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex); ActiveShader->SetMat4((UniformName + std::string(".LightSpaceMatrix")).c_str(), ActiveScene->SpotLights[i]->LightSpaceMatrix); + std::cout<SpotLights[i]->DepthMap.DepthMapTextureIndex< Date: Mon, 13 Jun 2022 21:41:50 +0000 Subject: [PATCH 113/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 1 + .../ERS_CLASS_VisualRenderer/ERS_CLASS_VisualRenderer.cpp | 2 -- 2 files changed, 1 insertion(+), 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 b93267c97e..3269dafdf6 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -383,6 +383,7 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { // Check If Light Has DepthMap if (!Light->DepthMap.Initialized) { Light->DepthMap = GenerateDepthMap(); + std::cout<DepthMap.DepthMapTextureIndex<SetInt((UniformName + std::string(".DepthMapIndex")).c_str(), ActiveScene->SpotLights[i]->DepthMap.DepthMapTextureIndex); ActiveShader->SetMat4((UniformName + std::string(".LightSpaceMatrix")).c_str(), ActiveScene->SpotLights[i]->LightSpaceMatrix); - std::cout<SpotLights[i]->DepthMap.DepthMapTextureIndex< Date: Mon, 13 Jun 2022 21:43:45 +0000 Subject: [PATCH 114/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 3269dafdf6..7f5d23c632 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -14,7 +14,7 @@ ERS_CLASS_DepthMaps::ERS_CLASS_DepthMaps(ERS_STRUCT_SystemUtils* SystemUtils, ER SystemUtils_->Logger_->Log("Initializing Viewport Overlay Subsystem", 5); // Create Array Texture For Depth Maps - RegenerateDepthMapTextureArray(1, 2048, 2048); + RegenerateDepthMapTextureArray(16, 2048, 2048); } From b78239a0596c6473f37f805a50ee2c5698dff38f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 14 Jun 2022 01:08:40 +0000 Subject: [PATCH 115/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 7f5d23c632..3269dafdf6 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -14,7 +14,7 @@ ERS_CLASS_DepthMaps::ERS_CLASS_DepthMaps(ERS_STRUCT_SystemUtils* SystemUtils, ER SystemUtils_->Logger_->Log("Initializing Viewport Overlay Subsystem", 5); // Create Array Texture For Depth Maps - RegenerateDepthMapTextureArray(16, 2048, 2048); + RegenerateDepthMapTextureArray(1, 2048, 2048); } From 860928fd7a621e703df7b919b61cddf609c132d2 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 14 Jun 2022 01:13:56 +0000 Subject: [PATCH 116/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 3269dafdf6..56bc74b4f5 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -155,7 +155,7 @@ unsigned int ERS_CLASS_DepthMaps::AllocateDepthMapIndex(unsigned int Framebuffer RegenerateDepthMapTextureArray(StartSize + DepthMapAllocationChunkSize_, DepthTextureArrayWidth_, DepthTextureArrayHeight_); SystemUtils_->Logger_->Log(std::string("Finished Updating Depth Map Array, Allocating Depth Map Texture Array Index: ") + std::to_string(StartSize + DepthMapAllocationChunkSize_), 5); - return StartSize + 1; + return StartSize; } From 7727a9a1f10e8eaf70f46c56d9b7d22694e405bb Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 14 Jun 2022 01:17:15 +0000 Subject: [PATCH 117/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 4 +++- 1 file changed, 3 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 56bc74b4f5..85969f3e66 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -155,7 +155,9 @@ unsigned int ERS_CLASS_DepthMaps::AllocateDepthMapIndex(unsigned int Framebuffer RegenerateDepthMapTextureArray(StartSize + DepthMapAllocationChunkSize_, DepthTextureArrayWidth_, DepthTextureArrayHeight_); SystemUtils_->Logger_->Log(std::string("Finished Updating Depth Map Array, Allocating Depth Map Texture Array Index: ") + std::to_string(StartSize + DepthMapAllocationChunkSize_), 5); - return StartSize; + DepthMapTexturesAlreadyAllocated_[StartSize + 1] = FramebufferObjectID; + + return StartSize + 1; } From 4969e97b76a3648d0d03a65c87e9ba45979a864f Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 14 Jun 2022 01:19:43 +0000 Subject: [PATCH 118/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_DepthMaps.cpp | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 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 85969f3e66..f4897a1fd0 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -358,23 +358,23 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { // 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 = GenerateDepthMap(); - // } + // Check If Light Has DepthMap + if (!Light->DepthMap.Initialized) { + Light->DepthMap = GenerateDepthMap(); + } - // // Render To Depth Map - // glm::mat4* LightSpaceMatrix = new glm::mat4(); - // UpdateDepthMap(Light, DepthShader, LightSpaceMatrix); - // Light->LightSpaceMatrix = *LightSpaceMatrix; + // Render To Depth Map + glm::mat4* LightSpaceMatrix = new glm::mat4(); + UpdateDepthMap(Light, DepthShader, LightSpaceMatrix); + Light->LightSpaceMatrix = *LightSpaceMatrix; - // } + } // Handle Spot Lights for (unsigned int i = 0; i < ActiveScene->SpotLights.size(); i++) { From d8528994ee1a68c09778cce62a0ea0bd727f8b47 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 14 Jun 2022 01:19:49 +0000 Subject: [PATCH 119/121] Implement Spot Light Shadows (#217) --- .../ERS_CLASS_DepthMaps.cpp | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 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 f4897a1fd0..57ea7405f7 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -395,23 +395,23 @@ void ERS_CLASS_DepthMaps::UpdateDepthMaps(ERS_STRUCT_Shader* DepthShader) { } - // // Handle Point Lights - // for (unsigned int i = 0; i < ActiveScene->PointLights.size(); i++) { + // Handle Point Lights + 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 = GenerateDepthMap(); - // } + // Check If Light Has DepthMap + if (!Light->DepthMap.Initialized) { + Light->DepthMap = GenerateDepthMap(); + } - // // Render To Depth Map - // glm::mat4* LightSpaceMatrix = new glm::mat4(); - // UpdateDepthMap(Light, DepthShader, LightSpaceMatrix); // set this to false later, debugging - // Light->LightSpaceMatrix = *LightSpaceMatrix; + // Render To Depth Map + glm::mat4* LightSpaceMatrix = new glm::mat4(); + UpdateDepthMap(Light, DepthShader, LightSpaceMatrix); // set this to false later, debugging + Light->LightSpaceMatrix = *LightSpaceMatrix; - // } + } // Return To Normal Culling From 18ef76de659a7297b4c5a53332a5afee0fcbf7d8 Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 14 Jun 2022 01:20:10 +0000 Subject: [PATCH 120/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 57ea7405f7..8fe8c5f9a3 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -14,7 +14,7 @@ ERS_CLASS_DepthMaps::ERS_CLASS_DepthMaps(ERS_STRUCT_SystemUtils* SystemUtils, ER SystemUtils_->Logger_->Log("Initializing Viewport Overlay Subsystem", 5); // Create Array Texture For Depth Maps - RegenerateDepthMapTextureArray(1, 2048, 2048); + RegenerateDepthMapTextureArray(64, 2048, 2048); } From a47c6be0afd98c14290a68f59bea3252949806be Mon Sep 17 00:00:00 2001 From: datacrystals Date: Tue, 14 Jun 2022 01:20:51 +0000 Subject: [PATCH 121/121] Implement Spot Light Shadows (#217) --- .../Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp | 2 +- 1 file changed, 1 insertion(+), 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 8fe8c5f9a3..1a340741a9 100644 --- a/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp +++ b/Source/Core/Renderer/ERS_CLASS_VisualRenderer/ERS_CLASS_DepthMaps.cpp @@ -14,7 +14,7 @@ ERS_CLASS_DepthMaps::ERS_CLASS_DepthMaps(ERS_STRUCT_SystemUtils* SystemUtils, ER SystemUtils_->Logger_->Log("Initializing Viewport Overlay Subsystem", 5); // Create Array Texture For Depth Maps - RegenerateDepthMapTextureArray(64, 2048, 2048); + RegenerateDepthMapTextureArray(64, SystemUtils_->RendererSettings_->ShadowMapX_, SystemUtils_->RendererSettings_->ShadowMapY_); }