Added toggle for SSAO

This commit is contained in:
Antoine Pilote
2023-09-07 20:50:50 -04:00
parent 97a477ac20
commit 6a73249da7
4 changed files with 35 additions and 2 deletions

View File

@@ -761,6 +761,21 @@ namespace Nuake {
ImGui::TableSetupColumn("set", 0, 0.6);
ImGui::TableSetupColumn("reset", 0, 0.1);
ImGui::TableNextColumn();
{
// Title
ImGui::Text("SSAO");
ImGui::TableNextColumn();
ImGui::Checkbox("##SSAOEnabled", &env->SSAOEnabled);
ImGui::TableNextColumn();
// Reset button
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
std::string resetSSAO = ICON_FA_UNDO + std::string("##resetSSAO");
if (ImGui::Button(resetSSAO.c_str())) env->SSAOEnabled = false;
ImGui::PopStyleColor();
}
ImGui::TableNextColumn();
{
// Title

View File

@@ -40,6 +40,16 @@ namespace Nuake
_ssaoBlurFramebuffer->QueueResize(size);
}
void SSAO::Clear()
{
_ssaoBlurFramebuffer->Bind();
{
RenderCommand::SetClearColor({ 1, 1, 1, 1});
_ssaoBlurFramebuffer->Clear();
}
_ssaoBlurFramebuffer->Unbind();
}
void SSAO::GenerateKernel()
{
std::uniform_real_distribution<float> randomFloats(0.0, 1.0); // random floats between [0.0, 1.0]

View File

@@ -33,6 +33,7 @@ namespace Nuake
float Falloff = 0.002f;
float Strength = 0.2f;
void Resize(const Vector2& size);
void Clear();
SSAO();
void Draw(FrameBuffer* gBuffer, const Matrix4& projection, const Matrix4& view);
Ref<FrameBuffer> GetOuput() const;

View File

@@ -56,8 +56,15 @@ namespace Nuake
// SSAO
const auto& sceneEnv = scene.GetEnvironment();
sceneEnv->mSSAO->Resize(framebuffer.GetSize());
sceneEnv->mSSAO->Draw(mGBuffer.get(), mProjection, mView);
if (sceneEnv->SSAOEnabled)
{
sceneEnv->mSSAO->Resize(framebuffer.GetSize());
sceneEnv->mSSAO->Draw(mGBuffer.get(), mProjection, mView);
}
else
{
sceneEnv->mSSAO->Clear();
}
mShadingBuffer->QueueResize(framebuffer.GetSize());
ShadingPass(scene);