diff options
author | LaG1924 <lag1924@gmail.com> | 2021-12-07 21:55:37 +0100 |
---|---|---|
committer | LaG1924 <lag1924@gmail.com> | 2021-12-07 22:27:55 +0100 |
commit | 039f05be5a548a9b5051b988869f984d7e335a47 (patch) | |
tree | a5d0f41fafcace53d9238dda0f56b5316089f0be /src | |
parent | Fixed SSAO normals (diff) | |
download | AltCraft-039f05be5a548a9b5051b988869f984d7e335a47.tar AltCraft-039f05be5a548a9b5051b988869f984d7e335a47.tar.gz AltCraft-039f05be5a548a9b5051b988869f984d7e335a47.tar.bz2 AltCraft-039f05be5a548a9b5051b988869f984d7e335a47.tar.lz AltCraft-039f05be5a548a9b5051b988869f984d7e335a47.tar.xz AltCraft-039f05be5a548a9b5051b988869f984d7e335a47.tar.zst AltCraft-039f05be5a548a9b5051b988869f984d7e335a47.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Render.cpp | 6 | ||||
-rw-r--r-- | src/RenderConfigs.cpp | 24 | ||||
-rw-r--r-- | src/RenderConfigs.hpp | 2 |
3 files changed, 21 insertions, 11 deletions
diff --git a/src/Render.cpp b/src/Render.cpp index 35ee695..be7e2b2 100644 --- a/src/Render.cpp +++ b/src/Render.cpp @@ -152,7 +152,11 @@ void Render::PrepareToRendering() { bool useDeffered = Settings::ReadBool("deffered", false); if (useDeffered) { - gbuffer = std::make_unique<Gbuffer>(scaledW, scaledH, scaledW, scaledH, Settings::ReadBool("ssao", false)); + int ssaoSamples = Settings::ReadDouble("ssaoSamples", 0.5f); + float ssaoScale = Settings::ReadDouble("ssaoScale", 0.5f); + size_t ssaoW = scaledW * ssaoScale, ssaoH = scaledH * ssaoScale; + + gbuffer = std::make_unique<Gbuffer>(scaledW, scaledH, scaledW, scaledH, ssaoSamples, ssaoW, ssaoH); gbuffer->SetRenderBuff(renderBuff); std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count()); diff --git a/src/RenderConfigs.cpp b/src/RenderConfigs.cpp index 3d91a1d..56c24bf 100644 --- a/src/RenderConfigs.cpp +++ b/src/RenderConfigs.cpp @@ -80,7 +80,7 @@ PostProcess::PostProcess( }); } -Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, bool applySsao) { +Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, int ssaoSamples, size_t ssaoW, size_t ssaoH) { auto gal = Gal::GetImplementation(); auto colorConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8B8); @@ -124,7 +124,7 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, bool geomFramebuffer = gal->BuildFramebuffer(geomFbConf); geomFramebuffer->SetViewport(0, 0, geomW, geomH); - if (applySsao) { + if (ssaoSamples > 0) { auto noiseConf = gal->CreateTexture2DConfig(4, 4, Gal::Format::R32G32B32A32F); noiseConf->SetWrapping(Gal::Wrapping::Repeat); noiseConf->SetMinFilter(Gal::Filtering::Bilinear); @@ -148,14 +148,20 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, bool {"ssaoNoise", ssaoNoise}, }; + std::vector<std::pair<std::string_view, Gal::Type>> ssaoParameters = { + {"ssaoSamples", Gal::Type::Int32}, + }; + ssaoPass = std::make_unique<PostProcess>(LoadPixelShader("/altcraft/shaders/frag/ssao"), ssaoTextures, - std::vector<std::pair<std::string_view, Gal::Type>>{}, - lightW, - lightH, + ssaoParameters, + ssaoW, + ssaoH, Gal::Format::R8G8B8A8, Gal::Filtering::Bilinear); + ssaoPass->SetShaderParameter("ssaoSamples", ssaoSamples); + std::vector<std::pair<std::string_view, std::shared_ptr<Gal::Texture>>> ssaoBlurTextures = { {"blurInput", ssaoPass->GetResultTexture()}, }; @@ -167,8 +173,8 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, bool ssaoBlurPass = std::make_unique<PostProcess>(LoadPixelShader("/altcraft/shaders/frag/blur"), ssaoBlurTextures, ssaoBlurParameters, - lightW, - lightH, + ssaoW, + ssaoH, Gal::Format::R8G8B8A8, Gal::Filtering::Bilinear); @@ -189,7 +195,7 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, bool {"light", light}, }; - if (applySsao) + if (ssaoSamples > 0) lightingTextures.emplace_back("ssao", ssaoBlurPass->GetResultTexture()); lightingPass = std::make_unique<PostProcess>(LoadPixelShader("/altcraft/shaders/frag/light"), @@ -200,5 +206,5 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, bool Gal::Format::R8G8B8A8, Gal::Filtering::Bilinear); - lightingPass->SetShaderParameter("applySsao", applySsao); + lightingPass->SetShaderParameter("applySsao", ssaoSamples); } diff --git a/src/RenderConfigs.hpp b/src/RenderConfigs.hpp index a9b8d72..d76647e 100644 --- a/src/RenderConfigs.hpp +++ b/src/RenderConfigs.hpp @@ -73,7 +73,7 @@ class Gbuffer { std::shared_ptr<Gal::Framebuffer> geomFramebuffer; public: - Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, bool applySsao); + Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, int ssaoSamples, size_t ssaoW, size_t ssaoH); std::shared_ptr<Gal::Framebuffer> GetGeometryTarget() { return geomFramebuffer; |