diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-22 01:01:02 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-22 01:01:02 +0100 |
commit | 9edf8711471db08427c5441ed37b6dfe3dd7f3b4 (patch) | |
tree | 4356058e9fd85e44c4404c5db8d5d3322a64aa29 /game/scenary/foliage.cpp | |
parent | Bump to CTRE to v3.9.0-1-gacb2f4d to fix compilation with clang 19 (diff) | |
parent | Further template maths functions (diff) | |
download | ilt-9edf8711471db08427c5441ed37b6dfe3dd7f3b4.tar.bz2 ilt-9edf8711471db08427c5441ed37b6dfe3dd7f3b4.tar.xz ilt-9edf8711471db08427c5441ed37b6dfe3dd7f3b4.zip |
Merge branch 'billboard-shadows'
Diffstat (limited to 'game/scenary/foliage.cpp')
-rw-r--r-- | game/scenary/foliage.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp index 73d285f..a0ec576 100644 --- a/game/scenary/foliage.cpp +++ b/game/scenary/foliage.cpp @@ -2,8 +2,6 @@ #include "gfx/gl/sceneShader.h" #include "gfx/gl/shadowMapper.h" #include "gfx/gl/vertexArrayObject.h" -#include "gfx/models/texture.h" -#include "location.h" bool Foliage::persist(Persistence::PersistenceStore & store) @@ -16,7 +14,18 @@ Foliage::postLoad() { texture = getTexture(); bodyMesh->configureVAO(instanceVAO) - .addAttribs<LocationVertex, &LocationVertex::first, &LocationVertex::second>(instances.bufferName(), 1); + .addAttribs<LocationVertex, &LocationVertex::rotation, &LocationVertex::position>( + instances.bufferName(), 1); + VertexArrayObject {instancePointVAO}.addAttribs<LocationVertex, &LocationVertex::position, &LocationVertex::yaw>( + instances.bufferName()); +} + +void +Foliage::updateStencil(const ShadowStenciller & ss) const +{ + if (instances.size() > 0) { + ss.renderStencil(shadowStencil, *bodyMesh, texture); + } } void @@ -35,10 +44,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); } } |