Browse Source

Integratring some fixes for SSAORenderingPipeline
Adding node.getAnimationByName

David catuhe 10 năm trước cách đây
mục cha
commit
2b4acdec22

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 13 - 13
dist/preview release/babylon.core.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 896 - 894
dist/preview release/babylon.d.ts


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 14 - 14
dist/preview release/babylon.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 28 - 25
dist/preview release/babylon.max.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 14 - 14
dist/preview release/babylon.noworker.js


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

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

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

@@ -821,7 +821,7 @@
         // Skeleton
         // Skeleton
         if (parsedMesh.skeletonId > -1) {
         if (parsedMesh.skeletonId > -1) {
             mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
             mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
-            if (parsedMesh.numBoneInfluencers){
+            if (parsedMesh.numBoneInfluencers) {
                 mesh.numBoneInfluencers = 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.applyFog = true;
             this.computeBonesUsingShaders = true;
             this.computeBonesUsingShaders = true;
             this.scalingDeterminant = 1;
             this.scalingDeterminant = 1;
+            this.numBoneInfluencers = 4;
             this.useOctreeForRenderingSelection = true;
             this.useOctreeForRenderingSelection = true;
             this.useOctreeForPicking = true;
             this.useOctreeForPicking = true;
             this.useOctreeForCollisions = true;
             this.useOctreeForCollisions = true;

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

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

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

@@ -1334,28 +1334,18 @@ var BABYLON;
             var tempVector3 = BABYLON.Vector3.Zero();
             var tempVector3 = BABYLON.Vector3.Zero();
             var finalMatrix = new BABYLON.Matrix();
             var finalMatrix = new BABYLON.Matrix();
             var tempMatrix = new BABYLON.Matrix();
             var tempMatrix = new BABYLON.Matrix();
+            var matWeightIdx = 0;
             for (var index = 0; index < positionsData.length; index += 3) {
             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);
                 BABYLON.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
                 tempVector3.toArray(positionsData, index);
                 tempVector3.toArray(positionsData, index);
                 BABYLON.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
                 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,
                 zmax: zmax,
                 subdivisions: subdivisions,
                 subdivisions: subdivisions,
                 precision: precision,
                 precision: precision,
-                updatable: updatable               
+                updatable: updatable
             }
             }
 
 
             return MeshBuilder.CreateTiledGround(name, options, scene);
             return MeshBuilder.CreateTiledGround(name, options, scene);
@@ -1441,7 +1441,7 @@
                 height: height,
                 height: height,
                 subdivisions: subdivisions,
                 subdivisions: subdivisions,
                 minHeight: minHeight,
                 minHeight: minHeight,
-                maxHeight: maxHeight, 
+                maxHeight: maxHeight,
                 updatable: updatable,
                 updatable: updatable,
                 onReady: onReady
                 onReady: onReady
             };
             };
@@ -1459,7 +1459,7 @@
                 cap: cap,
                 cap: cap,
                 updatable: updatable,
                 updatable: updatable,
                 sideOrientation: sideOrientation,
                 sideOrientation: sideOrientation,
-                instance: instance        
+                instance: instance
             }
             }
             return MeshBuilder.CreateTube(name, options, scene);
             return MeshBuilder.CreateTube(name, options, scene);
         }
         }
@@ -1473,7 +1473,7 @@
             var options = {
             var options = {
                 position: position,
                 position: position,
                 normal: normal,
                 normal: normal,
-                size: size, 
+                size: size,
                 angle: angle
                 angle: angle
             }
             }
 
 
@@ -1564,13 +1564,13 @@
 
 
             var matWeightIdx = 0;
             var matWeightIdx = 0;
             for (var index = 0; index < positionsData.length; index += 3) {
             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];
                     var weight = matricesWeightsData[matWeightIdx + inf];
                     if (weight > 0) {
                     if (weight > 0) {
                         Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[matWeightIdx + inf] * 16, weight, tempMatrix);
                         Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[matWeightIdx + inf] * 16, weight, tempMatrix);
                         finalMatrix.addToSelf(tempMatrix);
                         finalMatrix.addToSelf(tempMatrix);
-                        
-                    }else break;           
+
+                    } else break;
                 }
                 }
                 matWeightIdx += this.numBoneInfluencers;
                 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;
             var combineRatio = ratio.combineRatio || ratio;
             this._originalColorPostProcess = new BABYLON.PassPostProcess("SSAOOriginalSceneColor", combineRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
             this._originalColorPostProcess = new BABYLON.PassPostProcess("SSAOOriginalSceneColor", combineRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
             this._createSSAOPostProcess(ssaoRatio);
             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);
             this._createSSAOCombinePostProcess(combineRatio);
             // Set up pipeline
             // Set up pipeline
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
@@ -147,7 +147,7 @@ var BABYLON;
                 if (_this._firstUpdate) {
                 if (_this._firstUpdate) {
                     effect.setArray3("sampleSphere", sampleSphere);
                     effect.setArray3("sampleSphere", sampleSphere);
                     effect.setFloat("samplesFactor", samplesFactor);
                     effect.setFloat("samplesFactor", samplesFactor);
-                    effect.setFloat("randTextureTiles", 4.0 / ratio);
+                    effect.setFloat("randTextureTiles", 4.0);
                     _this._firstUpdate = false;
                     _this._firstUpdate = false;
                 }
                 }
                 effect.setFloat("totalStrength", _this.totalStrength);
                 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._originalColorPostProcess = new PassPostProcess("SSAOOriginalSceneColor", combineRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
             this._createSSAOPostProcess(ssaoRatio);
             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);
             this._createSSAOCombinePostProcess(combineRatio);
 
 
             // Set up pipeline
             // Set up pipeline
@@ -172,7 +172,7 @@
                 if (this._firstUpdate) {
                 if (this._firstUpdate) {
                     effect.setArray3("sampleSphere", sampleSphere);
                     effect.setArray3("sampleSphere", sampleSphere);
                     effect.setFloat("samplesFactor", samplesFactor);
                     effect.setFloat("samplesFactor", samplesFactor);
-                    effect.setFloat("randTextureTiles", 4.0 / ratio);
+                    effect.setFloat("randTextureTiles", 4.0);
                     this._firstUpdate = false;
                     this._firstUpdate = false;
                 }
                 }
 
 

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

@@ -36,7 +36,7 @@ void main(void)
 {
 {
 	const float base = 0.2;
 	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;
 	float depth = texture2D(textureSampler, vUV).r;
 	vec3 position = vec3(vUV, depth);
 	vec3 position = vec3(vUV, depth);
 	vec3 normal = normalFromDepth(depth, vUV);
 	vec3 normal = normalFromDepth(depth, vUV);

+ 10 - 1
src/babylon.node.js

@@ -144,7 +144,7 @@ var BABYLON;
             return results;
             return results;
         };
         };
         Node.prototype._setReady = function (state) {
         Node.prototype._setReady = function (state) {
-            if (state == this._isReady) {
+            if (state === this._isReady) {
                 return;
                 return;
             }
             }
             if (!state) {
             if (!state) {
@@ -156,6 +156,15 @@ var BABYLON;
                 this.onReady(this);
                 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;
         return Node;
     })();
     })();
     BABYLON.Node = Node;
     BABYLON.Node = Node;

+ 13 - 1
src/babylon.node.ts

@@ -191,7 +191,7 @@
         }
         }
 
 
         public _setReady(state: boolean): void {
         public _setReady(state: boolean): void {
-            if (state == this._isReady) {
+            if (state === this._isReady) {
                 return;
                 return;
             }
             }
 
 
@@ -205,5 +205,17 @@
                 this.onReady(this);
                 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;
+        }
     }
     }
 } 
 }