瀏覽代碼

Fix gammeSpace property not being set correctly

Popov72 5 年之前
父節點
當前提交
d596e0d0ec
共有 2 個文件被更改,包括 22 次插入7 次删除
  1. 21 6
      src/Materials/Textures/baseTexture.ts
  2. 1 1
      src/Materials/Textures/internalTexture.ts

+ 21 - 6
src/Materials/Textures/baseTexture.ts

@@ -233,6 +233,7 @@ export class BaseTexture implements IAnimatable {
         this._texture.is2DArray = value;
         this._texture.is2DArray = value;
     }
     }
 
 
+    private _gammaSpace = true;
     /**
     /**
      * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
      * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
      * HDR texture are usually stored in linear space.
      * HDR texture are usually stored in linear space.
@@ -240,18 +241,32 @@ export class BaseTexture implements IAnimatable {
      */
      */
     @serialize()
     @serialize()
     public get gammaSpace(): boolean {
     public get gammaSpace(): boolean {
-        return this._texture?._gammaSpace ?? true;
+        if (!this._texture) {
+            return this._gammaSpace;
+        } else {
+            if (this._texture._gammaSpace === null) {
+                this._texture._gammaSpace = this._gammaSpace;
+            }
+        }
+
+        return this._texture._gammaSpace;
     }
     }
 
 
     public set gammaSpace(gamma: boolean) {
     public set gammaSpace(gamma: boolean) {
-        if ((this._texture?._gammaSpace ?? gamma) === gamma) {
-            return;
-        }
+        if (!this._texture) {
+            if (this._gammaSpace === gamma) {
+                return;
+            }
 
 
-        if (this._texture) {
+            this._gammaSpace = gamma;
+        } else {
+            if (this._texture._gammaSpace === gamma) {
+                return;
+            }
             this._texture._gammaSpace = gamma;
             this._texture._gammaSpace = gamma;
-            this._markAllSubMeshesAsTexturesDirty();
         }
         }
+
+        this._markAllSubMeshesAsTexturesDirty();
     }
     }
 
 
     /**
     /**

+ 1 - 1
src/Materials/Textures/internalTexture.ts

@@ -254,7 +254,7 @@ export class InternalTexture {
     public _references: number = 1;
     public _references: number = 1;
 
 
     /** @hidden */
     /** @hidden */
-    public _gammaSpace = true;
+    public _gammaSpace: Nullable<boolean> = null;
 
 
     private _engine: ThinEngine;
     private _engine: ThinEngine;