浏览代码

Fix cube textures inverted in webgpu

Popov72 4 年之前
父节点
当前提交
1e2ec3fe2a

+ 3 - 0
src/Engines/engineFeatures.ts

@@ -48,6 +48,9 @@ export interface EngineFeatures {
     /** Indicates that synchronous texture reading is supported */
     supportSyncTextureRead: boolean;
 
+    /** Indicates that y should be inverted when dealing with bitmaps (notably in environment tools) */
+    needsInvertingBitmap: boolean;
+
     /** @hidden */
     _collectUbosUpdatedInFrame: boolean;
 }

+ 1 - 0
src/Engines/nativeEngine.ts

@@ -816,6 +816,7 @@ export class NativeEngine extends Engine {
             supportExtendedTextureFormats: false,
             supportSwitchCaseInShader: false,
             supportSyncTextureRead: false,
+            needsInvertingBitmap: true,
             _collectUbosUpdatedInFrame: false,
         };
 

+ 1 - 0
src/Engines/nullEngine.ts

@@ -162,6 +162,7 @@ export class NullEngine extends Engine {
             supportExtendedTextureFormats: false,
             supportSwitchCaseInShader: false,
             supportSyncTextureRead: false,
+            needsInvertingBitmap: false,
             _collectUbosUpdatedInFrame: false,
         };
 

+ 2 - 1
src/Engines/thinEngine.ts

@@ -1062,7 +1062,7 @@ export class ThinEngine {
 
     protected _initFeatures(): void {
         this._features = {
-            forceBitmapOverHTMLImageElement: false,
+            forceBitmapOverHTMLImageElement: true,
             supportRenderAndCopyToLodForFloatTextures: this._webGLVersion !== 1,
             supportDepthStencilTexture: this._webGLVersion !== 1,
             supportShadowSamplers: this._webGLVersion !== 1,
@@ -1078,6 +1078,7 @@ export class ThinEngine {
             supportExtendedTextureFormats: this._webGLVersion !== 1,
             supportSwitchCaseInShader: this._webGLVersion !== 1,
             supportSyncTextureRead: true,
+            needsInvertingBitmap: true,
             _collectUbosUpdatedInFrame: false,
         };
     }

+ 1 - 0
src/Engines/webgpuEngine.ts

@@ -562,6 +562,7 @@ export class WebGPUEngine extends Engine {
             supportExtendedTextureFormats: true,
             supportSwitchCaseInShader: true,
             supportSyncTextureRead: false,
+            needsInvertingBitmap: false,
             _collectUbosUpdatedInFrame: true,
         };
     }

+ 2 - 1
src/Misc/environmentTextureTools.ts

@@ -373,9 +373,10 @@ export class EnvironmentTextureTools {
 
                     rgbdPostProcess!.getEffect().executeWhenCompiled(() => {
                         // Uncompress the data to a RTT
+                        console.log(image instanceof ImageBitmap);
                         rgbdPostProcess!.onApply = (effect) => {
                             effect._bindTexture("textureSampler", tempTexture);
-                            effect.setFloat2("scale", 1, (image instanceof ImageBitmap) ? -1 : 1);
+                            effect.setFloat2("scale", 1, engine._features.needsInvertingBitmap && (image instanceof ImageBitmap) ? -1 : 1);
                         };
 
                         if (!engine.scenes.length) {