#ifndef OPENMW_MWRENDER_LUMINANCECALCULATOR_H #define OPENMW_MWRENDER_LUMINANCECALCULATOR_H #include #include #include #include namespace Shader { class ShaderManager; } namespace MWRender { class PingPongCanvas; class LuminanceCalculator { public: LuminanceCalculator() = default; LuminanceCalculator(Shader::ShaderManager& shaderManager); void draw(const PingPongCanvas& canvas, osg::RenderInfo& renderInfo, osg::State& state, osg::GLExtensions* ext, size_t frameId); bool isEnabled() const { return mEnabled; } void enable() { mEnabled = true; } void disable() { mEnabled = false; } void dirty(int w, int h); osg::ref_ptr getLuminanceTexture(size_t frameId) const; private: void compile(); struct Container { osg::ref_ptr sceneLumFbo; osg::ref_ptr resolveSceneLumFbo; osg::ref_ptr resolveFbo; osg::ref_ptr luminanceProxyFbo; osg::ref_ptr mipmappedSceneLuminanceTex; osg::ref_ptr luminanceTex; osg::ref_ptr luminanceProxyTex; osg::ref_ptr sceneLumSS; osg::ref_ptr resolveSS; }; std::array mBuffers; osg::ref_ptr mLuminanceProgram; osg::ref_ptr mResolveProgram; bool mCompiled = false; bool mEnabled = false; int mWidth = 1; int mHeight = 1; osg::Vec2f mScale = osg::Vec2f(1, 1); }; } #endif