Bläddra i källkod

Merge remote-tracking branch 'refs/remotes/BabylonJS/master'

Raanan Weber 9 år sedan
förälder
incheckning
a4173272b7
100 ändrade filer med 7039 tillägg och 7167 borttagningar
  1. 16 0
      Tools/Gulp/gulp-removeShaderComments.js
  2. 20 20
      dist/preview release/babylon.core.js
  3. 2025 2024
      dist/preview release/babylon.d.ts
  4. 15 15
      dist/preview release/babylon.js
  5. 32 12
      dist/preview release/babylon.max.js
  6. 12 12
      dist/preview release/babylon.noworker.js
  7. 2 2
      materialsLibrary/dist/babylon.fireMaterial.js
  8. 1 1
      materialsLibrary/dist/babylon.fireMaterial.min.js
  9. 2 2
      materialsLibrary/dist/babylon.furMaterial.js
  10. 1 1
      materialsLibrary/dist/babylon.furMaterial.min.js
  11. 2 2
      materialsLibrary/dist/babylon.gradientMaterial.js
  12. 1 1
      materialsLibrary/dist/babylon.gradientMaterial.min.js
  13. 2 2
      materialsLibrary/dist/babylon.lavaMaterial.js
  14. 1 1
      materialsLibrary/dist/babylon.lavaMaterial.min.js
  15. 2 2
      materialsLibrary/dist/babylon.normalMaterial.js
  16. 1 1
      materialsLibrary/dist/babylon.normalMaterial.min.js
  17. 5 5
      materialsLibrary/dist/babylon.pbrMaterial.js
  18. 3 3
      materialsLibrary/dist/babylon.pbrMaterial.min.js
  19. 2 2
      materialsLibrary/dist/babylon.simpleMaterial.js
  20. 1 1
      materialsLibrary/dist/babylon.simpleMaterial.min.js
  21. 2 2
      materialsLibrary/dist/babylon.skyMaterial.js
  22. 1 1
      materialsLibrary/dist/babylon.skyMaterial.min.js
  23. 2 2
      materialsLibrary/dist/babylon.terrainMaterial.js
  24. 1 1
      materialsLibrary/dist/babylon.terrainMaterial.min.js
  25. 2 2
      materialsLibrary/dist/babylon.triPlanarMaterial.js
  26. 1 1
      materialsLibrary/dist/babylon.triPlanarMaterial.min.js
  27. 2 2
      materialsLibrary/dist/babylon.waterMaterial.js
  28. 1 1
      materialsLibrary/dist/babylon.waterMaterial.min.js
  29. 16 0
      materialsLibrary/gulp-removeShaderComments.js
  30. 10 9
      materialsLibrary/materials/gradient/gradient.fragment.fx
  31. 9 8
      materialsLibrary/materials/lava/lava.fragment.fx
  32. 9 8
      materialsLibrary/materials/normal/normal.fragment.fx
  33. 1 1
      materialsLibrary/materials/pbr/babylon.pbrMaterial.ts
  34. 4 4
      materialsLibrary/materials/pbr/legacypbr.fragment.fx
  35. 14 13
      materialsLibrary/materials/pbr/pbr.fragment.fx
  36. 9 8
      materialsLibrary/materials/simple/simple.fragment.fx
  37. 4626 4577
      materialsLibrary/test/refs/babylon.max.js
  38. 2 2
      src/Materials/Textures/babylon.hdrCubeTexture.js
  39. 2 3
      src/Materials/Textures/babylon.hdrcubetexture.ts
  40. 23 6
      src/Materials/babylon.effect.js
  41. 26 8
      src/Materials/babylon.effect.ts
  42. 3 3
      src/Math/babylon.math.ts
  43. 3 0
      src/Physics/babylon.physicsImpostor.js
  44. 4 4
      src/Physics/babylon.physicsImpostor.ts
  45. 0 39
      src/Shaders/ShadersInclude/light0Fragment.fx
  46. 0 22
      src/Shaders/ShadersInclude/light0FragmentDeclaration.fx
  47. 0 39
      src/Shaders/ShadersInclude/light1Fragment.fx
  48. 0 22
      src/Shaders/ShadersInclude/light1FragmentDeclaration.fx
  49. 0 39
      src/Shaders/ShadersInclude/light2Fragment.fx
  50. 0 22
      src/Shaders/ShadersInclude/light2FragmentDeclaration.fx
  51. 0 39
      src/Shaders/ShadersInclude/light3Fragment.fx
  52. 0 22
      src/Shaders/ShadersInclude/light3FragmentDeclaration.fx
  53. 39 0
      src/Shaders/ShadersInclude/lightFragment.fx
  54. 22 0
      src/Shaders/ShadersInclude/lightFragmentDeclaration.fx
  55. 1 3
      src/Shaders/anaglyph.fragment.fx
  56. 1 3
      src/Shaders/blackAndWhite.fragment.fx
  57. 1 3
      src/Shaders/blur.fragment.fx
  58. 0 2
      src/Shaders/chromaticAberration.fragment.fx
  59. 1 3
      src/Shaders/color.fragment.fx
  60. 1 3
      src/Shaders/color.vertex.fx
  61. 1 3
      src/Shaders/colorCorrection.fragment.fx
  62. 1 3
      src/Shaders/convolution.fragment.fx
  63. 9 10
      src/Shaders/default.fragment.fx
  64. 1 3
      src/Shaders/default.vertex.fx
  65. 1 3
      src/Shaders/depth.fragment.fx
  66. 1 3
      src/Shaders/depth.vertex.fx
  67. 1 3
      src/Shaders/depthBoxBlur.fragment.fx
  68. 0 3
      src/Shaders/depthOfField.fragment.fx
  69. 1 3
      src/Shaders/displayPass.fragment.fx
  70. 1 3
      src/Shaders/filter.fragment.fx
  71. 1 3
      src/Shaders/fxaa.fragment.fx
  72. 1 3
      src/Shaders/hdr.fragment.fx
  73. 1 3
      src/Shaders/layer.fragment.fx
  74. 1 3
      src/Shaders/layer.vertex.fx
  75. 10 11
      src/Shaders/legacydefault.fragment.fx
  76. 1 3
      src/Shaders/legacydefault.vertex.fx
  77. 1 3
      src/Shaders/lensFlare.fragment.fx
  78. 1 3
      src/Shaders/lensFlare.vertex.fx
  79. 0 2
      src/Shaders/lensHighlights.fragment.fx
  80. 1 3
      src/Shaders/line.fragment.fx
  81. 1 3
      src/Shaders/line.vertex.fx
  82. 1 3
      src/Shaders/outline.fragment.fx
  83. 1 3
      src/Shaders/outline.vertex.fx
  84. 1 3
      src/Shaders/particles.fragment.fx
  85. 1 3
      src/Shaders/particles.vertex.fx
  86. 1 3
      src/Shaders/pass.fragment.fx
  87. 1 3
      src/Shaders/postprocess.vertex.fx
  88. 1 3
      src/Shaders/procedural.vertex.fx
  89. 1 3
      src/Shaders/refraction.fragment.fx
  90. 1 3
      src/Shaders/shadowMap.fragment.fx
  91. 1 3
      src/Shaders/shadowMap.vertex.fx
  92. 1 3
      src/Shaders/sprites.fragment.fx
  93. 1 3
      src/Shaders/sprites.vertex.fx
  94. 1 3
      src/Shaders/ssao.fragment.fx
  95. 1 3
      src/Shaders/ssaoCombine.fragment.fx
  96. 1 3
      src/Shaders/stereoscopicInterlace.fragment.fx
  97. 1 3
      src/Shaders/tonemap.fragment.fx
  98. 1 3
      src/Shaders/volumetricLightScattering.fragment.fx
  99. 1 3
      src/Shaders/volumetricLightScatteringPass.fragment.fx
  100. 0 0
      src/Shaders/vrDistortionCorrection.fragment.fx

+ 16 - 0
Tools/Gulp/gulp-removeShaderComments.js

@@ -18,6 +18,22 @@ function uncomment(str, opts) {
     str = str.replace(/\r\n/g, '\n');
     str = str.replace(/[ \f\t\v]+/g, ' ');
     str = str.replace(/^\s*\n/gm, '');
+    str = str.replace(/ \+ /g, '+');
+    str = str.replace(/ \- /g, '-');
+    str = str.replace(/ \/ /g, '/');
+    str = str.replace(/ \* /g, '*');
+    str = str.replace(/ > /g, '>');
+    str = str.replace(/ < /g, '<');
+    str = str.replace(/ >= /g, '>=');
+    str = str.replace(/ <= /g, '<=');
+    str = str.replace(/ \+= /g, '+=');
+    str = str.replace(/ \-= /g, '-=');
+    str = str.replace(/ \/= /g, '/=');
+    str = str.replace(/ \*= /g, '*=');
+    str = str.replace(/ = /g, '=');
+    str = str.replace(/, /g, ',');
+    str = str.replace(/\n\n/g, '\n');
+    str = str.replace(/\n /g, '\n');
     
 	for (var i = 0; i < str.length; i++) {
 		currentChar = str[i];

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 20 - 20
dist/preview release/babylon.core.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2025 - 2024
dist/preview release/babylon.d.ts


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 15 - 15
dist/preview release/babylon.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 32 - 12
dist/preview release/babylon.max.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 12 - 12
dist/preview release/babylon.noworker.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
materialsLibrary/dist/babylon.fireMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.fireMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
materialsLibrary/dist/babylon.furMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.furMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
materialsLibrary/dist/babylon.gradientMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.gradientMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
materialsLibrary/dist/babylon.lavaMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.lavaMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
materialsLibrary/dist/babylon.normalMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.normalMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 5 - 5
materialsLibrary/dist/babylon.pbrMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 3 - 3
materialsLibrary/dist/babylon.pbrMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
materialsLibrary/dist/babylon.simpleMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.simpleMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
materialsLibrary/dist/babylon.skyMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.skyMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
materialsLibrary/dist/babylon.terrainMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.terrainMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
materialsLibrary/dist/babylon.triPlanarMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.triPlanarMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
materialsLibrary/dist/babylon.waterMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.waterMaterial.min.js


+ 16 - 0
materialsLibrary/gulp-removeShaderComments.js

@@ -18,6 +18,22 @@ function uncomment(str, opts) {
     str = str.replace(/\r\n/g, '\n');
     str = str.replace(/[ \f\t\v]+/g, ' ');
     str = str.replace(/^\s*\n/gm, '');
+    str = str.replace(/ \+ /g, '+');
+    str = str.replace(/ \- /g, '-');
+    str = str.replace(/ \/ /g, '/');
+    str = str.replace(/ \* /g, '*');
+    str = str.replace(/ > /g, '>');
+    str = str.replace(/ < /g, '<');
+    str = str.replace(/ >= /g, '>=');
+    str = str.replace(/ <= /g, '<=');
+    str = str.replace(/ \+= /g, '+=');
+    str = str.replace(/ \-= /g, '-=');
+    str = str.replace(/ \/= /g, '/=');
+    str = str.replace(/ \*= /g, '*=');
+    str = str.replace(/ = /g, '=');
+    str = str.replace(/, /g, ',');
+    str = str.replace(/\n\n/g, '\n');
+    str = str.replace(/\n /g, '\n');
     
 	for (var i = 0; i < str.length; i++) {
 		currentChar = str[i];

+ 10 - 9
materialsLibrary/materials/gradient/gradient.fragment.fx

@@ -23,10 +23,10 @@ varying vec4 vColor;
 
 // Lights
 
-#include<light0FragmentDeclaration>
-#include<light1FragmentDeclaration>
-#include<light2FragmentDeclaration>
-#include<light3FragmentDeclaration>
+#include<lightFragmentDeclaration>[0]
+#include<lightFragmentDeclaration>[1]
+#include<lightFragmentDeclaration>[2]
+#include<lightFragmentDeclaration>[3]
 
 
 #include<lightsFragmentFunctions>
@@ -79,13 +79,14 @@ void main(void) {
 
 	// Lighting
 	vec3 diffuseBase = vec3(0., 0., 0.);
+    lightingInfo info;
 	float shadow = 1.;
     float glossiness = 0.;
     
-#include<light0Fragment>
-#include<light1Fragment>
-#include<light2Fragment>
-#include<light3Fragment>
+#include<lightFragment>[0]
+#include<lightFragment>[1]
+#include<lightFragment>[2]
+#include<lightFragment>[3]
 
 #ifdef VERTEXALPHA
 	alpha *= vColor.a;
@@ -99,4 +100,4 @@ void main(void) {
 #include<fogFragment>
 
 	gl_FragColor = color;
-}
+}

+ 9 - 8
materialsLibrary/materials/lava/lava.fragment.fx

@@ -27,10 +27,10 @@ varying vec4 vColor;
 #endif
 
 // Lights
-#include<light0FragmentDeclaration>
-#include<light1FragmentDeclaration>
-#include<light2FragmentDeclaration>
-#include<light3FragmentDeclaration>
+#include<lightFragmentDeclaration>[0]
+#include<lightFragmentDeclaration>[1]
+#include<lightFragmentDeclaration>[2]
+#include<lightFragmentDeclaration>[3]
 
 
 #include<lightsFragmentFunctions>
@@ -121,13 +121,14 @@ void main(void) {
 
 	// Lighting
 	vec3 diffuseBase = vec3(0., 0., 0.);
+    lightingInfo info;
 	float shadow = 1.;
     float glossiness = 0.;
     
-#include<light0Fragment>
-#include<light1Fragment>
-#include<light2Fragment>
-#include<light3Fragment>
+#include<lightFragment>[0]
+#include<lightFragment>[1]
+#include<lightFragment>[2]
+#include<lightFragment>[3]
 
 
 #ifdef VERTEXALPHA

+ 9 - 8
materialsLibrary/materials/normal/normal.fragment.fx

@@ -16,10 +16,10 @@ varying vec4 vColor;
 #endif
 
 // Lights
-#include<light0FragmentDeclaration>
-#include<light1FragmentDeclaration>
-#include<light2FragmentDeclaration>
-#include<light3FragmentDeclaration>
+#include<lightFragmentDeclaration>[0]
+#include<lightFragmentDeclaration>[1]
+#include<lightFragmentDeclaration>[2]
+#include<lightFragmentDeclaration>[3]
 
 
 #include<lightsFragmentFunctions>
@@ -77,13 +77,14 @@ void main(void) {
 
 	// Lighting
 	vec3 diffuseBase = vec3(0., 0., 0.);
+    lightingInfo info;
 	float shadow = 1.;
     float glossiness = 0.;
     
-#include<light0Fragment>
-#include<light1Fragment>
-#include<light2Fragment>
-#include<light3Fragment>
+#include<lightFragment>[0]
+#include<lightFragment>[1]
+#include<lightFragment>[2]
+#include<lightFragment>[3]
 
 
 #ifdef VERTEXALPHA

+ 1 - 1
materialsLibrary/materials/pbr/babylon.pbrMaterial.ts

@@ -1024,7 +1024,7 @@ module BABYLON {
                         this._effect.setFloat4("vRefractionInfos", this.refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
                     }
                     
-                    if ((this.reflectionTexture || this.refractionTexture) && this._myScene.getEngine().getCaps().textureLOD) {
+                    if ((this.reflectionTexture || this.refractionTexture)) {
                         this._effect.setFloat2("vMicrosurfaceTextureLods", this._microsurfaceTextureLods.x, this._microsurfaceTextureLods.y);
                     }
                 }

+ 4 - 4
materialsLibrary/materials/pbr/legacypbr.fragment.fx

@@ -189,10 +189,10 @@ varying vec4 vColor;
 #endif
 
 // Lights
-#include<light0FragmentDeclaration>
-#include<light1FragmentDeclaration>
-#include<light2FragmentDeclaration>
-#include<light3FragmentDeclaration>
+#include<lightFragmentDeclaration>[0]
+#include<lightFragmentDeclaration>[1]
+#include<lightFragmentDeclaration>[2]
+#include<lightFragmentDeclaration>[3]
 
 // Samplers
 #ifdef ALBEDO

+ 14 - 13
materialsLibrary/materials/pbr/pbr.fragment.fx

@@ -72,7 +72,7 @@ uniform vec4 vCameraInfos;
     }
 #endif
 
-#ifdef LODBASEDMICROSFURACE
+#if defined(REFLECTION) || defined(REFRACTION)
     uniform vec2 vMicrosurfaceTextureLods;
 #endif
 
@@ -343,10 +343,10 @@ varying vec4 vColor;
 #endif
 
 // Lights
-#include<light0FragmentDeclaration>
-#include<light1FragmentDeclaration>
-#include<light2FragmentDeclaration>
-#include<light3FragmentDeclaration>
+#include<lightFragmentDeclaration>[0]
+#include<lightFragmentDeclaration>[1]
+#include<lightFragmentDeclaration>[2]
+#include<lightFragmentDeclaration>[3]
 
 // Samplers
 #ifdef ALBEDO
@@ -1078,13 +1078,10 @@ vec3 surfaceRefractionColor = vec3(0., 0., 0.);
 // Go mat -> blurry reflexion according to microSurface
 #ifdef LODBASEDMICROSFURACE
     float alphaG = convertRoughnessToAverageSlope(roughness);
-#else
-    float bias = 20. * (1.0 - microSurface);
 #endif
         
 #ifdef REFRACTION
-	//vec3 refractionVector = normalize(refract(-viewDirectionW, normalW, vRefractionInfos.y));
-    vec3 refractionVector = refract(-viewDirectionW, normalW, vRefractionInfos.y);
+	vec3 refractionVector = refract(-viewDirectionW, normalW, vRefractionInfos.y);
     
     #ifdef LODBASEDMICROSFURACE
         #ifdef USEPMREMREFRACTION
@@ -1092,6 +1089,8 @@ vec3 surfaceRefractionColor = vec3(0., 0., 0.);
         #else
             float lodRefraction = getMipMapIndexFromAverageSlope(vMicrosurfaceTextureLods.y, alphaG);
         #endif
+    #else
+        float biasRefraction = (vMicrosurfaceTextureLods.y + 2.) * (1.0 - microSurface);
     #endif
     
     #ifdef REFRACTIONMAP_3D
@@ -1115,7 +1114,7 @@ vec3 surfaceRefractionColor = vec3(0., 0., 0.);
                 
                 surfaceRefractionColor = textureCubeLodEXT(refractionCubeSampler, refractionVector, lodRefraction).rgb * vRefractionInfos.x;
             #else
-                surfaceRefractionColor = textureCube(refractionCubeSampler, refractionVector, bias).rgb * vRefractionInfos.x;
+                surfaceRefractionColor = textureCube(refractionCubeSampler, refractionVector, biasRefraction).rgb * vRefractionInfos.x;
             #endif
         }
         
@@ -1132,7 +1131,7 @@ vec3 surfaceRefractionColor = vec3(0., 0., 0.);
         #ifdef LODBASEDMICROSFURACE
             surfaceRefractionColor = texture2DLodEXT(refraction2DSampler, refractionCoords, lodRefraction).rgb * vRefractionInfos.x;
         #else
-            surfaceRefractionColor = texture2D(refraction2DSampler, refractionCoords, bias).rgb * vRefractionInfos.x;
+            surfaceRefractionColor = texture2D(refraction2DSampler, refractionCoords, biasRefraction).rgb * vRefractionInfos.x;
         #endif    
         
         surfaceRefractionColor = toLinearSpace(surfaceRefractionColor.rgb); 
@@ -1152,6 +1151,8 @@ vec3 environmentIrradiance = vReflectionColor.rgb;
         #else
             float lodReflection = getMipMapIndexFromAverageSlope(vMicrosurfaceTextureLods.x, alphaG);
         #endif
+    #else
+        float biasReflection = (vMicrosurfaceTextureLods.x + 2.) * (1.0 - microSurface);
     #endif
     
     #ifdef REFLECTIONMAP_3D
@@ -1172,7 +1173,7 @@ vec3 environmentIrradiance = vReflectionColor.rgb;
                 
             environmentRadiance = textureCubeLodEXT(reflectionCubeSampler, vReflectionUVW, lodReflection).rgb * vReflectionInfos.x;
         #else
-            environmentRadiance = textureCube(reflectionCubeSampler, vReflectionUVW, bias).rgb * vReflectionInfos.x;
+            environmentRadiance = textureCube(reflectionCubeSampler, vReflectionUVW, biasReflection).rgb * vReflectionInfos.x;
         #endif
         
         #ifdef PoissonSamplingEnvironment
@@ -1202,7 +1203,7 @@ vec3 environmentIrradiance = vReflectionColor.rgb;
         #ifdef LODBASEDMICROSFURACE
             environmentRadiance = texture2DLodEXT(reflection2DSampler, coords, lodReflection).rgb * vReflectionInfos.x;
         #else
-            environmentRadiance = texture2D(reflection2DSampler, coords, bias).rgb * vReflectionInfos.x;
+            environmentRadiance = texture2D(reflection2DSampler, coords, biasReflection).rgb * vReflectionInfos.x;
         #endif
     
         environmentRadiance = toLinearSpace(environmentRadiance.rgb);

+ 9 - 8
materialsLibrary/materials/simple/simple.fragment.fx

@@ -16,10 +16,10 @@ varying vec4 vColor;
 #endif
 
 // Lights
-#include<light0FragmentDeclaration>
-#include<light1FragmentDeclaration>
-#include<light2FragmentDeclaration>
-#include<light3FragmentDeclaration>
+#include<lightFragmentDeclaration>[0]
+#include<lightFragmentDeclaration>[1]
+#include<lightFragmentDeclaration>[2]
+#include<lightFragmentDeclaration>[3]
 
 
 #include<lightsFragmentFunctions>
@@ -73,13 +73,14 @@ void main(void) {
 
 	// Lighting
 	vec3 diffuseBase = vec3(0., 0., 0.);
+    lightingInfo info;
 	float shadow = 1.;
     float glossiness = 0.;
     
-#include<light0Fragment>
-#include<light1Fragment>
-#include<light2Fragment>
-#include<light3Fragment>
+#include<lightFragment>[0]
+#include<lightFragment>[1]
+#include<lightFragment>[2]
+#include<lightFragment>[3]
 
 
 #ifdef VERTEXALPHA

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 4626 - 4577
materialsLibrary/test/refs/babylon.max.js


+ 2 - 2
src/Materials/Textures/babylon.hdrCubeTexture.js

@@ -24,8 +24,8 @@ var BABYLON;
             this.hasAlpha = false;
             this._size = size;
             this._useInGammaSpace = useInGammaSpace;
-            this._usePMREMGenerator = usePMREMGenerator;
-            this.isPMREM = usePMREMGenerator;
+            this._usePMREMGenerator = usePMREMGenerator && scene.getEngine().getCaps().textureLOD;
+            this.isPMREM = this._usePMREMGenerator;
             if (!url) {
                 return;
             }

+ 2 - 3
src/Materials/Textures/babylon.hdrcubetexture.ts

@@ -33,8 +33,8 @@ module BABYLON {
             this.hasAlpha = false;
             this._size = size;
             this._useInGammaSpace = useInGammaSpace;
-            this._usePMREMGenerator = usePMREMGenerator;
-            this.isPMREM = usePMREMGenerator;
+            this._usePMREMGenerator = usePMREMGenerator && scene.getEngine().getCaps().textureLOD;
+            this.isPMREM = this._usePMREMGenerator;
 
             if (!url) {
                 return;
@@ -196,4 +196,3 @@ module BABYLON {
         }
     }
 } 
-

+ 23 - 6
src/Materials/babylon.effect.js

@@ -189,7 +189,7 @@ var BABYLON;
         };
         Effect.prototype._processIncludes = function (sourceCode, callback) {
             var _this = this;
-            var regex = /#include<(.+)>(\((.*)\))*/g;
+            var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
             var match = regex.exec(sourceCode);
             var returnValue = new String(sourceCode);
             while (match != null) {
@@ -198,13 +198,16 @@ var BABYLON;
                     // Substitution
                     var includeContent = Effect.IncludesShadersStore[includeFile];
                     if (match[2]) {
-                        var splits = match[2].substr(1, match[2].length - 2).split(",");
+                        var splits = match[3].split(",");
                         for (var index = 0; index < splits.length; index += 2) {
                             var source = new RegExp(splits[index], "g");
                             var dest = splits[index + 1];
                             includeContent = includeContent.replace(source, dest);
                         }
                     }
+                    if (match[4]) {
+                        includeContent = includeContent.replace(/\{X\}/g, match[5]);
+                    }
                     // Replace
                     returnValue = returnValue.replace(match[0], includeContent);
                 }
@@ -220,14 +223,28 @@ var BABYLON;
             }
             callback(returnValue);
         };
+        Effect.prototype._processPrecision = function (source) {
+            if (source.indexOf("precision highp float") === -1) {
+                if (!this._engine.getCaps().highPrecisionShaderSupported) {
+                    source = "precision mediump float;\n" + source;
+                }
+                else {
+                    source = "precision highp float;\n" + source;
+                }
+            }
+            else {
+                if (!this._engine.getCaps().highPrecisionShaderSupported) {
+                    source = source.replace("precision highp float", "precision mediump float");
+                }
+            }
+            return source;
+        };
         Effect.prototype._prepareEffect = function (vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks) {
             try {
                 var engine = this._engine;
                 // Precision
-                if (!engine.getCaps().highPrecisionShaderSupported) {
-                    vertexSourceCode = vertexSourceCode.replace("precision highp float", "precision mediump float");
-                    fragmentSourceCode = fragmentSourceCode.replace("precision highp float", "precision mediump float");
-                }
+                vertexSourceCode = this._processPrecision(vertexSourceCode);
+                fragmentSourceCode = this._processPrecision(fragmentSourceCode);
                 this._program = engine.createShaderProgram(vertexSourceCode, fragmentSourceCode, defines);
                 this._uniforms = engine.getUniforms(this._program, this._uniformsNames);
                 this._attributes = engine.getAttributes(this._program, attributesNames);

+ 26 - 8
src/Materials/babylon.effect.ts

@@ -237,7 +237,7 @@
         }
 
         private _processIncludes(sourceCode: string, callback: (data: any) => void): void {
-            var regex = /#include<(.+)>(\((.*)\))*/g;
+            var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
             var match = regex.exec(sourceCode);
 
             var returnValue = new String(sourceCode);
@@ -249,8 +249,8 @@
                     // Substitution
                     var includeContent = Effect.IncludesShadersStore[includeFile];
                     if (match[2]) {
-                        var splits = match[2].substr(1, match[2].length - 2).split(",");
-
+                        var splits = match[3].split(",");
+                      
                         for (var index = 0; index < splits.length; index += 2) {
                             var source = new RegExp(splits[index], "g");
                             var dest = splits[index + 1];
@@ -259,6 +259,10 @@
                         }
                     }
 
+                    if (match[4]) {
+                        includeContent = includeContent.replace(/\{X\}/g, match[5]);
+                    }
+
                     // Replace
                     returnValue = returnValue.replace(match[0], includeContent);
                 } else {
@@ -277,16 +281,30 @@
             callback(returnValue);
         }
 
+        private _processPrecision(source: string): string {
+            if (source.indexOf("precision highp float") === -1) {
+                if (!this._engine.getCaps().highPrecisionShaderSupported) {
+                    source = "precision mediump float;\n" + source;
+                } else {
+                    source = "precision highp float;\n" + source;
+                }
+            } else {
+                if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
+                    source = source.replace("precision highp float", "precision mediump float");
+                }
+            }
+
+            return source;
+        }
+
         private _prepareEffect(vertexSourceCode: string, fragmentSourceCode: string, attributesNames: string[], defines: string, fallbacks?: EffectFallbacks): void {
             try {
                 var engine = this._engine;
 
                 // Precision
-                if (!engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
-                    vertexSourceCode = vertexSourceCode.replace("precision highp float", "precision mediump float");
-                    fragmentSourceCode = fragmentSourceCode.replace("precision highp float", "precision mediump float");
-                }
-
+                vertexSourceCode = this._processPrecision(vertexSourceCode);
+                fragmentSourceCode = this._processPrecision(fragmentSourceCode);
+                
                 this._program = engine.createShaderProgram(vertexSourceCode, fragmentSourceCode, defines);
 
                 this._uniforms = engine.getUniforms(this._program, this._uniformsNames);

+ 3 - 3
src/Math/babylon.math.ts

@@ -1593,19 +1593,19 @@
             return this;
         }
 
-        public conjugateToRef(ref: Quaternion) {
+        public conjugateToRef(ref: Quaternion): Quaternion {
             ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
             return this;
         }
 
-        public conjugateInPlace() {
+        public conjugateInPlace(): Quaternion {
             this.x *= -1;
             this.y *= -1;
             this.z *= -1;
             return this;
         }
 
-        public conjugate() {
+        public conjugate(): Quaternion {
             var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
             return result;
         }

+ 3 - 0
src/Physics/babylon.physicsImpostor.js

@@ -23,6 +23,9 @@ var BABYLON;
                 if (_this._deltaRotationConjugated) {
                     _this.mesh.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this._tmpRotationWithDelta);
                 }
+                else {
+                    _this._tmpRotationWithDelta.copyFrom(_this.mesh.rotationQuaternion);
+                }
                 _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, _this._tmpPositionWithDelta, _this._tmpRotationWithDelta);
                 _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
                     func(_this);

+ 4 - 4
src/Physics/babylon.physicsImpostor.ts

@@ -235,7 +235,7 @@ module BABYLON {
             this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(this);
 
             this.mesh.position.addInPlace(this._deltaPosition)
-            if(this._deltaRotation) {
+            if (this._deltaRotation) {
                 this.mesh.rotationQuaternion.multiplyInPlace(this._deltaRotation);
             }
         }
@@ -304,7 +304,7 @@ module BABYLON {
             if (this.parent) {
                 this.parent.forceUpdate();
             } else {
-                this.mesh.getChildMeshes().forEach(function(mesh) {
+                this.mesh.getChildMeshes().forEach(function (mesh) {
                     if (mesh.physicsImpostor) {
                         if (disposeChildren) {
                             mesh.physicsImpostor.dispose();
@@ -320,7 +320,7 @@ module BABYLON {
         }
 
         public setDeltaRotation(rotation: Quaternion) {
-            if(!this._deltaRotation) {
+            if (!this._deltaRotation) {
                 this._deltaRotation = new Quaternion();
             }
             this._deltaRotation.copyFrom(rotation);
@@ -340,4 +340,4 @@ module BABYLON {
         public static HeightmapImpostor = 9;
     }
 
-}
+}

+ 0 - 39
src/Shaders/ShadersInclude/light0Fragment.fx

@@ -1,39 +0,0 @@
-#ifdef LIGHT0
-	#ifndef SPECULARTERM
-		vec3 vLightSpecular0 = vec3(0.0);
-	#endif
-	#ifdef SPOTLIGHT0
-		lightingInfo info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0.rgb, vLightSpecular0, vLightDiffuse0.a, glossiness);
-	#endif
-	#ifdef HEMILIGHT0
-		lightingInfo info = computeHemisphericLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightGround0, glossiness);
-	#endif
-	#if defined(POINTLIGHT0) || defined(DIRLIGHT0)
-		lightingInfo info = computeLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightDiffuse0.a, glossiness);
-	#endif
-	#ifdef SHADOW0
-		#ifdef SHADOWVSM0
-			shadow = computeShadowWithVSM(vPositionFromLight0, shadowSampler0, shadowsInfo0.z, shadowsInfo0.x);
-		#else
-		#ifdef SHADOWPCF0
-			#if defined(POINTLIGHT0)
-				shadow = computeShadowWithPCFCube(vLightData0.xyz, shadowSampler0, shadowsInfo0.y, shadowsInfo0.z, shadowsInfo0.x);
-			#else
-				shadow = computeShadowWithPCF(vPositionFromLight0, shadowSampler0, shadowsInfo0.y, shadowsInfo0.z, shadowsInfo0.x);
-			#endif
-		#else
-			#if defined(POINTLIGHT0)
-				shadow = computeShadowCube(vLightData0.xyz, shadowSampler0, shadowsInfo0.x, shadowsInfo0.z);
-			#else
-				shadow = computeShadow(vPositionFromLight0, shadowSampler0, shadowsInfo0.x, shadowsInfo0.z);
-			#endif
-		#endif
-	#endif
-	#else
-		shadow = 1.;
-	#endif
-		diffuseBase += info.diffuse * shadow;
-	#ifdef SPECULARTERM
-		specularBase += info.specular * shadow;
-	#endif
-#endif

+ 0 - 22
src/Shaders/ShadersInclude/light0FragmentDeclaration.fx

@@ -1,22 +0,0 @@
-#ifdef LIGHT0
-	uniform vec4 vLightData0;
-	uniform vec4 vLightDiffuse0;
-	#ifdef SPECULARTERM
-		uniform vec3 vLightSpecular0;
-	#endif
-	#ifdef SHADOW0
-		#if defined(SPOTLIGHT0) || defined(DIRLIGHT0)
-			varying vec4 vPositionFromLight0;
-			uniform sampler2D shadowSampler0;
-		#else
-			uniform samplerCube shadowSampler0;
-		#endif
-		uniform vec3 shadowsInfo0;
-	#endif
-	#ifdef SPOTLIGHT0
-		uniform vec4 vLightDirection0;
-	#endif
-	#ifdef HEMILIGHT0
-		uniform vec3 vLightGround0;
-	#endif
-#endif

+ 0 - 39
src/Shaders/ShadersInclude/light1Fragment.fx

@@ -1,39 +0,0 @@
-#ifdef LIGHT1
-	#ifndef SPECULARTERM
-		vec3 vLightSpecular1 = vec3(0.0);
-	#endif
-	#ifdef SPOTLIGHT1
-		info = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1.rgb, vLightSpecular1, vLightDiffuse1.a, glossiness);
-	#endif
-	#ifdef HEMILIGHT1
-		info = computeHemisphericLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightGround1, glossiness);
-	#endif
-	#if defined(POINTLIGHT1) || defined(DIRLIGHT1)
-		info = computeLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightDiffuse1.a, glossiness);
-	#endif
-	#ifdef SHADOW1
-		#ifdef SHADOWVSM1
-			shadow = computeShadowWithVSM(vPositionFromLight1, shadowSampler1, shadowsInfo1.z, shadowsInfo1.x);
-		#else
-			#ifdef SHADOWPCF1
-				#if defined(POINTLIGHT1)
-					shadow = computeShadowWithPCFCube(vLightData1.xyz, shadowSampler1, shadowsInfo1.y, shadowsInfo1.z, shadowsInfo1.x);
-				#else
-					shadow = computeShadowWithPCF(vPositionFromLight1, shadowSampler1, shadowsInfo1.y, shadowsInfo1.z, shadowsInfo1.x);
-				#endif
-			#else
-				#if defined(POINTLIGHT1)
-					shadow = computeShadowCube(vLightData1.xyz, shadowSampler1, shadowsInfo1.x, shadowsInfo1.z);
-				#else
-					shadow = computeShadow(vPositionFromLight1, shadowSampler1, shadowsInfo1.x, shadowsInfo1.z);
-				#endif
-			#endif
-		#endif
-		#else
-			shadow = 1.;
-	#endif
-	diffuseBase += info.diffuse * shadow;
-	#ifdef SPECULARTERM
-		specularBase += info.specular * shadow;
-	#endif
-#endif

+ 0 - 22
src/Shaders/ShadersInclude/light1FragmentDeclaration.fx

@@ -1,22 +0,0 @@
-#ifdef LIGHT1
-	uniform vec4 vLightData1;
-	uniform vec4 vLightDiffuse1;
-	#ifdef SPECULARTERM
-		uniform vec3 vLightSpecular1;
-	#endif
-	#ifdef SHADOW1
-		#if defined(SPOTLIGHT1) || defined(DIRLIGHT1)
-			varying vec4 vPositionFromLight1;
-			uniform sampler2D shadowSampler1;
-		#else
-			uniform samplerCube shadowSampler1;
-		#endif
-		uniform vec3 shadowsInfo1;
-	#endif
-	#ifdef SPOTLIGHT1
-		uniform vec4 vLightDirection1;
-	#endif
-	#ifdef HEMILIGHT1
-		uniform vec3 vLightGround1;
-	#endif
-#endif

+ 0 - 39
src/Shaders/ShadersInclude/light2Fragment.fx

@@ -1,39 +0,0 @@
-#ifdef LIGHT2
-	#ifndef SPECULARTERM
-		vec3 vLightSpecular2 = vec3(0.0);
-	#endif
-	#ifdef SPOTLIGHT2
-		info = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2.rgb, vLightSpecular2, vLightDiffuse2.a, glossiness);
-	#endif
-	#ifdef HEMILIGHT2
-		info = computeHemisphericLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightGround2, glossiness);
-	#endif
-	#if defined(POINTLIGHT2) || defined(DIRLIGHT2)
-		info = computeLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightDiffuse2.a, glossiness);
-	#endif
-	#ifdef SHADOW2
-		#ifdef SHADOWVSM2
-			shadow = computeShadowWithVSM(vPositionFromLight2, shadowSampler2, shadowsInfo2.z, shadowsInfo2.x);
-		#else
-			#ifdef SHADOWPCF2
-				#if defined(POINTLIGHT2)
-					shadow = computeShadowWithPCFCube(vLightData2.xyz, shadowSampler2, shadowsInfo2.y, shadowsInfo2.z, shadowsInfo2.x);
-				#else
-					shadow = computeShadowWithPCF(vPositionFromLight2, shadowSampler2, shadowsInfo2.y, shadowsInfo2.z, shadowsInfo2.x);
-				#endif
-			#else
-				#if defined(POINTLIGHT2)
-					shadow = computeShadowCube(vLightData2.xyz, shadowSampler2, shadowsInfo2.x, shadowsInfo2.z);
-				#else
-					shadow = computeShadow(vPositionFromLight2, shadowSampler2, shadowsInfo2.x, shadowsInfo2.z);
-				#endif
-			#endif	
-		#endif	
-		#else
-		shadow = 1.;
-	#endif
-	diffuseBase += info.diffuse * shadow;
-	#ifdef SPECULARTERM
-		specularBase += info.specular * shadow;
-	#endif
-#endif

+ 0 - 22
src/Shaders/ShadersInclude/light2FragmentDeclaration.fx

@@ -1,22 +0,0 @@
-#ifdef LIGHT2
-	uniform vec4 vLightData2;
-	uniform vec4 vLightDiffuse2;
-	#ifdef SPECULARTERM
-		uniform vec3 vLightSpecular2;
-	#endif
-	#ifdef SHADOW2
-		#if defined(SPOTLIGHT2) || defined(DIRLIGHT2)
-			varying vec4 vPositionFromLight2;
-			uniform sampler2D shadowSampler2;
-		#else
-			uniform samplerCube shadowSampler2;
-		#endif
-		uniform vec3 shadowsInfo2;
-	#endif
-	#ifdef SPOTLIGHT2
-		uniform vec4 vLightDirection2;
-	#endif
-	#ifdef HEMILIGHT2
-		uniform vec3 vLightGround2;
-	#endif
-#endif

+ 0 - 39
src/Shaders/ShadersInclude/light3Fragment.fx

@@ -1,39 +0,0 @@
-#ifdef LIGHT3
-	#ifndef SPECULARTERM
-		vec3 vLightSpecular3 = vec3(0.0);
-	#endif
-	#ifdef SPOTLIGHT3
-		info = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3.rgb, vLightSpecular3, vLightDiffuse3.a, glossiness);
-	#endif
-	#ifdef HEMILIGHT3
-		info = computeHemisphericLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightGround3, glossiness);
-	#endif
-	#if defined(POINTLIGHT3) || defined(DIRLIGHT3)
-		info = computeLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightDiffuse3.a, glossiness);
-	#endif
-	#ifdef SHADOW3
-		#ifdef SHADOWVSM3
-			shadow = computeShadowWithVSM(vPositionFromLight3, shadowSampler3, shadowsInfo3.z, shadowsInfo3.x);
-		#else
-			#ifdef SHADOWPCF3
-				#if defined(POINTLIGHT3)
-					shadow = computeShadowWithPCFCube(vLightData3.xyz, shadowSampler3, shadowsInfo3.y, shadowsInfo3.z, shadowsInfo3.x);
-				#else
-					shadow = computeShadowWithPCF(vPositionFromLight3, shadowSampler3, shadowsInfo3.y, shadowsInfo3.z, shadowsInfo3.x);
-				#endif
-			#else
-				#if defined(POINTLIGHT3)
-					shadow = computeShadowCube(vLightData3.xyz, shadowSampler3, shadowsInfo3.x, shadowsInfo3.z);
-				#else
-					shadow = computeShadow(vPositionFromLight3, shadowSampler3, shadowsInfo3.x, shadowsInfo3.z);
-				#endif
-			#endif	
-		#endif	
-	#else
-		shadow = 1.;
-	#endif
-	diffuseBase += info.diffuse * shadow;
-	#ifdef SPECULARTERM
-		specularBase += info.specular * shadow;
-	#endif
-#endif

+ 0 - 22
src/Shaders/ShadersInclude/light3FragmentDeclaration.fx

@@ -1,22 +0,0 @@
-#ifdef LIGHT3
-	uniform vec4 vLightData3;
-	uniform vec4 vLightDiffuse3;
-	#ifdef SPECULARTERM
-		uniform vec3 vLightSpecular3;
-	#endif
-	#ifdef SHADOW3
-		#if defined(SPOTLIGHT3) || defined(DIRLIGHT3)
-			varying vec4 vPositionFromLight3;
-			uniform sampler2D shadowSampler3;
-		#else
-			uniform samplerCube shadowSampler3;
-		#endif
-		uniform vec3 shadowsInfo3;
-	#endif
-	#ifdef SPOTLIGHT3
-		uniform vec4 vLightDirection3;
-	#endif
-	#ifdef HEMILIGHT3
-		uniform vec3 vLightGround3;
-	#endif
-#endif

+ 39 - 0
src/Shaders/ShadersInclude/lightFragment.fx

@@ -0,0 +1,39 @@
+#ifdef LIGHT{X}
+	#ifndef SPECULARTERM
+		vec3 vLightSpecular{X} = vec3(0.);
+	#endif
+	#ifdef SPOTLIGHT{X}
+		info = computeSpotLighting(viewDirectionW, normalW, vLightData{X}, vLightDirection{X}, vLightDiffuse{X}.rgb, vLightSpecular{X}, vLightDiffuse{X}.a, glossiness);
+	#endif
+	#ifdef HEMILIGHT{X}
+		info = computeHemisphericLighting(viewDirectionW, normalW, vLightData{X}, vLightDiffuse{X}.rgb, vLightSpecular{X}, vLightGround{X}, glossiness);
+	#endif
+	#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
+		info = computeLighting(viewDirectionW, normalW, vLightData{X}, vLightDiffuse{X}.rgb, vLightSpecular{X}, vLightDiffuse{X}.a, glossiness);
+	#endif
+	#ifdef SHADOW{X}
+		#ifdef SHADOWVSM{X}
+			shadow = computeShadowWithVSM(vPositionFromLight{X}, shadowSampler{X}, shadowsInfo{X}.z, shadowsInfo{X}.x);
+		#else
+		#ifdef SHADOWPCF{X}
+			#if defined(POINTLIGHT{X})
+				shadow = computeShadowWithPCFCube(vLightData{X}.xyz, shadowSampler{X}, shadowsInfo{X}.y, shadowsInfo{X}.z, shadowsInfo{X}.x);
+			#else
+				shadow = computeShadowWithPCF(vPositionFromLight{X}, shadowSampler{X}, shadowsInfo{X}.y, shadowsInfo{X}.z, shadowsInfo{X}.x);
+			#endif
+		#else
+			#if defined(POINTLIGHT{X})
+				shadow = computeShadowCube(vLightData{X}.xyz, shadowSampler{X}, shadowsInfo{X}.x, shadowsInfo{X}.z);
+			#else
+				shadow = computeShadow(vPositionFromLight{X}, shadowSampler{X}, shadowsInfo{X}.x, shadowsInfo{X}.z);
+			#endif
+		#endif
+	#endif
+	#else
+		shadow = 1.;
+	#endif
+		diffuseBase += info.diffuse * shadow;
+	#ifdef SPECULARTERM
+		specularBase += info.specular * shadow;
+	#endif
+#endif

+ 22 - 0
src/Shaders/ShadersInclude/lightFragmentDeclaration.fx

@@ -0,0 +1,22 @@
+#ifdef LIGHT{X}
+	uniform vec4 vLightData{X};
+	uniform vec4 vLightDiffuse{X};
+	#ifdef SPECULARTERM
+		uniform vec3 vLightSpecular{X};
+	#endif
+	#ifdef SHADOW{X}
+		#if defined(SPOTLIGHT{X}) || defined(DIRLIGHT{X})
+			varying vec4 vPositionFromLight{X};
+			uniform sampler2D shadowSampler{X};
+		#else
+			uniform samplerCube shadowSampler{X};
+		#endif
+		uniform vec3 shadowsInfo{X};
+	#endif
+	#ifdef SPOTLIGHT{X}
+		uniform vec4 vLightDirection{X};
+	#endif
+	#ifdef HEMILIGHT{X}
+		uniform vec3 vLightGround{X};
+	#endif
+#endif

+ 1 - 3
src/Shaders/anaglyph.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 uniform sampler2D leftSampler;

+ 1 - 3
src/Shaders/blackAndWhite.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 

+ 1 - 3
src/Shaders/blur.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 

+ 0 - 2
src/Shaders/chromaticAberration.fragment.fx

@@ -1,5 +1,3 @@
-precision highp float;
-
 // samplers
 uniform sampler2D textureSampler;	// original color
 

+ 1 - 3
src/Shaders/color.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-uniform vec4 color;
+uniform vec4 color;
 
 void main(void) {
 	gl_FragColor = color;

+ 1 - 3
src/Shaders/color.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attributes
+// Attributes
 attribute vec3 position;
 
 // Uniforms

+ 1 - 3
src/Shaders/colorCorrection.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// samplers
+// samplers
 uniform sampler2D textureSampler;	// screen render
 uniform sampler2D colorTable;		// color table with modified colors
 

+ 1 - 3
src/Shaders/convolution.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 

+ 9 - 10
src/Shaders/default.fragment.fx

@@ -6,8 +6,6 @@
 #extension GL_EXT_frag_depth : enable
 #endif
 
-precision highp float;
-
 // Constants
 #define RECIPROCAL_PI2 0.15915494
 
@@ -34,10 +32,10 @@ varying vec4 vColor;
 #include<helperFunctions>
 
 // Lights
-#include<light0FragmentDeclaration>
-#include<light1FragmentDeclaration>
-#include<light2FragmentDeclaration>
-#include<light3FragmentDeclaration>
+#include<lightFragmentDeclaration>[0]
+#include<lightFragmentDeclaration>[1]
+#include<lightFragmentDeclaration>[2]
+#include<lightFragmentDeclaration>[3]
 
 #include<lightsFragmentFunctions>
 #include<shadowsFragmentFunctions>
@@ -221,15 +219,16 @@ void main(void) {
 
 	// Lighting
 	vec3 diffuseBase = vec3(0., 0., 0.);
+	lightingInfo info;
 #ifdef SPECULARTERM
 	vec3 specularBase = vec3(0., 0., 0.);
 #endif
 	float shadow = 1.;
 
-#include<light0Fragment>
-#include<light1Fragment>
-#include<light2Fragment>
-#include<light3Fragment>
+#include<lightFragment>[0]
+#include<lightFragment>[1]
+#include<lightFragment>[2]
+#include<lightFragment>[3]
 
 	// Refraction
 	vec3 refractionColor = vec3(0., 0., 0.);

+ 1 - 3
src/Shaders/default.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attributes
+// Attributes
 attribute vec3 position;
 #ifdef NORMAL
 attribute vec3 normal;

+ 1 - 3
src/Shaders/depth.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-#ifdef ALPHATEST
+#ifdef ALPHATEST
 varying vec2 vUV;
 uniform sampler2D diffuseSampler;
 #endif

+ 1 - 3
src/Shaders/depth.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attribute
+// Attribute
 attribute vec3 position;
 #include<bonesDeclaration>
 

+ 1 - 3
src/Shaders/depthBoxBlur.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 

+ 0 - 3
src/Shaders/depthOfField.fragment.fx

@@ -3,9 +3,6 @@
 // Does depth-of-field blur, edge blur
 // Inspired by Francois Tarlier & Martins Upitis
 
-precision highp float;
-
-
 // samplers
 uniform sampler2D textureSampler;
 uniform sampler2D highlightsSampler;

+ 1 - 3
src/Shaders/displayPass.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 uniform sampler2D passSampler;

+ 1 - 3
src/Shaders/filter.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 

+ 1 - 3
src/Shaders/fxaa.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-#define FXAA_REDUCE_MIN   (1.0/128.0)
+#define FXAA_REDUCE_MIN   (1.0/128.0)
 #define FXAA_REDUCE_MUL   (1.0/8.0)
 #define FXAA_SPAN_MAX     8.0
 

+ 1 - 3
src/Shaders/hdr.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-uniform sampler2D textureSampler;
+uniform sampler2D textureSampler;
 varying vec2 vUV;
 
 #if defined(GAUSSIAN_BLUR_H) || defined(GAUSSIAN_BLUR_V)

+ 1 - 3
src/Shaders/layer.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 

+ 1 - 3
src/Shaders/layer.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attributes
+// Attributes
 attribute vec2 position;
 
 // Uniforms

+ 10 - 11
src/Shaders/legacydefault.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-#define MAP_PROJECTION	4.
+#define MAP_PROJECTION	4.
 
 // Constants
 uniform vec3 vEyePosition;
@@ -20,10 +18,10 @@ varying vec4 vColor;
 #endif
 
 // Lights
-#include<light0FragmentDeclaration>
-#include<light1FragmentDeclaration>
-#include<light2FragmentDeclaration>
-#include<light3FragmentDeclaration>
+#include<lightFragmentDeclaration>[0]
+#include<lightFragmentDeclaration>[1]
+#include<lightFragmentDeclaration>[2]
+#include<lightFragmentDeclaration>[3]
 
 #include<lightsFragmentFunctions>
 #include<shadowsFragmentFunctions>
@@ -130,6 +128,7 @@ void main(void) {
 
 	// Lighting
 	vec3 diffuseBase = vec3(0., 0., 0.);
+	lightingInfo info;
 	float glossiness = 0.;
 #ifdef SPECULARTERM
 	vec3 specularBase = vec3(0., 0., 0.);
@@ -137,10 +136,10 @@ void main(void) {
 #endif
 	float shadow = 1.;
 
-#include<light0Fragment>
-#include<light1Fragment>
-#include<light2Fragment>
-#include<light3Fragment>
+#include<lightFragment>[0]
+#include<lightFragment>[1]
+#include<lightFragment>[2]
+#include<lightFragment>[3]
 
 	// Reflection
 	vec3 reflectionColor = vec3(0., 0., 0.);

+ 1 - 3
src/Shaders/legacydefault.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attributes
+// Attributes
 attribute vec3 position;
 attribute vec3 normal;
 #ifdef UV1

+ 1 - 3
src/Shaders/lensFlare.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 

+ 1 - 3
src/Shaders/lensFlare.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attributes
+// Attributes
 attribute vec2 position;
 
 // Uniforms

+ 0 - 2
src/Shaders/lensHighlights.fragment.fx

@@ -1,5 +1,3 @@
-precision highp float;
-
 // samplers
 uniform sampler2D textureSampler;	// original color
 

+ 1 - 3
src/Shaders/line.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-uniform vec4 color;
+uniform vec4 color;
 
 void main(void) {
 	gl_FragColor = color;

+ 1 - 3
src/Shaders/line.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attributes
+// Attributes
 attribute vec3 position;
 attribute vec4 normal;
 

+ 1 - 3
src/Shaders/outline.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-uniform vec4 color;
+uniform vec4 color;
 
 #ifdef ALPHATEST
 varying vec2 vUV;

+ 1 - 3
src/Shaders/outline.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attribute
+// Attribute
 attribute vec3 position;
 attribute vec3 normal;
 

+ 1 - 3
src/Shaders/particles.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 varying vec4 vColor;
 uniform vec4 textureMask;

+ 1 - 3
src/Shaders/particles.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attributes
+// Attributes
 attribute vec3 position;
 attribute vec4 color;
 attribute vec4 options;

+ 1 - 3
src/Shaders/pass.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 

+ 1 - 3
src/Shaders/postprocess.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attributes
+// Attributes
 attribute vec2 position;
 
 // Output

+ 1 - 3
src/Shaders/procedural.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attributes
+// Attributes
 attribute vec2 position;
 
 // Output

+ 1 - 3
src/Shaders/refraction.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 uniform sampler2D refractionSampler;

+ 1 - 3
src/Shaders/shadowMap.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-vec4 pack(float depth)
+vec4 pack(float depth)
 {
 	const vec4 bit_shift = vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);
 	const vec4 bit_mask = vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);

+ 1 - 3
src/Shaders/shadowMap.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attribute
+// Attribute
 attribute vec3 position;
 
 #include<bonesDeclaration>

+ 1 - 3
src/Shaders/sprites.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-uniform bool alphaTest;
+uniform bool alphaTest;
 
 varying vec4 vColor;
 

+ 1 - 3
src/Shaders/sprites.vertex.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Attributes
+// Attributes
 attribute vec4 position;
 attribute vec4 options;
 attribute vec4 cellInfo;

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

@@ -1,6 +1,4 @@
-precision highp float;
-
-uniform sampler2D textureSampler;
+uniform sampler2D textureSampler;
 uniform sampler2D randomSampler;
 
 uniform float randTextureTiles;

+ 1 - 3
src/Shaders/ssaoCombine.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-uniform sampler2D textureSampler;
+uniform sampler2D textureSampler;
 uniform sampler2D originalColor;
 
 varying vec2 vUV;

+ 1 - 3
src/Shaders/stereoscopicInterlace.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-const vec3 TWO = vec3(2.0, 2.0, 2.0);
+const vec3 TWO = vec3(2.0, 2.0, 2.0);
 
 varying vec2 vUV;
 uniform sampler2D camASampler;

+ 1 - 3
src/Shaders/tonemap.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-// Samplers
+// Samplers
 varying vec2 vUV;
 uniform sampler2D textureSampler;
 

+ 1 - 3
src/Shaders/volumetricLightScattering.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-uniform sampler2D textureSampler;
+uniform sampler2D textureSampler;
 uniform sampler2D lightScatteringSampler;
 
 uniform float decay;

+ 1 - 3
src/Shaders/volumetricLightScatteringPass.fragment.fx

@@ -1,6 +1,4 @@
-precision highp float;
-
-#if defined(ALPHATEST) || defined(NEED_UV)
+#if defined(ALPHATEST) || defined(NEED_UV)
 varying vec2 vUV;
 #endif
 

+ 0 - 0
src/Shaders/vrDistortionCorrection.fragment.fx


Vissa filer visades inte eftersom för många filer har ändrats