Browse Source

Bug fix for rgbe/float/half buffers. Inconsistency in rgbe/half float/float fixed. (written by @spidersharma03, modified by @bhouston)

Ben Houston 9 years ago
parent
commit
818a453917

+ 2 - 2
examples/js/loaders/HDRCubeMapLoader.js

@@ -87,7 +87,7 @@ THREE.HDRCubeMapLoader.prototype.load = function(type, urls, onLoad, onProgress,
                         var g = texData.data[j+1]/255;
                         var b = texData.data[j+2]/255;
                         var e = texData.data[j+3]/255;
-                        var d = Math.pow(2.0, e*256.0 - 128.0);
+                        var d = Math.pow(2.0, e*255.0 - 128.0);
                         floatdata[j]   = r * d;
                         floatdata[j+1] = g * d;
                         floatdata[j+2] = b * d;
@@ -103,7 +103,7 @@ THREE.HDRCubeMapLoader.prototype.load = function(type, urls, onLoad, onProgress,
                         var g = texData.data[j+1]/255;
                         var b = texData.data[j+2]/255;
                         var e = texData.data[j+3]/255;
-                        var d = Math.pow(2.0, e*256.0 - 128.0);
+                        var d = Math.pow(2.0, e*255.0 - 128.0);
                         floatdata[j]   = toHalf(r * d);
                         floatdata[j+1] = toHalf(g * d);
                         floatdata[j+2] = toHalf(b * d);

+ 1 - 1
src/renderers/shaders/ShaderChunk/encodings.glsl

@@ -22,7 +22,7 @@ vec4 texelDecode( in vec4 encodedTexel, in int encoding ) {
   }
 
   if( encoding == ENCODING_RGBE ) {
-    return vec4( encodedTexel.xyz * exp2( encodedTexel.w*256.0 - 128.0 ), 1.0 );
+    return vec4( encodedTexel.xyz * exp2( encodedTexel.w*255.0 - 128.0 ), 1.0 );
   }
 
   // TODO, see here http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html