Fixed framebuffer resizing and transform rotation matrix

This commit is contained in:
antopilo
2021-09-04 01:41:47 -04:00
parent c3d3e20ab4
commit 99ea3a906c
15 changed files with 115 additions and 48 deletions

View File

@@ -159,7 +159,6 @@ float ShadowCalculation(Light light, vec3 FragPos, vec3 normal)
// transform to [0,1] range
projCoords = projCoords * 0.5 + 0.5;
// get closest depth value from light's perspective (using [0,1] range fragPosLight as coords)
float closestDepth = texture(light.ShadowMaps[0], projCoords.xy).r;
// get depth of current fragment from light's perspective
float currentDepth = projCoords.z;
// check whether current frag pos is in shadow
@@ -214,7 +213,14 @@ vec3 ComputeVolumetric(vec3 FragPos, Light light)
if (closestDepth > currentDepth)
accumFog += (ComputeScattering(dot(rayDirection, light.Direction)).xxx * light.Color);
currentPosition += step;
//float ditherPattern[4][4] = {
// { 0.0f, 0.5f, 0.125f, 0.625f},
// { 0.75f, 0.22f, 0.875f, 0.375f},
// { 0.1875f, 0.6875f, 0.0625f, 0.5625},
// { 0.9375f, 0.4375f, 0.8125f, 0.3125}
//};
currentPosition += step; //* ditherPattern[int(gl_FragCoord.x) % 4][int(gl_FragCoord.y) % 4];
}
accumFog /= u_FogStepCount;

View File

@@ -69,10 +69,14 @@ namespace Nuake {
ImVec2 regionAvail = ImGui::GetContentRegionAvail();
Vector2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y);
if (Engine::GetCurrentWindow()->GetFrameBuffer()->GetSize() != viewportPanelSize)
Engine::GetCurrentWindow()->GetFrameBuffer()->QueueResize(viewportPanelSize);
Ref<FrameBuffer> framebuffer = Engine::GetCurrentWindow()->GetDeferredBuffer();
if (framebuffer->GetSize() != viewportPanelSize)
{
Engine::GetCurrentWindow()->GetGBuffer()->QueueResize(viewportPanelSize);
framebuffer->QueueResize(viewportPanelSize);
}
Ref<Texture> texture = Engine::GetCurrentWindow()->GetFrameBuffer()->GetTexture();
Ref<Texture> texture = framebuffer->GetTexture();
ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0));
ImGuizmo::SetDrawlist();
@@ -131,23 +135,23 @@ namespace Nuake {
if (m_IsEntitySelected)
{
if (ImGui::Begin("DEFERRED"))
{
ImVec2 regionAvail = ImGui::GetContentRegionAvail();
glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y);
Ref<Texture> texture = Engine::GetCurrentWindow()->GetDeferredBuffer()->GetTexture(GL_COLOR_ATTACHMENT0);
ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0));
}
ImGui::End();
//if (ImGui::Begin("DEFERRED"))
//{
// ImVec2 regionAvail = ImGui::GetContentRegionAvail();
// glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y);
// Ref<Texture> texture = Engine::GetCurrentWindow()->GetDeferredBuffer()->GetTexture(GL_COLOR_ATTACHMENT0);
// ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0));
//
//}
//ImGui::End();
//
if (ImGui::Begin("GBUFFER"))
{
ImVec2 regionAvail = ImGui::GetContentRegionAvail();
glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y);
Ref<Texture> texture = Engine::GetCurrentWindow()->GetGBuffer()->GetTexture(GL_DEPTH_ATTACHMENT);
ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0));
}
ImGui::End();
if (ImGui::Begin("GBUFFER2"))
@@ -156,7 +160,7 @@ namespace Nuake {
glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y);
Ref<Texture> texture = Engine::GetCurrentWindow()->GetGBuffer()->GetTexture(GL_COLOR_ATTACHMENT0);
ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0));
}
ImGui::End();
if (ImGui::Begin("GBUFFER3"))
@@ -165,7 +169,7 @@ namespace Nuake {
glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y);
Ref<Texture> texture = Engine::GetCurrentWindow()->GetGBuffer()->GetTexture(GL_COLOR_ATTACHMENT1);
ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0));
}
ImGui::End();
if (ImGui::Begin("GBUFFER4"))
@@ -174,7 +178,7 @@ namespace Nuake {
glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y);
Ref<Texture> texture = Engine::GetCurrentWindow()->GetGBuffer()->GetTexture(GL_COLOR_ATTACHMENT2);
ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0));
}
ImGui::End();
//