From b992bc4902feb22666407067ece3fb4acbcb8d6a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 11 Mar 2025 00:56:37 +0000 Subject: Cull terrain meshes from render that don't cast a shadow into the frustum --- game/terrain.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'game/terrain.cpp') diff --git a/game/terrain.cpp b/game/terrain.cpp index e9e9463..d3c1d1a 100644 --- a/game/terrain.cpp +++ b/game/terrain.cpp @@ -128,12 +128,14 @@ Terrain::render(const SceneShader & shader, const Frustum & frustum) const } void -Terrain::shadows(const ShadowMapper & shadowMapper, const Frustum &) const +Terrain::shadows(const ShadowMapper & shadowMapper, const Frustum & frustum) const { shadowMapper.landmess.use(); for (const auto & [surface, sab] : meshes) { - glBindVertexArray(sab.vertexArray); - glDrawElements(GL_TRIANGLES, sab.count, GL_UNSIGNED_INT, nullptr); + if (frustum.shadedBy(sab.aabb)) { + glBindVertexArray(sab.vertexArray); + glDrawElements(GL_TRIANGLES, sab.count, GL_UNSIGNED_INT, nullptr); + } } glBindVertexArray(0); } -- cgit v1.2.3