Browse Source

Merge remote-tracking branch 'BabylonJS/master'

MackeyK24 8 years ago
parent
commit
9d7680bedc
29 changed files with 3149 additions and 3093 deletions
  1. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/BabylonExport.Entities.dll
  2. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/ExportationOptions.cs
  3. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/ExporterWindow.cs
  4. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/Ionic.Zip.dll
  5. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/JsonFx.Json.dll
  6. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/JsonFx.dll
  7. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.Animations.cs
  8. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.Cameras.cs
  9. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.Lights.cs
  10. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.Materials.cs
  11. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.Meshes.cs
  12. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.cs
  13. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/SerializableVector3.cs
  14. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/Tools.cs
  15. 0 0
      Exporters/Unity 5/Deprecated/Unity3D2Babylon/WebServer.cs
  16. 0 0
      Exporters/Unity 5/Deprecated/readme.md
  17. 17 17
      dist/preview release/babylon.core.js
  18. 2980 2980
      dist/preview release/babylon.d.ts
  19. 17 17
      dist/preview release/babylon.js
  20. 8 8
      dist/preview release/babylon.max.js
  21. 17 17
      dist/preview release/babylon.noworker.js
  22. 1 0
      dist/preview release/what's new.md
  23. 2 1
      src/Cameras/babylon.camera.ts
  24. 11 3
      src/Materials/Textures/babylon.mirrorTexture.ts
  25. 35 21
      src/Materials/Textures/babylon.renderTargetTexture.ts
  26. 33 6
      src/Materials/babylon.pbrMaterial.ts
  27. 1 1
      src/Mesh/babylon.meshBuilder.ts
  28. 19 14
      src/Shaders/pbr.fragment.fx
  29. 8 8
      src/babylon.engine.ts

Exporters/Unity 5/Unity3D2Babylon/BabylonExport.Entities.dll → Exporters/Unity 5/Deprecated/Unity3D2Babylon/BabylonExport.Entities.dll


Exporters/Unity 5/Unity3D2Babylon/ExportationOptions.cs → Exporters/Unity 5/Deprecated/Unity3D2Babylon/ExportationOptions.cs


Exporters/Unity 5/Unity3D2Babylon/ExporterWindow.cs → Exporters/Unity 5/Deprecated/Unity3D2Babylon/ExporterWindow.cs


Exporters/Unity 5/Unity3D2Babylon/Ionic.Zip.dll → Exporters/Unity 5/Deprecated/Unity3D2Babylon/Ionic.Zip.dll


Exporters/Unity 5/Unity3D2Babylon/JsonFx.Json.dll → Exporters/Unity 5/Deprecated/Unity3D2Babylon/JsonFx.Json.dll


Exporters/Unity 5/Unity3D2Babylon/JsonFx.dll → Exporters/Unity 5/Deprecated/Unity3D2Babylon/JsonFx.dll


Exporters/Unity 5/Unity3D2Babylon/SceneBuilder.Animations.cs → Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.Animations.cs


Exporters/Unity 5/Unity3D2Babylon/SceneBuilder.Cameras.cs → Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.Cameras.cs


Exporters/Unity 5/Unity3D2Babylon/SceneBuilder.Lights.cs → Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.Lights.cs


Exporters/Unity 5/Unity3D2Babylon/SceneBuilder.Materials.cs → Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.Materials.cs


Exporters/Unity 5/Unity3D2Babylon/SceneBuilder.Meshes.cs → Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.Meshes.cs


Exporters/Unity 5/Unity3D2Babylon/SceneBuilder.cs → Exporters/Unity 5/Deprecated/Unity3D2Babylon/SceneBuilder.cs


Exporters/Unity 5/Unity3D2Babylon/SerializableVector3.cs → Exporters/Unity 5/Deprecated/Unity3D2Babylon/SerializableVector3.cs


Exporters/Unity 5/Unity3D2Babylon/Tools.cs → Exporters/Unity 5/Deprecated/Unity3D2Babylon/Tools.cs


Exporters/Unity 5/Unity3D2Babylon/WebServer.cs → Exporters/Unity 5/Deprecated/Unity3D2Babylon/WebServer.cs


Exporters/Unity 5/readme.md → Exporters/Unity 5/Deprecated/readme.md


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


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


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


+ 8 - 8
dist/preview release/babylon.max.js

@@ -6609,14 +6609,14 @@ var BABYLON;
             var renderToFullFloat = this._canRenderToFloatTexture();
             var renderToFullFloat = this._canRenderToFloatTexture();
             var renderToHalfFloat = this._canRenderToHalfFloatTexture();
             var renderToHalfFloat = this._canRenderToHalfFloatTexture();
             // 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 = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
+                if (this._gl) {
+                    this._webGLVersion = "2.0";
+                }
+            }
+            catch (e) {
+            }
             if (!this._gl) {
             if (!this._gl) {
                 if (!canvas) {
                 if (!canvas) {
                     throw new Error("The provided canvas is null or undefined.");
                     throw new Error("The provided canvas is null or undefined.");

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


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

@@ -1,6 +1,7 @@
 # 2.6.0:
 # 2.6.0:
 
 
 ### Major updates
 ### Major updates
+ - New Unity 5 Editor Toolkit. Complete pipeline integration [Doc](TODO) - ([MackeyK24](https://github.com/MackeyK24))
  - New DebugLayer. [Doc](TODO) - ([temechon](https://github.com/temechon))
  - New DebugLayer. [Doc](TODO) - ([temechon](https://github.com/temechon))
  - New `VideoTexture.CreateFromWebCam` to generate video texture using WebRTC. [Demo](https://www.babylonjs-playground.com#1R77YT#2) - (Sebastien Vandenberghe)(https://github.com/sebavanmicrosoft) / ([deltakosh](https://github.com/deltakosh))
  - New `VideoTexture.CreateFromWebCam` to generate video texture using WebRTC. [Demo](https://www.babylonjs-playground.com#1R77YT#2) - (Sebastien Vandenberghe)(https://github.com/sebavanmicrosoft) / ([deltakosh](https://github.com/deltakosh))
 
 

+ 2 - 1
src/Cameras/babylon.camera.ts

@@ -527,7 +527,8 @@
             }
             }
 
 
             // Postprocesses
             // Postprocesses
-            for (var i = 0; i < this._postProcesses.length; ++i) {
+            var i = this._postProcesses.length;
+            while (--i >= 0) {
                 this._postProcesses[i].dispose(this);
                 this._postProcesses[i].dispose(this);
             }
             }
 
 

+ 11 - 3
src/Materials/Textures/babylon.mirrorTexture.ts

@@ -6,8 +6,8 @@
         private _mirrorMatrix = Matrix.Zero();
         private _mirrorMatrix = Matrix.Zero();
         private _savedViewMatrix: Matrix;
         private _savedViewMatrix: Matrix;
 
 
-        constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean) {
-            super(name, size, scene, generateMipMaps, true);
+        constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, type: number = Engine.TEXTURETYPE_UNSIGNED_INT, samplingMode = Texture.BILINEAR_SAMPLINGMODE, generateDepthBuffer = true) {
+            super(name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer);
 
 
             this.onBeforeRenderObservable.add(() => {
             this.onBeforeRenderObservable.add(() => {
                 Matrix.ReflectionToRef(this.mirrorPlane, this._mirrorMatrix);
                 Matrix.ReflectionToRef(this.mirrorPlane, this._mirrorMatrix);
@@ -35,7 +35,15 @@
 
 
         public clone(): MirrorTexture {
         public clone(): MirrorTexture {
             var textureSize = this.getSize();
             var textureSize = this.getSize();
-            var newTexture = new MirrorTexture(this.name, textureSize.width, this.getScene(), this._generateMipMaps);
+            var newTexture = new MirrorTexture(
+                this.name,
+                textureSize.width,
+                this.getScene(),
+                this._renderTargetOptions.generateMipMaps,
+                this._renderTargetOptions.type,
+                this._renderTargetOptions.samplingMode,
+                this._renderTargetOptions.generateDepthBuffer
+            );
 
 
             // Base texture
             // Base texture
             newTexture.hasAlpha = this.hasAlpha;
             newTexture.hasAlpha = this.hasAlpha;

+ 35 - 21
src/Materials/Textures/babylon.renderTargetTexture.ts

@@ -99,9 +99,15 @@
         private _currentRefreshId = -1;
         private _currentRefreshId = -1;
         private _refreshRate = 1;
         private _refreshRate = 1;
         private _textureMatrix: Matrix;
         private _textureMatrix: Matrix;
-
-        constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio: boolean = true, type: number = Engine.TEXTURETYPE_UNSIGNED_INT, public isCube = false, samplingMode = Texture.TRILINEAR_SAMPLINGMODE, 
-            generateDepthBuffer = true, generateStencilBuffer = false) {
+        protected _renderTargetOptions: {
+            generateMipMaps: boolean,
+            type: number,
+            samplingMode: number,
+            generateDepthBuffer: boolean,
+            generateStencilBuffer: boolean
+        };
+
+        constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio: boolean = true, type: number = Engine.TEXTURETYPE_UNSIGNED_INT, public isCube = false, samplingMode = Texture.TRILINEAR_SAMPLINGMODE, generateDepthBuffer = true, generateStencilBuffer = false) {
             super(null, scene, !generateMipMaps);
             super(null, scene, !generateMipMaps);
 
 
             this.name = name;
             this.name = name;
@@ -110,28 +116,25 @@
             this._generateMipMaps = generateMipMaps;
             this._generateMipMaps = generateMipMaps;
             this._doNotChangeAspectRatio = doNotChangeAspectRatio;
             this._doNotChangeAspectRatio = doNotChangeAspectRatio;
 
 
+            this._renderTargetOptions = {
+                generateMipMaps: generateMipMaps,
+                type: type,
+                samplingMode: samplingMode,
+                generateDepthBuffer: generateDepthBuffer,
+                generateStencilBuffer: generateStencilBuffer
+            };
+
             if (samplingMode === Texture.NEAREST_SAMPLINGMODE) {
             if (samplingMode === Texture.NEAREST_SAMPLINGMODE) {
                 this.wrapU = Texture.CLAMP_ADDRESSMODE;
                 this.wrapU = Texture.CLAMP_ADDRESSMODE;
                 this.wrapV = Texture.CLAMP_ADDRESSMODE;
                 this.wrapV = Texture.CLAMP_ADDRESSMODE;
             }
             }
 
 
             if (isCube) {
             if (isCube) {
-                this._texture = scene.getEngine().createRenderTargetCubeTexture(size, { 
-                    generateMipMaps: generateMipMaps, 
-                    samplingMode: samplingMode,
-                    generateDepthBuffer: generateDepthBuffer,
-                    generateStencilBuffer: generateStencilBuffer 
-                });
+                this._texture = scene.getEngine().createRenderTargetCubeTexture(size, this._renderTargetOptions);
                 this.coordinatesMode = Texture.INVCUBIC_MODE;
                 this.coordinatesMode = Texture.INVCUBIC_MODE;
                 this._textureMatrix = Matrix.Identity();
                 this._textureMatrix = Matrix.Identity();
             } else {
             } else {
-                this._texture = scene.getEngine().createRenderTargetTexture(size, { 
-                    generateMipMaps: generateMipMaps, 
-                    type: type, 
-                    samplingMode: samplingMode,
-                    generateDepthBuffer: generateDepthBuffer,
-                    generateStencilBuffer: generateStencilBuffer 
-                });
+                this._texture = scene.getEngine().createRenderTargetTexture(size, this._renderTargetOptions);
             }
             }
 
 
             // Rendering groups
             // Rendering groups
@@ -185,7 +188,7 @@
         public scale(ratio: number): void {
         public scale(ratio: number): void {
             var newSize = this._size * ratio;
             var newSize = this._size * ratio;
 
 
-            this.resize(newSize, this._generateMipMaps);
+            this.resize(newSize);
         }
         }
 
 
         public getReflectionTextureMatrix(): Matrix {
         public getReflectionTextureMatrix(): Matrix {
@@ -196,12 +199,12 @@
             return super.getReflectionTextureMatrix();
             return super.getReflectionTextureMatrix();
         }
         }
 
 
-        public resize(size: any, generateMipMaps?: boolean) {
+        public resize(size: any) {
             this.releaseInternalTexture();
             this.releaseInternalTexture();
             if (this.isCube) {
             if (this.isCube) {
-                this._texture = this.getScene().getEngine().createRenderTargetCubeTexture(size);
+                this._texture = this.getScene().getEngine().createRenderTargetCubeTexture(size, this._renderTargetOptions);
             } else {
             } else {
-                this._texture = this.getScene().getEngine().createRenderTargetTexture(size, generateMipMaps);
+                this._texture = this.getScene().getEngine().createRenderTargetTexture(size, this._renderTargetOptions);
             }
             }
         }
         }
 
 
@@ -394,7 +397,18 @@
 
 
         public clone(): RenderTargetTexture {
         public clone(): RenderTargetTexture {
             var textureSize = this.getSize();
             var textureSize = this.getSize();
-            var newTexture = new RenderTargetTexture(this.name, textureSize.width, this.getScene(), this._generateMipMaps);
+            var newTexture = new RenderTargetTexture(
+                this.name,
+                textureSize.width,
+                this.getScene(),
+                this._renderTargetOptions.generateMipMaps,
+                this._doNotChangeAspectRatio,
+                this._renderTargetOptions.type,
+                this.isCube,
+                this._renderTargetOptions.samplingMode,
+                this._renderTargetOptions.generateDepthBuffer,
+                this._renderTargetOptions.generateStencilBuffer
+            );
 
 
             // Base texture
             // Base texture
             newTexture.hasAlpha = this.hasAlpha;
             newTexture.hasAlpha = this.hasAlpha;

+ 33 - 6
src/Materials/babylon.pbrMaterial.ts

@@ -64,8 +64,9 @@
         public INVERTNORMALMAPX = false;
         public INVERTNORMALMAPX = false;
         public INVERTNORMALMAPY = false;
         public INVERTNORMALMAPY = false;
         public SHADOWFULLFLOAT = false;
         public SHADOWFULLFLOAT = false;
-        
+
         public METALLICWORKFLOW = false;
         public METALLICWORKFLOW = false;
+        public METALLICROUGHNESSMAP = false;
         public METALLICROUGHNESSGSTOREINALPHA = false;
         public METALLICROUGHNESSGSTOREINALPHA = false;
         public METALLICROUGHNESSGSTOREINGREEN = false;
         public METALLICROUGHNESSGSTOREINGREEN = false;
 
 
@@ -292,6 +293,20 @@
         @serializeAsTexture()
         @serializeAsTexture()
         public metallicTexture: BaseTexture;
         public metallicTexture: BaseTexture;
 
 
+        /**
+         * Specifies the metallic scalar of the metallic/roughness workflow.
+         * Can also be used to scale the metalness values of the metallic texture.
+         */
+        @serialize()
+        public metallic: number;
+
+        /**
+         * Specifies the roughness scalar of the metallic/roughness workflow.
+         * Can also be used to scale the roughness values of the metallic texture.
+         */
+        @serialize()
+        public roughness: number;
+
         @serializeAsTexture()
         @serializeAsTexture()
         public bumpTexture: BaseTexture;
         public bumpTexture: BaseTexture;
 
 
@@ -749,13 +764,14 @@
                     }
                     }
                 }
                 }
 
 
-                if (StandardMaterial.SpecularTextureEnabled) {                        
+                if (StandardMaterial.SpecularTextureEnabled) {
                     if (this.metallicTexture) {
                     if (this.metallicTexture) {
                         if (!this.metallicTexture.isReady()) {
                         if (!this.metallicTexture.isReady()) {
                             return false;
                             return false;
                         } else {
                         } else {
                             needUVs = true;
                             needUVs = true;
                             this._defines.METALLICWORKFLOW = true;
                             this._defines.METALLICWORKFLOW = true;
+                            this._defines.METALLICROUGHNESSMAP = true;
                             this._defines.METALLICROUGHNESSGSTOREINALPHA = this.useRoughnessFromMetallicTextureAlpha;
                             this._defines.METALLICROUGHNESSGSTOREINALPHA = this.useRoughnessFromMetallicTextureAlpha;
                             this._defines.METALLICROUGHNESSGSTOREINGREEN = !this.useRoughnessFromMetallicTextureAlpha && this.useRoughnessFromMetallicTextureGreen;
                             this._defines.METALLICROUGHNESSGSTOREINGREEN = !this.useRoughnessFromMetallicTextureAlpha && this.useRoughnessFromMetallicTextureGreen;
                         }
                         }
@@ -917,6 +933,10 @@
                 this._defines.RADIANCEOVERALPHA = true;
                 this._defines.RADIANCEOVERALPHA = true;
             }
             }
 
 
+            if (this.metallic !== undefined || this.roughness !== undefined) {
+                this._defines.METALLICWORKFLOW = true;
+            }
+
             // Attribs
             // Attribs
             if (mesh) {
             if (mesh) {
                 if (needNormals && mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
                 if (needNormals && mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
@@ -1268,13 +1288,20 @@
 
 
                 // Colors
                 // Colors
                 this._myScene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
                 this._myScene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
-                
-                // GAMMA CORRECTION.
-                this.convertColorToLinearSpaceToRef(this.reflectivityColor, PBRMaterial._scaledReflectivity);
+
+                if (this._defines.METALLICWORKFLOW) {
+                    PBRMaterial._scaledReflectivity.r = this.metallic === undefined ? 1 : this.metallic;
+                    PBRMaterial._scaledReflectivity.g = this.roughness === undefined ? 1 : this.roughness;
+                    this._effect.setColor4("vReflectivityColor", PBRMaterial._scaledReflectivity, 0);
+                }
+                else {
+                    // GAMMA CORRECTION.
+                    this.convertColorToLinearSpaceToRef(this.reflectivityColor, PBRMaterial._scaledReflectivity);
+                    this._effect.setColor4("vReflectivityColor", PBRMaterial._scaledReflectivity, this.microSurface);
+                }
 
 
                 this._effect.setVector3("vEyePosition", this._myScene._mirroredCameraPosition ? this._myScene._mirroredCameraPosition : this._myScene.activeCamera.position);
                 this._effect.setVector3("vEyePosition", this._myScene._mirroredCameraPosition ? this._myScene._mirroredCameraPosition : this._myScene.activeCamera.position);
                 this._effect.setColor3("vAmbientColor", this._globalAmbientColor);
                 this._effect.setColor3("vAmbientColor", this._globalAmbientColor);
-                this._effect.setColor4("vReflectivityColor", PBRMaterial._scaledReflectivity, this.microSurface);
 
 
                 // GAMMA CORRECTION.
                 // GAMMA CORRECTION.
                 this.convertColorToLinearSpaceToRef(this.emissiveColor, PBRMaterial._scaledEmissive);
                 this.convertColorToLinearSpaceToRef(this.emissiveColor, PBRMaterial._scaledEmissive);

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

@@ -548,7 +548,7 @@
          * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.  
          * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.  
          */
          */
         public static CreateLathe(name: string, options: { shape: Vector3[], radius?: number, tessellation?: number, arc?: number, closed?: boolean, updatable?: boolean, sideOrientation?: number, cap?: number, invertUV?: boolean }, scene: Scene): Mesh {
         public static CreateLathe(name: string, options: { shape: Vector3[], radius?: number, tessellation?: number, arc?: number, closed?: boolean, updatable?: boolean, sideOrientation?: number, cap?: number, invertUV?: boolean }, scene: Scene): Mesh {
-            var arc: number = (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
+            var arc: number = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
             var closed: boolean = (options.closed === undefined) ? true : options.closed;
             var closed: boolean = (options.closed === undefined) ? true : options.closed;
             var shape = options.shape;
             var shape = options.shape;
             var radius = options.radius || 1;
             var radius = options.radius || 1;

+ 19 - 14
src/Shaders/pbr.fragment.fx

@@ -269,35 +269,40 @@ void main(void) {
 #endif
 #endif
 
 
 #ifdef METALLICWORKFLOW
 #ifdef METALLICWORKFLOW
-	vec4 surfaceMetallicColorMap = texture2D(reflectivitySampler, vReflectivityUV + uvOffset);
-
-	// No gamma space fro the metallic map in metallic workflow.
-	float metallic = surfaceMetallicColorMap.r; // Unity like base channel for metallness.
+	vec2 metallicRoughness = surfaceReflectivityColor.rg;
+
+	#ifdef METALLICROUGHNESSMAP
+		vec4 surfaceMetallicColorMap = texture2D(reflectivitySampler, vReflectivityUV + uvOffset);
+
+		// No gamma space from the metallic map in metallic workflow.
+		metallicRoughness.r *= surfaceMetallicColorMap.r;
+		#ifdef METALLICROUGHNESSGSTOREINALPHA
+			metallicRoughness.g *= surfaceMetallicColorMap.a;
+		#else
+			#ifdef METALLICROUGHNESSGSTOREINGREEN
+				metallicRoughness.g *= surfaceMetallicColorMap.g;
+			#endif
+		#endif
+	#endif
 
 
 	// Diffuse is used as the base of the reflectivity.
 	// Diffuse is used as the base of the reflectivity.
 	vec3 baseColor = surfaceAlbedo.rgb;
 	vec3 baseColor = surfaceAlbedo.rgb;
 
 
 	// Drop the surface diffuse by the 1.0 - metalness.
 	// Drop the surface diffuse by the 1.0 - metalness.
-	surfaceAlbedo.rgb *= (1.0 - metallic);
+	surfaceAlbedo.rgb *= (1.0 - metallicRoughness.r);
 	
 	
 	// Default specular reflectance at normal incidence.
 	// Default specular reflectance at normal incidence.
-	// 4% corresponds to index of refraction (IOR) of 1.50, approximately equal to glass.    
+	// 4% corresponds to index of refraction (IOR) of 1.50, approximately equal to glass.
 	const vec3 DefaultSpecularReflectanceDielectric = vec3(0.04, 0.04, 0.04);
 	const vec3 DefaultSpecularReflectanceDielectric = vec3(0.04, 0.04, 0.04);
 
 
 	// Compute the converted reflectivity.
 	// Compute the converted reflectivity.
-	surfaceReflectivityColor = mix(DefaultSpecularReflectanceDielectric, baseColor, metallic);
+	surfaceReflectivityColor = mix(DefaultSpecularReflectanceDielectric, baseColor, metallicRoughness.r);
 
 
 	#ifdef OVERLOADEDVALUES
 	#ifdef OVERLOADEDVALUES
 		surfaceReflectivityColor = mix(surfaceReflectivityColor, vOverloadedReflectivity, vOverloadedIntensity.z);
 		surfaceReflectivityColor = mix(surfaceReflectivityColor, vOverloadedReflectivity, vOverloadedIntensity.z);
 	#endif
 	#endif
 
 
-	#ifdef METALLICROUGHNESSGSTOREINALPHA
-		microSurface = 1.0 - surfaceMetallicColorMap.a;
-	#else
-		#ifdef METALLICROUGHNESSGSTOREINGREEN
-			microSurface = 1.0 - surfaceMetallicColorMap.g;
-		#endif
-	#endif
+	microSurface = 1.0 - metallicRoughness.g;
 #endif
 #endif
 
 
 #ifdef OVERLOADEDVALUES
 #ifdef OVERLOADEDVALUES

+ 8 - 8
src/babylon.engine.ts

@@ -524,14 +524,14 @@
             var renderToHalfFloat = this._canRenderToHalfFloatTexture();
             var renderToHalfFloat = this._canRenderToHalfFloatTexture();
 
 
             // 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) {
                 if (!canvas) {
                 if (!canvas) {