diff --git a/Pengine/Source/Core/EntryPoint.cpp b/Pengine/Source/Core/EntryPoint.cpp index 0f8d88ff..1f3c2308 100644 --- a/Pengine/Source/Core/EntryPoint.cpp +++ b/Pengine/Source/Core/EntryPoint.cpp @@ -120,7 +120,8 @@ void EntryPoint::Run() const window, camera->GetScene(), camera, - viewport->GetProjectionMat4()); + viewport->GetProjectionMat4(), + viewport->GetSize()); } else { diff --git a/Pengine/Source/Core/GraphicsSettings.h b/Pengine/Source/Core/GraphicsSettings.h index 025770f7..8f3828aa 100644 --- a/Pengine/Source/Core/GraphicsSettings.h +++ b/Pengine/Source/Core/GraphicsSettings.h @@ -28,8 +28,9 @@ namespace Pengine struct Shadows { bool isEnabled = true; - std::vector biases = { 0.01f, 0.03f, 0.1f }; + std::vector biases = { 0.2f, 0.5f, 0.2f }; float splitFactor = 0.75f; + float maxDistance = 200.0f; float fogFactor = 0.2f; bool pcfEnabled = true; bool visualize = false; diff --git a/Pengine/Source/Core/RenderPassManager.cpp b/Pengine/Source/Core/RenderPassManager.cpp index fa74c310..40a444a1 100644 --- a/Pengine/Source/Core/RenderPassManager.cpp +++ b/Pengine/Source/Core/RenderPassManager.cpp @@ -456,7 +456,6 @@ void RenderPassManager::CreateDeferred() { shadowCascadeLevels.emplace_back(glm::vec4(distance)); } - shadowCascadeLevels.emplace_back(camera.GetZFar()); WriterBufferHelper::WriteToBuffer(baseMaterial.get(), lightsBuffer, "Lights", "csm.distances", *shadowCascadeLevels.data()); @@ -464,6 +463,7 @@ void RenderPassManager::CreateDeferred() WriterBufferHelper::WriteToBuffer(baseMaterial.get(), lightsBuffer, "Lights", "csm.cascadeCount", cascadeCount); WriterBufferHelper::WriteToBuffer(baseMaterial.get(), lightsBuffer, "Lights", "csm.fogFactor", renderInfo.scene->GetGraphicsSettings().shadows.fogFactor); + WriterBufferHelper::WriteToBuffer(baseMaterial.get(), lightsBuffer, "Lights", "csm.maxDistance", renderInfo.scene->GetGraphicsSettings().shadows.maxDistance); WriterBufferHelper::WriteToBuffer(baseMaterial.get(), lightsBuffer, "Lights", "csm.pcfRange", renderInfo.scene->GetGraphicsSettings().shadows.pcfRange); const int pcfEnabled = renderInfo.scene->GetGraphicsSettings().shadows.pcfEnabled; @@ -477,7 +477,6 @@ void RenderPassManager::CreateDeferred() { biases.emplace_back(glm::vec4(bias)); } - shadowCascadeLevels.emplace_back(camera.GetZFar()); WriterBufferHelper::WriteToBuffer(baseMaterial.get(), lightsBuffer, "Lights", "csm.biases", *biases.data()); } else @@ -1249,7 +1248,8 @@ void RenderPassManager::CreateCSM() createInfo.renderCallback = [this](const RenderPass::RenderCallbackInfo& renderInfo) { - if (!renderInfo.scene->GetGraphicsSettings().shadows.isEnabled) + const GraphicsSettings::Shadows& shadowsSettings = renderInfo.scene->GetGraphicsSettings().shadows; + if (!shadowsSettings.isEnabled) { return; } @@ -1370,13 +1370,20 @@ void RenderPassManager::CreateCSM() if (!updatedLightSpaceMatrices) { updatedLightSpaceMatrices = true; + // TODO: Camera can be ortho, so need to make for ortho as well. + const glm::mat4 projection = glm::perspective( + camera.GetFov(), + (float)renderInfo.viewportSize.x / (float)renderInfo.viewportSize.y, + camera.GetZNear(), + shadowsSettings.maxDistance); + const bool recreateFrameBuffer = m_CSMRenderer.GenerateLightSpaceMatrices( - renderInfo.projection * camera.GetViewMat4(), + projection * camera.GetViewMat4(), lightDirection, camera.GetZNear(), - camera.GetZFar(), - scene->GetGraphicsSettings().shadows.cascadeCount, - scene->GetGraphicsSettings().shadows.splitFactor); + shadowsSettings.maxDistance, + shadowsSettings.cascadeCount, + shadowsSettings.splitFactor); WriterBufferHelper::WriteToBuffer( baseMaterial.get(), diff --git a/Pengine/Source/Core/Serializer.cpp b/Pengine/Source/Core/Serializer.cpp index 459d0ec8..ced3333c 100644 --- a/Pengine/Source/Core/Serializer.cpp +++ b/Pengine/Source/Core/Serializer.cpp @@ -2084,6 +2084,7 @@ void Serializer::SerializeGraphicsSettings(const GraphicsSettings& graphicsSetti out << YAML::Key << "IsEnabled" << YAML::Value << graphicsSettings.shadows.isEnabled; out << YAML::Key << "CascadeCount" << YAML::Value << graphicsSettings.shadows.cascadeCount; out << YAML::Key << "SplitFactor" << YAML::Value << graphicsSettings.shadows.splitFactor; + out << YAML::Key << "MaxDistance" << YAML::Value << graphicsSettings.shadows.maxDistance; out << YAML::Key << "FogFactor" << YAML::Value << graphicsSettings.shadows.fogFactor; out << YAML::Key << "PcfEnabled" << YAML::Value << graphicsSettings.shadows.pcfEnabled; out << YAML::Key << "PcfRange" << YAML::Value << graphicsSettings.shadows.pcfRange; @@ -2172,6 +2173,11 @@ GraphicsSettings Serializer::DeserializeGraphicsSettings(const std::filesystem:: graphicsSettings.shadows.splitFactor = splitFactorData.as(); } + if (const auto& maxDistanceData = csmData["MaxDistance"]) + { + graphicsSettings.shadows.maxDistance = maxDistanceData.as(); + } + if (const auto& biasesData = csmData["Biases"]) { graphicsSettings.shadows.biases = biasesData.as>(); diff --git a/Pengine/Source/Editor/Editor.cpp b/Pengine/Source/Editor/Editor.cpp index 461f7ebb..382f6f49 100644 --- a/Pengine/Source/Editor/Editor.cpp +++ b/Pengine/Source/Editor/Editor.cpp @@ -879,6 +879,7 @@ void Editor::GraphicsSettingsInfo(GraphicsSettings& graphicsSettings) ImGui::Checkbox("Visualize", &graphicsSettings.shadows.visualize); isChangedToSerialize += ImGui::SliderInt("Pcf Range", &graphicsSettings.shadows.pcfRange, 1, 5); isChangedToSerialize += ImGui::SliderFloat("Split Factor", &graphicsSettings.shadows.splitFactor, 0.0f, 1.0f); + isChangedToSerialize += ImGui::SliderFloat("Max Distance", &graphicsSettings.shadows.maxDistance, 0.0f, 1000.0f); isChangedToSerialize += ImGui::SliderFloat("Fog Factor", &graphicsSettings.shadows.fogFactor, 0.0f, 1.0f); for (size_t i = 0; i < graphicsSettings.shadows.biases.size(); i++) { diff --git a/Pengine/Source/Graphics/RenderPass.h b/Pengine/Source/Graphics/RenderPass.h index 17069697..84aea3aa 100644 --- a/Pengine/Source/Graphics/RenderPass.h +++ b/Pengine/Source/Graphics/RenderPass.h @@ -76,6 +76,7 @@ namespace Pengine std::shared_ptr scene; std::shared_ptr camera; glm::mat4 projection; + glm::ivec2 viewportSize; void* frame; }; diff --git a/Pengine/Source/Graphics/Renderer.cpp b/Pengine/Source/Graphics/Renderer.cpp index 764340db..e81c8800 100644 --- a/Pengine/Source/Graphics/Renderer.cpp +++ b/Pengine/Source/Graphics/Renderer.cpp @@ -51,7 +51,8 @@ void Renderer::Update( const std::shared_ptr& window, const std::shared_ptr& scene, const std::shared_ptr& camera, - const glm::mat4& projection) + const glm::mat4& projection, + const glm::ivec2& viewportSize) { if (!scene) { @@ -82,7 +83,8 @@ void Renderer::Update( renderInfo.scene = scene; renderInfo.renderPass = renderPass; renderInfo.projection = projection; - renderInfo.frame = frame;; + renderInfo.frame = frame; + renderInfo.viewportSize = viewportSize; renderPass->Render(renderInfo); } diff --git a/Pengine/Source/Graphics/Renderer.h b/Pengine/Source/Graphics/Renderer.h index 706ef54a..694461bf 100644 --- a/Pengine/Source/Graphics/Renderer.h +++ b/Pengine/Source/Graphics/Renderer.h @@ -33,7 +33,8 @@ namespace Pengine const std::shared_ptr& window, const std::shared_ptr& scene, const std::shared_ptr& camera, - const glm::mat4& projection); + const glm::mat4& projection, + const glm::ivec2& viewportSize); std::shared_ptr GetUniformWriter(const std::string& renderPassName) const; diff --git a/SandBox/Configs/GraphicsSettings.gs b/SandBox/Configs/GraphicsSettings.gs index 7cdb2c4d..298815a2 100644 --- a/SandBox/Configs/GraphicsSettings.gs +++ b/SandBox/Configs/GraphicsSettings.gs @@ -1,5 +1,5 @@ SSAO: - IsEnabled: false + IsEnabled: true AoScale: 2 Bias: 0.0250000004 KernelSize: 16 @@ -7,19 +7,14 @@ SSAO: Radius: 0.5 CSM: IsEnabled: true - CascadeCount: 10 - SplitFactor: 0 + CascadeCount: 4 + SplitFactor: 0.899999976 + MaxDistance: 200 FogFactor: 0.200000003 PcfEnabled: true PcfRange: 1 Biases: - 0.00999999978 - - 0.00999999978 - - 0.00999999978 - - 0.00999999978 - - 0.00999999978 - - 0.00999999978 - - 0.00999999978 - - 0.00999999978 - - 0.00999999978 - - 0.00999999978 \ No newline at end of file + - 0.0299999993 + - 0.0399999991 + - 0.5 \ No newline at end of file diff --git a/SandBox/Log.txt b/SandBox/Log.txt index eb376e48..a66557f5 100644 --- a/SandBox/Log.txt +++ b/SandBox/Log.txt @@ -1,69 +1,153 @@ -[Wed Sep 18 12:00:29 2024] Engine config has been loaded! -[Wed Sep 18 12:00:29 2024] Graphics API:2 -[Wed Sep 18 12:00:29 2024] Available extensions: -[Wed Sep 18 12:00:29 2024] VK_KHR_device_group_creation -[Wed Sep 18 12:00:29 2024] VK_KHR_external_fence_capabilities -[Wed Sep 18 12:00:29 2024] VK_KHR_external_memory_capabilities -[Wed Sep 18 12:00:29 2024] VK_KHR_external_semaphore_capabilities -[Wed Sep 18 12:00:29 2024] VK_KHR_get_physical_device_properties2 -[Wed Sep 18 12:00:29 2024] VK_KHR_get_surface_capabilities2 -[Wed Sep 18 12:00:29 2024] VK_KHR_surface -[Wed Sep 18 12:00:29 2024] VK_KHR_surface_protected_capabilities -[Wed Sep 18 12:00:29 2024] VK_KHR_win32_surface -[Wed Sep 18 12:00:29 2024] VK_EXT_debug_report -[Wed Sep 18 12:00:29 2024] VK_EXT_debug_utils -[Wed Sep 18 12:00:29 2024] VK_EXT_surface_maintenance1 -[Wed Sep 18 12:00:29 2024] VK_EXT_swapchain_colorspace -[Wed Sep 18 12:00:29 2024] VK_NV_external_memory_capabilities -[Wed Sep 18 12:00:29 2024] VK_KHR_portability_enumeration -[Wed Sep 18 12:00:29 2024] VK_LUNARG_direct_driver_loading -[Wed Sep 18 12:00:29 2024] Required extensions: -[Wed Sep 18 12:00:29 2024] VK_KHR_surface -[Wed Sep 18 12:00:29 2024] VK_KHR_win32_surface -[Wed Sep 18 12:00:29 2024] Device count: 1 -[Wed Sep 18 12:00:29 2024] Physical device: NVIDIA GeForce RTX 3060 Ti -[Wed Sep 18 12:00:29 2024] Texture:Editor/Images\FileIcon.png has been loaded! -[Wed Sep 18 12:00:29 2024] Texture:Editor/Images\FolderIcon.png has been loaded! -[Wed Sep 18 12:00:29 2024] Texture:Editor/Images\MaterialIcon.png has been loaded! -[Wed Sep 18 12:00:29 2024] Texture:Editor/Images\MeshIcon.png has been loaded! -[Wed Sep 18 12:00:29 2024] Texture:Editor/Images\MetaIcon.png has been loaded! -[Wed Sep 18 12:00:29 2024] Texture:Editor/Images\PlayButton.png has been loaded! -[Wed Sep 18 12:00:29 2024] Texture:Editor/Images\StopButton.png has been loaded! -[Wed Sep 18 12:00:31 2024] Mesh:Meshes\terrain01.mesh has been deserialized! -[Wed Sep 18 12:00:31 2024] BaseMaterial:Materials/MeshBase.basemat has been deserialized! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Opaque.vert has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Opaque.frag has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Transparent.vert has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Transparent.frag has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/CSM.vert has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/CSM.geom has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/CSM.frag has been loaded! -[Wed Sep 18 12:00:31 2024] Material:Meshes\Material.mat has been deserialized! -[Wed Sep 18 12:00:31 2024] Scene:Scenes\Test.scene has been deserialized! -[Wed Sep 18 12:00:31 2024] BaseMaterial:Materials\DefaultReflection.basemat has been deserialized! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/DefaultReflection.vert has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/DefaultReflection.frag has been loaded! -[Wed Sep 18 12:00:31 2024] Mesh:Meshes\Plane.mesh has been deserialized! -[Wed Sep 18 12:00:31 2024] BaseMaterial:Materials\Atmosphere.basemat has been deserialized! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Atmosphere.vert has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Atmosphere.geom has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Atmosphere.frag has been loaded! -[Wed Sep 18 12:00:31 2024] BaseMaterial:Materials/Line.basemat has been deserialized! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Line.vert has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Line.frag has been loaded! -[Wed Sep 18 12:00:31 2024] Mesh:Meshes\Cube.mesh has been deserialized! -[Wed Sep 18 12:00:31 2024] BaseMaterial:Materials\SkyBox.basemat has been deserialized! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/SkyBox.vert has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/SkyBox.frag has been loaded! -[Wed Sep 18 12:00:31 2024] BaseMaterial:Materials\SSAO.basemat has been deserialized! -[Wed Sep 18 12:00:31 2024] Shader:Shaders/SSAO.vert has been compiled! -[Wed Sep 18 12:00:31 2024] Shader:Shaders/SSAO.frag has been compiled! -[Wed Sep 18 12:00:31 2024] BaseMaterial:Materials\SSAOBlur.basemat has been deserialized! -[Wed Sep 18 12:00:31 2024] Shader:Shaders/SSAOBlur.vert has been compiled! -[Wed Sep 18 12:00:31 2024] Shader:Shaders/SSAOBlur.frag has been compiled! -[Wed Sep 18 12:00:31 2024] BaseMaterial:Materials\Deferred.basemat has been deserialized! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Deferred.vert has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Deferred.frag has been loaded! -[Wed Sep 18 12:00:31 2024] BaseMaterial:Materials/Final.basemat has been deserialized! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Final.vert has been loaded! -[Wed Sep 18 12:00:31 2024] Shader Cache:Shaders/Final.frag has been loaded! +[Wed Sep 18 15:31:00 2024] Engine config has been loaded! +[Wed Sep 18 15:31:00 2024] Graphics API:2 +[Wed Sep 18 15:31:00 2024] Available extensions: +[Wed Sep 18 15:31:00 2024] VK_KHR_device_group_creation +[Wed Sep 18 15:31:00 2024] VK_KHR_external_fence_capabilities +[Wed Sep 18 15:31:00 2024] VK_KHR_external_memory_capabilities +[Wed Sep 18 15:31:00 2024] VK_KHR_external_semaphore_capabilities +[Wed Sep 18 15:31:00 2024] VK_KHR_get_physical_device_properties2 +[Wed Sep 18 15:31:00 2024] VK_KHR_get_surface_capabilities2 +[Wed Sep 18 15:31:00 2024] VK_KHR_surface +[Wed Sep 18 15:31:00 2024] VK_KHR_surface_protected_capabilities +[Wed Sep 18 15:31:00 2024] VK_KHR_win32_surface +[Wed Sep 18 15:31:00 2024] VK_EXT_debug_report +[Wed Sep 18 15:31:00 2024] VK_EXT_debug_utils +[Wed Sep 18 15:31:00 2024] VK_EXT_surface_maintenance1 +[Wed Sep 18 15:31:00 2024] VK_EXT_swapchain_colorspace +[Wed Sep 18 15:31:00 2024] VK_NV_external_memory_capabilities +[Wed Sep 18 15:31:00 2024] VK_KHR_portability_enumeration +[Wed Sep 18 15:31:00 2024] VK_LUNARG_direct_driver_loading +[Wed Sep 18 15:31:00 2024] Required extensions: +[Wed Sep 18 15:31:00 2024] VK_KHR_surface +[Wed Sep 18 15:31:00 2024] VK_KHR_win32_surface +[Wed Sep 18 15:31:00 2024] Device count: 1 +[Wed Sep 18 15:31:00 2024] Physical device: NVIDIA GeForce RTX 3060 Ti +[Wed Sep 18 15:31:00 2024] Texture:Editor/Images\FileIcon.png has been loaded! +[Wed Sep 18 15:31:00 2024] Texture:Editor/Images\FolderIcon.png has been loaded! +[Wed Sep 18 15:31:00 2024] Texture:Editor/Images\MaterialIcon.png has been loaded! +[Wed Sep 18 15:31:00 2024] Texture:Editor/Images\MeshIcon.png has been loaded! +[Wed Sep 18 15:31:00 2024] Texture:Editor/Images\MetaIcon.png has been loaded! +[Wed Sep 18 15:31:00 2024] Texture:Editor/Images\PlayButton.png has been loaded! +[Wed Sep 18 15:31:00 2024] Texture:Editor/Images\StopButton.png has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\Plane.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] BaseMaterial:Materials/MeshBase.basemat has been deserialized! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Opaque.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Opaque.frag has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Transparent.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Transparent.frag has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/CSM.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/CSM.geom has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/CSM.frag has been loaded! +[Wed Sep 18 15:31:02 2024] Material:Materials\Blue.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\Sphere.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] BaseMaterial:Materials/Custom/Rotate.basemat has been deserialized! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Opaque.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Custom/Rotate.frag has been loaded! +[Wed Sep 18 15:31:02 2024] Material:Images\WoodPBR\WoodPBR.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Images\WoodPBR\older-wood-flooring_albedo.png has been loaded! +[Wed Sep 18 15:31:02 2024] Texture:Images\WoodPBR\older-wood-flooring_normal-ogl.png has been loaded! +[Wed Sep 18 15:31:02 2024] Texture:Images\WoodPBR\older-wood-flooring_metallic.png has been loaded! +[Wed Sep 18 15:31:02 2024] Texture:Images\WoodPBR\older-wood-flooring_roughness.png has been loaded! +[Wed Sep 18 15:31:02 2024] Texture:Images\WoodPBR\older-wood-flooring_ao.png has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_378_sponza_378_Material__25.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\Material__25.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\lion.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_378_sponza_378_Material__298.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\Material__298.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\background.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_257_sponza_257_Material__47.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\Material__47.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_369_sponza_369_Material__57.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\Material__57.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\vase_plant.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_39_sponza_39_arch.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\arch.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_arch_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_382_sponza_382_bricks.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\bricks.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\spnza_bricks_a_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_38_sponza_38_ceiling.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\ceiling.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_ceiling_a_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_339_sponza_339_chain.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\chain.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\chain_texture.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_10_sponza_10_column_a.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\column_a.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_column_a_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_141_sponza_141_column_b.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\column_b.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_column_b_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_83_sponza_83_column_c.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\column_c.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_column_c_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_72_sponza_72_details.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\details.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_details_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_288_sponza_288_fabric_a.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\fabric_a.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_fabric_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_325_sponza_325_fabric_c.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\fabric_c.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_curtain_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_289_sponza_289_fabric_d.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\fabric_d.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_fabric_blue_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_285_sponza_285_fabric_e.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\fabric_e.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_fabric_green_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_327_sponza_327_fabric_f.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\fabric_f.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_curtain_green_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_326_sponza_326_fabric_g.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\fabric_g.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_curtain_blue_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_271_sponza_271_flagpole.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\flagpole.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_flagpole_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_18_sponza_18_floor.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\floor.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_floor_a_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_275_sponza_275_leaf.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\leaf.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_thorn_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_381_sponza_381_roof.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\roof.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\sponza_roof_diff.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_373_sponza_373_vase.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\vase.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\vase_dif.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_344_sponza_344_vase_hanging.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\vase_hanging.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\vase_hanging.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\LargeFiles\SponzaOptimized\sponza_369_sponza_369_vase_round.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] Material:Meshes\LargeFiles\SponzaOptimized\vase_round.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Texture:Meshes\LargeFiles\SponzaOptimized\textures\vase_round.tga has been loaded! +[Wed Sep 18 15:31:02 2024] Material:Materials\Red.mat has been deserialized! +[Wed Sep 18 15:31:02 2024] Scene:Scenes\Sponza.scene has been deserialized! +[Wed Sep 18 15:31:02 2024] BaseMaterial:Materials\DefaultReflection.basemat has been deserialized! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/DefaultReflection.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/DefaultReflection.frag has been loaded! +[Wed Sep 18 15:31:02 2024] BaseMaterial:Materials\Atmosphere.basemat has been deserialized! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Atmosphere.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Atmosphere.geom has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Atmosphere.frag has been loaded! +[Wed Sep 18 15:31:02 2024] BaseMaterial:Materials/Line.basemat has been deserialized! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Line.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Line.frag has been loaded! +[Wed Sep 18 15:31:02 2024] Mesh:Meshes\Cube.mesh has been deserialized! +[Wed Sep 18 15:31:02 2024] BaseMaterial:Materials\SkyBox.basemat has been deserialized! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/SkyBox.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/SkyBox.frag has been loaded! +[Wed Sep 18 15:31:02 2024] BaseMaterial:Materials\SSAO.basemat has been deserialized! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/SSAO.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/SSAO.frag has been loaded! +[Wed Sep 18 15:31:02 2024] BaseMaterial:Materials\SSAOBlur.basemat has been deserialized! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/SSAOBlur.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/SSAOBlur.frag has been loaded! +[Wed Sep 18 15:31:02 2024] BaseMaterial:Materials\Deferred.basemat has been deserialized! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Deferred.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Deferred.frag has been loaded! +[Wed Sep 18 15:31:02 2024] BaseMaterial:Materials/Final.basemat has been deserialized! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Final.vert has been loaded! +[Wed Sep 18 15:31:02 2024] Shader Cache:Shaders/Final.frag has been loaded! diff --git a/SandBox/Materials/MeshBase.basemat b/SandBox/Materials/MeshBase.basemat index afb77ff6..5a98d6c6 100644 --- a/SandBox/Materials/MeshBase.basemat +++ b/SandBox/Materials/MeshBase.basemat @@ -68,7 +68,7 @@ Basemat: - RenderPass: CSM DepthTest: true DepthWrite: true - CullMode: None + CullMode: Front PolygonMode: Fill TopologyMode: TriangleList Vertex: Shaders/CSM.vert diff --git a/SandBox/Scenes/Bistro.scene b/SandBox/Scenes/Bistro.scene index 380a0a25..558d3c34 100644 --- a/SandBox/Scenes/Bistro.scene +++ b/SandBox/Scenes/Bistro.scene @@ -3,6 +3,7 @@ Viewports: Camera: c4c2d917-05b8-47e5-8fa2-d55c5b704a9b Settings: DrawBoundingBoxes: false +GraphicsSettings: d9afc1d9-1ca8-4529-805a-055fb67d6fe0 Scene: - UUID: c4c2d917-05b8-47e5-8fa2-d55c5b704a9b Name: Camera @@ -10,14 +11,14 @@ Scene: Childs: [] Transform: - Position: [-4.07326174, 1.50972712, -0.779115498] - Rotation: [-0.190946057, -1.71978951, 0] + Position: [-3.22452593, 1.91673326, -0.739340782] + Rotation: [-0.345817029, -1.86475074, 0] Scale: [1, 1, 1] FollowOwner: true Camera: Fov: 1.57079637 Type: 1 - ZNear: 0.100000001 + ZNear: 0.00100000005 ZFar: 1000 RenderPassName: Final RenderTargetIndex: 0 diff --git a/SandBox/Scenes/Sponza.scene b/SandBox/Scenes/Sponza.scene index 40454dcb..d3f58fc5 100644 --- a/SandBox/Scenes/Sponza.scene +++ b/SandBox/Scenes/Sponza.scene @@ -11,15 +11,15 @@ Scene: Childs: [] Transform: - Position: [-5.99818897, 9.72147751, 0.133784026] - Rotation: [-0.0187698472, -1.46206903, 0] + Position: [-4.2290597, 7.68311548, -0.191679239] + Rotation: [-0.685250401, -1.38104177, 0] Scale: [1, 1, 1] FollowOwner: true Camera: Fov: 1.57079637 Type: 1 - ZNear: 0.00999999978 - ZFar: 40 + ZNear: 0.00100000005 + ZFar: 1000 RenderPassName: Final RenderTargetIndex: 0 - UUID: 573523b7-abe0-42b0-a71a-03ca0abf758f @@ -29,7 +29,7 @@ Scene: [] Transform: Position: [-0.331472993, 3.18549967, 0.502656162] - Rotation: [1.93731546, -0.69813168, 6.06503008e-08] + Rotation: [1.57079637, -0.69813168, 6.06503008e-08] Scale: [0.99999994, 0.99999994, 0.999999881] FollowOwner: true DirectionalLight: diff --git a/SandBox/Scenes/Test.scene b/SandBox/Scenes/Test.scene index 49dde0ff..472b35b8 100644 --- a/SandBox/Scenes/Test.scene +++ b/SandBox/Scenes/Test.scene @@ -3,6 +3,7 @@ Viewports: Camera: a85f08e6-856d-4a82-951b-539835dfac68 Settings: DrawBoundingBoxes: false +GraphicsSettings: d9afc1d9-1ca8-4529-805a-055fb67d6fe0 Scene: - UUID: a85f08e6-856d-4a82-951b-539835dfac68 Name: Camera @@ -10,14 +11,14 @@ Scene: Childs: [] Transform: - Position: [-7.10935879, 8.78676128, -5.50891972] - Rotation: [-0.751129627, -2.34395504, 0] + Position: [-14.4475927, 16.0579834, 9.35839081] + Rotation: [-0.669687748, -1.20781517, 0] Scale: [1, 1, 1] FollowOwner: true Camera: Fov: 1.57079637 Type: 1 - ZNear: 0.100000001 + ZNear: 0.00100000005 ZFar: 1000 RenderPassName: Final RenderTargetIndex: 0 @@ -46,4 +47,115 @@ Scene: FollowOwner: true Renderer3D: Mesh: 35b89d54-6f9a-4951-a0fb-8a9ce024ced0 - Material: 1ca330ab-eb3e-48b7-a338-c274669afbd3 \ No newline at end of file + Material: 1ca330ab-eb3e-48b7-a338-c274669afbd3 + - UUID: b5cd06b1-baab-43ed-a609-46fdf9947190 + Name: ROOT + IsEnabled: true + Childs: + - 47f1b92d-555b-45fa-a609-661cd7919539 + - 2c6f4f57-fc36-47e3-88a6-141718ba5dab + Transform: + Position: [0, 0, 0] + Rotation: [0, -0, 0] + Scale: [1, 1, 1] + FollowOwner: true + - UUID: 47f1b92d-555b-45fa-a609-661cd7919539 + Name: tree.003 + IsEnabled: true + Childs: + [] + Transform: + Position: [0, 0, 0] + Rotation: [0, -0, 0] + Scale: [1, 1, 1] + FollowOwner: true + Renderer3D: + Mesh: 08dafeb1-dcdc-4ca2-8cad-2e33d16ea4c7 + Material: ab0c18d2-9ed5-47d7-bada-7b62390ef9bd + - UUID: 2c6f4f57-fc36-47e3-88a6-141718ba5dab + Name: tree.002 + IsEnabled: true + Childs: + [] + Transform: + Position: [0, 0, 0] + Rotation: [0, -0, 0] + Scale: [1, 1, 1] + FollowOwner: true + Renderer3D: + Mesh: 9f699d65-314e-4eed-acaa-01c0c47e69e4 + Material: 837417fd-d3d0-48cf-9eca-90bd5aaa6bf3 + - UUID: 833cd755-4a19-454c-9d9f-289ec8ae1296 + Name: ROOTClone + IsEnabled: true + Childs: + - 88002099-1cb3-4e39-b425-8eb2d5bc3e9c + - 6991eb91-5fc3-4e1a-a991-07b6976a2935 + Transform: + Position: [-2.17055774, 0, 1.35592246] + Rotation: [0, -0, 0] + Scale: [1, 1, 1] + FollowOwner: true + - UUID: 88002099-1cb3-4e39-b425-8eb2d5bc3e9c + Name: tree.003Clone + IsEnabled: true + Childs: + [] + Transform: + Position: [-2.17055774, 0, 1.35592246] + Rotation: [0, -0, 0] + Scale: [1, 1, 1] + FollowOwner: true + Renderer3D: + Mesh: 08dafeb1-dcdc-4ca2-8cad-2e33d16ea4c7 + Material: ab0c18d2-9ed5-47d7-bada-7b62390ef9bd + - UUID: 6991eb91-5fc3-4e1a-a991-07b6976a2935 + Name: tree.002Clone + IsEnabled: true + Childs: + [] + Transform: + Position: [-2.17055774, 0, 1.35592246] + Rotation: [0, -0, 0] + Scale: [1, 1, 1] + FollowOwner: true + Renderer3D: + Mesh: 9f699d65-314e-4eed-acaa-01c0c47e69e4 + Material: 837417fd-d3d0-48cf-9eca-90bd5aaa6bf3 + - UUID: 731d9877-b280-4b71-a032-aea5fe677afe + Name: ROOTCloneClone + IsEnabled: true + Childs: + - e0fd3b04-c2c7-45c6-819a-aa560e967f92 + - 29e43619-71f5-4bef-b3f0-4b96a21e91f9 + Transform: + Position: [-1.69252849, 0, -1.07592905] + Rotation: [0, -0, 0] + Scale: [1, 1, 1] + FollowOwner: true + - UUID: e0fd3b04-c2c7-45c6-819a-aa560e967f92 + Name: tree.003CloneClone + IsEnabled: true + Childs: + [] + Transform: + Position: [-1.69252849, 0, -1.07592905] + Rotation: [0, -0, 0] + Scale: [1, 1, 1] + FollowOwner: true + Renderer3D: + Mesh: 08dafeb1-dcdc-4ca2-8cad-2e33d16ea4c7 + Material: ab0c18d2-9ed5-47d7-bada-7b62390ef9bd + - UUID: 29e43619-71f5-4bef-b3f0-4b96a21e91f9 + Name: tree.002CloneClone + IsEnabled: true + Childs: + [] + Transform: + Position: [-1.69252849, 0, -1.07592905] + Rotation: [0, -0, 0] + Scale: [1, 1, 1] + FollowOwner: true + Renderer3D: + Mesh: 9f699d65-314e-4eed-acaa-01c0c47e69e4 + Material: 837417fd-d3d0-48cf-9eca-90bd5aaa6bf3 \ No newline at end of file diff --git a/SandBox/Shaders/Deferred.frag b/SandBox/Shaders/Deferred.frag index ebb80330..309d4e97 100644 --- a/SandBox/Shaders/Deferred.frag +++ b/SandBox/Shaders/Deferred.frag @@ -65,9 +65,7 @@ void main() abs(position.z), worldSpacePosition, normal.xyz, - directionalLight.direction, - camera.viewMat4, - camera.zFar); + directionalLight.direction); result += CalculateDirectionalLight( directionalLight, diff --git a/SandBox/Shaders/Includes/CSM.h b/SandBox/Shaders/Includes/CSM.h index 9b1f95c3..65c7751a 100644 --- a/SandBox/Shaders/Includes/CSM.h +++ b/SandBox/Shaders/Includes/CSM.h @@ -4,6 +4,7 @@ struct CSM { int cascadeCount; float fogFactor; + float maxDistance; int pcfEnabled; int pcfRange; int visualize; @@ -18,9 +19,7 @@ vec3 CalculateCSM( in float depth, in vec3 positionWorldSpace, in vec3 normalViewSpace, - in vec3 lightDirectionViewSpace, - in mat4 viewMat4, - in float zFar) + in vec3 lightDirectionViewSpace) { if (csm.cascadeCount == 0) { @@ -59,7 +58,7 @@ vec3 CalculateCSM( float bias = max(csm.biases[layer] * (1.0f - dot(normalViewSpace, lightDirectionViewSpace)), 0.001f); if (layer == csm.cascadeCount) { - bias *= 1 / (zFar * 0.5f); + bias *= 1 / (csm.maxDistance * 0.5f); } else { @@ -86,10 +85,10 @@ vec3 CalculateCSM( shadow += (currentDepth - bias) > shadowDepth ? 1.0f : 0.0f; } - float fadeDistance = zFar * (1.0f - csm.fogFactor); + float fadeDistance = csm.maxDistance * (1.0f - csm.fogFactor); if (depth > fadeDistance) { - float fogFactor = clamp((depth - fadeDistance) / (zFar * csm.fogFactor), 0.0f, 1.0f); + float fogFactor = clamp((depth - fadeDistance) / (csm.maxDistance * csm.fogFactor), 0.0f, 1.0f); shadow *= (1.0f - fogFactor); } diff --git a/SandBox/Shaders/Transparent.frag b/SandBox/Shaders/Transparent.frag index 2e75629b..97afde74 100644 --- a/SandBox/Shaders/Transparent.frag +++ b/SandBox/Shaders/Transparent.frag @@ -95,9 +95,7 @@ void main() abs(viewSpacePosition.z), worldSpacePosition, normal.xyz, - directionalLight.direction, - camera.viewMat4, - camera.zFar); + directionalLight.direction); result += CalculateDirectionalLight( directionalLight,