From 425add81fc8718f1ac4fde48a71344cd332d5a58 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 7 Jul 2024 20:10:24 +0100 Subject: Add shadow shader which takes into account texture transparency --- gfx/gl/shadowMapper.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'gfx/gl/shadowMapper.cpp') 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 #include #include -#include #include 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 {&landmess, &dynamicPoint, &dynamicPointInst}) { + for (const auto p : std::initializer_list { + &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 viewProjection, const GlobalPosition3D viewPoint) const -- cgit v1.2.3