summaryrefslogtreecommitdiff
path: root/game/scenary/foliage.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-09-23 20:12:48 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-09-23 20:12:48 +0100
commitdbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c (patch)
tree0a880b2d14ac152014649d32088b73f17bf77297 /game/scenary/foliage.cpp
parentMerge branch 'sunpos' (diff)
parentPopulate all layers of shadow stencil with view from all around (diff)
downloadilt-dbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c.tar.bz2
ilt-dbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c.tar.xz
ilt-dbbfd39eef3b4d063ab7cdeb8d139b1bc11ba72c.zip
Psycho-rebased branch billboard-shadows on top of main
Diffstat (limited to 'game/scenary/foliage.cpp')
-rw-r--r--game/scenary/foliage.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp
index 73d285f..1e7424e 100644
--- a/game/scenary/foliage.cpp
+++ b/game/scenary/foliage.cpp
@@ -3,7 +3,6 @@
#include "gfx/gl/shadowMapper.h"
#include "gfx/gl/vertexArrayObject.h"
#include "gfx/models/texture.h"
-#include "location.h"
bool
Foliage::persist(Persistence::PersistenceStore & store)
@@ -17,6 +16,17 @@ Foliage::postLoad()
texture = getTexture();
bodyMesh->configureVAO(instanceVAO)
.addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(instances.bufferName(), 1);
+ VertexArrayObject {instancePointVAO}.addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(
+ instances.bufferName());
+}
+
+void
+Foliage::updateStencil(const ShadowStenciller & ss) const
+{
+ if (instances.size() > 0) {
+ ss.renderStencil(shadowStencil, *bodyMesh, texture);
+ Texture::saveDepth(shadowStencil, std::format("/tmp/stencil-{}.tga", id).c_str());
+ }
}
void
@@ -35,10 +45,12 @@ void
Foliage::shadows(const ShadowMapper & mapper) const
{
if (const auto count = instances.size()) {
- mapper.dynamicPointInstWithTextures.use();
- if (texture) {
- texture->bind(GL_TEXTURE3);
- }
- bodyMesh->DrawInstanced(instanceVAO, static_cast<GLsizei>(count));
+ const auto dimensions = bodyMesh->getDimensions();
+ mapper.stencilShadowProgram.use(dimensions.centre, dimensions.size);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D_ARRAY, shadowStencil);
+ glBindVertexArray(instancePointVAO);
+ glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(count));
+ glBindVertexArray(0);
}
}