Ver código fonte

Merge pull request #9495 from Popov72/fix-alpha-glb

Fix alpha in glb test
sebavan 4 anos atrás
pai
commit
4ed49aa88d

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

@@ -55,5 +55,4 @@
     - [ReadPixels and ProceduralTexture.getContent are now async](https://doc.babylonjs.com/advanced_topics/webGPU/webGPUBreakingChanges#readpixels-is-now-asynchronous)
     - [Shader support differences](https://doc.babylonjs.com/advanced_topics/webGPU/webGPUBreakingChanges#shader-code-differences)
 - Use both `mesh.visibility` and `material.alpha` values to compute the global alpha value used by the soft transparent shadow rendering code. Formerly was only using `mesh.visibility` ([Popov72](https://github.com/Popov72))
-- The `Texture.hasAlpha` property is automatically set by the KTX2 loader if the texture has an alpha channel ([Popov72](https://github.com/Popov72))
 - Depth renderer: don't render mesh if `infiniteDistance = true` or if `material.disableDepthWrite = true` ([Popov72](https://github.com/Popov72))

+ 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);

BIN
tests/validation/ReferenceImages/glTFAlphaBlend.png


BIN
tests/validation/ReferenceImages/ktx2decoder.png


+ 8 - 1
tests/validation/config.json

@@ -632,6 +632,12 @@
             "excludeFromAutomaticTesting": true
         },
         {
+            "title": "GLTF Alpha Blend",
+            "playgroundId": "#SYQW69#578",
+            "referenceImage": "glTFAlphaBlend.png",
+            "renderCount": 1
+        },
+        {
             "title": "GLTF Serializer with Negative World Matrix",
             "playgroundId": "#KX53VK#35",
             "referenceImage": "glTFSerializerNegativeWorldMatrix.png",
@@ -953,7 +959,8 @@
         },
         {
             "title": "KTX2 decoder test",
-            "playgroundId": "#EIJH8L#26",
+            "playgroundId": "#EIJH8L#27",
+            "renderCount": 5,
             "referenceImage": "ktx2decoder.png",
             "excludeFromAutomaticTesting": true
         },