From 900d19a41bc1886e7a809d99d6119b12235a4f0a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 20 Jul 2024 10:57:17 +0100 Subject: Initial commit of basic shadow depth map creation --- gfx/gl/shadowStenciller.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 gfx/gl/shadowStenciller.h (limited to 'gfx/gl/shadowStenciller.h') diff --git a/gfx/gl/shadowStenciller.h b/gfx/gl/shadowStenciller.h new file mode 100644 index 0000000..460fa68 --- /dev/null +++ b/gfx/gl/shadowStenciller.h @@ -0,0 +1,21 @@ +#pragma once + +#include "config/types.h" +#include "gfx/gl/program.h" +#include "gfx/models/mesh.h" +#include "glArrays.h" + +class ShadowStenciller { +public: + ShadowStenciller(); + + [[nodiscard]] + static glTexture createStencilTexture(GLsizei width, GLsizei height); + void renderStencil(const glTexture &, const MeshBase &, const RelativePosition3D & mins, + const RelativePosition3D & maxs) const; + +private: + glFrameBuffer fbo; + Program shadowCaster; + Program::UniformLocation viewProjectionLoc {shadowCaster, "viewProjection"}; +}; -- cgit v1.2.3 From 4ba67f34eac848e43bad2ccc4b5c09ac65dd7952 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 20 Jul 2024 12:55:15 +0100 Subject: Use mesh extents for shadow stencil extents --- gfx/gl/shadowStenciller.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gfx/gl/shadowStenciller.h') diff --git a/gfx/gl/shadowStenciller.h b/gfx/gl/shadowStenciller.h index 460fa68..5a22a7e 100644 --- a/gfx/gl/shadowStenciller.h +++ b/gfx/gl/shadowStenciller.h @@ -11,8 +11,7 @@ public: [[nodiscard]] static glTexture createStencilTexture(GLsizei width, GLsizei height); - void renderStencil(const glTexture &, const MeshBase &, const RelativePosition3D & mins, - const RelativePosition3D & maxs) const; + void renderStencil(const glTexture &, const MeshBase &) const; private: glFrameBuffer fbo; -- cgit v1.2.3 From f737aada2b7164683303beb3bb490c30a4949fb0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 21 Jul 2024 02:33:24 +0100 Subject: Use texture alpha in shadow stencil --- gfx/gl/shadowStenciller.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gfx/gl/shadowStenciller.h') diff --git a/gfx/gl/shadowStenciller.h b/gfx/gl/shadowStenciller.h index 5a22a7e..bf6d204 100644 --- a/gfx/gl/shadowStenciller.h +++ b/gfx/gl/shadowStenciller.h @@ -1,8 +1,8 @@ #pragma once -#include "config/types.h" #include "gfx/gl/program.h" #include "gfx/models/mesh.h" +#include "gfx/models/texture.h" #include "glArrays.h" class ShadowStenciller { @@ -11,7 +11,7 @@ public: [[nodiscard]] static glTexture createStencilTexture(GLsizei width, GLsizei height); - void renderStencil(const glTexture &, const MeshBase &) const; + void renderStencil(const glTexture &, const MeshBase &, const Texture::AnyPtr texture) const; private: glFrameBuffer fbo; -- cgit v1.2.3 From 172beac34e82c86f8c16b8a1be5fca9d7ccfc0d1 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 18 Aug 2024 16:14:29 +0100 Subject: Update asset stencils from shadow mapper --- gfx/gl/shadowStenciller.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gfx/gl/shadowStenciller.h') diff --git a/gfx/gl/shadowStenciller.h b/gfx/gl/shadowStenciller.h index bf6d204..87dc044 100644 --- a/gfx/gl/shadowStenciller.h +++ b/gfx/gl/shadowStenciller.h @@ -7,7 +7,7 @@ class ShadowStenciller { public: - ShadowStenciller(); + ShadowStenciller(const Direction3D & lightDir, const Direction3D & lightDirUp); [[nodiscard]] static glTexture createStencilTexture(GLsizei width, GLsizei height); @@ -16,5 +16,6 @@ public: private: glFrameBuffer fbo; Program shadowCaster; + glm::mat4 lightDirMat; Program::UniformLocation viewProjectionLoc {shadowCaster, "viewProjection"}; }; -- cgit v1.2.3 From dd452f3e9238be954c3ecd325ed11e97a50ec1c3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 19 Aug 2024 23:26:32 +0100 Subject: Persist a single ShadowStenciller within ShadowMapper --- gfx/gl/shadowStenciller.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gfx/gl/shadowStenciller.h') diff --git a/gfx/gl/shadowStenciller.h b/gfx/gl/shadowStenciller.h index 87dc044..009285c 100644 --- a/gfx/gl/shadowStenciller.h +++ b/gfx/gl/shadowStenciller.h @@ -7,15 +7,17 @@ class ShadowStenciller { public: - ShadowStenciller(const Direction3D & lightDir, const Direction3D & lightDirUp); + ShadowStenciller(); [[nodiscard]] static glTexture createStencilTexture(GLsizei width, GLsizei height); + void setLightDirection(const Direction3D & lightDir, const Direction3D & lightDirUp); void renderStencil(const glTexture &, const MeshBase &, const Texture::AnyPtr texture) const; private: glFrameBuffer fbo; Program shadowCaster; - glm::mat4 lightDirMat; Program::UniformLocation viewProjectionLoc {shadowCaster, "viewProjection"}; + + glm::mat4 lightDirMat {}; }; -- cgit v1.2.3 From 10e0fee323e6277ba73ee1fc148417882bc381c3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 26 Aug 2024 13:55:32 +0100 Subject: Add helper to test if a uniform was found --- gfx/gl/shadowStenciller.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gfx/gl/shadowStenciller.h') diff --git a/gfx/gl/shadowStenciller.h b/gfx/gl/shadowStenciller.h index 009285c..925f82a 100644 --- a/gfx/gl/shadowStenciller.h +++ b/gfx/gl/shadowStenciller.h @@ -17,7 +17,7 @@ public: private: glFrameBuffer fbo; Program shadowCaster; - Program::UniformLocation viewProjectionLoc {shadowCaster, "viewProjection"}; + Program::RequiredUniformLocation viewProjectionLoc {shadowCaster, "viewProjection"}; glm::mat4 lightDirMat {}; }; -- cgit v1.2.3 From 5ec74c35fb1f2524add7fd03ace78667f93edb2e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 7 Sep 2024 12:35:03 +0100 Subject: Populate all layers of shadow stencil with view from all around --- gfx/gl/shadowStenciller.h | 1 + 1 file changed, 1 insertion(+) (limited to 'gfx/gl/shadowStenciller.h') diff --git a/gfx/gl/shadowStenciller.h b/gfx/gl/shadowStenciller.h index 925f82a..2edb955 100644 --- a/gfx/gl/shadowStenciller.h +++ b/gfx/gl/shadowStenciller.h @@ -20,4 +20,5 @@ private: Program::RequiredUniformLocation viewProjectionLoc {shadowCaster, "viewProjection"}; glm::mat4 lightDirMat {}; + std::array viewProjections; }; -- cgit v1.2.3