Skip to content

Commit 5eaea5f

Browse files
committed
fix spherical harmonics baker format fallback and catch NaN early
1 parent e8ebcb4 commit 5eaea5f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

jme3-core/src/main/java/com/jme3/environment/baker/IBLGLEnvBakerLight.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ public void bakeSphericalHarmonicsCoefficients() {
104104
float remapMaxValue = 0;
105105
Format format = Format.RGBA32F;
106106
if (!renderManager.getRenderer().getCaps().contains(Caps.FloatColorBufferRGBA)) {
107-
LOG.warning("Float textures not supported, using RGB8 instead. This may cause accuracy issues.");
108-
format = renderManager.getRenderer().getBestColorTargetFormat(true, true, false, false);
109-
remapMaxValue = 0.05f;
107+
format = renderManager.getRenderer().getBestColorTargetFormat(true, true, true, false);
108+
if(!format.isFloatingPont()){
109+
LOG.warning("Float textures not supported, using RGB8 instead. This may cause accuracy issues.");
110+
remapMaxValue = 0.05f;
111+
}
110112
}
111113

112114
if (remapMaxValue > 0) {
@@ -170,6 +172,7 @@ else if (weightAccum != c.a) {
170172
for (int i = 0; i < NUM_SH_COEFFICIENT; ++i) {
171173
if (remapMaxValue > 0) shCoef[i].divideLocal(remapMaxValue);
172174
shCoef[i].multLocal(4.0f * FastMath.PI / weightAccum);
175+
assert Vector3f.isValidVector(shCoef[i]);
173176
}
174177
EnvMapUtils.prepareShCoefs(shCoef);
175178
img.dispose();

0 commit comments

Comments
 (0)