From 5992fa44ddb40ee8194e8168e7ba998221473f8e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 16 Sep 2024 02:04:23 +0200 Subject: [PATCH] Fix culling bug --- wadsrc/static/shaders/scene/comp_lighttiles.glsl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wadsrc/static/shaders/scene/comp_lighttiles.glsl b/wadsrc/static/shaders/scene/comp_lighttiles.glsl index 295907710..18734e47c 100644 --- a/wadsrc/static/shaders/scene/comp_lighttiles.glsl +++ b/wadsrc/static/shaders/scene/comp_lighttiles.glsl @@ -89,6 +89,9 @@ void main() bool isLightVisible(Tile tile, vec3 lightPos, float lightRadius) { + // Negative Z go into the screen, but zminmax is positive Z + lightPos.z = -lightPos.z; + // aabb/sphere test for the light vec3 e = max(tile.aabbMin - lightPos, 0.0f) + max(lightPos - tile.aabbMax, 0.0f); return dot(e, e) <= lightRadius * lightRadius;