From 615727774b643ebef3f076ee8907f7c78a1def9f Mon Sep 17 00:00:00 2001 From: hkitzmiller Date: Sun, 30 Nov 2025 22:48:00 -0500 Subject: [PATCH] Fix PointLight infinite radius shader overflow(#2566) Clamps infinite, negative, or Not a Number radius to Float.MAX_VALUE / 4f to prevent type overflow in shaders, as discussed in #2566. --- jme3-core/src/main/java/com/jme3/light/PointLight.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/light/PointLight.java b/jme3-core/src/main/java/com/jme3/light/PointLight.java index 440a45a740..a215409148 100644 --- a/jme3-core/src/main/java/com/jme3/light/PointLight.java +++ b/jme3-core/src/main/java/com/jme3/light/PointLight.java @@ -165,11 +165,11 @@ public final void setRadius(float radius) { if (radius < 0) { throw new IllegalArgumentException("Light radius cannot be negative"); } - - if (radius == Float.POSITIVE_INFINITY) { - radius = Float.MAX_VALUE; + + // Fix #2566 - Prevent shader overflow with infinite or invalid radius + if (radius == Float.POSITIVE_INFINITY || radius < 0f || Float.isNaN(radius)) { + radius = Float.MAX_VALUE / 4f; // Safe large value, avoids overflow in shaders } - this.radius = radius; if (radius != 0f) { this.invRadius = 1f / radius;