浏览代码

Merge branch 'master' into PBRLodFiltering

Sébastien Vandenberghe 9 年之前
父节点
当前提交
843adefa65
共有 45 个文件被更改,包括 2225 次插入1955 次删除
  1. 6 0
      Tools/Gulp/config.json
  2. 21 4
      Tools/Gulp/gulpfile.js
  3. 1 1
      bower.json
  4. 20 20
      dist/preview release/babylon.core.js
  5. 1209 1205
      dist/preview release/babylon.d.ts
  6. 28 28
      dist/preview release/babylon.js
  7. 71 13
      dist/preview release/babylon.max.js
  8. 27 27
      dist/preview release/babylon.noworker.js
  9. 1 0
      dist/preview release/what's new.md
  10. 1 1
      materialsLibrary/dist/babylon.fireMaterial.js
  11. 1 1
      materialsLibrary/dist/babylon.fireMaterial.min.js
  12. 3 3
      materialsLibrary/dist/babylon.pbrMaterial.js
  13. 3 3
      materialsLibrary/dist/babylon.pbrMaterial.min.js
  14. 11 9
      materialsLibrary/dist/babylon.simpleMaterial.js
  15. 1 1
      materialsLibrary/dist/babylon.simpleMaterial.min.js
  16. 2 36
      materialsLibrary/materials/pbr/legacypbr.vertex.fx
  17. 1 35
      materialsLibrary/materials/pbr/pbr.fragment.fx
  18. 6 60
      materialsLibrary/materials/pbr/pbr.vertex.fx
  19. 10 8
      materialsLibrary/materials/simple/babylon.simpleMaterial.ts
  20. 2 39
      materialsLibrary/materials/simple/simple.fragment.fx
  21. 138 173
      materialsLibrary/materials/simple/simple.vertex.fx
  22. 71 13
      materialsLibrary/test/refs/babylon.max.js
  23. 6 1
      src/Culling/babylon.boundingBox.ts
  24. 1 1
      src/Loading/Plugins/babylon.babylonFileLoader.ts
  25. 419 0
      src/Materials/Textures/Procedurals/babylon.standardProceduralTexture.js
  26. 30 2
      src/Materials/babylon.effect.js
  27. 35 2
      src/Materials/babylon.effect.ts
  28. 1 6
      src/Particles/babylon.particleSystem.js
  29. 2 8
      src/Particles/babylon.particleSystem.ts
  30. 1 2
      src/Particles/babylon.solidParticleSystem.js
  31. 3 8
      src/Particles/babylon.solidParticleSystem.ts
  32. 10 0
      src/Shaders/ShadersInclude/bonesDeclaration.fx
  33. 29 0
      src/Shaders/ShadersInclude/bonesVertex.fx
  34. 8 0
      src/Shaders/ShadersInclude/instancesDeclaration.fx
  35. 5 0
      src/Shaders/ShadersInclude/instancesVertex.fx
  36. 5 54
      src/Shaders/default.vertex.fx
  37. 4 53
      src/Shaders/depth.vertex.fx
  38. 4 52
      src/Shaders/outline.vertex.fx
  39. 5 55
      src/Shaders/shadowMap.vertex.fx
  40. 1 6
      src/Tools/babylon.sceneSerializer.js
  41. 2 6
      src/Tools/babylon.sceneSerializer.ts
  42. 1 1
      src/Tools/babylon.tools.ts
  43. 8 8
      src/babylon.engine.js
  44. 8 8
      src/babylon.engine.ts
  45. 3 2
      src/babylon.scene.ts

+ 6 - 0
Tools/Gulp/config.json

@@ -111,6 +111,12 @@
       "files": "../../src/Shaders/*.fx"
       "files": "../../src/Shaders/*.fx"
     }
     }
   ],
   ],
+  "includeShadersDirectories": [
+    {
+      "variable": "BABYLON.Effect.IncludesShadersStore",
+      "files": "../../src/Shaders/ShadersInclude/*.fx"
+    }
+  ],
   "workers": [
   "workers": [
     {
     {
       "variable": "BABYLON.CollisionWorker",
       "variable": "BABYLON.CollisionWorker",

+ 21 - 4
Tools/Gulp/gulpfile.js

@@ -14,6 +14,7 @@ var replace = require("gulp-replace");
 
 
 var config = require("./config.json");
 var config = require("./config.json");
 
 
+var includeShadersStream;
 var shadersStream;
 var shadersStream;
 var workersStream;
 var workersStream;
 
 
@@ -26,7 +27,20 @@ function shadersName(filename) {
         .replace('.fx', 'Shader');
         .replace('.fx', 'Shader');
 }
 }
 
 
-gulp.task("shaders", function (cb) {
+function includeShadersName(filename) {
+    return filename.replace('.fx', '');
+}
+
+gulp.task("includeShaders", function (cb) {
+    includeShadersStream = config.includeShadersDirectories.map(function (shadersDef) {
+        return gulp.src(shadersDef.files).pipe(srcToVariable({
+            variableName: shadersDef.variable, asMap: true, namingCallback: includeShadersName
+        }));
+    });
+    cb();
+});
+
+gulp.task("shaders", ["includeShaders"], function (cb) {
     shadersStream = config.shadersDirectories.map(function (shadersDef) {
     shadersStream = config.shadersDirectories.map(function (shadersDef) {
         return gulp.src(shadersDef.files).pipe(srcToVariable({
         return gulp.src(shadersDef.files).pipe(srcToVariable({
             variableName: shadersDef.variable, asMap: true, namingCallback: shadersName
             variableName: shadersDef.variable, asMap: true, namingCallback: shadersName
@@ -81,7 +95,8 @@ gulp.task('typescript-sourcemaps', function () {
 gulp.task("buildCore", ["shaders"], function () {
 gulp.task("buildCore", ["shaders"], function () {
     return merge2(
     return merge2(
         gulp.src(config.core.files),
         gulp.src(config.core.files),
-        shadersStream
+        shadersStream, 
+        includeShadersStream
         )
         )
         .pipe(concat(config.build.minCoreFilename))
         .pipe(concat(config.build.minCoreFilename))
         .pipe(cleants())
         .pipe(cleants())
@@ -95,7 +110,8 @@ gulp.task("buildNoWorker", ["shaders"], function () {
     return merge2(
     return merge2(
         gulp.src(config.core.files),
         gulp.src(config.core.files),
         gulp.src(config.extras.files),
         gulp.src(config.extras.files),
-        shadersStream
+        shadersStream, 
+        includeShadersStream
         )
         )
         .pipe(concat(config.build.minNoWorkerFilename))
         .pipe(concat(config.build.minNoWorkerFilename))
         .pipe(cleants())
         .pipe(cleants())
@@ -110,7 +126,8 @@ gulp.task("build", ["workers", "shaders"], function () {
         gulp.src(config.core.files),
         gulp.src(config.core.files),
         gulp.src(config.extras.files),
         gulp.src(config.extras.files),
         shadersStream,
         shadersStream,
-        workersStream
+        workersStream, 
+        includeShadersStream
         )
         )
         .pipe(concat(config.build.filename))
         .pipe(concat(config.build.filename))
         .pipe(cleants())
         .pipe(cleants())

+ 1 - 1
bower.json

@@ -1,7 +1,7 @@
 {
 {
   "name": "babylonjs",
   "name": "babylonjs",
   "description": "Babylon.js is a complete JavaScript framework for building 3D games with HTML 5 and WebGL",
   "description": "Babylon.js is a complete JavaScript framework for building 3D games with HTML 5 and WebGL",
-  "main": "./dist/babylon.2.2.js",
+  "main": "./dist/babylon.2.3.js",
   "homepage": "https://www.babylonjs.com",
   "homepage": "https://www.babylonjs.com",
   "repository": {
   "repository": {
     "type": "git",
     "type": "git",

文件差异内容过多而无法显示
+ 20 - 20
dist/preview release/babylon.core.js


文件差异内容过多而无法显示
+ 1209 - 1205
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 28 - 28
dist/preview release/babylon.js


文件差异内容过多而无法显示
+ 71 - 13
dist/preview release/babylon.max.js


文件差异内容过多而无法显示
+ 27 - 27
dist/preview release/babylon.noworker.js


+ 1 - 0
dist/preview release/what's new.md

@@ -2,6 +2,7 @@
   - **Major updates**
   - **Major updates**
     - New refraction channel for Standard material (including fresnel support). Refraction texture can be provided by a reflection probe or a refraction texture. [See demo here](http://www.babylonjs.com/Demos/refraction/) ([deltakosh](https://github.com/deltakosh))
     - New refraction channel for Standard material (including fresnel support). Refraction texture can be provided by a reflection probe or a refraction texture. [See demo here](http://www.babylonjs.com/Demos/refraction/) ([deltakosh](https://github.com/deltakosh))
     - Added support for HDR cubemaps ([sebavan](https://github.com/sebavan))
     - Added support for HDR cubemaps ([sebavan](https://github.com/sebavan))
+    - Support for shaders includes ([deltakosh](https://github.com/deltakosh))
   - **Updates**
   - **Updates**
     - New OnPickTrigger support for spritesManager ([deltakosh](https://github.com/deltakosh))
     - New OnPickTrigger support for spritesManager ([deltakosh](https://github.com/deltakosh))
     - New SPS method `digest()` ([jerome](https://github.com/jbousquie))    
     - New SPS method `digest()` ([jerome](https://github.com/jbousquie))    

文件差异内容过多而无法显示
+ 1 - 1
materialsLibrary/dist/babylon.fireMaterial.js


文件差异内容过多而无法显示
+ 1 - 1
materialsLibrary/dist/babylon.fireMaterial.min.js


文件差异内容过多而无法显示
+ 3 - 3
materialsLibrary/dist/babylon.pbrMaterial.js


文件差异内容过多而无法显示
+ 3 - 3
materialsLibrary/dist/babylon.pbrMaterial.min.js


文件差异内容过多而无法显示
+ 11 - 9
materialsLibrary/dist/babylon.simpleMaterial.js


文件差异内容过多而无法显示
+ 1 - 1
materialsLibrary/dist/babylon.simpleMaterial.min.js


+ 2 - 36
materialsLibrary/materials/pbr/legacypbr.vertex.fx

@@ -13,16 +13,7 @@ attribute vec2 uv2;
 attribute vec4 color;
 attribute vec4 color;
 #endif
 #endif
 
 
-#if NUM_BONE_INFLUENCERS > 0
-uniform mat4 mBones[BonesPerMesh];
-
-attribute vec4 matricesIndices;
-attribute vec4 matricesWeights;
-#if NUM_BONE_INFLUENCERS > 4
-attribute vec4 matricesIndicesExtra;
-attribute vec4 matricesWeightsExtra;
-#endif
-#endif
+#include<bonesDeclaration>
 
 
 // Uniforms
 // Uniforms
 uniform mat4 world;
 uniform mat4 world;
@@ -75,32 +66,7 @@ varying float fClipDistance;
 void main(void) {
 void main(void) {
     mat4 finalWorld = world;
     mat4 finalWorld = world;
 
 
-#if NUM_BONE_INFLUENCERS > 0
-    mat4 influence;
-    influence = mBones[int(matricesIndices[0])] * matricesWeights[0];
-
-#if NUM_BONE_INFLUENCERS > 1
-    influence += mBones[int(matricesIndices[1])] * matricesWeights[1];
-#endif 
-#if NUM_BONE_INFLUENCERS > 2
-    influence += mBones[int(matricesIndices[2])] * matricesWeights[2];
-#endif	
-#if NUM_BONE_INFLUENCERS > 3
-    influence += mBones[int(matricesIndices[3])] * matricesWeights[3];
-#endif	
-
-#if NUM_BONE_INFLUENCERS > 4
-    influence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];
-#endif
-#if NUM_BONE_INFLUENCERS > 5
-    influence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];
-#endif	
-#if NUM_BONE_INFLUENCERS > 6
-    influence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];
-#endif	
-#if NUM_BONE_INFLUENCERS > 7
-    influence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];
-#endif	
+#include<bonesVertex>
 
 
     finalWorld = finalWorld * influence;
     finalWorld = finalWorld * influence;
 #endif
 #endif

+ 1 - 35
materialsLibrary/materials/pbr/pbr.fragment.fx

@@ -781,41 +781,7 @@ varying float vFragmentDepth;
 #endif
 #endif
 
 
 // Fog
 // Fog
-#ifdef FOG
-
-#define FOGMODE_NONE    0.
-#define FOGMODE_EXP     1.
-#define FOGMODE_EXP2    2.
-#define FOGMODE_LINEAR  3.
-#define E 2.71828
-
-uniform vec4 vFogInfos;
-uniform vec3 vFogColor;
-varying float fFogDistance;
-
-float CalcFogFactor()
-{
-    float fogCoeff = 1.0;
-    float fogStart = vFogInfos.y;
-    float fogEnd = vFogInfos.z;
-    float fogDensity = vFogInfos.w;
-
-    if (FOGMODE_LINEAR == vFogInfos.x)
-    {
-        fogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);
-    }
-    else if (FOGMODE_EXP == vFogInfos.x)
-    {
-        fogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);
-    }
-    else if (FOGMODE_EXP2 == vFogInfos.x)
-    {
-        fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);
-    }
-
-    return clamp(fogCoeff, 0.0, 1.0);
-}
-#endif
+#include<fogFragmentDeclaration>
 
 
 // Light Computing
 // Light Computing
 struct lightingInfo
 struct lightingInfo

+ 6 - 60
materialsLibrary/materials/pbr/pbr.vertex.fx

@@ -15,27 +15,10 @@ attribute vec2 uv2;
 attribute vec4 color;
 attribute vec4 color;
 #endif
 #endif
 
 
-#if NUM_BONE_INFLUENCERS > 0
-    uniform mat4 mBones[BonesPerMesh];
-
-    attribute vec4 matricesIndices;
-    attribute vec4 matricesWeights;
-    #if NUM_BONE_INFLUENCERS > 4
-        attribute vec4 matricesIndicesExtra;
-        attribute vec4 matricesWeightsExtra;
-    #endif
-#endif
+#include<bonesDeclaration>
 
 
 // Uniforms
 // Uniforms
-
-#ifdef INSTANCES
-attribute vec4 world0;
-attribute vec4 world1;
-attribute vec4 world2;
-attribute vec4 world3;
-#else
-uniform mat4 world;
-#endif
+#include<instancesDeclaration>
 
 
 uniform mat4 view;
 uniform mat4 view;
 uniform mat4 viewProjection;
 uniform mat4 viewProjection;
@@ -101,9 +84,7 @@ uniform vec4 vClipPlane;
 varying float fClipDistance;
 varying float fClipDistance;
 #endif
 #endif
 
 
-#ifdef FOG
-varying float fFogDistance;
-#endif
+#include<fogVertexDeclaration>
 
 
 #ifdef SHADOWS
 #ifdef SHADOWS
 #if defined(SPOTLIGHT0) || defined(DIRLIGHT0)
 #if defined(SPOTLIGHT0) || defined(DIRLIGHT0)
@@ -142,41 +123,8 @@ void main(void) {
     vPositionUVW = position;
     vPositionUVW = position;
 #endif 
 #endif 
 
 
-#ifdef INSTANCES
-    mat4 finalWorld = mat4(world0, world1, world2, world3);
-#else
-    mat4 finalWorld = world;
-#endif
-
-#if NUM_BONE_INFLUENCERS > 0
-    mat4 influence;
-    influence = mBones[int(matricesIndices[0])] * matricesWeights[0];
-
-#if NUM_BONE_INFLUENCERS > 1
-    influence += mBones[int(matricesIndices[1])] * matricesWeights[1];
-#endif 
-#if NUM_BONE_INFLUENCERS > 2
-    influence += mBones[int(matricesIndices[2])] * matricesWeights[2];
-#endif	
-#if NUM_BONE_INFLUENCERS > 3
-    influence += mBones[int(matricesIndices[3])] * matricesWeights[3];
-#endif	
-
-#if NUM_BONE_INFLUENCERS > 4
-    influence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];
-#endif
-#if NUM_BONE_INFLUENCERS > 5
-    influence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];
-#endif	
-#if NUM_BONE_INFLUENCERS > 6
-    influence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];
-#endif	
-#if NUM_BONE_INFLUENCERS > 7
-    influence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];
-#endif	
-
-    finalWorld = finalWorld * influence;
-#endif
+#include<instancesVertex>
+#include<bonesVertex>
 
 
     gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
     gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 
 
@@ -282,9 +230,7 @@ void main(void) {
 #endif
 #endif
 
 
     // Fog
     // Fog
-#ifdef FOG
-    fFogDistance = (view * worldPos).z;
-#endif
+#include<fogVertex>
 
 
     // Shadows
     // Shadows
 #ifdef SHADOWS
 #ifdef SHADOWS

+ 10 - 8
materialsLibrary/materials/simple/babylon.simpleMaterial.ts

@@ -47,8 +47,7 @@ module BABYLON {
         public UV2 = false;
         public UV2 = false;
         public VERTEXCOLOR = false;
         public VERTEXCOLOR = false;
         public VERTEXALPHA = false;
         public VERTEXALPHA = false;
-        public BONES = false;
-        public BONES4 = false;
+        public NUM_BONE_INFLUENCERS = 0;
         public BonesPerMesh = 0;
         public BonesPerMesh = 0;
         public INSTANCES = false;
         public INSTANCES = false;
 
 
@@ -259,9 +258,8 @@ module BABYLON {
                     }
                     }
                 }
                 }
                 if (mesh.useBones && mesh.computeBonesUsingShaders) {
                 if (mesh.useBones && mesh.computeBonesUsingShaders) {
-                    this._defines.BONES = true;
+                    this._defines.NUM_BONE_INFLUENCERS = mesh.numBoneInfluencers;
                     this._defines.BonesPerMesh = (mesh.skeleton.bones.length + 1);
                     this._defines.BonesPerMesh = (mesh.skeleton.bones.length + 1);
-                    this._defines.BONES4 = true;
                 }
                 }
 
 
                 // Instances
                 // Instances
@@ -303,9 +301,9 @@ module BABYLON {
                         fallbacks.addFallback(0, "SHADOWVSM" + lightIndex);
                         fallbacks.addFallback(0, "SHADOWVSM" + lightIndex);
                     }
                     }
                 }
                 }
-             
-                if (this._defines.BONES4) {
-                    fallbacks.addFallback(0, "BONES4");
+                
+                if (this._defines.NUM_BONE_INFLUENCERS > 0) {
+                    fallbacks.addCPUSkinningFallback(0, mesh);
                 }
                 }
 
 
                 //Attributes
                 //Attributes
@@ -327,9 +325,13 @@ module BABYLON {
                     attribs.push(VertexBuffer.ColorKind);
                     attribs.push(VertexBuffer.ColorKind);
                 }
                 }
 
 
-                if (this._defines.BONES) {
+                if (this._defines.NUM_BONE_INFLUENCERS > 0) {
                     attribs.push(VertexBuffer.MatricesIndicesKind);
                     attribs.push(VertexBuffer.MatricesIndicesKind);
                     attribs.push(VertexBuffer.MatricesWeightsKind);
                     attribs.push(VertexBuffer.MatricesWeightsKind);
+                    if (this._defines.NUM_BONE_INFLUENCERS > 4) {
+                        attribs.push(VertexBuffer.MatricesIndicesExtraKind);
+                        attribs.push(VertexBuffer.MatricesWeightsExtraKind);
+                    }
                 }
                 }
 
 
                 if (this._defines.INSTANCES) {
                 if (this._defines.INSTANCES) {

+ 2 - 39
materialsLibrary/materials/simple/simple.fragment.fx

@@ -261,41 +261,7 @@ varying float fClipDistance;
 #endif
 #endif
 
 
 // Fog
 // Fog
-#ifdef FOG
-
-#define FOGMODE_NONE    0.
-#define FOGMODE_EXP     1.
-#define FOGMODE_EXP2    2.
-#define FOGMODE_LINEAR  3.
-#define E 2.71828
-
-uniform vec4 vFogInfos;
-uniform vec3 vFogColor;
-varying float fFogDistance;
-
-float CalcFogFactor()
-{
-	float fogCoeff = 1.0;
-	float fogStart = vFogInfos.y;
-	float fogEnd = vFogInfos.z;
-	float fogDensity = vFogInfos.w;
-
-	if (FOGMODE_LINEAR == vFogInfos.x)
-	{
-		fogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);
-	}
-	else if (FOGMODE_EXP == vFogInfos.x)
-	{
-		fogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);
-	}
-	else if (FOGMODE_EXP2 == vFogInfos.x)
-	{
-		fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);
-	}
-
-	return clamp(fogCoeff, 0.0, 1.0);
-}
-#endif
+#include<fogFragmentDeclaration>
 
 
 // Light Computing
 // Light Computing
 struct lightingInfo
 struct lightingInfo
@@ -552,10 +518,7 @@ void main(void) {
 	// Composition
 	// Composition
 	vec4 color = vec4(finalDiffuse, alpha);
 	vec4 color = vec4(finalDiffuse, alpha);
 
 
-#ifdef FOG
-	float fog = CalcFogFactor();
-	color.rgb = fog * color.rgb + (1.0 - fog) * vFogColor;
-#endif
+#include<fogFragment>
 
 
 	gl_FragColor = color;
 	gl_FragColor = color;
 }
 }

+ 138 - 173
materialsLibrary/materials/simple/simple.vertex.fx

@@ -1,173 +1,138 @@
-precision highp float;
-
-// Attributes
-attribute vec3 position;
-#ifdef NORMAL
-attribute vec3 normal;
-#endif
-#ifdef UV1
-attribute vec2 uv;
-#endif
-#ifdef UV2
-attribute vec2 uv2;
-#endif
-#ifdef VERTEXCOLOR
-attribute vec4 color;
-#endif
-#ifdef BONES
-attribute vec4 matricesIndices;
-attribute vec4 matricesWeights;
-#endif
-
-// Uniforms
-
-#ifdef INSTANCES
-attribute vec4 world0;
-attribute vec4 world1;
-attribute vec4 world2;
-attribute vec4 world3;
-#else
-uniform mat4 world;
-#endif
-
-uniform mat4 view;
-uniform mat4 viewProjection;
-
-#ifdef DIFFUSE
-varying vec2 vDiffuseUV;
-uniform mat4 diffuseMatrix;
-uniform vec2 vDiffuseInfos;
-#endif
-
-#ifdef BONES
-uniform mat4 mBones[BonesPerMesh];
-#endif
-
-#ifdef POINTSIZE
-uniform float pointSize;
-#endif
-
-// Output
-varying vec3 vPositionW;
-#ifdef NORMAL
-varying vec3 vNormalW;
-#endif
-
-#ifdef VERTEXCOLOR
-varying vec4 vColor;
-#endif
-
-#ifdef CLIPPLANE
-uniform vec4 vClipPlane;
-varying float fClipDistance;
-#endif
-
-#ifdef FOG
-varying float fFogDistance;
-#endif
-
-#ifdef SHADOWS
-#if defined(SPOTLIGHT0) || defined(DIRLIGHT0)
-uniform mat4 lightMatrix0;
-varying vec4 vPositionFromLight0;
-#endif
-#if defined(SPOTLIGHT1) || defined(DIRLIGHT1)
-uniform mat4 lightMatrix1;
-varying vec4 vPositionFromLight1;
-#endif
-#if defined(SPOTLIGHT2) || defined(DIRLIGHT2)
-uniform mat4 lightMatrix2;
-varying vec4 vPositionFromLight2;
-#endif
-#if defined(SPOTLIGHT3) || defined(DIRLIGHT3)
-uniform mat4 lightMatrix3;
-varying vec4 vPositionFromLight3;
-#endif
-#endif
-
-void main(void) {
-	mat4 finalWorld;
-
-#ifdef INSTANCES
-	finalWorld = mat4(world0, world1, world2, world3);
-#else
-	finalWorld = world;
-#endif
-
-#ifdef BONES
-	mat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;
-	mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;
-	mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;
-
-#ifdef BONES4
-	mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
-	finalWorld = finalWorld * (m0 + m1 + m2 + m3);
-#else
-	finalWorld = finalWorld * (m0 + m1 + m2);
-#endif 
-
-#endif
-	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
-
-	vec4 worldPos = finalWorld * vec4(position, 1.0);
-	vPositionW = vec3(worldPos);
-
-#ifdef NORMAL
-	vNormalW = normalize(vec3(finalWorld * vec4(normal, 0.0)));
-#endif
-
-	// Texture coordinates
-#ifndef UV1
-	vec2 uv = vec2(0., 0.);
-#endif
-#ifndef UV2
-	vec2 uv2 = vec2(0., 0.);
-#endif
-
-#ifdef DIFFUSE
-	if (vDiffuseInfos.x == 0.)
-	{
-		vDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
-	}
-	else
-	{
-		vDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
-	}
-#endif
-
-	// Clip plane
-#ifdef CLIPPLANE
-	fClipDistance = dot(worldPos, vClipPlane);
-#endif
-
-	// Fog
-#ifdef FOG
-	fFogDistance = (view * worldPos).z;
-#endif
-
-	// Shadows
-#ifdef SHADOWS
-#if defined(SPOTLIGHT0) || defined(DIRLIGHT0)
-	vPositionFromLight0 = lightMatrix0 * worldPos;
-#endif
-#if defined(SPOTLIGHT1) || defined(DIRLIGHT1)
-	vPositionFromLight1 = lightMatrix1 * worldPos;
-#endif
-#if defined(SPOTLIGHT2) || defined(DIRLIGHT2)
-	vPositionFromLight2 = lightMatrix2 * worldPos;
-#endif
-#if defined(SPOTLIGHT3) || defined(DIRLIGHT3)
-	vPositionFromLight3 = lightMatrix3 * worldPos;
-#endif
-#endif
-
-	// Vertex color
-#ifdef VERTEXCOLOR
-	vColor = color;
-#endif
-
-	// Point size
-#ifdef POINTSIZE
-	gl_PointSize = pointSize;
-#endif
-}
+precision highp float;
+
+// Attributes
+attribute vec3 position;
+#ifdef NORMAL
+attribute vec3 normal;
+#endif
+#ifdef UV1
+attribute vec2 uv;
+#endif
+#ifdef UV2
+attribute vec2 uv2;
+#endif
+#ifdef VERTEXCOLOR
+attribute vec4 color;
+#endif
+
+#include<bonesDeclaration>
+
+// Uniforms
+#include<instancesDeclaration>
+
+uniform mat4 view;
+uniform mat4 viewProjection;
+
+#ifdef DIFFUSE
+varying vec2 vDiffuseUV;
+uniform mat4 diffuseMatrix;
+uniform vec2 vDiffuseInfos;
+#endif
+
+#ifdef POINTSIZE
+uniform float pointSize;
+#endif
+
+// Output
+varying vec3 vPositionW;
+#ifdef NORMAL
+varying vec3 vNormalW;
+#endif
+
+#ifdef VERTEXCOLOR
+varying vec4 vColor;
+#endif
+
+#ifdef CLIPPLANE
+uniform vec4 vClipPlane;
+varying float fClipDistance;
+#endif
+
+#include<fogVertexDeclaration>
+
+#ifdef SHADOWS
+#if defined(SPOTLIGHT0) || defined(DIRLIGHT0)
+uniform mat4 lightMatrix0;
+varying vec4 vPositionFromLight0;
+#endif
+#if defined(SPOTLIGHT1) || defined(DIRLIGHT1)
+uniform mat4 lightMatrix1;
+varying vec4 vPositionFromLight1;
+#endif
+#if defined(SPOTLIGHT2) || defined(DIRLIGHT2)
+uniform mat4 lightMatrix2;
+varying vec4 vPositionFromLight2;
+#endif
+#if defined(SPOTLIGHT3) || defined(DIRLIGHT3)
+uniform mat4 lightMatrix3;
+varying vec4 vPositionFromLight3;
+#endif
+#endif
+
+void main(void) {
+
+#include<instancesVertex>
+#include<bonesVertex>
+
+	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
+
+	vec4 worldPos = finalWorld * vec4(position, 1.0);
+	vPositionW = vec3(worldPos);
+
+#ifdef NORMAL
+	vNormalW = normalize(vec3(finalWorld * vec4(normal, 0.0)));
+#endif
+
+	// Texture coordinates
+#ifndef UV1
+	vec2 uv = vec2(0., 0.);
+#endif
+#ifndef UV2
+	vec2 uv2 = vec2(0., 0.);
+#endif
+
+#ifdef DIFFUSE
+	if (vDiffuseInfos.x == 0.)
+	{
+		vDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
+	}
+	else
+	{
+		vDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
+	}
+#endif
+
+	// Clip plane
+#ifdef CLIPPLANE
+	fClipDistance = dot(worldPos, vClipPlane);
+#endif
+
+	// Fog
+#include<fogVertex>
+
+	// Shadows
+#ifdef SHADOWS
+#if defined(SPOTLIGHT0) || defined(DIRLIGHT0)
+	vPositionFromLight0 = lightMatrix0 * worldPos;
+#endif
+#if defined(SPOTLIGHT1) || defined(DIRLIGHT1)
+	vPositionFromLight1 = lightMatrix1 * worldPos;
+#endif
+#if defined(SPOTLIGHT2) || defined(DIRLIGHT2)
+	vPositionFromLight2 = lightMatrix2 * worldPos;
+#endif
+#if defined(SPOTLIGHT3) || defined(DIRLIGHT3)
+	vPositionFromLight3 = lightMatrix3 * worldPos;
+#endif
+#endif
+
+	// Vertex color
+#ifdef VERTEXCOLOR
+	vColor = color;
+#endif
+
+	// Point size
+#ifdef POINTSIZE
+	gl_PointSize = pointSize;
+#endif
+}

文件差异内容过多而无法显示
+ 71 - 13
materialsLibrary/test/refs/babylon.max.js


+ 6 - 1
src/Culling/babylon.boundingBox.ts

@@ -53,6 +53,11 @@
             return this._worldMatrix;
             return this._worldMatrix;
         }
         }
 
 
+        public setWorldMatrix(matrix: Matrix): BoundingBox {
+            this._worldMatrix.copyFrom(matrix);
+            return this;
+        }
+
         public _update(world: Matrix): void {
         public _update(world: Matrix): void {
             Vector3.FromFloatsToRef(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, this.minimumWorld);
             Vector3.FromFloatsToRef(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, this.minimumWorld);
             Vector3.FromFloatsToRef(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE, this.maximumWorld);
             Vector3.FromFloatsToRef(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE, this.maximumWorld);
@@ -175,4 +180,4 @@
             return true;
             return true;
         }
         }
     }
     }
-}
+}

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

@@ -441,4 +441,4 @@
             return true;
             return true;
         }
         }
     });
     });
-}
+}

+ 419 - 0
src/Materials/Textures/Procedurals/babylon.standardProceduralTexture.js

@@ -0,0 +1,419 @@
+var __extends = (this && this.__extends) || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+};
+var BABYLON;
+(function (BABYLON) {
+    var WoodProceduralTexture = (function (_super) {
+        __extends(WoodProceduralTexture, _super);
+        function WoodProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
+            _super.call(this, name, size, "woodtexture", scene, fallbackTexture, generateMipMaps);
+            this._ampScale = 100.0;
+            this._woodColor = new BABYLON.Color3(0.32, 0.17, 0.09);
+            this.updateShaderUniforms();
+            this.refreshRate = 0;
+        }
+        WoodProceduralTexture.prototype.updateShaderUniforms = function () {
+            this.setFloat("ampScale", this._ampScale);
+            this.setColor3("woodColor", this._woodColor);
+        };
+        Object.defineProperty(WoodProceduralTexture.prototype, "ampScale", {
+            get: function () {
+                return this._ampScale;
+            },
+            set: function (value) {
+                this._ampScale = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(WoodProceduralTexture.prototype, "woodColor", {
+            get: function () {
+                return this._woodColor;
+            },
+            set: function (value) {
+                this._woodColor = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        return WoodProceduralTexture;
+    })(BABYLON.ProceduralTexture);
+    BABYLON.WoodProceduralTexture = WoodProceduralTexture;
+    var FireProceduralTexture = (function (_super) {
+        __extends(FireProceduralTexture, _super);
+        function FireProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
+            _super.call(this, name, size, "firetexture", scene, fallbackTexture, generateMipMaps);
+            this._time = 0.0;
+            this._speed = new BABYLON.Vector2(0.5, 0.3);
+            this._autoGenerateTime = true;
+            this._alphaThreshold = 0.5;
+            this._fireColors = FireProceduralTexture.RedFireColors;
+            this.updateShaderUniforms();
+            this.refreshRate = 1;
+        }
+        FireProceduralTexture.prototype.updateShaderUniforms = function () {
+            this.setFloat("time", this._time);
+            this.setVector2("speed", this._speed);
+            this.setColor3("c1", this._fireColors[0]);
+            this.setColor3("c2", this._fireColors[1]);
+            this.setColor3("c3", this._fireColors[2]);
+            this.setColor3("c4", this._fireColors[3]);
+            this.setColor3("c5", this._fireColors[4]);
+            this.setColor3("c6", this._fireColors[5]);
+            this.setFloat("alphaThreshold", this._alphaThreshold);
+        };
+        FireProceduralTexture.prototype.render = function (useCameraPostProcess) {
+            if (this._autoGenerateTime) {
+                this._time += this.getScene().getAnimationRatio() * 0.03;
+                this.updateShaderUniforms();
+            }
+            _super.prototype.render.call(this, useCameraPostProcess);
+        };
+        Object.defineProperty(FireProceduralTexture, "PurpleFireColors", {
+            get: function () {
+                return [
+                    new BABYLON.Color3(0.5, 0.0, 1.0),
+                    new BABYLON.Color3(0.9, 0.0, 1.0),
+                    new BABYLON.Color3(0.2, 0.0, 1.0),
+                    new BABYLON.Color3(1.0, 0.9, 1.0),
+                    new BABYLON.Color3(0.1, 0.1, 1.0),
+                    new BABYLON.Color3(0.9, 0.9, 1.0)
+                ];
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(FireProceduralTexture, "GreenFireColors", {
+            get: function () {
+                return [
+                    new BABYLON.Color3(0.5, 1.0, 0.0),
+                    new BABYLON.Color3(0.5, 1.0, 0.0),
+                    new BABYLON.Color3(0.3, 0.4, 0.0),
+                    new BABYLON.Color3(0.5, 1.0, 0.0),
+                    new BABYLON.Color3(0.2, 0.0, 0.0),
+                    new BABYLON.Color3(0.5, 1.0, 0.0)
+                ];
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(FireProceduralTexture, "RedFireColors", {
+            get: function () {
+                return [
+                    new BABYLON.Color3(0.5, 0.0, 0.1),
+                    new BABYLON.Color3(0.9, 0.0, 0.0),
+                    new BABYLON.Color3(0.2, 0.0, 0.0),
+                    new BABYLON.Color3(1.0, 0.9, 0.0),
+                    new BABYLON.Color3(0.1, 0.1, 0.1),
+                    new BABYLON.Color3(0.9, 0.9, 0.9)
+                ];
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(FireProceduralTexture, "BlueFireColors", {
+            get: function () {
+                return [
+                    new BABYLON.Color3(0.1, 0.0, 0.5),
+                    new BABYLON.Color3(0.0, 0.0, 0.5),
+                    new BABYLON.Color3(0.1, 0.0, 0.2),
+                    new BABYLON.Color3(0.0, 0.0, 1.0),
+                    new BABYLON.Color3(0.1, 0.2, 0.3),
+                    new BABYLON.Color3(0.0, 0.2, 0.9)
+                ];
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(FireProceduralTexture.prototype, "fireColors", {
+            get: function () {
+                return this._fireColors;
+            },
+            set: function (value) {
+                this._fireColors = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(FireProceduralTexture.prototype, "time", {
+            get: function () {
+                return this._time;
+            },
+            set: function (value) {
+                this._time = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(FireProceduralTexture.prototype, "speed", {
+            get: function () {
+                return this._speed;
+            },
+            set: function (value) {
+                this._speed = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(FireProceduralTexture.prototype, "alphaThreshold", {
+            get: function () {
+                return this._alphaThreshold;
+            },
+            set: function (value) {
+                this._alphaThreshold = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        return FireProceduralTexture;
+    })(BABYLON.ProceduralTexture);
+    BABYLON.FireProceduralTexture = FireProceduralTexture;
+    var CloudProceduralTexture = (function (_super) {
+        __extends(CloudProceduralTexture, _super);
+        function CloudProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
+            _super.call(this, name, size, "cloudtexture", scene, fallbackTexture, generateMipMaps);
+            this._skyColor = new BABYLON.Color4(0.15, 0.68, 1.0, 1.0);
+            this._cloudColor = new BABYLON.Color4(1, 1, 1, 1.0);
+            this.updateShaderUniforms();
+            this.refreshRate = 0;
+        }
+        CloudProceduralTexture.prototype.updateShaderUniforms = function () {
+            this.setColor4("skyColor", this._skyColor);
+            this.setColor4("cloudColor", this._cloudColor);
+        };
+        Object.defineProperty(CloudProceduralTexture.prototype, "skyColor", {
+            get: function () {
+                return this._skyColor;
+            },
+            set: function (value) {
+                this._skyColor = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(CloudProceduralTexture.prototype, "cloudColor", {
+            get: function () {
+                return this._cloudColor;
+            },
+            set: function (value) {
+                this._cloudColor = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        return CloudProceduralTexture;
+    })(BABYLON.ProceduralTexture);
+    BABYLON.CloudProceduralTexture = CloudProceduralTexture;
+    var GrassProceduralTexture = (function (_super) {
+        __extends(GrassProceduralTexture, _super);
+        function GrassProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
+            _super.call(this, name, size, "grasstexture", scene, fallbackTexture, generateMipMaps);
+            this._herb1 = new BABYLON.Color3(0.29, 0.38, 0.02);
+            this._herb2 = new BABYLON.Color3(0.36, 0.49, 0.09);
+            this._herb3 = new BABYLON.Color3(0.51, 0.6, 0.28);
+            this._groundColor = new BABYLON.Color3(1, 1, 1);
+            this._grassColors = [
+                new BABYLON.Color3(0.29, 0.38, 0.02),
+                new BABYLON.Color3(0.36, 0.49, 0.09),
+                new BABYLON.Color3(0.51, 0.6, 0.28)
+            ];
+            this.updateShaderUniforms();
+            this.refreshRate = 0;
+        }
+        GrassProceduralTexture.prototype.updateShaderUniforms = function () {
+            this.setColor3("herb1Color", this._grassColors[0]);
+            this.setColor3("herb2Color", this._grassColors[1]);
+            this.setColor3("herb3Color", this._grassColors[2]);
+            this.setColor3("groundColor", this._groundColor);
+        };
+        Object.defineProperty(GrassProceduralTexture.prototype, "grassColors", {
+            get: function () {
+                return this._grassColors;
+            },
+            set: function (value) {
+                this._grassColors = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(GrassProceduralTexture.prototype, "groundColor", {
+            get: function () {
+                return this._groundColor;
+            },
+            set: function (value) {
+                this.groundColor = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        return GrassProceduralTexture;
+    })(BABYLON.ProceduralTexture);
+    BABYLON.GrassProceduralTexture = GrassProceduralTexture;
+    var RoadProceduralTexture = (function (_super) {
+        __extends(RoadProceduralTexture, _super);
+        function RoadProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
+            _super.call(this, name, size, "roadtexture", scene, fallbackTexture, generateMipMaps);
+            this._roadColor = new BABYLON.Color3(0.53, 0.53, 0.53);
+            this.updateShaderUniforms();
+            this.refreshRate = 0;
+        }
+        RoadProceduralTexture.prototype.updateShaderUniforms = function () {
+            this.setColor3("roadColor", this._roadColor);
+        };
+        Object.defineProperty(RoadProceduralTexture.prototype, "roadColor", {
+            get: function () {
+                return this._roadColor;
+            },
+            set: function (value) {
+                this._roadColor = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        return RoadProceduralTexture;
+    })(BABYLON.ProceduralTexture);
+    BABYLON.RoadProceduralTexture = RoadProceduralTexture;
+    var BrickProceduralTexture = (function (_super) {
+        __extends(BrickProceduralTexture, _super);
+        function BrickProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
+            _super.call(this, name, size, "bricktexture", scene, fallbackTexture, generateMipMaps);
+            this._numberOfBricksHeight = 15;
+            this._numberOfBricksWidth = 5;
+            this._jointColor = new BABYLON.Color3(0.72, 0.72, 0.72);
+            this._brickColor = new BABYLON.Color3(0.77, 0.47, 0.40);
+            this.updateShaderUniforms();
+            this.refreshRate = 0;
+        }
+        BrickProceduralTexture.prototype.updateShaderUniforms = function () {
+            this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
+            this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
+            this.setColor3("brickColor", this._brickColor);
+            this.setColor3("jointColor", this._jointColor);
+        };
+        Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksHeight", {
+            get: function () {
+                return this._numberOfBricksHeight;
+            },
+            set: function (value) {
+                this._numberOfBricksHeight = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksWidth", {
+            get: function () {
+                return this._numberOfBricksWidth;
+            },
+            set: function (value) {
+                this._numberOfBricksWidth = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(BrickProceduralTexture.prototype, "jointColor", {
+            get: function () {
+                return this._jointColor;
+            },
+            set: function (value) {
+                this._jointColor = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(BrickProceduralTexture.prototype, "brickColor", {
+            get: function () {
+                return this._brickColor;
+            },
+            set: function (value) {
+                this._brickColor = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        return BrickProceduralTexture;
+    })(BABYLON.ProceduralTexture);
+    BABYLON.BrickProceduralTexture = BrickProceduralTexture;
+    var MarbleProceduralTexture = (function (_super) {
+        __extends(MarbleProceduralTexture, _super);
+        function MarbleProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
+            _super.call(this, name, size, "marbletexture", scene, fallbackTexture, generateMipMaps);
+            this._numberOfTilesHeight = 3;
+            this._numberOfTilesWidth = 3;
+            this._amplitude = 9.0;
+            this._marbleColor = new BABYLON.Color3(0.77, 0.47, 0.40);
+            this._jointColor = new BABYLON.Color3(0.72, 0.72, 0.72);
+            this.updateShaderUniforms();
+            this.refreshRate = 0;
+        }
+        MarbleProceduralTexture.prototype.updateShaderUniforms = function () {
+            this.setFloat("numberOfTilesHeight", this._numberOfTilesHeight);
+            this.setFloat("numberOfTilesWidth", this._numberOfTilesWidth);
+            this.setFloat("amplitude", this._amplitude);
+            this.setColor3("marbleColor", this._marbleColor);
+            this.setColor3("jointColor", this._jointColor);
+        };
+        Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesHeight", {
+            get: function () {
+                return this._numberOfTilesHeight;
+            },
+            set: function (value) {
+                this._numberOfTilesHeight = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesWidth", {
+            get: function () {
+                return this._numberOfTilesWidth;
+            },
+            set: function (value) {
+                this._numberOfTilesWidth = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(MarbleProceduralTexture.prototype, "jointColor", {
+            get: function () {
+                return this._jointColor;
+            },
+            set: function (value) {
+                this._jointColor = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(MarbleProceduralTexture.prototype, "marbleColor", {
+            get: function () {
+                return this._marbleColor;
+            },
+            set: function (value) {
+                this._marbleColor = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+        return MarbleProceduralTexture;
+    })(BABYLON.ProceduralTexture);
+    BABYLON.MarbleProceduralTexture = MarbleProceduralTexture;
+})(BABYLON || (BABYLON = {}));

+ 30 - 2
src/Materials/babylon.effect.js

@@ -83,8 +83,12 @@ var BABYLON;
                 fragmentSource = baseName.fragment || baseName;
                 fragmentSource = baseName.fragment || baseName;
             }
             }
             this._loadVertexShader(vertexSource, function (vertexCode) {
             this._loadVertexShader(vertexSource, function (vertexCode) {
-                _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
-                    _this._prepareEffect(vertexCode, fragmentCode, attributesNames, defines, fallbacks);
+                _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
+                    _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
+                        _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
+                            _this._prepareEffect(vertexCodeWithIncludes, fragmentCodeWithIncludes, attributesNames, defines, fallbacks);
+                        });
+                    });
                 });
                 });
             });
             });
         }
         }
@@ -183,9 +187,32 @@ var BABYLON;
                 BABYLON.Tools.Error("Fragment shader:" + this.name);
                 BABYLON.Tools.Error("Fragment shader:" + this.name);
             }
             }
         };
         };
+        Effect.prototype._processIncludes = function (sourceCode, callback) {
+            var _this = this;
+            var regex = /#include<(.+)>/g;
+            var match = regex.exec(sourceCode);
+            var returnValue = new String(sourceCode);
+            while (match != null) {
+                var includeFile = match[1];
+                if (Effect.IncludesShadersStore[includeFile]) {
+                    returnValue = returnValue.replace(match[0], Effect.IncludesShadersStore[includeFile]);
+                }
+                else {
+                    var includeShaderUrl = BABYLON.Engine.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
+                    BABYLON.Tools.LoadFile(includeShaderUrl, function (fileContent) {
+                        Effect.IncludesShadersStore[includeFile] = fileContent;
+                        _this._processIncludes(returnValue, callback);
+                    });
+                    return;
+                }
+                match = regex.exec(sourceCode);
+            }
+            callback(returnValue);
+        };
         Effect.prototype._prepareEffect = function (vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks) {
         Effect.prototype._prepareEffect = function (vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks) {
             try {
             try {
                 var engine = this._engine;
                 var engine = this._engine;
+                // Precision
                 if (!engine.getCaps().highPrecisionShaderSupported) {
                 if (!engine.getCaps().highPrecisionShaderSupported) {
                     vertexSourceCode = vertexSourceCode.replace("precision highp float", "precision mediump float");
                     vertexSourceCode = vertexSourceCode.replace("precision highp float", "precision mediump float");
                     fragmentSourceCode = fragmentSourceCode.replace("precision highp float", "precision mediump float");
                     fragmentSourceCode = fragmentSourceCode.replace("precision highp float", "precision mediump float");
@@ -391,6 +418,7 @@ var BABYLON;
         };
         };
         // Statics
         // Statics
         Effect.ShadersStore = {};
         Effect.ShadersStore = {};
+        Effect.IncludesShadersStore = {};
         return Effect;
         return Effect;
     })();
     })();
     BABYLON.Effect = Effect;
     BABYLON.Effect = Effect;

+ 35 - 2
src/Materials/babylon.effect.ts

@@ -112,8 +112,12 @@
             }
             }
 
 
             this._loadVertexShader(vertexSource, vertexCode => {
             this._loadVertexShader(vertexSource, vertexCode => {
-                this._loadFragmentShader(fragmentSource, (fragmentCode) => {
-                    this._prepareEffect(vertexCode, fragmentCode, attributesNames, defines, fallbacks);
+                this._processIncludes(vertexCode, vertexCodeWithIncludes => {
+                    this._loadFragmentShader(fragmentSource, (fragmentCode) => {
+                        this._processIncludes(fragmentCode, fragmentCodeWithIncludes => {
+                            this._prepareEffect(vertexCodeWithIncludes, fragmentCodeWithIncludes, attributesNames, defines, fallbacks);
+                        });
+                    });
                 });
                 });
             });
             });
         }
         }
@@ -232,10 +236,38 @@
             }
             }
         }
         }
 
 
+        private _processIncludes(sourceCode: string, callback: (data: any) => void): void {
+            var regex = /#include<(.+)>/g;
+            var match = regex.exec(sourceCode);
+
+            var returnValue = new String(sourceCode);
+
+            while (match != null) {
+                var includeFile = match[1];
+
+                if (Effect.IncludesShadersStore[includeFile]) {
+                    returnValue = returnValue.replace(match[0], Effect.IncludesShadersStore[includeFile]);
+                } else {
+                    var includeShaderUrl = Engine.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
+
+                    Tools.LoadFile(includeShaderUrl, (fileContent) => {
+                        Effect.IncludesShadersStore[includeFile] = fileContent;
+                        this._processIncludes(<string>returnValue, callback)
+                    });
+                    return;
+                }
+
+                match = regex.exec(sourceCode);
+            }
+
+            callback(returnValue);
+        }
+
         private _prepareEffect(vertexSourceCode: string, fragmentSourceCode: string, attributesNames: string[], defines: string, fallbacks?: EffectFallbacks): void {
         private _prepareEffect(vertexSourceCode: string, fragmentSourceCode: string, attributesNames: string[], defines: string, fallbacks?: EffectFallbacks): void {
             try {
             try {
                 var engine = this._engine;
                 var engine = this._engine;
 
 
+                // Precision
                 if (!engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
                 if (!engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
                     vertexSourceCode = vertexSourceCode.replace("precision highp float", "precision mediump float");
                     vertexSourceCode = vertexSourceCode.replace("precision highp float", "precision mediump float");
                     fragmentSourceCode = fragmentSourceCode.replace("precision highp float", "precision mediump float");
                     fragmentSourceCode = fragmentSourceCode.replace("precision highp float", "precision mediump float");
@@ -507,5 +539,6 @@
 
 
         // Statics
         // Statics
         public static ShadersStore = {};
         public static ShadersStore = {};
+        public static IncludesShadersStore = {};
     }
     }
 } 
 } 

+ 1 - 6
src/Particles/babylon.particleSystem.js

@@ -347,12 +347,7 @@ var BABYLON;
                 serializationObject.textureName = this.particleTexture.name;
                 serializationObject.textureName = this.particleTexture.name;
             }
             }
             // Animations
             // Animations
-            serializationObject.animations = [];
-            var animation;
-            for (var index = 0; index < this.animations.length; index++) {
-                animation = this.animations[index];
-                serializationObject.animations.push(animation.serialize());
-            }
+            BABYLON.Animation.AppendSerializedAnimations(this, serializationObject);
             // Particle system
             // Particle system
             serializationObject.minAngularSpeed = this.minAngularSpeed;
             serializationObject.minAngularSpeed = this.minAngularSpeed;
             serializationObject.maxAngularSpeed = this.maxAngularSpeed;
             serializationObject.maxAngularSpeed = this.maxAngularSpeed;

+ 2 - 8
src/Particles/babylon.particleSystem.ts

@@ -466,12 +466,7 @@
             }
             }
             
             
             // Animations
             // Animations
-            serializationObject.animations = [];
-            var animation: Animation;
-            for (var index = 0; index < this.animations.length; index++) {
-                animation = this.animations[index];
-                serializationObject.animations.push(animation.serialize());
-            }
+            Animation.AppendSerializedAnimations(this, serializationObject);
 
 
             // Particle system
             // Particle system
             serializationObject.minAngularSpeed = this.minAngularSpeed;
             serializationObject.minAngularSpeed = this.minAngularSpeed;
@@ -551,5 +546,4 @@
             return particleSystem;
             return particleSystem;
         }
         }
     }
     }
-}  
-
+}

+ 1 - 2
src/Particles/babylon.solidParticleSystem.js

@@ -80,7 +80,6 @@ var BABYLON;
             this._w = 0.0;
             this._w = 0.0;
             this._minimum = BABYLON.Tmp.Vector3[0];
             this._minimum = BABYLON.Tmp.Vector3[0];
             this._maximum = BABYLON.Tmp.Vector3[1];
             this._maximum = BABYLON.Tmp.Vector3[1];
-            this._vertexWorld = BABYLON.Tmp.Vector3[2];
             this.name = name;
             this.name = name;
             this._scene = scene;
             this._scene = scene;
             this._camera = scene.activeCamera;
             this._camera = scene.activeCamera;
@@ -580,7 +579,7 @@ var BABYLON;
             }
             }
             if (this._computeBoundingBox) {
             if (this._computeBoundingBox) {
                 this.mesh._boundingInfo = new BABYLON.BoundingInfo(this._minimum, this._maximum);
                 this.mesh._boundingInfo = new BABYLON.BoundingInfo(this._minimum, this._maximum);
-                this.mesh._boundingInfo.boundingBox.setWorldMatrix(this.mesh._worldMatrix);
+                this.mesh._boundingInfo.update(this.mesh._worldMatrix);
             }
             }
             this.afterUpdateParticles(start, end, update);
             this.afterUpdateParticles(start, end, update);
         };
         };

+ 3 - 8
src/Particles/babylon.solidParticleSystem.ts

@@ -103,7 +103,7 @@ module BABYLON {
         private _minimum: Vector3 = Tmp.Vector3[0];
         private _minimum: Vector3 = Tmp.Vector3[0];
         private _maximum: Vector3 = Tmp.Vector3[1];
         private _maximum: Vector3 = Tmp.Vector3[1];
 
 
-
+        
         /**
         /**
         * Creates a SPS (Solid Particle System) object.
         * Creates a SPS (Solid Particle System) object.
         * @param name the SPS name, this will be the underlying mesh name
         * @param name the SPS name, this will be the underlying mesh name
@@ -175,13 +175,11 @@ module BABYLON {
         * Thus the particles generated from digest() have their property "positiion" yet set.
         * Thus the particles generated from digest() have their property "positiion" yet set.
         * @param mesh the mesh to be digested
         * @param mesh the mesh to be digested
         * @param facetNb the number of mesh facets per particle (optional, default 1), this parameter is overriden by the parameter "number" if any
         * @param facetNb the number of mesh facets per particle (optional, default 1), this parameter is overriden by the parameter "number" if any
-        * @param delta the random extra number of facets per partical (optional, default 0), each particle will have between facetNb and facetNb + delta facets
         * @param number the wanted number of particles : each particle is built with mesh_total_facets / number facets (optional)
         * @param number the wanted number of particles : each particle is built with mesh_total_facets / number facets (optional)
         */
         */
-        public digest(mesh: Mesh, options?: { facetNb?: number; number?: number; delta?: number }): void {
+        public digest(mesh: Mesh, options?: { facetNb?: number; number?: number }): void {
             var size: number = (options && options.facetNb) || 1;
             var size: number = (options && options.facetNb) || 1;
             var number: number = (options && options.number);
             var number: number = (options && options.number);
-            var delta: number = (options && options.delta) || 0;
             var meshPos = mesh.getVerticesData(VertexBuffer.PositionKind);
             var meshPos = mesh.getVerticesData(VertexBuffer.PositionKind);
             var meshInd = mesh.getIndices();
             var meshInd = mesh.getIndices();
             var meshUV = mesh.getVerticesData(VertexBuffer.UVKind);
             var meshUV = mesh.getVerticesData(VertexBuffer.UVKind);
@@ -193,7 +191,6 @@ module BABYLON {
             if (number) {
             if (number) {
                 number = (number > totalFacets) ? totalFacets : number;
                 number = (number > totalFacets) ? totalFacets : number;
                 size = Math.round(totalFacets / number);
                 size = Math.round(totalFacets / number);
-                delta = 0;
             } else {
             } else {
                 size = (size > totalFacets) ? totalFacets : size;
                 size = (size > totalFacets) ? totalFacets : size;
             }
             }
@@ -203,11 +200,8 @@ module BABYLON {
             var facetUV: number[] = [];       // submesh UV
             var facetUV: number[] = [];       // submesh UV
             var facetCol: number[] = [];      // submesh colors
             var facetCol: number[] = [];      // submesh colors
             var barycenter: Vector3 = Tmp.Vector3[0];
             var barycenter: Vector3 = Tmp.Vector3[0];
-            var rand: number;
-            var sizeO: number = size;
 
 
             while (f < totalFacets) {
             while (f < totalFacets) {
-                size = sizeO + Math.floor((1 + delta) * Math.random());
                 if (f > totalFacets - size) {
                 if (f > totalFacets - size) {
                     size = totalFacets - f;
                     size = totalFacets - f;
                 }
                 }
@@ -914,3 +908,4 @@ module BABYLON {
         }
         }
     }
     }
 }
 }
+

+ 10 - 0
src/Shaders/ShadersInclude/bonesDeclaration.fx

@@ -0,0 +1,10 @@
+#if NUM_BONE_INFLUENCERS > 0
+	uniform mat4 mBones[BonesPerMesh];
+
+	attribute vec4 matricesIndices;
+	attribute vec4 matricesWeights;
+	#if NUM_BONE_INFLUENCERS > 4
+		attribute vec4 matricesIndicesExtra;
+		attribute vec4 matricesWeightsExtra;
+	#endif
+#endif

+ 29 - 0
src/Shaders/ShadersInclude/bonesVertex.fx

@@ -0,0 +1,29 @@
+#if NUM_BONE_INFLUENCERS > 0
+	mat4 influence;
+	influence = mBones[int(matricesIndices[0])] * matricesWeights[0];
+
+	#if NUM_BONE_INFLUENCERS > 1
+		influence += mBones[int(matricesIndices[1])] * matricesWeights[1];
+	#endif	
+	#if NUM_BONE_INFLUENCERS > 2
+		influence += mBones[int(matricesIndices[2])] * matricesWeights[2];
+	#endif	
+	#if NUM_BONE_INFLUENCERS > 3
+		influence += mBones[int(matricesIndices[3])] * matricesWeights[3];
+	#endif	
+
+	#if NUM_BONE_INFLUENCERS > 4
+		influence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];
+	#endif	
+	#if NUM_BONE_INFLUENCERS > 5
+		influence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];
+	#endif	
+	#if NUM_BONE_INFLUENCERS > 6
+		influence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];
+	#endif	
+	#if NUM_BONE_INFLUENCERS > 7
+		influence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];
+	#endif	
+
+	finalWorld = finalWorld * influence;
+#endif

+ 8 - 0
src/Shaders/ShadersInclude/instancesDeclaration.fx

@@ -0,0 +1,8 @@
+#ifdef INSTANCES
+	attribute vec4 world0;
+	attribute vec4 world1;
+	attribute vec4 world2;
+	attribute vec4 world3;
+#else
+	uniform mat4 world;
+#endif

+ 5 - 0
src/Shaders/ShadersInclude/instancesVertex.fx

@@ -0,0 +1,5 @@
+#ifdef INSTANCES
+	mat4 finalWorld = mat4(world0, world1, world2, world3);
+#else
+	mat4 finalWorld = world;
+#endif

+ 5 - 54
src/Shaders/default.vertex.fx

@@ -15,27 +15,10 @@ attribute vec2 uv2;
 attribute vec4 color;
 attribute vec4 color;
 #endif
 #endif
 
 
-#if NUM_BONE_INFLUENCERS > 0
-	uniform mat4 mBones[BonesPerMesh];
-
-	attribute vec4 matricesIndices;
-	attribute vec4 matricesWeights;
-	#if NUM_BONE_INFLUENCERS > 4
-		attribute vec4 matricesIndicesExtra;
-		attribute vec4 matricesWeightsExtra;
-	#endif
-#endif
+#include<bonesDeclaration>
 
 
 // Uniforms
 // Uniforms
-
-#ifdef INSTANCES
-attribute vec4 world0;
-attribute vec4 world1;
-attribute vec4 world2;
-attribute vec4 world3;
-#else
-uniform mat4 world;
-#endif
+#include<instancesDeclaration>
 
 
 uniform mat4 view;
 uniform mat4 view;
 uniform mat4 viewProjection;
 uniform mat4 viewProjection;
@@ -142,41 +125,9 @@ void main(void) {
 	vPositionUVW = position;
 	vPositionUVW = position;
 #endif 
 #endif 
 
 
-#ifdef INSTANCES
-	mat4 finalWorld = mat4(world0, world1, world2, world3);
-#else
-	mat4 finalWorld = world;
-#endif
-
-#if NUM_BONE_INFLUENCERS > 0
-	mat4 influence;
-	influence = mBones[int(matricesIndices[0])] * matricesWeights[0];
-
-	#if NUM_BONE_INFLUENCERS > 1
-		influence += mBones[int(matricesIndices[1])] * matricesWeights[1];
-	#endif 
-	#if NUM_BONE_INFLUENCERS > 2
-		influence += mBones[int(matricesIndices[2])] * matricesWeights[2];
-	#endif	
-	#if NUM_BONE_INFLUENCERS > 3
-		influence += mBones[int(matricesIndices[3])] * matricesWeights[3];
-	#endif	
-
-	#if NUM_BONE_INFLUENCERS > 4
-		influence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];
-	#endif
-	#if NUM_BONE_INFLUENCERS > 5
-		influence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];
-	#endif	
-	#if NUM_BONE_INFLUENCERS > 6
-		influence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];
-	#endif	
-	#if NUM_BONE_INFLUENCERS > 7
-		influence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];
-	#endif	
-
-	finalWorld = finalWorld * influence;
-#endif
+#include<instancesVertex>
+#include<bonesVertex>
+
 	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 
 
 	vec4 worldPos = finalWorld * vec4(position, 1.0);
 	vec4 worldPos = finalWorld * vec4(position, 1.0);

+ 4 - 53
src/Shaders/depth.vertex.fx

@@ -2,28 +2,10 @@
 
 
 // Attribute
 // Attribute
 attribute vec3 position;
 attribute vec3 position;
-#if NUM_BONE_INFLUENCERS > 0
-
-	// having bone influencers implies you have bones
-	uniform mat4 mBones[BonesPerMesh];
-
-	attribute vec4 matricesIndices;
-	attribute vec4 matricesWeights;
-	#if NUM_BONE_INFLUENCERS > 4
-		attribute vec4 matricesIndicesExtra;
-		attribute vec4 matricesWeightsExtra;
-	#endif
-#endif
+#include<bonesDeclaration>
 
 
 // Uniform
 // Uniform
-#ifdef INSTANCES
-attribute vec4 world0;
-attribute vec4 world1;
-attribute vec4 world2;
-attribute vec4 world3;
-#else
-uniform mat4 world;
-#endif
+#include<instancesDeclaration>
 
 
 uniform mat4 viewProjection;
 uniform mat4 viewProjection;
 
 
@@ -40,41 +22,10 @@ attribute vec2 uv2;
 
 
 void main(void)
 void main(void)
 {
 {
-#ifdef INSTANCES
-	mat4 finalWorld = mat4(world0, world1, world2, world3);
-#else
-	mat4 finalWorld = world;
-#endif
-
-#if NUM_BONE_INFLUENCERS > 0
-	mat4 influence;
-	influence = mBones[int(matricesIndices[0])] * matricesWeights[0];
+#include<instancesVertex>
 
 
-	#if NUM_BONE_INFLUENCERS > 1
-		influence += mBones[int(matricesIndices[1])] * matricesWeights[1];
-	#endif	
-	#if NUM_BONE_INFLUENCERS > 2
-		influence += mBones[int(matricesIndices[2])] * matricesWeights[2];
-	#endif	
-	#if NUM_BONE_INFLUENCERS > 3
-		influence += mBones[int(matricesIndices[3])] * matricesWeights[3];
-	#endif	
-	
-	#if NUM_BONE_INFLUENCERS > 4
-		influence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];
-	#endif	
-	#if NUM_BONE_INFLUENCERS > 5
-		influence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];
-	#endif	
-	#if NUM_BONE_INFLUENCERS > 6
-		influence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];
-	#endif	
-	#if NUM_BONE_INFLUENCERS > 7
-		influence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];
-	#endif	
+#include<bonesVertex>
 
 
-	finalWorld = finalWorld * influence;
-#endif
 	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 
 
 #if defined(ALPHATEST) || defined(BASIC_RENDER)
 #if defined(ALPHATEST) || defined(BASIC_RENDER)

+ 4 - 52
src/Shaders/outline.vertex.fx

@@ -4,28 +4,12 @@
 attribute vec3 position;
 attribute vec3 position;
 attribute vec3 normal;
 attribute vec3 normal;
 
 
-#if NUM_BONE_INFLUENCERS > 0
-uniform mat4 mBones[BonesPerMesh];
-
-attribute vec4 matricesIndices;
-attribute vec4 matricesWeights;
-#if NUM_BONE_INFLUENCERS > 4
-attribute vec4 matricesIndicesExtra;
-attribute vec4 matricesWeightsExtra;
-#endif
-#endif
+#include<bonesDeclaration>
 
 
 // Uniform
 // Uniform
 uniform float offset;
 uniform float offset;
 
 
-#ifdef INSTANCES
-attribute vec4 world0;
-attribute vec4 world1;
-attribute vec4 world2;
-attribute vec4 world3;
-#else
-uniform mat4 world;
-#endif
+#include<instancesDeclaration>
 
 
 uniform mat4 viewProjection;
 uniform mat4 viewProjection;
 
 
@@ -44,41 +28,9 @@ void main(void)
 {
 {
 	vec3 offsetPosition = position + normal * offset;
 	vec3 offsetPosition = position + normal * offset;
 
 
-#ifdef INSTANCES
-	mat4 finalWorld = mat4(world0, world1, world2, world3);
-#else
-	mat4 finalWorld = world;
-#endif
+#include<instancesVertex>
+#include<bonesVertex>
 
 
-#if NUM_BONE_INFLUENCERS > 0
-	mat4 influence;
-	influence = mBones[int(matricesIndices[0])] * matricesWeights[0];
-
-#if NUM_BONE_INFLUENCERS > 1
-	influence += mBones[int(matricesIndices[1])] * matricesWeights[1];
-#endif	
-#if NUM_BONE_INFLUENCERS > 2
-	influence += mBones[int(matricesIndices[2])] * matricesWeights[2];
-#endif	
-#if NUM_BONE_INFLUENCERS > 3
-	influence += mBones[int(matricesIndices[3])] * matricesWeights[3];
-#endif	
-
-#if NUM_BONE_INFLUENCERS > 4
-	influence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];
-#endif	
-#if NUM_BONE_INFLUENCERS > 5
-	influence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];
-#endif	
-#if NUM_BONE_INFLUENCERS > 6
-	influence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];
-#endif	
-#if NUM_BONE_INFLUENCERS > 7
-	influence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];
-#endif	
-
-	finalWorld = finalWorld * influence;
-#endif
 	gl_Position = viewProjection * finalWorld * vec4(offsetPosition, 1.0);
 	gl_Position = viewProjection * finalWorld * vec4(offsetPosition, 1.0);
 
 
 #ifdef ALPHATEST
 #ifdef ALPHATEST

+ 5 - 55
src/Shaders/shadowMap.vertex.fx

@@ -2,28 +2,11 @@
 
 
 // Attribute
 // Attribute
 attribute vec3 position;
 attribute vec3 position;
-#if NUM_BONE_INFLUENCERS > 0
 
 
-// having bone influencers implies you have bones
-uniform mat4 mBones[BonesPerMesh];
+#include<bonesDeclaration>
 
 
-attribute vec4 matricesIndices;
-attribute vec4 matricesWeights;
-#if NUM_BONE_INFLUENCERS > 4
-attribute vec4 matricesIndicesExtra;
-attribute vec4 matricesWeightsExtra;
-#endif
-#endif
-
-// Uniform
-#ifdef INSTANCES
-attribute vec4 world0;
-attribute vec4 world1;
-attribute vec4 world2;
-attribute vec4 world3;
-#else
-uniform mat4 world;
-#endif
+// Uniforms
+#include<instancesDeclaration>
 
 
 uniform mat4 viewProjection;
 uniform mat4 viewProjection;
 
 
@@ -42,41 +25,8 @@ attribute vec2 uv2;
 
 
 void main(void)
 void main(void)
 {
 {
-#ifdef INSTANCES
-	mat4 finalWorld = mat4(world0, world1, world2, world3);
-#else
-	mat4 finalWorld = world;
-#endif
-
-#if NUM_BONE_INFLUENCERS > 0
-	mat4 influence;
-	influence = mBones[int(matricesIndices[0])] * matricesWeights[0];
-
-#if NUM_BONE_INFLUENCERS > 1
-	influence += mBones[int(matricesIndices[1])] * matricesWeights[1];
-#endif	
-#if NUM_BONE_INFLUENCERS > 2
-	influence += mBones[int(matricesIndices[2])] * matricesWeights[2];
-#endif	
-#if NUM_BONE_INFLUENCERS > 3
-	influence += mBones[int(matricesIndices[3])] * matricesWeights[3];
-#endif	
-
-#if NUM_BONE_INFLUENCERS > 4
-	influence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];
-#endif	
-#if NUM_BONE_INFLUENCERS > 5
-	influence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];
-#endif	
-#if NUM_BONE_INFLUENCERS > 6
-	influence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];
-#endif	
-#if NUM_BONE_INFLUENCERS > 7
-	influence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];
-#endif	
-
-	finalWorld = finalWorld * influence;
-#endif
+#include<instancesVertex>
+#include<bonesVertex>
 
 
 #ifdef CUBEMAP
 #ifdef CUBEMAP
 	vPosition = finalWorld * vec4(position, 1.0);
 	vPosition = finalWorld * vec4(position, 1.0);

+ 1 - 6
src/Tools/babylon.sceneSerializer.js

@@ -228,12 +228,7 @@ var BABYLON;
                 serializationObject.activeCameraID = scene.activeCamera.id;
                 serializationObject.activeCameraID = scene.activeCamera.id;
             }
             }
             // Animations
             // Animations
-            serializationObject.animations = [];
-            var animation;
-            for (index = 0; index < scene.animations.length; index++) {
-                animation = scene.animations[index];
-                serializationObject.animations.push(animation.serialize());
-            }
+            BABYLON.Animation.AppendSerializedAnimations(scene, serializationObject);
             // Materials
             // Materials
             serializationObject.materials = [];
             serializationObject.materials = [];
             serializationObject.multiMaterials = [];
             serializationObject.multiMaterials = [];

+ 2 - 6
src/Tools/babylon.sceneSerializer.ts

@@ -260,12 +260,7 @@
             }
             }
 
 
             // Animations
             // Animations
-            serializationObject.animations = [];
-            var animation: Animation;
-            for (index = 0; index < scene.animations.length; index++) {
-                animation = scene.animations[index];
-                serializationObject.animations.push(animation.serialize());
-            }
+            Animation.AppendSerializedAnimations(scene, serializationObject);
 
 
             // Materials
             // Materials
             serializationObject.materials = [];
             serializationObject.materials = [];
@@ -379,3 +374,4 @@
         }
         }
     }
     }
 }
 }
+

+ 1 - 1
src/Tools/babylon.tools.ts

@@ -592,7 +592,7 @@
                     var a = window.document.createElement("a");
                     var a = window.document.createElement("a");
                     a.href = base64Image;
                     a.href = base64Image;
                     var date = new Date();
                     var date = new Date();
-                    var stringDate = date.getFullYear() + "-" + (date.getMonth()+1)).slice(-2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
+                    var stringDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
                     a.setAttribute("download", "screenshot_" + stringDate + ".png");
                     a.setAttribute("download", "screenshot_" + stringDate + ".png");
 
 
                     window.document.body.appendChild(a);
                     window.document.body.appendChild(a);

+ 8 - 8
src/babylon.engine.js

@@ -394,14 +394,14 @@ var BABYLON;
                 options.preserveDrawingBuffer = false;
                 options.preserveDrawingBuffer = false;
             }
             }
             // GL
             // GL
-            try {
-                this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
-                if (this._gl) {
-                    this._webGLVersion = "2.0";
-                }
-            }
-            catch (e) {
-            }
+            //try {
+            //    this._gl = <WebGLRenderingContext>(canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
+            //    if (this._gl) {
+            //        this._webGLVersion = "2.0";
+            //    }
+            //} catch (e) {
+            //    // Do nothing
+            //}
             if (!this._gl) {
             if (!this._gl) {
                 try {
                 try {
                     this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
                     this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));

+ 8 - 8
src/babylon.engine.ts

@@ -588,14 +588,14 @@
             }
             }
 
 
             // GL
             // GL
-            try {
-                this._gl = <WebGLRenderingContext>(canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
-                if (this._gl) {
-                    this._webGLVersion = "2.0";
-                }
-            } catch (e) {
-                // Do nothing
-            }
+            //try {
+            //    this._gl = <WebGLRenderingContext>(canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
+            //    if (this._gl) {
+            //        this._webGLVersion = "2.0";
+            //    }
+            //} catch (e) {
+            //    // Do nothing
+            //}
 
 
             if (!this._gl) {
             if (!this._gl) {
                 try {
                 try {

+ 3 - 2
src/babylon.scene.ts

@@ -281,7 +281,7 @@
         private _depthRenderer: DepthRenderer;
         private _depthRenderer: DepthRenderer;
 
 
         private _uniqueIdCounter = 0;
         private _uniqueIdCounter = 0;
-        
+
         private _pickedDownMesh: AbstractMesh;
         private _pickedDownMesh: AbstractMesh;
         private _pickedDownSprite: Sprite;
         private _pickedDownSprite: Sprite;
 
 
@@ -631,7 +631,7 @@
                 if (this._pickedDownMesh && this._pickedDownMesh !== pickResult.pickedMesh) {
                 if (this._pickedDownMesh && this._pickedDownMesh !== pickResult.pickedMesh) {
                     this._pickedDownMesh.actionManager.processTrigger(ActionManager.OnPickOutTrigger, ActionEvent.CreateNew(this._pickedDownMesh, evt));
                     this._pickedDownMesh.actionManager.processTrigger(ActionManager.OnPickOutTrigger, ActionEvent.CreateNew(this._pickedDownMesh, evt));
                 }
                 }
-                
+
                 if (this.onPointerUp) {
                 if (this.onPointerUp) {
                     this.onPointerUp(evt, pickResult);
                     this.onPointerUp(evt, pickResult);
                 }
                 }
@@ -2614,3 +2614,4 @@
         }
         }
     }
     }
 }
 }
+