From aa75b018f3b97c72b57de68867417cbda51439c3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 3 Dec 2022 03:41:32 +0000 Subject: Initial commit of the shadow map generator and shadows render interface Lots of hard coding, buggy in places, far from great, but the basics work. --- gfx/gl/shadowMapper.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 gfx/gl/shadowMapper.h (limited to 'gfx/gl/shadowMapper.h') diff --git a/gfx/gl/shadowMapper.h b/gfx/gl/shadowMapper.h new file mode 100644 index 0000000..dcd0a02 --- /dev/null +++ b/gfx/gl/shadowMapper.h @@ -0,0 +1,46 @@ +#pragma once + +#include "lib/glArrays.h" +#include "program.h" +#include + +class SceneProvider; + +class ShadowMapper { +public: + ShadowMapper(const glm::ivec2 & size = {1024, 1024}); + + glm::mat4x4 update(const SceneProvider &, const glm::vec3 & direction) const; + + class FixedPoint : public Program { + public: + FixedPoint(); + void setViewProjection(const glm::mat4 &) const; + void use() const; + + private: + RequiredUniformLocation viewProjectionLoc; + }; + class DynamicPoint : public Program { + public: + DynamicPoint(); + void setViewProjection(const glm::mat4 &) const; + void use(const Location &) const; + + private: + RequiredUniformLocation viewProjectionLoc; + RequiredUniformLocation modelLoc; + }; + FixedPoint fixedPoint; + DynamicPoint dynamicPoint; + + operator GLuint() const + { + return depthMap; + } + +private: + glFrameBuffer depthMapFBO; + glTexture depthMap; + glm::ivec2 size; +}; -- cgit v1.2.3