Pārlūkot izejas kodu

Fixes to correctly specify the texture type for native.

Justin Murray 6 gadi atpakaļ
vecāks
revīzija
515dcac1c2
1 mainītis faili ar 13 papildinājumiem un 8 dzēšanām
  1. 13 8
      src/Engines/nativeEngine.ts

+ 13 - 8
src/Engines/nativeEngine.ts

@@ -150,7 +150,8 @@ class NativeAddressMode {
 }
 
 class NativeTextureFormat {
-    public static readonly RGBA = 0;
+    public static readonly RGBA8 = 0;
+    public static readonly RGBA32F = 1;
 }
 
 /** @hidden */
@@ -1088,12 +1089,16 @@ export class NativeEngine extends Engine {
         }
     }
 
-    private static _GetNativeTextureFormat(format: number): number {
-        switch (format) {
-            case Engine.TEXTUREFORMAT_RGBA:
-                return NativeTextureFormat.RGBA;
-            default:
-                throw new Error("Unexpected texture format: " + format + ".");
+    private static _GetNativeTextureFormat(format: number, type: number): number {
+        if (format == Engine.TEXTUREFORMAT_RGBA && (type == Engine.TEXTURETYPE_UNSIGNED_INT || type == Engine.TEXTURETYPE_UNSIGNED_BYTE)) {
+            // Note: Babylon considers TEXTURETYPE_UNSIGNED_INT and TEXTURETYPE_UNSIGNED_BYTE to be synonyms.
+            return NativeTextureFormat.RGBA8;
+        }
+        else if (format == Engine.TEXTUREFORMAT_RGBA && type == Engine.TEXTURETYPE_FLOAT) {
+            return NativeTextureFormat.RGBA32F;
+        }
+        else {
+            throw new Error("Unexpected texture format or type: format " + format + ", type " + type + ".");
         }
     }
 
@@ -1138,7 +1143,7 @@ export class NativeEngine extends Engine {
             texture._webGLTexture!,
             width,
             height,
-            NativeEngine._GetNativeTextureFormat(fullOptions.format),
+            NativeEngine._GetNativeTextureFormat(fullOptions.format, fullOptions.type),
             fullOptions.samplingMode!,
             fullOptions.generateStencilBuffer ? true : false,
             fullOptions.generateDepthBuffer,