Bläddra i källkod

Perceptual Color Experiment

Sebastien Vandenberghe 7 år sedan
förälder
incheckning
821f919a08

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 3455 - 3458
Playground/babylon.d.txt


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


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


+ 12 - 48
dist/preview release/babylon.max.js

@@ -96023,8 +96023,10 @@ var BABYLON;
             };
             return _this;
         }
-        Object.defineProperty(BackgroundMaterial.prototype, "perceptualColor", {
+        Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
             /**
+             * Experimental Internal Use Only.
+             *
              * Key light Color in "perceptual value" meaning the color you would like to see on screen.
              * This acts as a helper to set the primary color to a more "human friendly" value.
              * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
@@ -96033,10 +96035,10 @@ var BABYLON;
              * part of lighting setup.)
              */
             get: function () {
-                return this._perceptualColor;
+                return this.__perceptualColor;
             },
             set: function (value) {
-                this._perceptualColor = value;
+                this.__perceptualColor = value;
                 this._computePrimaryColorFromPerceptualColor();
                 this._markAllSubMeshesAsLightsDirty();
             },
@@ -96536,29 +96538,14 @@ var BABYLON;
          * Compute the primary color according to the chosen perceptual color.
          */
         BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
-            if (!this._perceptualColor) {
+            if (!this.__perceptualColor) {
                 return;
             }
-            this._primaryColor.copyFrom(this._perceptualColor);
+            this._primaryColor.copyFrom(this.__perceptualColor);
             // Revert gamma space.
             this._primaryColor.toLinearSpaceToRef(this._primaryColor);
             // Revert image processing configuration.
             if (this._imageProcessingConfiguration) {
-                // Revert tone mapping.
-                if (this._imageProcessingConfiguration.toneMappingEnabled) {
-                    // shader reference.
-                    // tonemapped.rgb = 1.0 - exp2(-tonemappingCalibration * color.rgb);
-                    // providing
-                    // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration = color.rgb;
-                    // 1.0 - tonemapped.rgb
-                    this._white.subtractToRef(this._primaryColor, this._primaryColor);
-                    // log2(1.0 - tonemapped.rgb)
-                    this._primaryColor.r = BABYLON.Scalar.Log2(this._primaryColor.r);
-                    this._primaryColor.g = BABYLON.Scalar.Log2(this._primaryColor.g);
-                    this._primaryColor.b = BABYLON.Scalar.Log2(this._primaryColor.b);
-                    // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration
-                    this._primaryColor.scaleToRef(-1 / BackgroundMaterial._tonemappingCalibration, this._primaryColor);
-                }
                 // Revert Exposure.
                 this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
             }
@@ -96574,12 +96561,10 @@ var BABYLON;
             // Find the highlight color based on the configuration.
             this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
             this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
-            this._primaryShadowColor.clampToRef(0, 1, this._primaryShadowColor);
             // Find the shadow color based on the configuration.
             this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
             this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
             this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
-            this._primaryHighlightColor.clampToRef(0, 1, this._primaryHighlightColor);
         };
         /**
          * Build the uniform buffer used in the material.
@@ -96781,10 +96766,6 @@ var BABYLON;
          * Standard reflectance value at grazing angle.
          */
         BackgroundMaterial.StandardReflectance90 = 0.5;
-        /**
-         * Tone Mapping calibration (should match image processing tone mapping calibration value).
-         */
-        BackgroundMaterial._tonemappingCalibration = 1.590579;
         __decorate([
             BABYLON.serializeAsColor3()
         ], BackgroundMaterial.prototype, "_primaryColor", void 0);
@@ -96793,7 +96774,7 @@ var BABYLON;
         ], BackgroundMaterial.prototype, "primaryColor", void 0);
         __decorate([
             BABYLON.serializeAsColor3()
-        ], BackgroundMaterial.prototype, "_perceptualColor", void 0);
+        ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
         __decorate([
             BABYLON.serialize()
         ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
@@ -97110,33 +97091,16 @@ var BABYLON;
         /**
          * Sets the primary color of all the available elements.
          * @param color the main color to affect to the ground and the background
-         * @param perceptual Specifies wether the chosen color has been set as intented to be seen e.g. in gamma space not accounting for exposure and tone mapping
          */
-        EnvironmentHelper.prototype.setMainColor = function (color, perceptual) {
-            if (perceptual === void 0) { perceptual = false; }
+        EnvironmentHelper.prototype.setMainColor = function (color) {
             if (this.groundMaterial) {
-                if (perceptual) {
-                    this.groundMaterial.perceptualColor = color;
-                }
-                else {
-                    this.groundMaterial.primaryColor = color;
-                }
+                this.groundMaterial.primaryColor = color;
             }
             if (this.skyboxMaterial) {
-                if (perceptual) {
-                    this.skyboxMaterial.perceptualColor = color;
-                }
-                else {
-                    this.skyboxMaterial.primaryColor = color;
-                }
+                this.skyboxMaterial.primaryColor = color;
             }
             if (this.groundMirror) {
-                if (perceptual && this.groundMaterial) {
-                    this.groundMirror.clearColor = new BABYLON.Color4(this.groundMaterial.primaryColor.r, this.groundMaterial.primaryColor.g, this.groundMaterial.primaryColor.b, 1.0);
-                }
-                else {
-                    this.groundMirror.clearColor = new BABYLON.Color4(color.r, color.g, color.b, 1.0);
-                }
+                this.groundMirror.clearColor = new BABYLON.Color4(color.r, color.g, color.b, 1.0);
             }
         };
         /**

+ 12 - 48
dist/preview release/babylon.no-module.max.js

@@ -95990,8 +95990,10 @@ var BABYLON;
             };
             return _this;
         }
-        Object.defineProperty(BackgroundMaterial.prototype, "perceptualColor", {
+        Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
             /**
+             * Experimental Internal Use Only.
+             *
              * Key light Color in "perceptual value" meaning the color you would like to see on screen.
              * This acts as a helper to set the primary color to a more "human friendly" value.
              * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
@@ -96000,10 +96002,10 @@ var BABYLON;
              * part of lighting setup.)
              */
             get: function () {
-                return this._perceptualColor;
+                return this.__perceptualColor;
             },
             set: function (value) {
-                this._perceptualColor = value;
+                this.__perceptualColor = value;
                 this._computePrimaryColorFromPerceptualColor();
                 this._markAllSubMeshesAsLightsDirty();
             },
@@ -96503,29 +96505,14 @@ var BABYLON;
          * Compute the primary color according to the chosen perceptual color.
          */
         BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
-            if (!this._perceptualColor) {
+            if (!this.__perceptualColor) {
                 return;
             }
-            this._primaryColor.copyFrom(this._perceptualColor);
+            this._primaryColor.copyFrom(this.__perceptualColor);
             // Revert gamma space.
             this._primaryColor.toLinearSpaceToRef(this._primaryColor);
             // Revert image processing configuration.
             if (this._imageProcessingConfiguration) {
-                // Revert tone mapping.
-                if (this._imageProcessingConfiguration.toneMappingEnabled) {
-                    // shader reference.
-                    // tonemapped.rgb = 1.0 - exp2(-tonemappingCalibration * color.rgb);
-                    // providing
-                    // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration = color.rgb;
-                    // 1.0 - tonemapped.rgb
-                    this._white.subtractToRef(this._primaryColor, this._primaryColor);
-                    // log2(1.0 - tonemapped.rgb)
-                    this._primaryColor.r = BABYLON.Scalar.Log2(this._primaryColor.r);
-                    this._primaryColor.g = BABYLON.Scalar.Log2(this._primaryColor.g);
-                    this._primaryColor.b = BABYLON.Scalar.Log2(this._primaryColor.b);
-                    // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration
-                    this._primaryColor.scaleToRef(-1 / BackgroundMaterial._tonemappingCalibration, this._primaryColor);
-                }
                 // Revert Exposure.
                 this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
             }
@@ -96541,12 +96528,10 @@ var BABYLON;
             // Find the highlight color based on the configuration.
             this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
             this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
-            this._primaryShadowColor.clampToRef(0, 1, this._primaryShadowColor);
             // Find the shadow color based on the configuration.
             this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
             this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
             this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
-            this._primaryHighlightColor.clampToRef(0, 1, this._primaryHighlightColor);
         };
         /**
          * Build the uniform buffer used in the material.
@@ -96748,10 +96733,6 @@ var BABYLON;
          * Standard reflectance value at grazing angle.
          */
         BackgroundMaterial.StandardReflectance90 = 0.5;
-        /**
-         * Tone Mapping calibration (should match image processing tone mapping calibration value).
-         */
-        BackgroundMaterial._tonemappingCalibration = 1.590579;
         __decorate([
             BABYLON.serializeAsColor3()
         ], BackgroundMaterial.prototype, "_primaryColor", void 0);
@@ -96760,7 +96741,7 @@ var BABYLON;
         ], BackgroundMaterial.prototype, "primaryColor", void 0);
         __decorate([
             BABYLON.serializeAsColor3()
-        ], BackgroundMaterial.prototype, "_perceptualColor", void 0);
+        ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
         __decorate([
             BABYLON.serialize()
         ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
@@ -97077,33 +97058,16 @@ var BABYLON;
         /**
          * Sets the primary color of all the available elements.
          * @param color the main color to affect to the ground and the background
-         * @param perceptual Specifies wether the chosen color has been set as intented to be seen e.g. in gamma space not accounting for exposure and tone mapping
          */
-        EnvironmentHelper.prototype.setMainColor = function (color, perceptual) {
-            if (perceptual === void 0) { perceptual = false; }
+        EnvironmentHelper.prototype.setMainColor = function (color) {
             if (this.groundMaterial) {
-                if (perceptual) {
-                    this.groundMaterial.perceptualColor = color;
-                }
-                else {
-                    this.groundMaterial.primaryColor = color;
-                }
+                this.groundMaterial.primaryColor = color;
             }
             if (this.skyboxMaterial) {
-                if (perceptual) {
-                    this.skyboxMaterial.perceptualColor = color;
-                }
-                else {
-                    this.skyboxMaterial.primaryColor = color;
-                }
+                this.skyboxMaterial.primaryColor = color;
             }
             if (this.groundMirror) {
-                if (perceptual && this.groundMaterial) {
-                    this.groundMirror.clearColor = new BABYLON.Color4(this.groundMaterial.primaryColor.r, this.groundMaterial.primaryColor.g, this.groundMaterial.primaryColor.b, 1.0);
-                }
-                else {
-                    this.groundMirror.clearColor = new BABYLON.Color4(color.r, color.g, color.b, 1.0);
-                }
+                this.groundMirror.clearColor = new BABYLON.Color4(color.r, color.g, color.b, 1.0);
             }
         };
         /**

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


+ 12 - 48
dist/preview release/es6.js

@@ -95990,8 +95990,10 @@ var BABYLON;
             };
             return _this;
         }
-        Object.defineProperty(BackgroundMaterial.prototype, "perceptualColor", {
+        Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
             /**
+             * Experimental Internal Use Only.
+             *
              * Key light Color in "perceptual value" meaning the color you would like to see on screen.
              * This acts as a helper to set the primary color to a more "human friendly" value.
              * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
@@ -96000,10 +96002,10 @@ var BABYLON;
              * part of lighting setup.)
              */
             get: function () {
-                return this._perceptualColor;
+                return this.__perceptualColor;
             },
             set: function (value) {
-                this._perceptualColor = value;
+                this.__perceptualColor = value;
                 this._computePrimaryColorFromPerceptualColor();
                 this._markAllSubMeshesAsLightsDirty();
             },
@@ -96503,29 +96505,14 @@ var BABYLON;
          * Compute the primary color according to the chosen perceptual color.
          */
         BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
-            if (!this._perceptualColor) {
+            if (!this.__perceptualColor) {
                 return;
             }
-            this._primaryColor.copyFrom(this._perceptualColor);
+            this._primaryColor.copyFrom(this.__perceptualColor);
             // Revert gamma space.
             this._primaryColor.toLinearSpaceToRef(this._primaryColor);
             // Revert image processing configuration.
             if (this._imageProcessingConfiguration) {
-                // Revert tone mapping.
-                if (this._imageProcessingConfiguration.toneMappingEnabled) {
-                    // shader reference.
-                    // tonemapped.rgb = 1.0 - exp2(-tonemappingCalibration * color.rgb);
-                    // providing
-                    // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration = color.rgb;
-                    // 1.0 - tonemapped.rgb
-                    this._white.subtractToRef(this._primaryColor, this._primaryColor);
-                    // log2(1.0 - tonemapped.rgb)
-                    this._primaryColor.r = BABYLON.Scalar.Log2(this._primaryColor.r);
-                    this._primaryColor.g = BABYLON.Scalar.Log2(this._primaryColor.g);
-                    this._primaryColor.b = BABYLON.Scalar.Log2(this._primaryColor.b);
-                    // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration
-                    this._primaryColor.scaleToRef(-1 / BackgroundMaterial._tonemappingCalibration, this._primaryColor);
-                }
                 // Revert Exposure.
                 this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
             }
@@ -96541,12 +96528,10 @@ var BABYLON;
             // Find the highlight color based on the configuration.
             this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
             this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
-            this._primaryShadowColor.clampToRef(0, 1, this._primaryShadowColor);
             // Find the shadow color based on the configuration.
             this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
             this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
             this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
-            this._primaryHighlightColor.clampToRef(0, 1, this._primaryHighlightColor);
         };
         /**
          * Build the uniform buffer used in the material.
@@ -96748,10 +96733,6 @@ var BABYLON;
          * Standard reflectance value at grazing angle.
          */
         BackgroundMaterial.StandardReflectance90 = 0.5;
-        /**
-         * Tone Mapping calibration (should match image processing tone mapping calibration value).
-         */
-        BackgroundMaterial._tonemappingCalibration = 1.590579;
         __decorate([
             BABYLON.serializeAsColor3()
         ], BackgroundMaterial.prototype, "_primaryColor", void 0);
@@ -96760,7 +96741,7 @@ var BABYLON;
         ], BackgroundMaterial.prototype, "primaryColor", void 0);
         __decorate([
             BABYLON.serializeAsColor3()
-        ], BackgroundMaterial.prototype, "_perceptualColor", void 0);
+        ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
         __decorate([
             BABYLON.serialize()
         ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
@@ -97077,33 +97058,16 @@ var BABYLON;
         /**
          * Sets the primary color of all the available elements.
          * @param color the main color to affect to the ground and the background
-         * @param perceptual Specifies wether the chosen color has been set as intented to be seen e.g. in gamma space not accounting for exposure and tone mapping
          */
-        EnvironmentHelper.prototype.setMainColor = function (color, perceptual) {
-            if (perceptual === void 0) { perceptual = false; }
+        EnvironmentHelper.prototype.setMainColor = function (color) {
             if (this.groundMaterial) {
-                if (perceptual) {
-                    this.groundMaterial.perceptualColor = color;
-                }
-                else {
-                    this.groundMaterial.primaryColor = color;
-                }
+                this.groundMaterial.primaryColor = color;
             }
             if (this.skyboxMaterial) {
-                if (perceptual) {
-                    this.skyboxMaterial.perceptualColor = color;
-                }
-                else {
-                    this.skyboxMaterial.primaryColor = color;
-                }
+                this.skyboxMaterial.primaryColor = color;
             }
             if (this.groundMirror) {
-                if (perceptual && this.groundMaterial) {
-                    this.groundMirror.clearColor = new BABYLON.Color4(this.groundMaterial.primaryColor.r, this.groundMaterial.primaryColor.g, this.groundMaterial.primaryColor.b, 1.0);
-                }
-                else {
-                    this.groundMirror.clearColor = new BABYLON.Color4(color.r, color.g, color.b, 1.0);
-                }
+                this.groundMirror.clearColor = new BABYLON.Color4(color.r, color.g, color.b, 1.0);
             }
         };
         /**

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


+ 55 - 85
dist/preview release/viewer/babylon.viewer.max.js

@@ -96111,8 +96111,10 @@ var BABYLON;
             };
             return _this;
         }
-        Object.defineProperty(BackgroundMaterial.prototype, "perceptualColor", {
+        Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
             /**
+             * Experimental Internal Use Only.
+             *
              * Key light Color in "perceptual value" meaning the color you would like to see on screen.
              * This acts as a helper to set the primary color to a more "human friendly" value.
              * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
@@ -96121,10 +96123,10 @@ var BABYLON;
              * part of lighting setup.)
              */
             get: function () {
-                return this._perceptualColor;
+                return this.__perceptualColor;
             },
             set: function (value) {
-                this._perceptualColor = value;
+                this.__perceptualColor = value;
                 this._computePrimaryColorFromPerceptualColor();
                 this._markAllSubMeshesAsLightsDirty();
             },
@@ -96624,29 +96626,14 @@ var BABYLON;
          * Compute the primary color according to the chosen perceptual color.
          */
         BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
-            if (!this._perceptualColor) {
+            if (!this.__perceptualColor) {
                 return;
             }
-            this._primaryColor.copyFrom(this._perceptualColor);
+            this._primaryColor.copyFrom(this.__perceptualColor);
             // Revert gamma space.
             this._primaryColor.toLinearSpaceToRef(this._primaryColor);
             // Revert image processing configuration.
             if (this._imageProcessingConfiguration) {
-                // Revert tone mapping.
-                if (this._imageProcessingConfiguration.toneMappingEnabled) {
-                    // shader reference.
-                    // tonemapped.rgb = 1.0 - exp2(-tonemappingCalibration * color.rgb);
-                    // providing
-                    // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration = color.rgb;
-                    // 1.0 - tonemapped.rgb
-                    this._white.subtractToRef(this._primaryColor, this._primaryColor);
-                    // log2(1.0 - tonemapped.rgb)
-                    this._primaryColor.r = BABYLON.Scalar.Log2(this._primaryColor.r);
-                    this._primaryColor.g = BABYLON.Scalar.Log2(this._primaryColor.g);
-                    this._primaryColor.b = BABYLON.Scalar.Log2(this._primaryColor.b);
-                    // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration
-                    this._primaryColor.scaleToRef(-1 / BackgroundMaterial._tonemappingCalibration, this._primaryColor);
-                }
                 // Revert Exposure.
                 this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
             }
@@ -96662,12 +96649,10 @@ var BABYLON;
             // Find the highlight color based on the configuration.
             this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
             this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
-            this._primaryShadowColor.clampToRef(0, 1, this._primaryShadowColor);
             // Find the shadow color based on the configuration.
             this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
             this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
             this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
-            this._primaryHighlightColor.clampToRef(0, 1, this._primaryHighlightColor);
         };
         /**
          * Build the uniform buffer used in the material.
@@ -96869,10 +96854,6 @@ var BABYLON;
          * Standard reflectance value at grazing angle.
          */
         BackgroundMaterial.StandardReflectance90 = 0.5;
-        /**
-         * Tone Mapping calibration (should match image processing tone mapping calibration value).
-         */
-        BackgroundMaterial._tonemappingCalibration = 1.590579;
         __decorate([
             BABYLON.serializeAsColor3()
         ], BackgroundMaterial.prototype, "_primaryColor", void 0);
@@ -96881,7 +96862,7 @@ var BABYLON;
         ], BackgroundMaterial.prototype, "primaryColor", void 0);
         __decorate([
             BABYLON.serializeAsColor3()
-        ], BackgroundMaterial.prototype, "_perceptualColor", void 0);
+        ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
         __decorate([
             BABYLON.serialize()
         ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
@@ -97198,33 +97179,16 @@ var BABYLON;
         /**
          * Sets the primary color of all the available elements.
          * @param color the main color to affect to the ground and the background
-         * @param perceptual Specifies wether the chosen color has been set as intented to be seen e.g. in gamma space not accounting for exposure and tone mapping
          */
-        EnvironmentHelper.prototype.setMainColor = function (color, perceptual) {
-            if (perceptual === void 0) { perceptual = false; }
+        EnvironmentHelper.prototype.setMainColor = function (color) {
             if (this.groundMaterial) {
-                if (perceptual) {
-                    this.groundMaterial.perceptualColor = color;
-                }
-                else {
-                    this.groundMaterial.primaryColor = color;
-                }
+                this.groundMaterial.primaryColor = color;
             }
             if (this.skyboxMaterial) {
-                if (perceptual) {
-                    this.skyboxMaterial.perceptualColor = color;
-                }
-                else {
-                    this.skyboxMaterial.primaryColor = color;
-                }
+                this.skyboxMaterial.primaryColor = color;
             }
             if (this.groundMirror) {
-                if (perceptual && this.groundMaterial) {
-                    this.groundMirror.clearColor = new BABYLON.Color4(this.groundMaterial.primaryColor.r, this.groundMaterial.primaryColor.g, this.groundMaterial.primaryColor.b, 1.0);
-                }
-                else {
-                    this.groundMirror.clearColor = new BABYLON.Color4(color.r, color.g, color.b, 1.0);
-                }
+                this.groundMirror.clearColor = new BABYLON.Color4(color.r, color.g, color.b, 1.0);
             }
         };
         /**
@@ -105112,7 +105076,6 @@ var BABYLON;
                 return Promise.all(promises).then(function () { });
             };
             GLTFLoader.prototype._loadMeshAsync = function (context, node, mesh, babylonMesh) {
-                // TODO: instancing
                 var _this = this;
                 var promises = new Array();
                 var primitives = mesh.primitives;
@@ -105314,9 +105277,9 @@ var BABYLON;
             };
             GLTFLoader.prototype._loadSkinAsync = function (context, node, mesh, skin) {
                 var _this = this;
-                var assignSkeleton = function () {
+                var assignSkeleton = function (skeleton) {
                     _this._forEachPrimitive(node, function (babylonMesh) {
-                        babylonMesh.skeleton = skin._babylonSkeleton;
+                        babylonMesh.skeleton = skeleton;
                     });
                     // Ignore the TRS of skinned nodes.
                     // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
@@ -105327,61 +105290,68 @@ var BABYLON;
                 };
                 if (skin._loaded) {
                     return skin._loaded.then(function () {
-                        assignSkeleton();
+                        assignSkeleton(skin._babylonSkeleton);
                     });
                 }
-                // TODO: split into two parts so that bones are created before inverseBindMatricesData is loaded (for compiling materials).
+                var skeletonId = "skeleton" + skin._index;
+                var babylonSkeleton = new BABYLON.Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene);
+                skin._babylonSkeleton = babylonSkeleton;
+                this._loadBones(context, skin);
+                assignSkeleton(babylonSkeleton);
                 return (skin._loaded = this._loadSkinInverseBindMatricesDataAsync(context, skin).then(function (inverseBindMatricesData) {
-                    var skeletonId = "skeleton" + skin._index;
-                    var babylonSkeleton = new BABYLON.Skeleton(skin.name || skeletonId, skeletonId, _this._babylonScene);
-                    skin._babylonSkeleton = babylonSkeleton;
-                    _this._loadBones(context, skin, inverseBindMatricesData);
-                    assignSkeleton();
+                    _this._updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
                 }));
             };
-            GLTFLoader.prototype._loadSkinInverseBindMatricesDataAsync = function (context, skin) {
-                if (skin.inverseBindMatrices == undefined) {
-                    return Promise.resolve(null);
-                }
-                var accessor = GLTFLoader._GetProperty(context + "/inverseBindMatrices", this._gltf.accessors, skin.inverseBindMatrices);
-                return this._loadAccessorAsync("#/accessors/" + accessor._index, accessor).then(function (data) {
-                    return data;
-                });
-            };
-            GLTFLoader.prototype._createBone = function (node, skin, parent, localMatrix, baseMatrix, index) {
-                var babylonBone = new BABYLON.Bone(node.name || "joint" + node._index, skin._babylonSkeleton, parent, localMatrix, null, baseMatrix, index);
-                node._babylonAnimationTargets = node._babylonAnimationTargets || [];
-                node._babylonAnimationTargets.push(babylonBone);
-                return babylonBone;
-            };
-            GLTFLoader.prototype._loadBones = function (context, skin, inverseBindMatricesData) {
+            GLTFLoader.prototype._loadBones = function (context, skin) {
                 var babylonBones = {};
                 for (var _i = 0, _a = skin.joints; _i < _a.length; _i++) {
                     var index = _a[_i];
                     var node = GLTFLoader._GetProperty(context + "/joints/" + index, this._gltf.nodes, index);
-                    this._loadBone(node, skin, inverseBindMatricesData, babylonBones);
+                    this._loadBone(node, skin, babylonBones);
                 }
             };
-            GLTFLoader.prototype._loadBone = function (node, skin, inverseBindMatricesData, babylonBones) {
+            GLTFLoader.prototype._loadBone = function (node, skin, babylonBones) {
                 var babylonBone = babylonBones[node._index];
                 if (babylonBone) {
                     return babylonBone;
                 }
-                var boneIndex = skin.joints.indexOf(node._index);
-                var baseMatrix = BABYLON.Matrix.Identity();
-                if (inverseBindMatricesData && boneIndex !== -1) {
-                    baseMatrix = BABYLON.Matrix.FromArray(inverseBindMatricesData, boneIndex * 16);
-                    baseMatrix.invertToRef(baseMatrix);
-                }
                 var babylonParentBone = null;
                 if (node._parent._babylonMesh !== this._rootBabylonMesh) {
-                    babylonParentBone = this._loadBone(node._parent, skin, inverseBindMatricesData, babylonBones);
-                    baseMatrix.multiplyToRef(babylonParentBone.getInvertedAbsoluteTransform(), baseMatrix);
+                    babylonParentBone = this._loadBone(node._parent, skin, babylonBones);
                 }
-                babylonBone = this._createBone(node, skin, babylonParentBone, this._getNodeMatrix(node), baseMatrix, boneIndex);
+                var boneIndex = skin.joints.indexOf(node._index);
+                babylonBone = new BABYLON.Bone(node.name || "joint" + node._index, skin._babylonSkeleton, babylonParentBone, this._getNodeMatrix(node), null, null, boneIndex);
                 babylonBones[node._index] = babylonBone;
+                node._babylonAnimationTargets = node._babylonAnimationTargets || [];
+                node._babylonAnimationTargets.push(babylonBone);
                 return babylonBone;
             };
+            GLTFLoader.prototype._loadSkinInverseBindMatricesDataAsync = function (context, skin) {
+                if (skin.inverseBindMatrices == undefined) {
+                    return Promise.resolve(null);
+                }
+                var accessor = GLTFLoader._GetProperty(context + "/inverseBindMatrices", this._gltf.accessors, skin.inverseBindMatrices);
+                return this._loadAccessorAsync("#/accessors/" + accessor._index, accessor).then(function (data) {
+                    return data;
+                });
+            };
+            GLTFLoader.prototype._updateBoneMatrices = function (babylonSkeleton, inverseBindMatricesData) {
+                for (var _i = 0, _a = babylonSkeleton.bones; _i < _a.length; _i++) {
+                    var babylonBone = _a[_i];
+                    var baseMatrix = BABYLON.Matrix.Identity();
+                    var boneIndex = babylonBone._index;
+                    if (inverseBindMatricesData && boneIndex !== -1) {
+                        BABYLON.Matrix.FromArrayToRef(inverseBindMatricesData, boneIndex * 16, baseMatrix);
+                        baseMatrix.invertToRef(baseMatrix);
+                    }
+                    var babylonParentBone = babylonBone.getParent();
+                    if (babylonParentBone) {
+                        baseMatrix.multiplyToRef(babylonParentBone.getInvertedAbsoluteTransform(), baseMatrix);
+                    }
+                    babylonBone.updateMatrix(baseMatrix, false, false);
+                    babylonBone._updateDifferenceMatrix(undefined, false);
+                }
+            };
             GLTFLoader.prototype._getNodeMatrix = function (node) {
                 return node.matrix ?
                     BABYLON.Matrix.FromArray(node.matrix) :

+ 4 - 23
src/Helpers/babylon.environmentHelper.ts

@@ -396,37 +396,18 @@ module BABYLON {
         /**
          * Sets the primary color of all the available elements.
          * @param color the main color to affect to the ground and the background
-         * @param perceptual Specifies wether the chosen color has been set as intented to be seen e.g. in gamma space not accounting for exposure and tone mapping
          */
-        public setMainColor(color: Color3, perceptual = false): void {
+        public setMainColor(color: Color3): void {
             if (this.groundMaterial) {
-                if (perceptual) {
-                    this.groundMaterial.perceptualColor = color;
-                }
-                else {
-                    this.groundMaterial.primaryColor = color;
-                }
+                this.groundMaterial.primaryColor = color;
             }
 
             if (this.skyboxMaterial) {
-                if (perceptual) {
-                    this.skyboxMaterial.perceptualColor = color;
-                }
-                else {
-                    this.skyboxMaterial.primaryColor = color;
-                }
+                this.skyboxMaterial.primaryColor = color;
             }
 
             if (this.groundMirror) {
-                if (perceptual && this.groundMaterial) {
-                    this.groundMirror.clearColor = new Color4(this.groundMaterial.primaryColor.r, 
-                        this.groundMaterial.primaryColor.g, 
-                        this.groundMaterial.primaryColor.b, 
-                        1.0);
-                }
-                else {
-                    this.groundMirror.clearColor = new Color4(color.r, color.g, color.b, 1.0);
-                }
+                this.groundMirror.clearColor = new Color4(color.r, color.g, color.b, 1.0);
             }
         }
 

+ 9 - 33
src/Materials/Background/babylon.backgroundMaterial.ts

@@ -155,8 +155,10 @@
         public primaryColor = Color3.White();
         
         @serializeAsColor3()
-        protected _perceptualColor: Nullable<Color3>;
+        protected __perceptualColor: Nullable<Color3>;
         /**
+         * Experimental Internal Use Only.
+         * 
          * Key light Color in "perceptual value" meaning the color you would like to see on screen.
          * This acts as a helper to set the primary color to a more "human friendly" value.
          * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
@@ -164,11 +166,11 @@
          * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
          * part of lighting setup.)
          */
-        public get perceptualColor(): Nullable<Color3> {
-            return this._perceptualColor;
+        public get _perceptualColor(): Nullable<Color3> {
+            return this.__perceptualColor;
         }
-        public set perceptualColor(value: Nullable<Color3>) {
-            this._perceptualColor = value;
+        public set _perceptualColor(value: Nullable<Color3>) {
+            this.__perceptualColor = value;
             this._computePrimaryColorFromPerceptualColor();
             this._markAllSubMeshesAsLightsDirty();
         }
@@ -865,44 +867,20 @@
         }
 
         /**
-         * Tone Mapping calibration (should match image processing tone mapping calibration value).
-         */
-        private static readonly _tonemappingCalibration = 1.590579;
-
-        /**
          * Compute the primary color according to the chosen perceptual color.
          */
         private _computePrimaryColorFromPerceptualColor(): void {
-            if (!this._perceptualColor) {
+            if (!this.__perceptualColor) {
                 return;
             }
 
-            this._primaryColor.copyFrom(this._perceptualColor);
+            this._primaryColor.copyFrom(this.__perceptualColor);
 
             // Revert gamma space.
             this._primaryColor.toLinearSpaceToRef(this._primaryColor);
 
             // Revert image processing configuration.
             if (this._imageProcessingConfiguration) {
-                // Revert tone mapping.
-                if (this._imageProcessingConfiguration.toneMappingEnabled) {
-                    // shader reference.
-                    // tonemapped.rgb = 1.0 - exp2(-tonemappingCalibration * color.rgb);
-                    // providing
-                    // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration = color.rgb;
-
-                    // 1.0 - tonemapped.rgb
-                    this._white.subtractToRef(this._primaryColor, this._primaryColor);
-
-                    // log2(1.0 - tonemapped.rgb)
-                    this._primaryColor.r = Scalar.Log2(this._primaryColor.r);
-                    this._primaryColor.g = Scalar.Log2(this._primaryColor.g);
-                    this._primaryColor.b = Scalar.Log2(this._primaryColor.b);
-                    
-                    // log2(1.0 - tonemapped.rgb) / -tonemappingCalibration
-                    this._primaryColor.scaleToRef(-1 / BackgroundMaterial._tonemappingCalibration, this._primaryColor);
-                }
-
                 // Revert Exposure.
                 this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
             }
@@ -921,13 +899,11 @@
             // Find the highlight color based on the configuration.
             this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
             this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
-            this._primaryShadowColor.clampToRef(0, 1, this._primaryShadowColor);
 
             // Find the shadow color based on the configuration.
             this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
             this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
             this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
-            this._primaryHighlightColor.clampToRef(0, 1, this._primaryHighlightColor);
         }
 
         /**