From 959782d2f261e2ecf73f10def7ba9d5afac5fd6a Mon Sep 17 00:00:00 2001 From: hotstreams Date: Fri, 30 Aug 2024 22:17:27 +0300 Subject: [PATCH] fix --- CMakeLists.txt | 6 ++--- include/limitless/postprocessing/ssr.hpp | 4 +-- .../limitless/renderer/renderer_settings.hpp | 4 +-- include/limitless/renderer/ssr_pass.hpp | 9 +++---- src/limitless/postprocessing/ssr.cpp | 26 +++---------------- src/limitless/renderer/color_picker.cpp | 6 ++--- src/limitless/renderer/renderer.cpp | 6 +++-- src/limitless/renderer/ssr_pass.cpp | 19 +++++--------- 8 files changed, 27 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bec3f766..0095ee81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ OPTION(BUILD_SAMPLES "Builds samples" ON) OPTION(BUILD_TESTS "Builds tests" ON) OPTION(OPENGL_DEBUG "Enables debug mode for OpenGL" ON) -OPTION(OPENGL_NO_EXTENSIONS "Disables all extensions" OFF) +OPTION(OPENGL_NO_EXTENSIONS "Disables all extensions" ON) OPTION(OPENGL_SHADER_OUTPUT "Outputs all source shaders for GLSLANG testing" OFF) ######################################### @@ -175,13 +175,13 @@ set(ENGINE_RENDERER src/limitless/renderer/translucent_pass.cpp src/limitless/renderer/bloom_pass.cpp src/limitless/renderer/composite_pass.cpp -# src/limitless/pipeline/common/ssao_pass.cpp + src/limitless/renderer/ssao_pass.cpp # src/limitless/pipeline/common/fxaa_pass.cpp src/limitless/renderer/screen_pass.cpp src/limitless/renderer/render_debug_pass.cpp # src/limitless/pipeline/common/dof_pass.cpp src/limitless/renderer/outline_pass.cpp -# src/limitless/pipeline/common/ssr_pass.cpp + src/limitless/renderer/ssr_pass.cpp src/limitless/renderer/decal_pass.cpp src/limitless/postprocessing/blur.cpp src/limitless/postprocessing/bloom.cpp diff --git a/include/limitless/postprocessing/ssr.hpp b/include/limitless/postprocessing/ssr.hpp index bf4c85ba..5e86a0b5 100644 --- a/include/limitless/postprocessing/ssr.hpp +++ b/include/limitless/postprocessing/ssr.hpp @@ -7,6 +7,7 @@ namespace Limitless { class UniformSetter; class Assets; class Camera; + class Renderer; class SSR { public: @@ -45,8 +46,7 @@ namespace Limitless { Settings settings; Blur blur; public: - SSR(Context &ctx, glm::uvec2 frame_size); - explicit SSR(Context &ctx); + SSR(Renderer& renderer); std::shared_ptr getResult(); diff --git a/include/limitless/renderer/renderer_settings.hpp b/include/limitless/renderer/renderer_settings.hpp index 106ee532..0f07e5d9 100644 --- a/include/limitless/renderer/renderer_settings.hpp +++ b/include/limitless/renderer/renderer_settings.hpp @@ -24,13 +24,13 @@ namespace Limitless { /** * Screen Space Ambient Occlusion */ - bool screen_space_ambient_occlusion {false}; + bool screen_space_ambient_occlusion {true}; SSAO::Settings ssao_settings; /** * Screen Space Reflections */ - bool screen_space_reflections {false}; + bool screen_space_reflections {true}; SSR::Settings ssr_settings; /** diff --git a/include/limitless/renderer/ssr_pass.hpp b/include/limitless/renderer/ssr_pass.hpp index ec34bdf2..ccd2dcb7 100644 --- a/include/limitless/renderer/ssr_pass.hpp +++ b/include/limitless/renderer/ssr_pass.hpp @@ -10,18 +10,15 @@ namespace Limitless { private: SSR ssr; public: - SSRPass(Pipeline& pipeline, Context& ctx); - SSRPass(Pipeline& pipeline, Context& ctx, glm::uvec2 frame_size); + SSRPass(Renderer& renderer); - std::shared_ptr getResult() override { return ssr.getResult(); } + std::shared_ptr getResult() { return ssr.getResult(); } void addUniformSetter(UniformSetter &setter) override; // void update(Limitless::Scene &scene, Limitless::Instances &instances, Limitless::Context &ctx, const Limitless::Camera &camera) override; - void - draw(InstanceRenderer &renderer, Scene &scene, Context &ctx, const Assets &assets, const Camera &camera, - UniformSetter &setter) override; + void render(InstanceRenderer &renderer, Scene &scene, Context &ctx, const Assets &assets, const Camera &camera, UniformSetter &setter) override; void onFramebufferChange(glm::uvec2 size) override; }; diff --git a/src/limitless/postprocessing/ssr.cpp b/src/limitless/postprocessing/ssr.cpp index 1150486e..e860137f 100644 --- a/src/limitless/postprocessing/ssr.cpp +++ b/src/limitless/postprocessing/ssr.cpp @@ -6,35 +6,17 @@ #include #include #include +#include using namespace Limitless; -SSR::SSR(Context& ctx) - : blur {ctx.getSize()} { +SSR::SSR(Renderer& renderer) + : blur {renderer.getResolution()} { auto ssr = Texture::builder() .target(Texture::Type::Tex2D) .internal_format(Texture::InternalFormat::RGB16F) .data_type(Texture::DataType::Float) - .size(ctx.getSize()) - .min_filter(Texture::Filter::Nearest) - .mag_filter(Texture::Filter::Nearest) - .wrap_s(Texture::Wrap::ClampToEdge) - .wrap_t(Texture::Wrap::ClampToEdge) - .build(); - - framebuffer.bind(); - framebuffer << TextureAttachment{FramebufferAttachment::Color0, ssr}; - framebuffer.checkStatus(); - framebuffer.unbind(); -} - -SSR::SSR(Context &ctx, glm::uvec2 frame_size) - : blur {frame_size} { - auto ssr = Texture::builder() - .target(Texture::Type::Tex2D) - .internal_format(Texture::InternalFormat::RGB16F) - .data_type(Texture::DataType::Float) - .size(ctx.getSize()) + .size(renderer.getResolution()) .min_filter(Texture::Filter::Nearest) .mag_filter(Texture::Filter::Nearest) .wrap_s(Texture::Wrap::ClampToEdge) diff --git a/src/limitless/renderer/color_picker.cpp b/src/limitless/renderer/color_picker.cpp index de349db5..9144368c 100644 --- a/src/limitless/renderer/color_picker.cpp +++ b/src/limitless/renderer/color_picker.cpp @@ -44,9 +44,9 @@ void ColorPicker::process(Context& ctx) { } void ColorPicker::render(InstanceRenderer& renderer, [[maybe_unused]] Scene &scene, Context &ctx, const Assets &assets, [[maybe_unused]] const Camera &camera, UniformSetter &setter) { -// if (data.empty()) { -// return; -// } + if (data.empty()) { + return; + } framebuffer.bind(); diff --git a/src/limitless/renderer/renderer.cpp b/src/limitless/renderer/renderer.cpp index b1de957d..c487f162 100644 --- a/src/limitless/renderer/renderer.cpp +++ b/src/limitless/renderer/renderer.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include using namespace Limitless; @@ -100,12 +102,12 @@ Renderer::Builder &Renderer::Builder::addSkyboxPass() { } Renderer::Builder &Renderer::Builder::addSSAOPass() { -// renderer->passes.emplace_back(std::make_unique(*renderer)); + renderer->passes.emplace_back(std::make_unique(*renderer)); return *this; } Renderer::Builder &Renderer::Builder::addSSRPass() { -// renderer->passes.emplace_back(std::make_unique(renderer)); + renderer->passes.emplace_back(std::make_unique(*renderer)); return *this; } diff --git a/src/limitless/renderer/ssr_pass.cpp b/src/limitless/renderer/ssr_pass.cpp index 7b4ef9aa..b3475286 100644 --- a/src/limitless/renderer/ssr_pass.cpp +++ b/src/limitless/renderer/ssr_pass.cpp @@ -10,29 +10,22 @@ #include "limitless/core/uniform/uniform.hpp" #include "limitless/core/shader/shader_program.hpp" #include -#include #include #include -#include #include #include #include +#include using namespace Limitless; -SSRPass::SSRPass(Pipeline& pipeline, Context& ctx) - : RendererPass(pipeline) - , ssr {ctx} { +SSRPass::SSRPass(Renderer& renderer) + : RendererPass(renderer) + , ssr {renderer} { } -SSRPass::SSRPass(Pipeline& pipeline, Context& ctx, glm::uvec2 frame_size) - : RendererPass(pipeline) - , ssr {ctx, frame_size} { -} - -void SSRPass::draw(InstanceRenderer &renderer, Scene &scene, Context &ctx, const Assets &assets, const Camera &camera, - UniformSetter &setter) { - auto& gbuffer = pipeline.get(); +void SSRPass::render(InstanceRenderer &instance_renderer, Scene &scene, Context &ctx, const Assets &assets, const Camera &camera, UniformSetter &setter) { + auto& gbuffer = renderer.getPass(); ssr.draw(ctx, assets, camera, gbuffer.getDepth(), gbuffer.getNormal(), gbuffer.getProperties(), gbuffer.getAlbedo()); }