Sfoglia il codice sorgente

Integratring some fixes for SSAORenderingPipeline
Adding node.getAnimationByName

David catuhe 9 anni fa
parent
commit
2b4acdec22

File diff suppressed because it is too large
+ 13 - 13
dist/preview release/babylon.core.js


File diff suppressed because it is too large
+ 896 - 894
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 14 - 14
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 28 - 25
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 14 - 14
dist/preview release/babylon.noworker.js


+ 3 - 0
src/Loading/Plugins/babylon.babylonFileLoader.js

@@ -657,6 +657,9 @@ var BABYLON;
             // Skeleton
             if (parsedMesh.skeletonId > -1) {
                 mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
+                if (parsedMesh.numBoneInfluencers) {
+                    mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
+                }
             }
             // Physics
             if (parsedMesh.physicsImpostor) {

+ 2 - 1
src/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -821,7 +821,7 @@
         // Skeleton
         if (parsedMesh.skeletonId > -1) {
             mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
-            if (parsedMesh.numBoneInfluencers){
+            if (parsedMesh.numBoneInfluencers) {
                 mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
             }
         }
@@ -1747,3 +1747,4 @@
     });
 }
 
+

+ 1 - 0
src/Mesh/babylon.abstractMesh.js

@@ -38,6 +38,7 @@ var BABYLON;
             this.applyFog = true;
             this.computeBonesUsingShaders = true;
             this.scalingDeterminant = 1;
+            this.numBoneInfluencers = 4;
             this.useOctreeForRenderingSelection = true;
             this.useOctreeForPicking = true;
             this.useOctreeForCollisions = true;

+ 1 - 1
src/Mesh/babylon.abstractMesh.ts

@@ -58,8 +58,8 @@
         public useVertexColors = true;
         public applyFog = true;
         public computeBonesUsingShaders = true;
-        public numBoneInfluencers = 4;
         public scalingDeterminant = 1;
+        public numBoneInfluencers = 4; 
 
         public useOctreeForRenderingSelection = true;
         public useOctreeForPicking = true;

+ 10 - 20
src/Mesh/babylon.mesh.js

@@ -1334,28 +1334,18 @@ var BABYLON;
             var tempVector3 = BABYLON.Vector3.Zero();
             var finalMatrix = new BABYLON.Matrix();
             var tempMatrix = new BABYLON.Matrix();
+            var matWeightIdx = 0;
             for (var index = 0; index < positionsData.length; index += 3) {
-                var index4 = (index / 3) * 4;
-                var matricesWeight0 = matricesWeightsData[index4];
-                var matricesWeight1 = matricesWeightsData[index4 + 1];
-                var matricesWeight2 = matricesWeightsData[index4 + 2];
-                var matricesWeight3 = matricesWeightsData[index4 + 3];
-                if (matricesWeight0 > 0) {
-                    BABYLON.Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[index4] * 16, matricesWeight0, tempMatrix);
-                    finalMatrix.addToSelf(tempMatrix);
-                }
-                if (matricesWeight1 > 0) {
-                    BABYLON.Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[index4 + 1] * 16, matricesWeight1, tempMatrix);
-                    finalMatrix.addToSelf(tempMatrix);
-                }
-                if (matricesWeight2 > 0) {
-                    BABYLON.Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[index4 + 2] * 16, matricesWeight2, tempMatrix);
-                    finalMatrix.addToSelf(tempMatrix);
-                }
-                if (matricesWeight3 > 0) {
-                    BABYLON.Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[index4 + 3] * 16, matricesWeight3, tempMatrix);
-                    finalMatrix.addToSelf(tempMatrix);
+                for (var inf = 0; inf < this.numBoneInfluencers; inf++) {
+                    var weight = matricesWeightsData[matWeightIdx + inf];
+                    if (weight > 0) {
+                        BABYLON.Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[matWeightIdx + inf] * 16, weight, tempMatrix);
+                        finalMatrix.addToSelf(tempMatrix);
+                    }
+                    else
+                        break;
                 }
+                matWeightIdx += this.numBoneInfluencers;
                 BABYLON.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
                 tempVector3.toArray(positionsData, index);
                 BABYLON.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);

+ 8 - 7
src/Mesh/babylon.mesh.ts

@@ -1429,7 +1429,7 @@
                 zmax: zmax,
                 subdivisions: subdivisions,
                 precision: precision,
-                updatable: updatable               
+                updatable: updatable
             }
 
             return MeshBuilder.CreateTiledGround(name, options, scene);
@@ -1441,7 +1441,7 @@
                 height: height,
                 subdivisions: subdivisions,
                 minHeight: minHeight,
-                maxHeight: maxHeight, 
+                maxHeight: maxHeight,
                 updatable: updatable,
                 onReady: onReady
             };
@@ -1459,7 +1459,7 @@
                 cap: cap,
                 updatable: updatable,
                 sideOrientation: sideOrientation,
-                instance: instance        
+                instance: instance
             }
             return MeshBuilder.CreateTube(name, options, scene);
         }
@@ -1473,7 +1473,7 @@
             var options = {
                 position: position,
                 normal: normal,
-                size: size, 
+                size: size,
                 angle: angle
             }
 
@@ -1564,13 +1564,13 @@
 
             var matWeightIdx = 0;
             for (var index = 0; index < positionsData.length; index += 3) {
-                for (var inf = 0; inf < this.numBoneInfluencers; inf++){
+                for (var inf = 0; inf < this.numBoneInfluencers; inf++) {
                     var weight = matricesWeightsData[matWeightIdx + inf];
                     if (weight > 0) {
                         Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[matWeightIdx + inf] * 16, weight, tempMatrix);
                         finalMatrix.addToSelf(tempMatrix);
-                        
-                    }else break;           
+
+                    } else break;
                 }
                 matWeightIdx += this.numBoneInfluencers;
 
@@ -1687,3 +1687,4 @@
 
 
 
+

+ 3 - 3
src/PostProcess/babylon.ssaoRenderingPipeline.js

@@ -76,8 +76,8 @@ var BABYLON;
             var combineRatio = ratio.combineRatio || ratio;
             this._originalColorPostProcess = new BABYLON.PassPostProcess("SSAOOriginalSceneColor", combineRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
             this._createSSAOPostProcess(ssaoRatio);
-            this._blurHPostProcess = new BABYLON.BlurPostProcess("SSAOBlurH", new BABYLON.Vector2(2.0, 0.0), 2.0, ssaoRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._blurVPostProcess = new BABYLON.BlurPostProcess("SSAOBlurV", new BABYLON.Vector2(0.0, 2.0), 2.0, ssaoRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._blurHPostProcess = new BABYLON.BlurPostProcess("SSAOBlurH", new BABYLON.Vector2(1.0, 0.0), 4.0, ssaoRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._blurVPostProcess = new BABYLON.BlurPostProcess("SSAOBlurV", new BABYLON.Vector2(0.0, 1.0), 4.0, ssaoRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
             this._createSSAOCombinePostProcess(combineRatio);
             // Set up pipeline
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
@@ -147,7 +147,7 @@ var BABYLON;
                 if (_this._firstUpdate) {
                     effect.setArray3("sampleSphere", sampleSphere);
                     effect.setFloat("samplesFactor", samplesFactor);
-                    effect.setFloat("randTextureTiles", 4.0 / ratio);
+                    effect.setFloat("randTextureTiles", 4.0);
                     _this._firstUpdate = false;
                 }
                 effect.setFloat("totalStrength", _this.totalStrength);

+ 3 - 3
src/PostProcess/babylon.ssaoRenderingPipeline.ts

@@ -89,8 +89,8 @@
 
             this._originalColorPostProcess = new PassPostProcess("SSAOOriginalSceneColor", combineRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
             this._createSSAOPostProcess(ssaoRatio);
-            this._blurHPostProcess = new BlurPostProcess("SSAOBlurH", new Vector2(2.0, 0.0), 2.0, ssaoRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._blurVPostProcess = new BlurPostProcess("SSAOBlurV", new Vector2(0.0, 2.0), 2.0, ssaoRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._blurHPostProcess = new BlurPostProcess("SSAOBlurH", new Vector2(1.0, 0.0), 4.0, ssaoRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._blurVPostProcess = new BlurPostProcess("SSAOBlurV", new Vector2(0.0, 1.0), 4.0, ssaoRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
             this._createSSAOCombinePostProcess(combineRatio);
 
             // Set up pipeline
@@ -172,7 +172,7 @@
                 if (this._firstUpdate) {
                     effect.setArray3("sampleSphere", sampleSphere);
                     effect.setFloat("samplesFactor", samplesFactor);
-                    effect.setFloat("randTextureTiles", 4.0 / ratio);
+                    effect.setFloat("randTextureTiles", 4.0);
                     this._firstUpdate = false;
                 }
 

+ 1 - 1
src/Shaders/ssao.fragment.fx

@@ -36,7 +36,7 @@ void main(void)
 {
 	const float base = 0.2;
 
-	vec3 random = texture2D(randomSampler, vUV * randTextureTiles).rgb;
+	vec3 random = normalize(texture2D(randomSampler, vUV * randTextureTiles).rgb);
 	float depth = texture2D(textureSampler, vUV).r;
 	vec3 position = vec3(vUV, depth);
 	vec3 normal = normalFromDepth(depth, vUV);

+ 10 - 1
src/babylon.node.js

@@ -144,7 +144,7 @@ var BABYLON;
             return results;
         };
         Node.prototype._setReady = function (state) {
-            if (state == this._isReady) {
+            if (state === this._isReady) {
                 return;
             }
             if (!state) {
@@ -156,6 +156,15 @@ var BABYLON;
                 this.onReady(this);
             }
         };
+        Node.prototype.getAnimationByName = function (name) {
+            for (var i = 0; i < this.animations.length; i++) {
+                var animation = this.animations[i];
+                if (animation.name === name) {
+                    return animation;
+                }
+            }
+            return null;
+        };
         return Node;
     })();
     BABYLON.Node = Node;

+ 13 - 1
src/babylon.node.ts

@@ -191,7 +191,7 @@
         }
 
         public _setReady(state: boolean): void {
-            if (state == this._isReady) {
+            if (state === this._isReady) {
                 return;
             }
 
@@ -205,5 +205,17 @@
                 this.onReady(this);
             }
         }
+
+        public getAnimationByName(name: string): Animation {
+            for (var i = 0; i < this.animations.length; i++) {
+                var animation = this.animations[i];
+
+                if (animation.name === name) {
+                    return animation;
+                }
+            }
+
+            return null;
+        }
     }
 }