Skip to content

Commit 1315af8

Browse files
committed
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.
1 parent efd47c4 commit 1315af8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

jme3-core/src/main/java/com/jme3/math/FastMath.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,9 @@ public static short convertFloatToHalf(float flt) {
981981
return 0x7bff;
982982
} else if (flt < -65504f) {
983983
return (short) (0x7bff | 0x8000);
984-
} else if (flt > 0f && flt < 5.96046E-8f) {
984+
} else if (flt > 0f && flt < 3.054738E-5f) {
985985
return 0x0001;
986-
} else if (flt < 0f && flt > -5.96046E-8f) {
986+
} else if (flt < 0f && flt > -3.054738E-5f) {
987987
return (short) 0x8001;
988988
}
989989

0 commit comments

Comments
 (0)