From ffdaa93edf5eeaf9db7dc17e51554a77dd9d596d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 19 Nov 2022 15:04:30 +0000 Subject: Separate out the illumation of the scene --- ui/sceneRenderer.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'ui/sceneRenderer.h') diff --git a/ui/sceneRenderer.h b/ui/sceneRenderer.h index c06fa83..8b81d0c 100644 --- a/ui/sceneRenderer.h +++ b/ui/sceneRenderer.h @@ -9,9 +9,18 @@ class SceneRenderer { public: + class SceneProvider { + public: + virtual ~SceneProvider() = default; + virtual void content(const SceneShader &) const = 0; + virtual void environment(const SceneShader &, const SceneRenderer &) const; + }; + explicit SceneRenderer(glm::ivec2 size, GLuint output); - void render(std::function content) const; + void render(const SceneProvider &) const; + void setAmbientLight(const glm::vec3 & colour) const; + void setDirectionalLight(const glm::vec3 & colour, const glm::vec3 & direction) const; Camera camera; @@ -19,14 +28,26 @@ private: glm::ivec2 size; GLuint output; glFrameBuffer gBuffer; - glTexture gPosition, gNormal, gAlbedoSpec; + glTexture gPosition, gNormal, gAlbedoSpec, gIllumination; glRenderBuffer depth; class DeferredLightProgram : public Program { public: using Program::Program; using Program::use; }; + class DirectionalLightProgram : public Program { + public: + DirectionalLightProgram(); + using Program::use; + + void setDirectionalLight(const glm::vec3 &, const glm::vec3 &) const; + + private: + RequiredUniformLocation directionLoc, colourLoc; + }; + DeferredLightProgram lighting; + DirectionalLightProgram dirLight; glVertexArray displayVAO; glBuffer displayVBO; SceneShader shader; -- cgit v1.2.3