From bcec3680b6ac0676262d755f588bfd0c6f0455b8 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Mon, 25 Sep 2017 11:51:23 +0200 Subject: [PATCH] First draft --- libraries/render-utils/src/BloomEffect.cpp | 36 ++++++++++++++ libraries/render-utils/src/BloomEffect.h | 47 +++++++++++++++++++ .../render-utils/src/RenderDeferredTask.cpp | 5 ++ 3 files changed, 88 insertions(+) create mode 100644 libraries/render-utils/src/BloomEffect.cpp create mode 100644 libraries/render-utils/src/BloomEffect.h diff --git a/libraries/render-utils/src/BloomEffect.cpp b/libraries/render-utils/src/BloomEffect.cpp new file mode 100644 index 0000000000..a0a36a2194 --- /dev/null +++ b/libraries/render-utils/src/BloomEffect.cpp @@ -0,0 +1,36 @@ +// +// BloomEffect.cpp +// render-utils/src/ +// +// Created by Olivier Prat on 09/25/17. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#include "BloomEffect.h" + +#include + +void BloomConfig::setMix(float value) { + +} + +void BloomConfig::setSize(float value) { + auto blurConfig = getConfig("Blur"); + assert(blurConfig); + blurConfig->setProperty("filterScale", value*10.0f); +} + +Bloom::Bloom() { + +} + +void Bloom::configure(const Config& config) { + +} + +void Bloom::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs) { + const auto& blurInput = inputs; + task.addJob("Blur", blurInput); +} diff --git a/libraries/render-utils/src/BloomEffect.h b/libraries/render-utils/src/BloomEffect.h new file mode 100644 index 0000000000..278236d2e9 --- /dev/null +++ b/libraries/render-utils/src/BloomEffect.h @@ -0,0 +1,47 @@ +// +// BloomEffect.h +// render-utils/src/ +// +// Created by Olivier Prat on 09/25/17. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_render_utils_BloomEffect_h +#define hifi_render_utils_BloomEffect_h + +#include + +class BloomConfig : public render::Task::Config { + Q_OBJECT + Q_PROPERTY(float mix MEMBER mix WRITE setMix NOTIFY dirty) + Q_PROPERTY(float size MEMBER size WRITE setSize NOTIFY dirty) + +public: + + float mix{ 0.2f }; + float size{ 0.1f }; + + void setMix(float value); + void setSize(float value); + +signals: + void dirty(); +}; + +class Bloom { +public: + using Inputs = gpu::FramebufferPointer; + using Config = BloomConfig; + using JobModel = render::Task::ModelI; + + Bloom(); + + void configure(const Config& config); + void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs); + +}; + +#endif // hifi_render_utils_BloomEffect_h diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index c67a1c7875..682d5db435 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -41,6 +41,7 @@ #include "ToneMappingEffect.h" #include "SubsurfaceScattering.h" #include "OutlineEffect.h" +#include "BloomEffect.h" #include @@ -168,6 +169,10 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto toneAndPostRangeTimer = task.addJob("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing"); + // Add bloom + const auto bloomInputs = lightingFramebuffer; + task.addJob("Bloom", bloomInputs); + // Lighting Buffer ready for tone mapping const auto toneMappingInputs = ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer).asVarying(); task.addJob("ToneMapping", toneMappingInputs);