#pragma once #include "Shader.hpp" #include #include #define GLFW_INCLUDE_NONE #include #ifdef __APPLE__ #include #endif namespace renderer { class SSAORenderer { public: SSAORenderer(); ~SSAORenderer(); bool init( int width, int height, bool halfRes = true ); void resize( int width, int height ); void bindGBuffer(); void unbind(); void computeSSAO( const glm::mat4& proj, const glm::mat4& invProj, float radius, float bias, float power ); void blurSSAO(); unsigned int getSSAOTextureID() const; void bindSSAOTextureToUnit( int unit, renderer::Shader& shader, const std::string& uniformName = "ssao" ) const; renderer::Shader& getGBufferShader () { return mGBufferShader; } private: void initBuffers(); void initKernelAndNoise(); int mWidth; int mHeight; bool mHalfRes; GLuint mGBufferFBO; GLuint mGNormal; GLuint mGDepth; GLuint mSSAOFBO; GLuint mSSAOTexture; GLuint mSSAOBlurFBO; GLuint mSSAOBlurTexture; GLuint mNoiseTexture; GLuint mQuadVAO; GLuint mQuadVBO; std::vector mKernel; int mKernelSize; renderer::Shader mGBufferShader; renderer::Shader mSSAOShader; renderer::Shader mBlurShader; }; } // namespace renderer