Преглед на файлове

Fixed issue with shadows and alpha testing

David Catuhe преди 9 години
родител
ревизия
a3c851c0e9

Файловите разлики са ограничени, защото са твърде много
+ 16 - 16
dist/preview release/babylon.core.js


Файловите разлики са ограничени, защото са твърде много
+ 5937 - 5937
dist/preview release/babylon.d.ts


Файловите разлики са ограничени, защото са твърде много
+ 18 - 18
dist/preview release/babylon.js


+ 12 - 6
dist/preview release/babylon.max.js

@@ -4927,7 +4927,8 @@ var BABYLON;
                 }
             }
         };
-        Tools.DumpFramebuffer = function (width, height, engine, successCallback) {
+        Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType) {
+            if (mimeType === void 0) { mimeType = "image/png"; }
             // Read the contents of the framebuffer
             var numberOfChannelsByLine = width * 4;
             var halfHeight = height / 2;
@@ -4957,7 +4958,7 @@ var BABYLON;
             var castData = imageData.data;
             castData.set(data);
             context.putImageData(imageData, 0, 0);
-            var base64Image = screenshotCanvas.toDataURL();
+            var base64Image = screenshotCanvas.toDataURL(mimeType);
             if (successCallback) {
                 successCallback(base64Image);
             }
@@ -4983,7 +4984,8 @@ var BABYLON;
                 }
             }
         };
-        Tools.CreateScreenshot = function (engine, camera, size, successCallback) {
+        Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
+            if (mimeType === void 0) { mimeType = "image/png"; }
             var width;
             var height;
             //If a precision value is specified
@@ -5024,7 +5026,7 @@ var BABYLON;
             var texture = new BABYLON.RenderTargetTexture("screenShot", size, scene, false, false);
             texture.renderList = scene.meshes;
             texture.onAfterRenderObservable.add(function () {
-                Tools.DumpFramebuffer(width, height, engine, successCallback);
+                Tools.DumpFramebuffer(width, height, engine, successCallback, mimeType);
             });
             scene.incrementRenderId();
             scene.resetCachedMaterial();
@@ -11030,8 +11032,11 @@ var BABYLON;
                     defines.push("#define UV1");
                 }
                 if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind)) {
-                    attribs.push(BABYLON.VertexBuffer.UV2Kind);
-                    defines.push("#define UV2");
+                    var alphaTexture = material.getAlphaTestTexture();
+                    if (alphaTexture.coordinatesIndex === 1) {
+                        attribs.push(BABYLON.VertexBuffer.UV2Kind);
+                        defines.push("#define UV2");
+                    }
                 }
             }
             // Bones
@@ -41446,6 +41451,7 @@ var BABYLON;
             for (var _i = 0, _a = this._instanceDataParts; _i < _a.length; _i++) {
                 var part = _a[_i];
                 if (part) {
+                    part.dataBuffer.pack();
                     for (var _b = 0, _c = part.dataElements; _b < _c.length; _b++) {
                         var el = _c[_b];
                         minOff = Math.min(minOff, el.offset);

Файловите разлики са ограничени, защото са твърде много
+ 18 - 18
dist/preview release/babylon.noworker.js


+ 1 - 0
src/Canvas2d/babylon.renderablePrim2d.js

@@ -638,6 +638,7 @@ var BABYLON;
             for (var _i = 0, _a = this._instanceDataParts; _i < _a.length; _i++) {
                 var part = _a[_i];
                 if (part) {
+                    part.dataBuffer.pack();
                     for (var _b = 0, _c = part.dataElements; _b < _c.length; _b++) {
                         var el = _c[_b];
                         minOff = Math.min(minOff, el.offset);

+ 5 - 2
src/Lights/Shadows/babylon.shadowGenerator.js

@@ -264,8 +264,11 @@ var BABYLON;
                     defines.push("#define UV1");
                 }
                 if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind)) {
-                    attribs.push(BABYLON.VertexBuffer.UV2Kind);
-                    defines.push("#define UV2");
+                    var alphaTexture = material.getAlphaTestTexture();
+                    if (alphaTexture.coordinatesIndex === 1) {
+                        attribs.push(BABYLON.VertexBuffer.UV2Kind);
+                        defines.push("#define UV2");
+                    }
                 }
             }
             // Bones

+ 6 - 2
src/Lights/Shadows/babylon.shadowGenerator.ts

@@ -294,8 +294,12 @@
                     defines.push("#define UV1");
                 }
                 if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind)) {
-                    attribs.push(VertexBuffer.UV2Kind);
-                    defines.push("#define UV2");
+                    var alphaTexture = material.getAlphaTestTexture();
+
+                    if (alphaTexture.coordinatesIndex === 1) {
+                        attribs.push(VertexBuffer.UV2Kind);
+                        defines.push("#define UV2");
+                    }
                 }
             }
 

+ 6 - 4
src/Tools/babylon.tools.js

@@ -479,7 +479,8 @@ var BABYLON;
                 }
             }
         };
-        Tools.DumpFramebuffer = function (width, height, engine, successCallback) {
+        Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType) {
+            if (mimeType === void 0) { mimeType = "image/png"; }
             // Read the contents of the framebuffer
             var numberOfChannelsByLine = width * 4;
             var halfHeight = height / 2;
@@ -509,7 +510,7 @@ var BABYLON;
             var castData = imageData.data;
             castData.set(data);
             context.putImageData(imageData, 0, 0);
-            var base64Image = screenshotCanvas.toDataURL();
+            var base64Image = screenshotCanvas.toDataURL(mimeType);
             if (successCallback) {
                 successCallback(base64Image);
             }
@@ -535,7 +536,8 @@ var BABYLON;
                 }
             }
         };
-        Tools.CreateScreenshot = function (engine, camera, size, successCallback) {
+        Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
+            if (mimeType === void 0) { mimeType = "image/png"; }
             var width;
             var height;
             //If a precision value is specified
@@ -576,7 +578,7 @@ var BABYLON;
             var texture = new BABYLON.RenderTargetTexture("screenShot", size, scene, false, false);
             texture.renderList = scene.meshes;
             texture.onAfterRenderObservable.add(function () {
-                Tools.DumpFramebuffer(width, height, engine, successCallback);
+                Tools.DumpFramebuffer(width, height, engine, successCallback, mimeType);
             });
             scene.incrementRenderId();
             scene.resetCachedMaterial();

+ 15 - 16
src/Tools/babylon.tools.ts

@@ -188,10 +188,10 @@
             };
         }
 
-        public static Vector2ArrayFeeder(array: Array<Vector2>|Float32Array): (i) => Vector2 {
+        public static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i) => Vector2 {
             return (index: number) => {
                 let isFloatArray = ((<Float32Array>array).BYTES_PER_ELEMENT !== undefined);
-                let length = isFloatArray ? array.length / 2 : array.length; 
+                let length = isFloatArray ? array.length / 2 : array.length;
 
                 if (index >= length) {
                     return null;
@@ -200,13 +200,13 @@
                 if (isFloatArray) {
                     let fa = <Float32Array>array;
                     return new Vector2(fa[index * 2 + 0], fa[index * 2 + 1]);
-                } 
+                }
                 let a = <Array<Vector2>>array;
                 return a[index];
             };
         }
 
-        public static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias: Vector2 = null) : { minimum: Vector2; maximum: Vector2 } {
+        public static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias: Vector2 = null): { minimum: Vector2; maximum: Vector2 } {
             var minimum = new Vector2(Number.MAX_VALUE, Number.MAX_VALUE);
             var maximum = new Vector2(-Number.MAX_VALUE, -Number.MAX_VALUE);
 
@@ -982,8 +982,7 @@
          * @param array
          */
         public static arrayOrStringFeeder(array: any): (i) => number {
-            return (index: number) =>
-            {
+            return (index: number) => {
                 if (index >= array.length) {
                     return null;
                 }
@@ -1069,16 +1068,16 @@
 
         constructor() {
             this._startMonitoringTime = 0;
-            this._min                 = 0;
-            this._max                 = 0;
-            this._average             = 0;
-            this._lastSecAverage      = 0;
-            this._current             = 0;
-            this._totalValueCount     = 0;
-            this._totalAccumulated    = 0;
-            this._lastSecAccumulated  = 0;
-            this._lastSecTime         = 0;
-            this._lastSecValueCount   = 0;
+            this._min = 0;
+            this._max = 0;
+            this._average = 0;
+            this._lastSecAverage = 0;
+            this._current = 0;
+            this._totalValueCount = 0;
+            this._totalAccumulated = 0;
+            this._lastSecAccumulated = 0;
+            this._lastSecTime = 0;
+            this._lastSecValueCount = 0;
         }
 
         /**