Преглед изворни кода

Fix Color grading Arifacts

= пре 9 година
родитељ
комит
2e46741d1f
2 измењених фајлова са 7 додато и 9 уклоњено
  1. 7 5
      src/Materials/Textures/babylon.colorGradingTexture.ts
  2. 0 4
      src/babylon.engine.ts

+ 7 - 5
src/Materials/Textures/babylon.colorGradingTexture.ts

@@ -50,6 +50,7 @@ module BABYLON {
             this.isCube = false;
             this.isCube = false;
             this.wrapU = Texture.CLAMP_ADDRESSMODE;
             this.wrapU = Texture.CLAMP_ADDRESSMODE;
             this.wrapV = Texture.CLAMP_ADDRESSMODE;
             this.wrapV = Texture.CLAMP_ADDRESSMODE;
+            this.anisotropicFilteringLevel = 1;
             
             
             this._texture = this._getFromCache(url, true);
             this._texture = this._getFromCache(url, true);
 
 
@@ -77,7 +78,7 @@ module BABYLON {
 
 
             var mipLevels = 0;
             var mipLevels = 0;
             var floatArrayView: Float32Array = null;
             var floatArrayView: Float32Array = null;
-            var texture = this.getScene().getEngine().createRawTexture(null, 1, 1, BABYLON.Engine.TEXTUREFORMAT_RGB, false, false, Texture.BILINEAR_SAMPLINGMODE);
+            var texture = this.getScene().getEngine().createRawTexture(null, 1, 1, BABYLON.Engine.TEXTUREFORMAT_RGBA, false, false, Texture.BILINEAR_SAMPLINGMODE);
             this._texture = texture;
             this._texture = texture;
             
             
             var callback = (text: string) => {
             var callback = (text: string) => {
@@ -102,8 +103,8 @@ module BABYLON {
                     if (size === 0) {
                     if (size === 0) {
                         // Number of space + one
                         // Number of space + one
                         size = words.length;
                         size = words.length;
-                        data = new Uint8Array(size * size * size * 3); // volume texture of side size and rgb 8
-                        tempData = new Float32Array(size * size * size * 3);
+                        data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
+                        tempData = new Float32Array(size * size * size * 4);
                         continue;
                         continue;
                     }
                     }
                     
                     
@@ -117,11 +118,12 @@ module BABYLON {
                         maxColor = Math.max(g, maxColor);
                         maxColor = Math.max(g, maxColor);
                         maxColor = Math.max(b, maxColor);
                         maxColor = Math.max(b, maxColor);
                         
                         
-                        var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 3;
+                        var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
                         
                         
                         tempData[pixelStorageIndex + 0] = r;
                         tempData[pixelStorageIndex + 0] = r;
                         tempData[pixelStorageIndex + 1] = g;
                         tempData[pixelStorageIndex + 1] = g;
                         tempData[pixelStorageIndex + 2] = b;
                         tempData[pixelStorageIndex + 2] = b;
+                        tempData[pixelStorageIndex + 3] = 0;
                         
                         
                         pixelIndexSlice++;
                         pixelIndexSlice++;
                         if (pixelIndexSlice % size == 0) {
                         if (pixelIndexSlice % size == 0) {
@@ -141,7 +143,7 @@ module BABYLON {
                 }
                 }
                 
                 
                 this.getScene().getEngine().updateTextureSize(texture, size * size, size);
                 this.getScene().getEngine().updateTextureSize(texture, size * size, size);
-                this.getScene().getEngine().updateRawTexture(texture, data, BABYLON.Engine.TEXTUREFORMAT_RGB, false);
+                this.getScene().getEngine().updateRawTexture(texture, data, BABYLON.Engine.TEXTUREFORMAT_RGBA, false);
             }
             }
 
 
             Tools.LoadFile(this.url, callback);
             Tools.LoadFile(this.url, callback);

+ 0 - 4
src/babylon.engine.ts

@@ -1535,10 +1535,6 @@
             var internalFormat = this._getInternalFormat(format);
             var internalFormat = this._getInternalFormat(format);
             this._gl.bindTexture(this._gl.TEXTURE_2D, texture);
             this._gl.bindTexture(this._gl.TEXTURE_2D, texture);
             this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
             this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
-            
-            if (texture._width % 4 !== 0) {
-                this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
-            } 
 
 
             if (compression) {
             if (compression) {
                 this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture._width, texture._height, 0, data);
                 this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture._width, texture._height, 0, data);