Commit 9b6ae7e7 authored by Alexander Maximilian Nilles's avatar Alexander Maximilian Nilles
Browse files

Clear ss shadow textures when render layer is deleted

parent 0ec3df19
......@@ -76,7 +76,9 @@ void Editor::updateFromRenderer()
ActiveLayerInfo& info = m_activeRenderLayers.emplace_back();
info.indexInRenderer = i;
info.layerIndex = id;
m_inactiveRenderLayers.erase(std::remove(m_inactiveRenderLayers.begin(), m_inactiveRenderLayers.end(), id), m_inactiveRenderLayers.end());
m_inactiveRenderLayers.erase(
std::remove(m_inactiveRenderLayers.begin(), m_inactiveRenderLayers.end(), id),
m_inactiveRenderLayers.end());
++erased;
}
}
......@@ -757,6 +759,7 @@ void Editor::drawRenderingTab()
(std::string(ICON_MDI_DELETE "##") + std::to_string(info.layerIndex)).c_str()) &&
canDelete)
{
m_renderer->clearAllSsShadowTextures();
if(info.indexInRenderer)
m_renderer->removeRenderLayer(*info.indexInRenderer);
const auto id = it->indexInRenderer ? *it->indexInRenderer
......@@ -940,9 +943,9 @@ void Editor::drawSettings()
glfwGetFramebufferSize(*m_window, &w, &h);
glBlitNamedFramebuffer(
0, m_previewFramebuffer->id(), 0, 0, w, h, 0, 0, w, h, GL_COLOR_BUFFER_BIT, GL_NEAREST);
ImGui::SetNextWindowSize(ImVec2(250, h - m_menuBarHeight));
ImGui::SetNextWindowPos(ImVec2(0, m_menuBarHeight));
ImGui::SetNextWindowSize(ImVec2(250, h - m_menuBarHeight));
ImGui::SetNextWindowPos(ImVec2(0, m_menuBarHeight));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
......@@ -1317,7 +1320,7 @@ void Editor::drawMenuBar()
ImGui::EndMenu();
}
drawTimer();
m_menuBarHeight = ImGui::GetWindowSize().y;
m_menuBarHeight = ImGui::GetWindowSize().y;
ImGui::EndMainMenuBar();
}
}
......
......@@ -393,16 +393,6 @@ void Renderer::render(const glm::mat4& view, const glm::mat4& projection)
m_smBuffer.assign(shadowMaps);
m_smBuffer.bind(GL_SHADER_STORAGE_BUFFER, SM_STORAGE_BINDING);
/* Clear screen space shadow textures */
/* for(auto& l : m_lights)
{
if(l.second->shadowType() == ShadowType::SHADOWMAP_SHADOW ||
l.second->shadowType() == ShadowType::TRACED_SHADOW)
{
std::static_pointer_cast<TracedLight>(l.second)->clearSsShadowTexture();
}
} */
// render scene
glCullFace(GL_FRONT);
m_program.use();
......@@ -455,6 +445,20 @@ void Renderer::render(const glm::mat4& view, const glm::mat4& projection)
m_gBufferFbo->blitDepth();
}
void Renderer::clearAllSsShadowTextures()
{
/* Clear screen space shadow textures */
getLogger()->info("Clearing all screen space shadow textures...");
for(auto& l : m_lights)
{
if(l.second->shadowType() == ShadowType::SHADOWMAP_SHADOW ||
l.second->shadowType() == ShadowType::TRACED_SHADOW)
{
std::static_pointer_cast<TracedLight>(l.second)->clearSsShadowTexture();
}
}
}
void Renderer::addLightAt(std::shared_ptr<Light> light, uint32_t lightIndex)
{
m_lights[lightIndex] = light;
......
......@@ -10,11 +10,11 @@
#include "../opengl/VertexArray.h"
#include "dino/opengl/FrameBuffer.h"
#include "SkyBox.h"
#include "RenderLayer.h"
#include "RingBuffer.h"
#include "Light.h"
#include "Material.h"
#include "RenderLayer.h"
#include "RingBuffer.h"
#include "SkyBox.h"
#include <cinttypes>
#include <glm/glm.hpp>
......@@ -205,6 +205,11 @@ public:
*/
void removeLight(int lightIndex);
/**
* @brief Clears all screen space shadow textures of associated lights.
*/
void clearAllSsShadowTextures();
/**
* @brief Converts the shadow type of a light source at a given index to another shadow type
* (creates a new light object with the same lighting parameters but a different shadow
......@@ -295,8 +300,8 @@ public:
virtual ~Renderer() = default;
private:
void init(glm::ivec2 windowSize);
void rebuildRenderables();
void init(glm::ivec2 windowSize);
void rebuildRenderables();
Program m_program;
Shader::ShaderSource m_onTrace;
......@@ -342,6 +347,6 @@ private:
VertexArray m_vao;
std::vector<Program> m_deferredPrograms;
std::vector<std::shared_ptr<RenderLayer>> m_renderLayers;
glm::ivec2 m_lastWindowSize{ 0, 0 };
glm::ivec2 m_lastWindowSize{0, 0};
};
} // namespace dino
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment