Преглед изворни кода

Merge pull request #6809 from syntheticmagus/syntheticmagus/rttFormatFixes

Fixes to correctly specify the texture type for native.
David Catuhe пре 6 година
родитељ
комит
675f0485f8
2 измењених фајлова са 13 додато и 9 уклоњено
  1. 1 1
      dist/preview release/what's new.md
  2. 12 8
      src/Engines/nativeEngine.ts

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

@@ -118,7 +118,7 @@
 - Removing assetContainer from scene will also remove gui layers ([TrevorDev](https://github.com/TrevorDev))
 - A scene's input manager not adding key listeners when the canvas is already focused ([Poolminer](https://github.com/Poolminer))
 - Runtime animation `goToFrame` when going back in time now correctly triggers future events when reached ([zakhenry](https://github.com/zakhenry))
-- Fixed bug in Ray.intersectsTriangle where the barycentric coordinates `bu` and `bv` being returned is actually `bv` and `bw`. ([bghgary](https://github.com/bghgary))
+- Fixed bug in `Ray.intersectsTriangle` where the barycentric coordinates `bu` and `bv` being returned is actually `bv` and `bw`. ([bghgary](https://github.com/bghgary))
 - Do not call onError when creating a texture when falling back to another loader ([TrevorDev](https://github.com/TrevorDev))
 - Context loss should not cause PBR materials to render black or instances to stop rendering ([TrevorDev](https://github.com/TrevorDev))
 - Only cast pointer ray input when pointer is locked in webVR ([TrevorDev](https://github.com/TrevorDev))

+ 12 - 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,15 @@ 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) {
+            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 +1142,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,