diff --git a/Editor/resources/Shaders/bloom.shader b/Editor/resources/Shaders/bloom.shader new file mode 100644 index 00000000..cfef2373 --- /dev/null +++ b/Editor/resources/Shaders/bloom.shader @@ -0,0 +1,164 @@ +#shader vertex +#version 460 core + +layout(location = 0) in vec3 VertexPosition; +layout(location = 1) in vec2 UVPosition; + +out flat vec2 UV; + +void main() +{ + UV = UVPosition; + gl_Position = vec4(VertexPosition, 1.0f); +} + +#shader fragment +#version 460 core + +uniform int u_Stage; + +uniform sampler2D u_Source; +uniform vec2 u_SourceSize; + +uniform sampler2D u_Source2; +uniform vec2 u_Source2Size; + +uniform float u_Threshold; +uniform float u_BlurAmount; +uniform vec2 u_BlurDirection; + +in vec2 UV; + +out vec4 FragColor; + +vec4 Threshold(vec4 color, vec2 uv) +{ + float brightness = max(color.r, max(color.g, color.b)); + float contribution = max(0, brightness - u_Threshold); + contribution /= max(brightness, 0.00001); + return color * contribution; +} + +vec4 DownsampleBox13Tap(vec2 uv) +{ + vec2 texelSize = 1.0 / u_SourceSize; + vec4 A = texture(u_Source, uv + texelSize * vec2(-1.0, -1.0)); + vec4 B = texture(u_Source, uv + texelSize * vec2(0.0, -1.0)); + vec4 C = texture(u_Source, uv + texelSize * vec2(1.0, -1.0)); + vec4 D = texture(u_Source, uv + texelSize * vec2(-0.5, -0.5)); + vec4 E = texture(u_Source, uv + texelSize * vec2(0.5, -0.5)); + vec4 F = texture(u_Source, uv + texelSize * vec2(-1.0, 0.0)); + vec4 G = texture(u_Source, uv); + vec4 H = texture(u_Source, uv + texelSize * vec2(1.0, 0.0)); + vec4 I = texture(u_Source, uv + texelSize * vec2(-0.5, 0.5)); + vec4 J = texture(u_Source, uv + texelSize * vec2(0.5, 0.5)); + vec4 K = texture(u_Source, uv + texelSize * vec2(-1.0, 1.0)); + vec4 L = texture(u_Source, uv + texelSize * vec2(0.0, 1.0)); + vec4 M = texture(u_Source, uv + texelSize * vec2(1.0, 1.0)); + + vec2 div = (1.0 / 4.0) * vec2(0.5, 0.125); + + vec4 o = (D + E + I + J) * div.x; + o += (A + B + G + F) * div.y; + o += (B + C + H + G) * div.y; + o += (F + G + L + K) * div.y; + o += (G + H + M + L) * div.y; + + return o; +} + +vec4 Upsample(vec2 uv) +{ + vec4 d = (1.0 / u_Source2Size.xyxy) * vec4(1.0, 1.0, -1.0, 0.0) ; + + vec4 s; + s = texture(u_Source2, uv - d.xy); + s += texture(u_Source2, uv - d.wy) * 2.0; + s += texture(u_Source2, uv - d.zy); + + s += texture(u_Source2, uv + d.zw) * 2.0; + s += texture(u_Source2, uv) * 4.0; + s += texture(u_Source2, uv + d.xw) * 2.0; + + s += texture(u_Source2, uv + d.zy); + s += texture(u_Source2, uv + d.wy) * 2.0; + s += texture(u_Source2, uv + d.xy); + + return s * (1.0 / 16.0); +} + +vec4 blur9(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) { + vec4 color = vec4(0.0); + vec2 off1 = vec2(1.3846153846) * direction; + vec2 off2 = vec2(3.2307692308) * direction; + color += texture2D(image, uv) * 0.2270270270; + color += texture2D(image, uv + (off1 / resolution)) * 0.3162162162; + color += texture2D(image, uv - (off1 / resolution)) * 0.3162162162; + color += texture2D(image, uv + (off2 / resolution)) * 0.0702702703; + color += texture2D(image, uv - (off2 / resolution)) * 0.0702702703; + return color; +} + +vec3 acesOperator(vec3 rgbColour) +{ + const mat3 inputMatrix = mat3 + ( + vec3(0.59719, 0.07600, 0.02840), + vec3(0.35458, 0.90834, 0.13383), + vec3(0.04823, 0.01566, 0.83777) + ); + + const mat3 outputMatrix = mat3 + ( + vec3(1.60475, -0.10208, -0.00327), + vec3(-0.53108, 1.10813, -0.07276), + vec3(-0.07367, -0.00605, 1.07602) + ); + + vec3 inputColour = inputMatrix * rgbColour; + vec3 a = inputColour * (inputColour + vec3(0.0245786)) - vec3(0.000090537); + vec3 b = inputColour * (0.983729 * inputColour + 0.4329510) + 0.238081; + vec3 c = a / b; + return outputMatrix * c; +} + +void main() +{ + vec4 outputColor = texture(u_Source, UV).rgba; + if (u_Stage == 0) // Threshold + { + outputColor = Threshold(outputColor, UV); + } + else if (u_Stage == 1) // Downsampling + { + outputColor = DownsampleBox13Tap(UV); + } + else if (u_Stage == 2) // Blur + { + outputColor = blur9(u_Source, UV, u_SourceSize, u_BlurDirection); + } + else if (u_Stage == 3) // Copy + { + outputColor = texture(u_Source, UV); + } + else if (u_Stage == 4) // Upsampling + combine + { + outputColor += Upsample(UV) / 2.0; + } + else if (u_Stage == 5) // Final combine + { + outputColor += texture(u_Source2, UV); + + vec3 color = outputColor.rgb; + + color = acesOperator(color); + + color = color / (color + vec3(1.0)); + color = vec3(1.0) - exp(-color * 1.0); + color = pow(color, vec3(1.0 / 2.2)); + + outputColor = vec4(color, 1.0);//vec4(acesOperator(outputColor.rgb), 1.0f); + + } + FragColor = outputColor; +} \ No newline at end of file diff --git a/Editor/resources/Shaders/deferred.shader b/Editor/resources/Shaders/deferred.shader index c95d7942..507f96e1 100644 --- a/Editor/resources/Shaders/deferred.shader +++ b/Editor/resources/Shaders/deferred.shader @@ -226,7 +226,8 @@ void main() { vec3 worldPos = WorldPosFromDepth(texture(m_Depth, UV).r); - if (texture(m_Depth, UV).r == 1) { + if (texture(m_Depth, UV).r == 1) + { FragColor = vec4(0, 0, 0, 0); return; } @@ -313,12 +314,13 @@ void main() vec3 ambient = (kD * diffuse + specular) * ao; vec3 color = ambient + Lo; color += fog; - color = color / (color + vec3(1.0)); - const float gamma = 2.2; - // HDR tonemapping - color = vec3(1.0) - exp(-color * u_Exposure); - // gamma correct - color = pow(color, vec3(1.0 / gamma)); + + //color = color / (color + vec3(1.0)); + //const float gamma = 2.2; + //// HDR tonemapping + //color = vec3(1.0) - exp(-color * 1.0); + //// gamma correct + //color = pow(color, vec3(1.0 / gamma)); FragColor = mix(vec4(color, 1.0), vec4(albedo, 1.0), 0); } \ No newline at end of file diff --git a/Editor/resources/Shaders/tonemap.shader b/Editor/resources/Shaders/tonemap.shader new file mode 100644 index 00000000..f0a07fe4 --- /dev/null +++ b/Editor/resources/Shaders/tonemap.shader @@ -0,0 +1,34 @@ +#shader vertex +#version 460 core + +layout(location = 0) in vec3 VertexPosition; +layout(location = 1) in vec2 UVPosition; + +out flat vec2 UV; + +void main() +{ + UV = UVPosition; + gl_Position = vec4(VertexPosition, 1.0f); +} + +#shader fragment +#version 460 core + +uniform sampler2D u_Source; + +in vec2 UV; + +out vec4 FragColor; + +void main() +{ + vec4 color = texture(u_Source, UV); + color = color / (color + vec3(1.0)); + const float gamma = 2.2; + // HDR tonemapping + color = vec3(1.0) - exp(-color * u_Exposure); + // gamma correct + color = pow(color, vec3(1.0 / gamma)); + FragColor = color; +} \ No newline at end of file diff --git a/Editor/src/EditorInterface.cpp b/Editor/src/EditorInterface.cpp index df0b7c8e..08944bf8 100644 --- a/Editor/src/EditorInterface.cpp +++ b/Editor/src/EditorInterface.cpp @@ -342,7 +342,7 @@ namespace Nuake { if (ImGui::Begin("Environnement")) { Ref env = Engine::GetCurrentScene()->GetEnvironment(); - if (ImGui::CollapsingHeader("Procedural Sky")) + if (ImGui::CollapsingHeader("Procedural Sky", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::DragFloat("Sun Intensity", &env->ProceduralSkybox->SunIntensity, 0.1f, 0.0f); @@ -354,7 +354,13 @@ namespace Nuake { ImGuiHelper::DrawVec3("Mie Scattering", &mieScattering); env->ProceduralSkybox->MieScattering = mieScattering / 10000.0f; } - if (ImGui::CollapsingHeader("Fog")) + if (ImGui::CollapsingHeader("Bloom", ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::DragFloat("Threshold", &env->BloomThreshold, 0.01f, 0.0f, 300.0f); + ImGui::DragFloat("Blur", &env->BloomBlurAmount, 0.01f, 0.0f, 300.0f); + + } + if (ImGui::CollapsingHeader("Fog", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::DragFloat("Volumetric Scattering", &env->VolumetricFog, .01f, 0.0f, 1.0f); ImGui::DragFloat("Volumetric Step Count", &env->VolumetricStepCount, 1.f, 0.0f); diff --git a/Nuake/src/Rendering/Buffers/Framebuffer.h b/Nuake/src/Rendering/Buffers/Framebuffer.h index 68a81269..ead1fe22 100644 --- a/Nuake/src/Rendering/Buffers/Framebuffer.h +++ b/Nuake/src/Rendering/Buffers/Framebuffer.h @@ -35,6 +35,7 @@ namespace Nuake void Unbind(); void QueueResize(Vector2 size); Vector2 GetSize() const { return m_Size; } + void SetSize(const Vector2& size) { m_Size = size; } void UpdateSize(Vector2 size); void SetDrawBuffer(GLenum draw); diff --git a/Nuake/src/Rendering/PostFX/Bloom.cpp b/Nuake/src/Rendering/PostFX/Bloom.cpp new file mode 100644 index 00000000..68a7d177 --- /dev/null +++ b/Nuake/src/Rendering/PostFX/Bloom.cpp @@ -0,0 +1,186 @@ +#include "Bloom.h" +#include +#include "src/Rendering/Renderer.h" +#include + +namespace Nuake +{ + const float DownsamplingScale = 0.4f; + Bloom::Bloom(Ref source, unsigned int iteration) + { + m_Iteration = iteration; + m_Source = source; + + + + m_FinalFB = CreateRef(false, Vector2(1920, 1080)); + m_FinalFB->SetTexture(CreateRef(Vector2(1920, 1080), GL_RGBA, GL_RGBA16F, GL_FLOAT)); + + m_ThresholdFB = CreateRef(false, Vector2(1920, 1080)); + m_ThresholdFB->SetTexture(CreateRef(Vector2(1920, 1080), GL_RGBA, GL_RGBA16F, GL_FLOAT)); + + m_DownSampleFB = std::vector>(); + m_UpSampleFB = std::vector>(); + m_HBlurFB = std::vector>(); + m_VBlurFB = std::vector>(); + + Vector2 originalTargetSize = Vector2(source->GetWidth(), source->GetHeight()); + Vector2 currentSize = originalTargetSize; + for (int i = 0; i < m_Iteration; i++) + { + Ref fb = CreateRef(false, currentSize); + fb->SetTexture(CreateRef(currentSize, GL_RGBA, GL_RGBA16F, GL_FLOAT)); + m_DownSampleFB.push_back(fb); + + currentSize *= DownsamplingScale; + } + + for (int i = 0; i < m_Iteration; i++) + { + Ref fb = CreateRef(false, currentSize); + fb->SetTexture(CreateRef(currentSize, GL_RGBA, GL_RGBA16F, GL_FLOAT)); + m_UpSampleFB.push_back(fb); + + fb = CreateRef(false, currentSize); + fb->SetTexture(CreateRef(currentSize, GL_RGBA, GL_RGBA16F, GL_FLOAT)); + m_HBlurFB.push_back(fb); + + fb = CreateRef(false, currentSize); + fb->SetTexture(CreateRef(currentSize, GL_RGBA, GL_RGBA16F, GL_FLOAT)); + m_VBlurFB.push_back(fb); + + currentSize /= DownsamplingScale; + } + } + + + int downsampleMip = 0; + int upSampleMip = 0; + void Bloom::Draw() + { + Ref shader = ShaderManager::GetShader("resources/Shaders/bloom.shader"); + + // Threshold + m_ThresholdFB->Bind(); + { + m_ThresholdFB->Clear(); + + shader->Bind(); + shader->SetUniform1i("u_Stage", 0); + shader->SetUniform1f("u_Threshold", Threshold); + m_Source->Bind(1); + shader->SetUniform1i("u_Source", 1); + + Renderer::DrawQuad(Matrix4()); + } + + for (int i = 0; i < m_Iteration; i++) + { + m_DownSampleFB[i]->Bind(); + m_DownSampleFB[i]->Clear(); + + shader->SetUniform1i("u_Stage", 1); + + Ref downsampleTexture = i == 0 ? m_ThresholdFB->GetTexture() : m_DownSampleFB[i - 1]->GetTexture(); + downsampleTexture->Bind(1); + shader->SetUniform1i("u_Source", 1); + + if(i == 0) + shader->SetUniform2f("u_SourceSize", downsampleTexture->GetWidth(), downsampleTexture->GetHeight()); + else + shader->SetUniform2f("u_SourceSize", m_DownSampleFB[i]->GetTexture()->GetWidth(), m_DownSampleFB[i]->GetTexture()->GetHeight()); + Renderer::DrawQuad(Matrix4()); + m_DownSampleFB[i]->Unbind(); + } + + if (ImGui::Begin("Downsample")) + { + ImGui::DragInt("MIP", &downsampleMip, 1.0f, 0, m_Iteration - 1); + ImGui::Image((void*)m_DownSampleFB[downsampleMip]->GetTexture()->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0)); + } + ImGui::End(); + + + for (int i = 0; i < m_Iteration; i++) + { + // Horizontal blur + m_HBlurFB[i]->Bind(); + m_HBlurFB[i]->Clear(); + + shader->SetUniform1i("u_Stage", 2); + shader->SetUniform2f("u_BlurDirection", 0.0f, 1.0f); + + Ref blurTexture = m_DownSampleFB[m_Iteration - i - 1]->GetTexture(); + blurTexture->Bind(1); + shader->SetUniform1i("u_Source", 1); + shader->SetUniform2f("u_SourceSize", blurTexture->GetWidth(), blurTexture->GetHeight()); + + Renderer::DrawQuad(Matrix4()); + m_HBlurFB[i]->Unbind(); + + // Vertical blur + m_VBlurFB[i]->Bind(); + m_VBlurFB[i]->Clear(); + + shader->SetUniform1i("u_Stage", 2); + shader->SetUniform2f("u_BlurDirection", 1.0f, 0.0f); + + m_HBlurFB[i]->GetTexture()->Bind(1); + shader->SetUniform1i("u_Source", 1); + shader->SetUniform2f("u_SourceSize", m_HBlurFB[i]->GetTexture()->GetWidth(), m_HBlurFB[i]->GetTexture()->GetHeight()); + + Renderer::DrawQuad(Matrix4()); + m_VBlurFB[i]->Unbind(); + + + // Upsampling + m_UpSampleFB[i]->Bind(); + m_UpSampleFB[i]->Clear(); + if (i == 0) + { + shader->SetUniform1i("u_Stage", 3); + shader->SetUniform1i("u_Source", 1); + m_VBlurFB[i]->GetTexture()->Bind(1); + } + if (i > 0) + { + shader->SetUniform1i("u_Stage", 4); + + m_VBlurFB[i]->GetTexture()->Bind(1); + shader->SetUniform1i("u_Source", 1); + + m_UpSampleFB[i - 1]->GetTexture()->Bind(2); + shader->SetUniform1i("u_Source2", 2); + shader->SetUniform2f("u_Source2Size", m_UpSampleFB[i]->GetTexture()->GetWidth(), m_UpSampleFB[i]->GetTexture()->GetHeight()); + } + Renderer::DrawQuad(Matrix4()); + m_UpSampleFB[i]->Unbind(); + } + + if (ImGui::Begin("UpSample")) + { + ImGui::DragInt("MIP", &upSampleMip, 1.0f, 0, m_Iteration - 1); + ImGui::Image((void*)m_UpSampleFB[upSampleMip]->GetTexture()->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0)); + } + ImGui::End(); + + m_FinalFB->Bind(); + m_FinalFB->Clear(); + { + shader->SetUniform1i("u_Stage", 5); + shader->SetUniform1i("u_Source", 1); + shader->SetUniform1i("u_Source2", 2); + + m_UpSampleFB[m_Iteration - 1]->GetTexture()->Bind(1); + m_Source->Bind(2); + Renderer::DrawQuad(Matrix4()); + } + + m_FinalFB->Unbind(); + if (ImGui::Begin("Final")) + { + ImGui::Image((void*)m_FinalFB->GetTexture()->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0)); + } + ImGui::End(); + } +} \ No newline at end of file diff --git a/Nuake/src/Rendering/PostFX/Bloom.h b/Nuake/src/Rendering/PostFX/Bloom.h new file mode 100644 index 00000000..754ca20b --- /dev/null +++ b/Nuake/src/Rendering/PostFX/Bloom.h @@ -0,0 +1,39 @@ +#pragma once +#include "src/Core/Core.h" +#include "src/Core/Maths.h" +#include "src/Rendering/Textures/Texture.h" +#include "src/Rendering/Shaders/ShaderManager.h" +#include "src/Rendering/Buffers/Framebuffer.h" + +#include + +namespace Nuake { + class Bloom + { + public: + float Threshold = 0.3f; + float BlurAmount = 12.0f; + Bloom() {} + Bloom(Ref source, unsigned int iteration = 4); + + void Draw(); + + Ref GetThreshold() const { return m_ThresholdFB->GetTexture(); } + + unsigned int m_Iteration; + Ref m_Source; + + std::vector> m_DownsampleMIP; + std::vector> m_UpSampleMIP; + + Ref m_FinalFB; + Ref m_Final; + Ref m_ThresholdFB; + + + std::vector> m_DownSampleFB; + std::vector> m_HBlurFB; + std::vector> m_VBlurFB; + std::vector> m_UpSampleFB; + }; +} \ No newline at end of file diff --git a/Nuake/src/Rendering/Textures/Material.h b/Nuake/src/Rendering/Textures/Material.h index 96f7e2c4..4ba44496 100644 --- a/Nuake/src/Rendering/Textures/Material.h +++ b/Nuake/src/Rendering/Textures/Material.h @@ -47,11 +47,11 @@ namespace Nuake 0, // Padding byte Vector3(0.f, 0.f, 0.f), // Albedo color 0, // Has metalness - 0.5f, // Metalness value + 0.f, // Metalness value 0, // u_HasRoughness - 0.5f, // u_RoughnessValue + 1.f, // u_RoughnessValue 0, // u_HasAO - 0.5f, // u_AOValue + 1.f, // u_AOValue 0, // u_HasNormal 0, // u_HasDisplacement 0 diff --git a/Nuake/src/Rendering/Textures/Texture.cpp b/Nuake/src/Rendering/Textures/Texture.cpp index 8048168f..b8967bf3 100644 --- a/Nuake/src/Rendering/Textures/Texture.cpp +++ b/Nuake/src/Rendering/Textures/Texture.cpp @@ -36,17 +36,25 @@ namespace Nuake std::cout << "Error: failed to load texture: " << path << std::endl; } - Texture::Texture(glm::vec2 size, GLenum format) + Texture::Texture(glm::vec2 size, GLenum format, GLenum format2, GLenum format3) { m_RendererId = 0; m_Format = format; + m_Format2 = format; + if (format2 != 0) + m_Format2 = format2; + + m_Format3 = GL_UNSIGNED_BYTE; + if (format3 != 0) + m_Format3 = format3; + m_Width = size.x; m_Height = size.y; glGenTextures(1, &m_RendererId); glBindTexture(GL_TEXTURE_2D, m_RendererId); - glTexImage2D(GL_TEXTURE_2D, 0, format, size.x, size.y, 0, format, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, format2, size.x, size.y, 0, format, format3, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //glGenerateMipmap(GL_TEXTURE_2D); @@ -103,7 +111,7 @@ namespace Nuake m_Height = size.y; glGenTextures(1, &m_RendererId); glBindTexture(GL_TEXTURE_2D, m_RendererId); - glTexImage2D(GL_TEXTURE_2D, 0, m_Format, size.x, size.y, 0, m_Format, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, m_Format2, size.x, size.y, 0, m_Format, m_Format3, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } diff --git a/Nuake/src/Rendering/Textures/Texture.h b/Nuake/src/Rendering/Textures/Texture.h index 51f74434..871e9b9b 100644 --- a/Nuake/src/Rendering/Textures/Texture.h +++ b/Nuake/src/Rendering/Textures/Texture.h @@ -16,6 +16,8 @@ namespace Nuake std::string m_FilePath; unsigned char* m_LocalBuffer; GLenum m_Format; + GLenum m_Format2; + GLenum m_Format3; int m_Width; int m_Height; @@ -24,7 +26,7 @@ namespace Nuake public: Texture(const std::string& path); Texture(glm::vec2 size, msdfgen::BitmapConstRef& bitmap, bool t); - Texture(glm::vec2 size, GLenum format); + Texture(glm::vec2 size, GLenum format, GLenum format2 = 0, GLenum format3 = 0); Texture(Vector2 size, unsigned char* data, int len); ~Texture(); diff --git a/Nuake/src/Scene/Components/LightComponent.cpp b/Nuake/src/Scene/Components/LightComponent.cpp index e331fdea..6ad416ce 100644 --- a/Nuake/src/Scene/Components/LightComponent.cpp +++ b/Nuake/src/Scene/Components/LightComponent.cpp @@ -36,7 +36,7 @@ namespace Nuake { for (int i = 0; i < CSM_AMOUNT; i++) { m_Framebuffers[i] = CreateRef(false, glm::vec2(4096, 4096)); - m_Framebuffers[i]->SetTexture(CreateRef(glm::vec2(4096, 4096), GL_DEPTH_COMPONENT), GL_DEPTH_ATTACHMENT); + m_Framebuffers[i]->SetTexture(CreateRef(glm::vec2(4096, 4096), GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT), GL_DEPTH_ATTACHMENT); } } else { diff --git a/Nuake/src/Scene/Lighting/Environment.cpp b/Nuake/src/Scene/Lighting/Environment.cpp index 8b95c093..0e9f829c 100644 --- a/Nuake/src/Scene/Lighting/Environment.cpp +++ b/Nuake/src/Scene/Lighting/Environment.cpp @@ -34,6 +34,8 @@ namespace Nuake { BEGIN_SERIALIZE(); SERIALIZE_VAL(VolumetricFog); SERIALIZE_VAL(VolumetricStepCount); + SERIALIZE_VAL(BloomBlurAmount); + SERIALIZE_VAL(BloomThreshold); SERIALIZE_VEC4(AmbientColor); SERIALIZE_OBJECT(ProceduralSkybox); END_SERIALIZE(); @@ -41,6 +43,16 @@ namespace Nuake { bool Environment::Deserialize(const std::string& str) { + BEGIN_DESERIALIZE(); + + if (j.contains("VolumetricFog")) + VolumetricFog = j["VolumetricFog"]; + if (j.contains("VolumetricStepCount")) + VolumetricFog = j["VolumetricStepCount"]; + if (j.contains("BloomBlurAmount")) + VolumetricFog = j["BloomBlurAmount"]; + if (j.contains("BloomThreshold")) + VolumetricFog = j["BloomThreshold"]; return false; } } diff --git a/Nuake/src/Scene/Lighting/Environment.h b/Nuake/src/Scene/Lighting/Environment.h index 92db2687..e1b5b75f 100644 --- a/Nuake/src/Scene/Lighting/Environment.h +++ b/Nuake/src/Scene/Lighting/Environment.h @@ -13,6 +13,9 @@ namespace Nuake float VolumetricFog = 0.95f; float VolumetricStepCount = 100.f; + float BloomThreshold = 0.6f; + float BloomBlurAmount = 12.0f; + glm::vec4 AmbientColor; Ref ProceduralSkybox; diff --git a/Nuake/src/Scene/Scene.cpp b/Nuake/src/Scene/Scene.cpp index 3d89adf5..47ada628 100644 --- a/Nuake/src/Scene/Scene.cpp +++ b/Nuake/src/Scene/Scene.cpp @@ -387,7 +387,7 @@ namespace Nuake { deferredShader->Bind(); deferredShader->SetUniformMat4f("u_Projection", cam->GetPerspective()); deferredShader->SetUniformMat4f("u_View", cam->GetTransform()); - deferredShader->SetUniform1f("u_Exposure", 1.0); + //deferredShader->SetUniform1f("u_Exposure", 1.0); Vector3 camPosition = cam->GetTranslation(); deferredShader->SetUniform3f("u_EyePosition", camPosition.x, camPosition.y, camPosition.z); @@ -442,7 +442,7 @@ namespace Nuake { pbrShader->SetUniform1i("u_ShowNormal", 0); if (m_EditorCamera) { - Renderer::m_Shader->SetUniform1f("u_Exposure", m_EditorCamera->Exposure); + //Renderer::m_Shader->SetUniform1f("u_Exposure", m_EditorCamera->Exposure); Renderer::m_Shader->SetUniform3f("u_EyePosition", m_EditorCamera->GetTranslation().x, m_EditorCamera->GetTranslation().y, m_EditorCamera->GetTranslation().z); Renderer::m_Shader->SetUniformMat4f("u_View", m_EditorCamera->GetTransform()); Renderer::m_Shader->SetUniformMat4f("u_Projection", m_EditorCamera->GetPerspective()); @@ -563,7 +563,7 @@ namespace Nuake { deferredShader->Bind(); deferredShader->SetUniformMat4f("u_Projection", m_EditorCamera->GetPerspective()); deferredShader->SetUniformMat4f("u_View", m_EditorCamera->GetTransform()); - deferredShader->SetUniform1f("u_Exposure", 1.0); + //deferredShader->SetUniform1f("u_Exposure", 1.0); Vector3 camPosition = m_EditorCamera->GetTranslation(); deferredShader->SetUniform3f("u_EyePosition", camPosition.x, camPosition.y, camPosition.z); diff --git a/Nuake/src/Scripting/Modules/MathModule.h b/Nuake/src/Scripting/Modules/MathModule.h index d64b90a4..a34ae72f 100644 --- a/Nuake/src/Scripting/Modules/MathModule.h +++ b/Nuake/src/Scripting/Modules/MathModule.h @@ -107,7 +107,8 @@ namespace Nuake { wrenGetSlotDouble(vm, 2), wrenGetSlotDouble(vm, 3)); - wrenSetSlotDouble(vm, 0, v1.length()); + float length = glm::length(v1); + wrenSetSlotDouble(vm, 0, glm::length(v1)); } }; } diff --git a/Nuake/src/Window.cpp b/Nuake/src/Window.cpp index 52c0b189..cfd82dc0 100644 --- a/Nuake/src/Window.cpp +++ b/Nuake/src/Window.cpp @@ -19,8 +19,11 @@ #include "Resource/FontAwesome5.h" #include "Engine.h" #include +#include "src/Rendering/PostFX/Bloom.h" namespace Nuake { + + Bloom bloom; // TODO: Use abstraction for vertex buffers unsigned int vbo; unsigned int vao; @@ -96,7 +99,6 @@ namespace Nuake { return Vector2(w, h); } - int Window::Init() { if (!glfwInit()) @@ -105,44 +107,44 @@ namespace Nuake { return -1; } - // Create window - m_Window = glfwCreateWindow(m_Width, m_Height, "Nuake - Dev build", NULL, NULL); + { // Create window + m_Window = glfwCreateWindow(m_Width, m_Height, "Nuake - Dev build", NULL, NULL); + if (!m_Window) + { + Logger::Log("Window creation failed.", CRITICAL); + return -1; + } - if (!m_Window) - { - Logger::Log("Window creation failed.", CRITICAL); - return -1; + glfwMakeContextCurrent(m_Window); + + Logger::Log((char*)glGetString(GL_VERSION)); + + if (glewInit() != GLEW_OK) + { + Logger::Log("GLEW initialization failed!", CRITICAL); + return -1; + } + + // TODO: Move this to renderer init. The window shouldnt have to do gl calls. + glfwWindowHint(GLFW_SAMPLES, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + + // TODO: have clear color in environnement. + glClearColor(0.f, 0.f, 0.f, 1.0f); + + glfwSwapInterval(1); + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + glEnable(GL_DEPTH_TEST); + glEnable(GL_MULTISAMPLE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + //glEnable(GL_CULL_FACE); } - glfwMakeContextCurrent(m_Window); - - Logger::Log((char*)glGetString(GL_VERSION)); - - if (glewInit() != GLEW_OK) - { - Logger::Log("GLEW initialization failed!", CRITICAL); - return -1; - } - - // TODO: Move this to renderer init. The window shouldnt have to do gl calls. - glfwWindowHint(GLFW_SAMPLES, 4); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - - // TODO: have clear color in environnement. - glClearColor(0.019f, 0.501f, 1.0f, 1.0f); - - glfwSwapInterval(1); - glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - glEnable(GL_DEPTH_TEST); - glEnable(GL_MULTISAMPLE); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - //glEnable(GL_CULL_FACE); - // Create viewports m_Framebuffer = CreateRef(true, glm::vec2(1920, 1080)); m_Framebuffer->SetTexture(CreateRef(glm::vec2(1920, 1080), GL_RGB)); @@ -154,86 +156,78 @@ namespace Nuake { m_GBuffer->SetTexture(CreateRef(Vector2(1920, 1080), GL_RGB), GL_COLOR_ATTACHMENT2); m_DeferredBuffer = CreateRef(true, Vector2(1920, 1080)); - m_DeferredBuffer->SetTexture(CreateRef(Vector2(1920, 1080), GL_RGB)); + m_DeferredBuffer->SetTexture(CreateRef(Vector2(1920, 1080), GL_RGB, GL_RGB16F, GL_FLOAT)); - // Temporary quad vbo for deferred. - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); + m_BloomFrameBuffer = CreateRef(false, Vector2(1920, 1080)); + m_BloomFrameBuffer->SetTexture(CreateRef(Vector2(1920, 1080), GL_RGBA, GL_RGBA16F, GL_FLOAT)); + + bloom = Bloom(m_DeferredBuffer->GetTexture(), 5); - glGenBuffers(1, &vbo); - glBindBuffer(GL_ARRAY_BUFFER, vbo); + { + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); (void)io; + //io.Fonts->AddFontDefault(); + io.Fonts->AddFontFromFileTTF("resources/Fonts/OpenSans-Regular.ttf", 16.0); + io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; + ImGui::StyleColorsDark(); - glBindBuffer(GL_ARRAY_BUFFER, vbo); - glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); + ImGui::GetStyle().FrameRounding = 2.0f; + ImGui::GetStyle().GrabRounding = 2.0f; - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 5, (void*)0); - glEnableVertexAttribArray(0); + ImVec4* colors = ImGui::GetStyle().Colors; + colors[ImGuiCol_Text] = ImVec4(0.95f, 0.96f, 0.98f, 1.00f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.36f, 0.42f, 0.47f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); + colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f); + colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); + colors[ImGuiCol_Border] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f); + colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_FrameBg] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.12f, 0.20f, 0.28f, 1.00f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.09f, 0.12f, 0.14f, 1.00f); + colors[ImGuiCol_TitleBg] = ImVec4(0.09f, 0.12f, 0.14f, 0.65f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f); + colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.39f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.18f, 0.22f, 0.25f, 1.00f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.09f, 0.21f, 0.31f, 1.00f); + colors[ImGuiCol_CheckMark] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); + colors[ImGuiCol_SliderGrab] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.37f, 0.61f, 1.00f, 1.00f); + colors[ImGuiCol_Button] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); + colors[ImGuiCol_Header] = ImVec4(0.20f, 0.25f, 0.29f, 0.55f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Separator] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); + colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + colors[ImGuiCol_Tab] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); + colors[ImGuiCol_TabHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); + colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); + colors[ImGuiCol_TabUnfocused] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); + colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); + colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); + colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); + colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); + colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); + colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); + colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); + colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 5, (void*)(sizeof(float) * 3)); - glEnableVertexAttribArray(1); - - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.Fonts->AddFontDefault(); - io.Fonts->AddFontFromFileTTF("resources/Fonts/OpenSans-Regular.ttf", 16.0); - io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; - ImGui::StyleColorsDark(); - - ImGui::GetStyle().FrameRounding = 2.0f; - ImGui::GetStyle().GrabRounding = 2.0f; - - ImVec4* colors = ImGui::GetStyle().Colors; - colors[ImGuiCol_Text] = ImVec4(0.95f, 0.96f, 0.98f, 1.00f); - colors[ImGuiCol_TextDisabled] = ImVec4(0.36f, 0.42f, 0.47f, 1.00f); - colors[ImGuiCol_WindowBg] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); - colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f); - colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); - colors[ImGuiCol_Border] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f); - colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_FrameBg] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); - colors[ImGuiCol_FrameBgHovered] = ImVec4(0.12f, 0.20f, 0.28f, 1.00f); - colors[ImGuiCol_FrameBgActive] = ImVec4(0.09f, 0.12f, 0.14f, 1.00f); - colors[ImGuiCol_TitleBg] = ImVec4(0.09f, 0.12f, 0.14f, 0.65f); - colors[ImGuiCol_TitleBgActive] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f); - colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); - colors[ImGuiCol_MenuBarBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f); - colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.39f); - colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); - colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.18f, 0.22f, 0.25f, 1.00f); - colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.09f, 0.21f, 0.31f, 1.00f); - colors[ImGuiCol_CheckMark] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); - colors[ImGuiCol_SliderGrab] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); - colors[ImGuiCol_SliderGrabActive] = ImVec4(0.37f, 0.61f, 1.00f, 1.00f); - colors[ImGuiCol_Button] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); - colors[ImGuiCol_ButtonHovered] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); - colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); - colors[ImGuiCol_Header] = ImVec4(0.20f, 0.25f, 0.29f, 0.55f); - colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); - colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_Separator] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); - colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); - colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); - colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f); - colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); - colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); - colors[ImGuiCol_Tab] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); - colors[ImGuiCol_TabHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); - colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); - colors[ImGuiCol_TabUnfocused] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); - colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); - colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); - colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); - colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); - colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); - colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); - colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); - colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); - colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); - colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); - - ImGui_ImplGlfw_InitForOpenGL(m_Window, true); - ImGui_ImplOpenGL3_Init("#version 330"); + ImGui_ImplGlfw_InitForOpenGL(m_Window, true); + ImGui_ImplOpenGL3_Init("#version 330"); + } + return 0; } @@ -249,6 +243,8 @@ namespace Nuake { m_Scene->FixedUpdate(ts); } + + void Window::Draw() { // Dont render if no scene is loaded. @@ -327,6 +323,72 @@ namespace Nuake { } } m_DeferredBuffer->Unbind(); + + bloom.Threshold = GetScene()->GetEnvironment()->BloomThreshold; + bloom.BlurAmount = GetScene()->GetEnvironment()->BloomBlurAmount; + + bloom.Draw(); + + + + // m_BloomFrameBuffer->Bind(); + // m_BloomFrameBuffer->Clear(); + // m_BloomFrameBuffer->SetTexture(m_BloomTextures[0]); + // { + // + // Ref bloomShader = ShaderManager::GetShader("resources/Shaders/bloom.shader"); + // bloomShader->Bind(); + // + // // Threshold + // bloomShader->SetUniform1i("u_Stage", 0); + // bloomShader->SetUniform1f("u_Threshold", 0.5); + // m_DeferredBuffer->GetTexture()->Bind(1); + // bloomShader->SetUniform1i("u_LightingBuffer", 1); + // + // Renderer::DrawQuad(Matrix4()); + + // Downsample + + //m_BloomTextures.clear(); + //const int DownsampleAmount = 4; + //m_BloomTextures.reserve(4); + //m_BloomTextures.push_back(m_BloomFrameBuffer->GetTexture()); + // + //Vector2 originalSize = m_BloomFrameBuffer->GetSize(); + //Vector2 currentSize = originalSize; + //for (unsigned int i = 1; i < DownsampleAmount; i++) // # of iterations for down sample + //{ + // m_BloomFrameBuffer->Clear(); + // currentSize /= 2; + // m_BloomTextures.push_back(m_BloomFrameBuffer->GetTexture()); + // + // m_BloomFrameBuffer->SetSize(currentSize); + // m_BloomFrameBuffer->SetTexture(CreateRef(currentSize, GL_RGB)); + // + // m_BloomFrameBuffer->Clear(); + // bloomShader->SetUniform1i("u_Stage", 1); + // bloomShader->SetUniform1i("u_DownsamplingSource", m_BloomTextures[i - 1]->GetID()); + // Renderer::DrawQuad(Matrix4()); + // + // if (ImGui::Begin(("Downsample " + std::to_string(i)).c_str())) + // { + // ImGui::Image((void*)m_BloomTextures[i]->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0)); + // } + // ImGui::End(); + //} + + // Upsample + + + //} + //m_BloomFrameBuffer->Unbind(); + + //if (ImGui::Begin("Bloom")) + //{ + // ImGui::Image((void*)bloom.GetThreshold()->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0)); + //} + //ImGui::End(); + glEnable(GL_DEPTH_TEST); Renderer::EndDraw(); } diff --git a/Nuake/src/Window.h b/Nuake/src/Window.h index bd12e517..d3ec4b3e 100644 --- a/Nuake/src/Window.h +++ b/Nuake/src/Window.h @@ -21,6 +21,7 @@ namespace Nuake Ref m_Framebuffer; Ref m_GBuffer; Ref m_DeferredBuffer; + Ref m_BloomFrameBuffer; Ref m_Scene; Vector2 m_FramebufferOffset; @@ -44,7 +45,6 @@ namespace Nuake Ref GetGBuffer() const; Ref GetDeferredBuffer() const; Vector2 GetSize(); - Ref GetScene(); bool SetScene(Ref scene); };