Просмотр исходного кода

Adding bones and fog as shared resources

David Catuhe 9 лет назад
Родитель
Сommit
15844401a9

Разница между файлами не показана из-за своего большого размера
+ 7 - 7
dist/preview release/babylon.core.js


Разница между файлами не показана из-за своего большого размера
+ 2477 - 2475
dist/preview release/babylon.d.ts


Разница между файлами не показана из-за своего большого размера
+ 14 - 14
dist/preview release/babylon.js


+ 15 - 9
dist/preview release/babylon.max.js

@@ -19860,7 +19860,7 @@ var BABYLON;
             }
             }
             return needNormals;
             return needNormals;
         };
         };
-        StandardMaterial.BindLightShadow = function (light, scene, mesh, lightIndex, effect, defines, depthValuesAlreadySet) {
+        StandardMaterial.BindLightShadow = function (light, scene, mesh, lightIndex, effect, depthValuesAlreadySet) {
             var shadowGenerator = light.getShadowGenerator();
             var shadowGenerator = light.getShadowGenerator();
             if (mesh.receiveShadows && shadowGenerator) {
             if (mesh.receiveShadows && shadowGenerator) {
                 if (!light.needCube()) {
                 if (!light.needCube()) {
@@ -19912,7 +19912,7 @@ var BABYLON;
                 }
                 }
                 // Shadows
                 // Shadows
                 if (scene.shadowsEnabled) {
                 if (scene.shadowsEnabled) {
-                    depthValuesAlreadySet = this.BindLightShadow(light, scene, mesh, lightIndex, effect, defines, depthValuesAlreadySet);
+                    depthValuesAlreadySet = this.BindLightShadow(light, scene, mesh, lightIndex, effect, depthValuesAlreadySet);
                 }
                 }
                 lightIndex++;
                 lightIndex++;
                 if (lightIndex === maxSimultaneousLights)
                 if (lightIndex === maxSimultaneousLights)
@@ -20296,9 +20296,7 @@ var BABYLON;
             // Matrices        
             // Matrices        
             this.bindOnlyWorldMatrix(world);
             this.bindOnlyWorldMatrix(world);
             // Bones
             // Bones
-            if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
-                this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
-            }
+            StandardMaterial.ApplyBonesParameters(mesh, this._effect);
             if (scene.getCachedMaterial() !== this) {
             if (scene.getCachedMaterial() !== this) {
                 this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
                 this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
                 if (StandardMaterial.FresnelEnabled) {
                 if (StandardMaterial.FresnelEnabled) {
@@ -20415,10 +20413,7 @@ var BABYLON;
                     this._effect.setMatrix("view", scene.getViewMatrix());
                     this._effect.setMatrix("view", scene.getViewMatrix());
                 }
                 }
                 // Fog
                 // Fog
-                if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
-                    this._effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
-                    this._effect.setColor3("vFogColor", scene.fogColor);
-                }
+                StandardMaterial.ApplyFogParameters(scene, mesh, this._effect);
                 // Log. depth
                 // Log. depth
                 if (this._defines.LOGARITHMICDEPTH) {
                 if (this._defines.LOGARITHMICDEPTH) {
                     this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
                     this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
@@ -20426,6 +20421,17 @@ var BABYLON;
             }
             }
             _super.prototype.bind.call(this, world, mesh);
             _super.prototype.bind.call(this, world, mesh);
         };
         };
+        StandardMaterial.ApplyFogParameters = function (scene, mesh, effect) {
+            if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+                effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
+                effect.setColor3("vFogColor", scene.fogColor);
+            }
+        };
+        StandardMaterial.ApplyBonesParameters = function (mesh, effect) {
+            if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
+                effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
+            }
+        };
         StandardMaterial.prototype.getAnimatables = function () {
         StandardMaterial.prototype.getAnimatables = function () {
             var results = [];
             var results = [];
             if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
             if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {

Разница между файлами не показана из-за своего большого размера
+ 14 - 14
dist/preview release/babylon.noworker.js


+ 2 - 4
materialsLibrary/dist/babylon.pbrMaterial.js

@@ -242,7 +242,7 @@ var BABYLON;
                 }
                 }
                 // Shadows
                 // Shadows
                 if (scene.shadowsEnabled) {
                 if (scene.shadowsEnabled) {
-                    depthValuesAlreadySet = BABYLON.StandardMaterial.BindLightShadow(light, scene, mesh, lightIndex, effect, defines, depthValuesAlreadySet);
+                    depthValuesAlreadySet = BABYLON.StandardMaterial.BindLightShadow(light, scene, mesh, lightIndex, effect, depthValuesAlreadySet);
                 }
                 }
                 lightIndex++;
                 lightIndex++;
                 if (lightIndex === maxSimultaneousLights)
                 if (lightIndex === maxSimultaneousLights)
@@ -637,9 +637,7 @@ var BABYLON;
             // Matrices        
             // Matrices        
             this.bindOnlyWorldMatrix(world);
             this.bindOnlyWorldMatrix(world);
             // Bones
             // Bones
-            if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
-                this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
-            }
+            BABYLON.StandardMaterial.ApplyBonesParameters(mesh, this._effect);
             if (this._myScene.getCachedMaterial() !== this) {
             if (this._myScene.getCachedMaterial() !== this) {
                 this._effect.setMatrix("viewProjection", this._myScene.getTransformMatrix());
                 this._effect.setMatrix("viewProjection", this._myScene.getTransformMatrix());
                 if (BABYLON.StandardMaterial.FresnelEnabled) {
                 if (BABYLON.StandardMaterial.FresnelEnabled) {

Разница между файлами не показана из-за своего большого размера
+ 2 - 2
materialsLibrary/dist/babylon.pbrMaterial.min.js


+ 2 - 7
materialsLibrary/dist/babylon.simpleMaterial.js

@@ -264,9 +264,7 @@ var BABYLON;
             this.bindOnlyWorldMatrix(world);
             this.bindOnlyWorldMatrix(world);
             this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
             this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
             // Bones
             // Bones
-            if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
-                this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
-            }
+            BABYLON.StandardMaterial.ApplyBonesParameters(mesh, this._effect);
             if (scene.getCachedMaterial() !== this) {
             if (scene.getCachedMaterial() !== this) {
                 // Textures        
                 // Textures        
                 if (this.diffuseTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
                 if (this.diffuseTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
@@ -295,10 +293,7 @@ var BABYLON;
                 this._effect.setMatrix("view", scene.getViewMatrix());
                 this._effect.setMatrix("view", scene.getViewMatrix());
             }
             }
             // Fog
             // Fog
-            if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
-                this._effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
-                this._effect.setColor3("vFogColor", scene.fogColor);
-            }
+            BABYLON.StandardMaterial.ApplyFogParameters(scene, mesh, this._effect);
             _super.prototype.bind.call(this, world, mesh);
             _super.prototype.bind.call(this, world, mesh);
         };
         };
         SimpleMaterial.prototype.getAnimatables = function () {
         SimpleMaterial.prototype.getAnimatables = function () {

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
materialsLibrary/dist/babylon.simpleMaterial.min.js


+ 2 - 4
materialsLibrary/materials/pbr/babylon.pbrMaterial.ts

@@ -291,7 +291,7 @@ module BABYLON {
 
 
                 // Shadows
                 // Shadows
                 if (scene.shadowsEnabled) {
                 if (scene.shadowsEnabled) {
-                    depthValuesAlreadySet = StandardMaterial.BindLightShadow(light, scene, mesh, lightIndex, effect, defines, depthValuesAlreadySet);
+                    depthValuesAlreadySet = StandardMaterial.BindLightShadow(light, scene, mesh, lightIndex, effect, depthValuesAlreadySet);
                 }
                 }
 
 
                 lightIndex++;
                 lightIndex++;
@@ -768,9 +768,7 @@ module BABYLON {
             this.bindOnlyWorldMatrix(world);
             this.bindOnlyWorldMatrix(world);
 
 
             // Bones
             // Bones
-            if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
-                this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
-            }
+            StandardMaterial.ApplyBonesParameters(mesh, this._effect);
 
 
             if (this._myScene.getCachedMaterial() !== (<BABYLON.Material>this)) {
             if (this._myScene.getCachedMaterial() !== (<BABYLON.Material>this)) {
                 this._effect.setMatrix("viewProjection", this._myScene.getTransformMatrix());
                 this._effect.setMatrix("viewProjection", this._myScene.getTransformMatrix());

+ 2 - 7
materialsLibrary/materials/simple/babylon.simpleMaterial.ts

@@ -319,9 +319,7 @@ module BABYLON {
             this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
             this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
 
 
             // Bones
             // Bones
-            if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
-                this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
-            }
+            StandardMaterial.ApplyBonesParameters(mesh, this._effect);
 
 
             if (scene.getCachedMaterial() !== this) {
             if (scene.getCachedMaterial() !== this) {
                 // Textures        
                 // Textures        
@@ -358,10 +356,7 @@ module BABYLON {
             }
             }
 
 
             // Fog
             // Fog
-            if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
-                this._effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
-                this._effect.setColor3("vFogColor", scene.fogColor);
-            }
+            StandardMaterial.ApplyFogParameters(scene, mesh, this._effect);
 
 
             super.bind(world, mesh);
             super.bind(world, mesh);
         }
         }

+ 15 - 9
materialsLibrary/test/refs/babylon.max.js

@@ -19860,7 +19860,7 @@ var BABYLON;
             }
             }
             return needNormals;
             return needNormals;
         };
         };
-        StandardMaterial.BindLightShadow = function (light, scene, mesh, lightIndex, effect, defines, depthValuesAlreadySet) {
+        StandardMaterial.BindLightShadow = function (light, scene, mesh, lightIndex, effect, depthValuesAlreadySet) {
             var shadowGenerator = light.getShadowGenerator();
             var shadowGenerator = light.getShadowGenerator();
             if (mesh.receiveShadows && shadowGenerator) {
             if (mesh.receiveShadows && shadowGenerator) {
                 if (!light.needCube()) {
                 if (!light.needCube()) {
@@ -19912,7 +19912,7 @@ var BABYLON;
                 }
                 }
                 // Shadows
                 // Shadows
                 if (scene.shadowsEnabled) {
                 if (scene.shadowsEnabled) {
-                    depthValuesAlreadySet = this.BindLightShadow(light, scene, mesh, lightIndex, effect, defines, depthValuesAlreadySet);
+                    depthValuesAlreadySet = this.BindLightShadow(light, scene, mesh, lightIndex, effect, depthValuesAlreadySet);
                 }
                 }
                 lightIndex++;
                 lightIndex++;
                 if (lightIndex === maxSimultaneousLights)
                 if (lightIndex === maxSimultaneousLights)
@@ -20296,9 +20296,7 @@ var BABYLON;
             // Matrices        
             // Matrices        
             this.bindOnlyWorldMatrix(world);
             this.bindOnlyWorldMatrix(world);
             // Bones
             // Bones
-            if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
-                this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
-            }
+            StandardMaterial.ApplyBonesParameters(mesh, this._effect);
             if (scene.getCachedMaterial() !== this) {
             if (scene.getCachedMaterial() !== this) {
                 this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
                 this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
                 if (StandardMaterial.FresnelEnabled) {
                 if (StandardMaterial.FresnelEnabled) {
@@ -20415,10 +20413,7 @@ var BABYLON;
                     this._effect.setMatrix("view", scene.getViewMatrix());
                     this._effect.setMatrix("view", scene.getViewMatrix());
                 }
                 }
                 // Fog
                 // Fog
-                if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
-                    this._effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
-                    this._effect.setColor3("vFogColor", scene.fogColor);
-                }
+                StandardMaterial.ApplyFogParameters(scene, mesh, this._effect);
                 // Log. depth
                 // Log. depth
                 if (this._defines.LOGARITHMICDEPTH) {
                 if (this._defines.LOGARITHMICDEPTH) {
                     this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
                     this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
@@ -20426,6 +20421,17 @@ var BABYLON;
             }
             }
             _super.prototype.bind.call(this, world, mesh);
             _super.prototype.bind.call(this, world, mesh);
         };
         };
+        StandardMaterial.ApplyFogParameters = function (scene, mesh, effect) {
+            if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+                effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
+                effect.setColor3("vFogColor", scene.fogColor);
+            }
+        };
+        StandardMaterial.ApplyBonesParameters = function (mesh, effect) {
+            if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
+                effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
+            }
+        };
         StandardMaterial.prototype.getAnimatables = function () {
         StandardMaterial.prototype.getAnimatables = function () {
             var results = [];
             var results = [];
             if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
             if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {