Sebastien Vandenberghe 7 anni fa
parent
commit
ab4a1c94e2

+ 7 - 5
sandbox/index.js

@@ -43,7 +43,7 @@ if (indexOf !== -1) {
 
 if (BABYLON.Engine.isSupported()) {
     var canvas = document.getElementById("renderCanvas");
-    var engine = new BABYLON.Engine(canvas, true);
+    var engine = new BABYLON.Engine(canvas, true, { premultipliedAlpha: false, preserveDrawingBuffer: true });
     var htmlInput = document.getElementById("files");
     var footer = document.getElementById("footer");
     var btnFullScreen = document.getElementById("btnFullscreen");
@@ -235,10 +235,12 @@ if (BABYLON.Engine.isSupported()) {
     else {
         filesInput = new BABYLON.FilesInput(engine, null, sceneLoaded, null, null, null, function () { BABYLON.Tools.ClearLogCache() }, null, sceneError);
         filesInput.onProcessFileCallback = (function (file, name, extension) {
-            if (filesInput._filesToLoad && filesInput._filesToLoad.length === 1 && extension && extension.toLowerCase() === "dds") {
-                BABYLON.FilesInput.FilesToLoad[name] = file;
-                skyboxPath = "file:" + file.correctName;
-                return false;
+            if (filesInput._filesToLoad && filesInput._filesToLoad.length === 1 && extension) {
+                if (extension.toLowerCase() === "dds" || extension.toLowerCase() === "env") {
+                    BABYLON.FilesInput.FilesToLoad[name] = file;
+                    skyboxPath = "file:" + file.correctName;
+                    return false;
+                }
             }
             return true;
         }).bind(this);

+ 1 - 4
src/Engine/babylon.engine.ts

@@ -1182,10 +1182,7 @@
                     options.stencil = true;
                 }
 
-                if (options.premultipliedAlpha) {
-                    this.premultipliedAlpha = true;
-                }
-                else {
+                if (options.premultipliedAlpha === false) {
                     this.premultipliedAlpha = false;
                 }
 

+ 10 - 6
src/Materials/Textures/babylon.cubeTexture.ts

@@ -107,20 +107,14 @@
             this._noMipmap = noMipmap;
             this.hasAlpha = false;
             this._format = format;
-            this._prefiltered = prefiltered;
             this.isCube = true;
             this._textureMatrix = Matrix.Identity();
             this._createPolynomials = createPolynomials;
-            if (prefiltered) {
-                this.gammaSpace = false;
-            }
 
             if (!rootUrl && !files) {
                 return;
             }
 
-            this._texture = this._getFromCache(rootUrl, noMipmap);
-
             const lastDot = rootUrl.lastIndexOf(".");
             const extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
             const isDDS = (extension === ".dds");
@@ -128,7 +122,17 @@
 
             if (isEnv) {
                 this.gammaSpace = false;
+                this._prefiltered = false;
             }
+            else {
+                this._prefiltered = prefiltered;
+                
+                if (prefiltered) {
+                    this.gammaSpace = false;
+                }
+            }
+
+            this._texture = this._getFromCache(rootUrl, noMipmap);
 
             if (!files) {
                 if (!isEnv && !isDDS && !extensions) {

+ 1 - 1
src/Shaders/ShadersInclude/helperFunctions.fx

@@ -99,5 +99,5 @@ vec3 fromRGBD(vec4 rgbd) {
 
     // return rgbd.rgb * ((rgbdMaxRange / 255.0) / rgbd.a);
 
-    return rgbd.rgb * rgbd.a;
+    return rgbd.rgb / rgbd.a;
 }