浏览代码

Add instance support

Sebastien Vandenberghe 6 年之前
父节点
当前提交
89795e8d5e
共有 2 个文件被更改,包括 27 次插入8 次删除
  1. 4 0
      src/Engines/webgpuEngine.ts
  2. 23 8
      src/Shaders/pbr.vertex.fx

+ 4 - 0
src/Engines/webgpuEngine.ts

@@ -1466,6 +1466,10 @@ export class WebGPUEngine extends Engine {
             case VertexBuffer.MatricesWeightsKind:
             case VertexBuffer.MatricesWeightsExtraKind:
             case VertexBuffer.TangentKind:
+            case "world0":
+            case "world1":
+            case "world2":
+            case "world3":
                 switch (type) {
                     case VertexBuffer.BYTE:
                         return normalized ? WebGPUConstants.GPUVertexFormat_char4norm : WebGPUConstants.GPUVertexFormat_char4;

+ 23 - 8
src/Shaders/pbr.vertex.fx

@@ -51,17 +51,32 @@
     #endif
 #endif
 
-#include<helperFunctions>
-#include<bonesDeclaration>
-
-// Uniforms
 #ifdef INSTANCES
-	attribute vec4 world0;
-	attribute vec4 world1;
-	attribute vec4 world2;
-	attribute vec4 world3;
+    #ifdef WEBGPU
+        layout(location = 6) in vec4 world0;
+    #else
+        attribute vec4 world0;
+    #endif
+    #ifdef WEBGPU
+        layout(location = 7) in vec4 world1;
+    #else
+        attribute vec4 world1;
+    #endif
+    #ifdef WEBGPU
+        layout(location = 8) in vec4 world2;
+    #else
+        attribute vec4 world2;
+    #endif
+    #ifdef WEBGPU
+        layout(location = 9) in vec4 world3;
+    #else
+        attribute vec4 world3;
+    #endif
 #endif
 
+#include<helperFunctions>
+#include<bonesDeclaration>
+
 // Output
 #ifdef WEBGPU
     layout(location = 0) out vec3 vPositionW;