瀏覽代碼

Revert changes on hasAlpha because different textures can have the same internal texture but with different hasAlpha values

Popov72 4 年之前
父節點
當前提交
73281cb12f

+ 7 - 25
src/Materials/Textures/baseTexture.ts

@@ -50,41 +50,23 @@ export class BaseTexture extends ThinTexture implements IAnimatable {
      */
     public reservedDataStore: any = null;
 
+    @serialize("hasAlpha")
     private _hasAlpha = false;
     /**
      * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
      */
-    @serialize()
-    public get hasAlpha(): boolean {
-        if (!this._texture) {
-            return this._hasAlpha;
-        } else {
-            if (this._texture._hasAlpha === null) {
-                this._texture._hasAlpha = this._hasAlpha;
-            }
-        }
-
-        return this._texture._hasAlpha;
-    }
-
     public set hasAlpha(value: boolean) {
-        if (!this._texture) {
-            if (this._hasAlpha === value) {
-                return;
-            }
-
-            this._hasAlpha = value;
-        } else {
-            if (this._texture._hasAlpha === value) {
-                return;
-            }
-            this._texture._hasAlpha = value;
+        if (this._hasAlpha === value) {
+            return;
         }
-
+        this._hasAlpha = value;
         if (this._scene) {
             this._scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag | Constants.MATERIAL_MiscDirtyFlag);
         }
     }
+    public get hasAlpha(): boolean {
+        return this._hasAlpha;
+    }
 
     /**
      * Defines if the alpha value should be determined via the rgb values.

+ 0 - 2
src/Materials/Textures/internalTexture.ts

@@ -263,8 +263,6 @@ export class InternalTexture {
 
     /** @hidden */
     public _gammaSpace: Nullable<boolean> = null;
-    /** @hidden */
-    public _hasAlpha: Nullable<boolean> = null;
 
     private _engine: ThinEngine;
     private _uniqueId: number;

+ 0 - 1
src/Misc/khronosTextureContainer2.ts

@@ -213,7 +213,6 @@ export class KhronosTextureContainer2 {
 
         internalTexture._gammaSpace = data.isInGammaSpace;
         internalTexture.generateMipMaps = data.mipmaps.length > 1;
-        internalTexture._hasAlpha = data.hasAlpha;
 
         if (data.errors) {
             throw new Error("KTX2 container - could not transcode the data. " + data.errors);

二進制
tests/validation/ReferenceImages/ktx2decoder.png


+ 2 - 1
tests/validation/config.json

@@ -953,7 +953,8 @@
         },
         {
             "title": "KTX2 decoder test",
-            "playgroundId": "#EIJH8L#26",
+            "playgroundId": "#EIJH8L#27",
+            "renderCount": 5,
             "referenceImage": "ktx2decoder.png",
             "excludeFromAutomaticTesting": true
         },