diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-07-07 20:10:24 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-07-07 20:10:24 +0100 |
commit | 425add81fc8718f1ac4fde48a71344cd332d5a58 (patch) | |
tree | 7f4bcbd89342b07d2faee1eb00f3f9b804ed5ac2 /gfx/gl/shadowMapper.cpp | |
parent | Merge branch 'imgui' (diff) | |
download | ilt-425add81fc8718f1ac4fde48a71344cd332d5a58.tar.bz2 ilt-425add81fc8718f1ac4fde48a71344cd332d5a58.tar.xz ilt-425add81fc8718f1ac4fde48a71344cd332d5a58.zip |
Add shadow shader which takes into account texture transparency
Diffstat (limited to 'gfx/gl/shadowMapper.cpp')
-rw-r--r-- | gfx/gl/shadowMapper.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index 206e4a7..c537314 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -1,9 +1,12 @@ #include "shadowMapper.h" #include "camera.h" #include "collections.h" +#include "gfx/gl/shaders/fs-shadowDynamicPointInstWithTextures.h" #include "gfx/gl/shaders/gs-commonShadowPoint.h" +#include "gfx/gl/shaders/gs-shadowDynamicPointInstWithTextures.h" #include "gfx/gl/shaders/vs-shadowDynamicPoint.h" #include "gfx/gl/shaders/vs-shadowDynamicPointInst.h" +#include "gfx/gl/shaders/vs-shadowDynamicPointInstWithTextures.h" #include "gfx/gl/shaders/vs-shadowLandmass.h" #include "gl_traits.h" #include "location.h" @@ -14,11 +17,13 @@ #include <glm/gtc/type_ptr.hpp> #include <glm/gtx/transform.hpp> #include <glm/matrix.hpp> -#include <tuple> #include <vector> ShadowMapper::ShadowMapper(const TextureAbsCoord & s) : - landmess {shadowLandmass_vs}, dynamicPointInst {shadowDynamicPointInst_vs}, size {s} + landmess {shadowLandmass_vs}, dynamicPointInst {shadowDynamicPointInst_vs}, + dynamicPointInstWithTextures {shadowDynamicPointInstWithTextures_vs, shadowDynamicPointInstWithTextures_gs, + shadowDynamicPointInstWithTextures_fs}, + size {s} { glBindTexture(GL_TEXTURE_2D_ARRAY, depthMap); glTexImage3D( @@ -92,7 +97,8 @@ ShadowMapper::update(const SceneProvider & scene, const Direction3D & dir, const return lightProjection * lightViewDir; }); - for (const auto p : std::initializer_list<const ShadowProgram *> {&landmess, &dynamicPoint, &dynamicPointInst}) { + for (const auto p : std::initializer_list<const ShadowProgram *> { + &landmess, &dynamicPoint, &dynamicPointInst, &dynamicPointInstWithTextures}) { p->setView(out, lightViewPoint); } scene.shadows(*this); @@ -108,6 +114,12 @@ ShadowMapper::ShadowProgram::ShadowProgram(const Shader & vs) : { } +ShadowMapper::ShadowProgram::ShadowProgram(const Shader & vs, const Shader & gs, const Shader & fs) : + Program {vs, gs, fs}, viewProjectionLoc {*this, "viewProjection"}, viewProjectionsLoc {*this, "viewProjections"}, + viewPointLoc {*this, "viewPoint"} +{ +} + void ShadowMapper::ShadowProgram::setView( const std::span<const glm::mat4> viewProjection, const GlobalPosition3D viewPoint) const |