Explorar o código

Add IsBlocking and Remove PBR Transparency Enum

sevan %!s(int64=8) %!d(string=hai) anos
pai
achega
ccf203c9ef

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 8368 - 8855
dist/preview release/babylon.d.ts


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 40 - 40
dist/preview release/babylon.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 428 - 1090
dist/preview release/babylon.max.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 8368 - 8855
dist/preview release/babylon.module.d.ts


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 41 - 41
dist/preview release/babylon.worker.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 11 - 11
dist/preview release/canvas2D/babylon.canvas2d.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 17 - 17
dist/preview release/inspector/babylon.inspector.bundle.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 3 - 3
dist/preview release/inspector/babylon.inspector.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 2 - 2
dist/preview release/loaders/babylon.glTFFileLoader.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/materialsLibrary/babylon.customMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/materialsLibrary/babylon.waterMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


+ 12 - 10
src/Materials/PBR/babylon.pbrBaseMaterial.ts

@@ -555,7 +555,7 @@
                 }
 
                 if (this._albedoTexture && StandardMaterial.DiffuseTextureEnabled) {
-                    if (!this._albedoTexture.isReady()) {
+                    if (!this._albedoTexture.isReadyOrNoneBlocking()) {
                         return false;
                     }
 
@@ -564,7 +564,7 @@
                 }
 
                 if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
-                    if (!this._ambientTexture.isReady()) {
+                    if (!this._ambientTexture.isReadyOrNoneBlocking()) {
                         return false;
                     }
 
@@ -574,7 +574,7 @@
                 }
 
                 if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
-                    if (!this._opacityTexture.isReady()) {
+                    if (!this._opacityTexture.isReadyOrNoneBlocking()) {
                         return false;
                     }
                     
@@ -588,7 +588,7 @@
 
                 var reflectionTexture = this._reflectionTexture || scene.environmentTexture;
                 if (reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
-                    if (!reflectionTexture.isReady()) {
+                    if (!reflectionTexture.isReadyOrNoneBlocking()) {
                         return false;
                     }
                     
@@ -641,7 +641,7 @@
                 }
 
                 if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
-                    if (!this._lightmapTexture.isReady()) {
+                    if (!this._lightmapTexture.isReadyOrNoneBlocking()) {
                         return false;
                     }
 
@@ -651,7 +651,7 @@
                 }
 
                 if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
-                    if (!this._emissiveTexture.isReady()) {
+                    if (!this._emissiveTexture.isReadyOrNoneBlocking()) {
                         return false;
                     }
 
@@ -661,7 +661,7 @@
 
                 if (StandardMaterial.SpecularTextureEnabled) {
                     if (this._metallicTexture) {
-                        if (!this._metallicTexture.isReady()) {
+                        if (!this._metallicTexture.isReadyOrNoneBlocking()) {
                             return false;
                         }
 
@@ -674,7 +674,7 @@
                         this._defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
                     }
                     else if (this._reflectivityTexture) {
-                        if (!this._reflectivityTexture.isReady()) {
+                        if (!this._reflectivityTexture.isReadyOrNoneBlocking()) {
                             return false;
                         }
 
@@ -685,7 +685,7 @@
                     }
 
                     if (this._microSurfaceTexture) {
-                        if (!this._microSurfaceTexture.isReady()) {
+                        if (!this._microSurfaceTexture.isReadyOrNoneBlocking()) {
                             return false;
                         }
 
@@ -695,6 +695,7 @@
                 }
 
                 if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled && !this._disableBumpMap) {
+                    // Bump texure can not be none blocking.
                     if (!this._bumpTexture.isReady()) {
                         return false;
                     }
@@ -726,7 +727,7 @@
                 }
 
                 if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
-                    if (!this._refractionTexture.isReady()) {
+                    if (!this._refractionTexture.isReadyOrNoneBlocking()) {
                         return false;
                     }
                     
@@ -747,6 +748,7 @@
                 }
             
                 if (this._cameraColorGradingTexture && StandardMaterial.ColorGradingTextureEnabled) {
+                    // Color Grading texure can not be none blocking.
                     if (!this._cameraColorGradingTexture.isReady()) {
                         return false;
                     }

+ 17 - 36
src/Materials/PBR/babylon.pbrBaseSimpleMaterial.ts

@@ -1,48 +1,29 @@
 module BABYLON {
-
     /**
-     * Specifies the transparency mode used in the pbr simple materials.
+     * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
      */
-    export const enum PBRMaterialTransparencyMode {
-        /**
-         * No transparency mode, Alpha channel is not use.
-         */
-        Opaque = 0,
-        /**
-         * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
-         */
-        AlphaTest = 1,
-        /**
-         * Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
-         */
-        AlphaBlend = 2,
-        /**
-         * Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
-         * They are also discarded below the alpha cutoff threshold to improve performances.
-         */
-        AlphaTestAndBlend = 3,
-    }
+    export const PBRMATERIAL_OPAQUE = 0;
 
     /**
-     * JS helper for PBRMaterialTransparencyMode const enum: No transparency mode, Alpha channel is not use.
+     * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
      */
-    export const PBRMATERIAL_OPAQUE = PBRMaterialTransparencyMode.Opaque;
+    export const PBRMATERIAL_ALPHATEST = 1;
 
     /**
-     * JS helper for PBRMaterialTransparencyMode const enum: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
+     * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
      */
-    export const PBRMATERIAL_ALPHATEST = PBRMaterialTransparencyMode.AlphaTest;
+    export const PBRMATERIAL_ALPHABLEND = 2;
 
     /**
-     * JS helper for PBRMaterialTransparencyMode const enum: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
+     * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
+     * They are also discarded below the alpha cutoff threshold to improve performances.
      */
-    export const PBRMATERIAL_ALPHABLEND = PBRMaterialTransparencyMode.AlphaBlend;
+    export const PBRMATERIAL_ALPHATESTANDBLEND = 3;
 
     /**
-     * JS helper for PBRMaterialTransparencyMode const enum: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
-     * They are also discarded below the alpha cutoff threshold to improve performances.
+     * Limits the values allowed in the transparency ones to the known ones.
      */
-    export const PBRMATERIAL_ALPHATESTANDBLEND = PBRMaterialTransparencyMode.AlphaTestAndBlend;
+    export type PBRMaterialTransparencyMode = 0 | 1 | 2 | 3;
 }
 
 module BABYLON.Internals {
@@ -131,7 +112,7 @@ module BABYLON.Internals {
         @expandToProperty(null, "_alphaCutOff")
         public alphaCutOff: number;
 
-        protected _transparencyMode = PBRMaterialTransparencyMode.Opaque;
+        protected _transparencyMode: PBRMaterialTransparencyMode = PBRMATERIAL_OPAQUE;
         /**
          * Gets the current transparency mode.
          */
@@ -144,7 +125,7 @@ module BABYLON.Internals {
          */
         public set transparencyMode(value: PBRMaterialTransparencyMode) {
             this._transparencyMode = value;
-            if (value === PBRMaterialTransparencyMode.AlphaTestAndBlend) {
+            if (value === PBRMATERIAL_ALPHATESTANDBLEND) {
                 this._forceAlphaTest = true;
             }
             else {
@@ -171,7 +152,7 @@ module BABYLON.Internals {
          * Specifies wether or not the alpha value of the albedo texture should be used.
          */
         protected _shouldUseAlphaFromAlbedoTexture(): boolean {
-            return this._albedoTexture && this._albedoTexture.hasAlpha && this._transparencyMode !== PBRMaterialTransparencyMode.Opaque;
+            return this._albedoTexture && this._albedoTexture.hasAlpha && this._transparencyMode !== PBRMATERIAL_OPAQUE;
         }
 
         /**
@@ -184,8 +165,8 @@ module BABYLON.Internals {
 
             return (this.alpha < 1.0) || 
                     (this._shouldUseAlphaFromAlbedoTexture() &&
-                        (this._transparencyMode === PBRMaterialTransparencyMode.AlphaBlend ||
-                            this._transparencyMode === PBRMaterialTransparencyMode.AlphaTestAndBlend));
+                        (this._transparencyMode === PBRMATERIAL_ALPHABLEND ||
+                            this._transparencyMode === PBRMATERIAL_ALPHATESTANDBLEND));
         }
 
         /**
@@ -197,7 +178,7 @@ module BABYLON.Internals {
             }
 
             return this._shouldUseAlphaFromAlbedoTexture() &&
-                 this._transparencyMode === PBRMaterialTransparencyMode.AlphaTest;
+                 this._transparencyMode === PBRMATERIAL_ALPHATEST;
         }
 
         /**

+ 8 - 0
src/Materials/Textures/babylon.baseTexture.ts

@@ -90,6 +90,10 @@
         public _texture: WebGLTexture;
         private _uid: string;
 
+        public get isBlocking(): boolean {
+            return true;
+        }
+
         constructor(scene: Scene) {
             this._scene = scene || Engine.LastCreatedScene;
             this._scene.textures.push(this);
@@ -112,6 +116,10 @@
             return this._texture;
         }
 
+        public isReadyOrNoneBlocking(): boolean {
+            return !this.isBlocking || this.isReady();
+        }
+
         public isReady(): boolean {
             if (this.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) {
                 this.delayLoad();

+ 12 - 0
src/Materials/Textures/babylon.texture.ts

@@ -74,6 +74,14 @@
         private _delayedOnError: () => void;
         private _onLoadObservarble: Observable<boolean>;
 
+        protected _isBlocking: boolean = true;
+        public set isBlocking(value: boolean) {
+            this._isBlocking = value;
+        }
+        public get isBlocking(): boolean {
+            return this._isBlocking;
+        }
+
         constructor(url: string, scene: Scene, noMipmap: boolean = false, invertY: boolean = true, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE, onLoad: () => void = null, onError: () => void = null, buffer: any = null, deleteBuffer: boolean = false, format?: number) {
             super(scene);
 
@@ -100,6 +108,10 @@
                 if (onLoad) {
                     onLoad();
                 }
+
+                if (!this.isBlocking) {
+                    scene.markAllMaterialsAsDirty(Material.TextureDirtyFlag);
+                }
             }
 
             if (!this._texture) {

+ 10 - 8
src/Materials/babylon.standardMaterial.ts

@@ -379,7 +379,7 @@ module BABYLON {
                 defines._needUVs = false;
                 if (scene.texturesEnabled) {
                     if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
-                        if (!this._diffuseTexture.isReady()) {
+                        if (!this._diffuseTexture.isReadyOrNoneBlocking()) {
                             return false;
                         } else {
                             defines._needUVs = true;
@@ -390,7 +390,7 @@ module BABYLON {
                     }
 
                     if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
-                        if (!this._ambientTexture.isReady()) {
+                        if (!this._ambientTexture.isReadyOrNoneBlocking()) {
                             return false;
                         } else {
                             defines._needUVs = true;
@@ -401,7 +401,7 @@ module BABYLON {
                     }
 
                     if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
-                        if (!this._opacityTexture.isReady()) {
+                        if (!this._opacityTexture.isReadyOrNoneBlocking()) {
                             return false;
                         } else {
                             defines._needUVs = true;
@@ -413,7 +413,7 @@ module BABYLON {
                     }
 
                     if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
-                        if (!this._reflectionTexture.isReady()) {
+                        if (!this._reflectionTexture.isReadyOrNoneBlocking()) {
                             return false;
                         } else {
                             defines._needNormals = true;
@@ -460,7 +460,7 @@ module BABYLON {
                     }
 
                     if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
-                        if (!this._emissiveTexture.isReady()) {
+                        if (!this._emissiveTexture.isReadyOrNoneBlocking()) {
                             return false;
                         } else {
                             defines._needUVs = true;
@@ -471,7 +471,7 @@ module BABYLON {
                     }
 
                     if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
-                        if (!this._lightmapTexture.isReady()) {
+                        if (!this._lightmapTexture.isReadyOrNoneBlocking()) {
                             return false;
                         } else {
                             defines._needUVs = true;
@@ -483,7 +483,7 @@ module BABYLON {
                     }
 
                     if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
-                        if (!this._specularTexture.isReady()) {
+                        if (!this._specularTexture.isReadyOrNoneBlocking()) {
                             return false;
                         } else {
                             defines._needUVs = true;
@@ -495,6 +495,7 @@ module BABYLON {
                     }
 
                     if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
+                        // Bump texure can not be none blocking.
                         if (!this._bumpTexture.isReady()) {
                             return false;
                         } else {
@@ -512,7 +513,7 @@ module BABYLON {
                     }
 
                     if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
-                        if (!this._refractionTexture.isReady()) {
+                        if (!this._refractionTexture.isReadyOrNoneBlocking()) {
                             return false;
                         } else {
                             defines._needUVs = true;
@@ -525,6 +526,7 @@ module BABYLON {
                     }
 
                     if (this._cameraColorGradingTexture && StandardMaterial.ColorGradingTextureEnabled) {
+                        // Camera Color Grading can not be none blocking.
                         if (!this._cameraColorGradingTexture.isReady()) {
                             return false;
                         } else {