diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /apps/openmb/renderer/SSAORenderer.hpp | |
Diffstat (limited to 'apps/openmb/renderer/SSAORenderer.hpp')
| -rw-r--r-- | apps/openmb/renderer/SSAORenderer.hpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/apps/openmb/renderer/SSAORenderer.hpp b/apps/openmb/renderer/SSAORenderer.hpp new file mode 100644 index 0000000..3075252 --- /dev/null +++ b/apps/openmb/renderer/SSAORenderer.hpp @@ -0,0 +1,64 @@ +#pragma once + +#include "Shader.hpp" +#include <glm/glm.hpp> +#include <vector> + +#define GLFW_INCLUDE_NONE +#include <GLFW/glfw3.h> +#ifdef __APPLE__ +#include <OpenGL/gl3.h> +#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<glm::vec3> mKernel; + int mKernelSize; + + renderer::Shader mGBufferShader; + renderer::Shader mSSAOShader; + renderer::Shader mBlurShader; +}; + +} // namespace renderer |