From 1315af8d52adb5a113c4690f5c81b44f7f666cc9 Mon Sep 17 00:00:00 2001 From: Nehon Date: Fri, 4 Nov 2016 20:08:44 +0100 Subject: [PATCH] Changed the minimum value of a float when converting it to half float. It was 5.96046E-8f and it's now 3.054738E-5f. This values seems to be the lowest one before 0 when converting back half to float. This issue has been revealed in this post https://hub.jmonkeyengine.org/t/pbr-nan-to-half-conversion-errors/37219 The bad minimum was causing erratic data being wrote to the texture when the value was very close to 0, and causing the glitches and even crashes when color values were given as Float.Infinity or Float.NaN. --- jme3-core/src/main/java/com/jme3/math/FastMath.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/math/FastMath.java b/jme3-core/src/main/java/com/jme3/math/FastMath.java index 5ca65bb7f..c1c3fa8a9 100644 --- a/jme3-core/src/main/java/com/jme3/math/FastMath.java +++ b/jme3-core/src/main/java/com/jme3/math/FastMath.java @@ -981,9 +981,9 @@ final public class FastMath { return 0x7bff; } else if (flt < -65504f) { return (short) (0x7bff | 0x8000); - } else if (flt > 0f && flt < 5.96046E-8f) { + } else if (flt > 0f && flt < 3.054738E-5f) { return 0x0001; - } else if (flt < 0f && flt > -5.96046E-8f) { + } else if (flt < 0f && flt > -3.054738E-5f) { return (short) 0x8001; }