| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- #pragma once
- #include <AnKi/Renderer/RendererObject.h>
- #include <AnKi/Gr.h>
- #include <AnKi/Resource/ImageResource.h>
- namespace anki
- {
- /// @addtogroup renderer
- /// @{
- /// Bloom passes.
- class Bloom : public RendererObject
- {
- public:
- Bloom(Renderer* r);
- ~Bloom();
- ANKI_USE_RESULT Error init(const ConfigSet& cfg)
- {
- ANKI_R_LOGI("Initializing bloom passes");
- Error err = initInternal(cfg);
- if(err)
- {
- ANKI_R_LOGE("Failed to initialize bloom passes");
- }
- return err;
- }
- /// Populate the rendergraph.
- void populateRenderGraph(RenderingContext& ctx);
- RenderTargetHandle getRt() const
- {
- return m_runCtx.m_upscaleRt;
- }
- F32 getThreshold() const
- {
- return m_exposure.m_threshold;
- }
- void setThreshold(F32 t)
- {
- m_exposure.m_threshold = t;
- }
- F32 getScale() const
- {
- return m_exposure.m_scale;
- }
- void setScale(F32 t)
- {
- m_exposure.m_scale = t;
- }
- private:
- static constexpr Format RT_PIXEL_FORMAT = Format::A2B10G10R10_UNORM_PACK32;
- const Array<U32, 3> m_workgroupSize = {16, 16, 1};
- class
- {
- public:
- ShaderProgramResourcePtr m_prog;
- ShaderProgramPtr m_grProg;
- F32 m_threshold = 10.0f; ///< How bright it is
- F32 m_scale = 1.0f;
- U32 m_width = 0;
- U32 m_height = 0;
- RenderTargetDescription m_rtDescr;
- } m_exposure;
- class
- {
- public:
- ImageResourcePtr m_lensDirtImage;
- ShaderProgramResourcePtr m_prog;
- ShaderProgramPtr m_grProg;
- U32 m_width = 0;
- U32 m_height = 0;
- RenderTargetDescription m_rtDescr;
- } m_upscale;
- class
- {
- public:
- RenderTargetHandle m_exposureRt;
- RenderTargetHandle m_upscaleRt;
- } m_runCtx;
- ANKI_USE_RESULT Error initExposure(const ConfigSet& cfg);
- ANKI_USE_RESULT Error initUpscale(const ConfigSet& cfg);
- ANKI_USE_RESULT Error initInternal(const ConfigSet& cfg)
- {
- ANKI_CHECK(initExposure(cfg));
- ANKI_CHECK(initUpscale(cfg));
- return Error::NONE;
- }
- void runExposure(RenderPassWorkContext& rgraphCtx);
- void runUpscaleAndSslf(RenderPassWorkContext& rgraphCtx);
- };
- /// @}
- } // end namespace anki
|