From b7b7cca992f50aeeafb5d0d6e773d9435fbe5755 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Fri, 20 Sep 2024 20:07:38 -0700 Subject: [PATCH] Happy as a clamp - Fix instances vanishing close to the edge of your screen --- .../assets/flywheel/flywheel/internal/indirect/cull.glsl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/cull.glsl b/common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/cull.glsl index 38724599f..395979d5c 100644 --- a/common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/cull.glsl +++ b/common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/cull.glsl @@ -100,6 +100,10 @@ bool _flw_isVisible(uint instanceIndex, uint modelIndex) { ivec4 bounds = ivec4(aabb * vec4(levelSizePair)); + // Clamp to the texture bounds. + // Since we're not going through a sampler out of bounds texel fetches will return 0. + bounds = clamp(bounds, ivec4(0), levelSizePair); + float depth01 = texelFetch(_flw_depthPyramid, bounds.xw, level).r; float depth11 = texelFetch(_flw_depthPyramid, bounds.zw, level).r; float depth10 = texelFetch(_flw_depthPyramid, bounds.zy, level).r;