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 --- game/scenary/foliage.cpp | 13 +++++++++---- game/scenary/foliage.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'game/scenary') diff --git a/game/scenary/foliage.cpp b/game/scenary/foliage.cpp index ba1b37e..13d2f3b 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,9 +16,15 @@ Foliage::postLoad() texture = getTexture(); bodyMesh->configureVAO(instanceVAO) .addAttribs(instances.bufferName(), 1); - ShadowStenciller ss; - ss.renderStencil(shadowStencil, *bodyMesh, texture); - Texture::saveDepth(shadowStencil, std::format("/tmp/stencil-{}.tga", id).c_str()); +} + +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 diff --git a/game/scenary/foliage.h b/game/scenary/foliage.h index 5367d44..fa6c63b 100644 --- a/game/scenary/foliage.h +++ b/game/scenary/foliage.h @@ -20,6 +20,7 @@ public: mutable InstanceVertices instances; void render(const SceneShader &) const override; void shadows(const ShadowMapper &) const override; + void updateStencil(const ShadowStenciller &) const override; glTexture shadowStencil = ShadowStenciller::createStencilTexture(256, 256); protected: -- cgit v1.2.3