Sebastien Vandenberghe преди 6 години
родител
ревизия
f9d3beb59e

+ 1 - 1
src/Engines/webgpuEngine.ts

@@ -727,7 +727,7 @@ export class WebGPUEngine extends Engine {
     private _compilePipelineStageDescriptor(vertexCode: string, fragmentCode: string, defines: Nullable<string>): GPURenderPipelineStageDescriptor {
         this.onBeforeShaderCompilationObservable.notifyObservers(this);
 
-        var shaderVersion = "#version 450\n#define WEBGGPU \n";
+        var shaderVersion = "#version 450\n#define WEBGPU \n";
         var vertexShader = this._compileShaderToSpirV(vertexCode, "vertex", defines, shaderVersion);
         var fragmentShader = this._compileShaderToSpirV(fragmentCode, "fragment", defines, shaderVersion);
 

+ 8 - 8
src/Shaders/ShadersInclude/pbrFragmentExtraDeclaration.fx

@@ -1,20 +1,20 @@
 // Input
-#ifdef WEBGGPU
+#ifdef WEBGPU
     layout(location = 0) in vec3 vPositionW;
 #else
     varying vec3 vPositionW;
 #endif
 
 #ifdef NORMAL
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 1) in vec3 vNormalW;
     #else
         varying vec3 vNormalW;
     #endif
 
     #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
-        #ifdef WEBGGPU
-            #ifdef WEBGGPU
+        #ifdef WEBGPU
+            #ifdef WEBGPU
                 layout(location = 2) in vec3 vEnvironmentIrradiance;
             #else
                 varying vec3 vEnvironmentIrradiance;
@@ -26,7 +26,7 @@
 #endif
 
 #ifdef VERTEXCOLOR
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 3) in vec4 vColor;
     #else
         varying vec4 vColor;
@@ -34,7 +34,7 @@
 #endif
 
 #if DEBUGMODE > 0
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 5) in vec4 vClipSpacePosition;
     #else
         varying vec4 vClipSpacePosition;
@@ -42,7 +42,7 @@
 #endif
 
 #ifdef MAINUV1
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 6) in vec2 vMainUV1;
     #else
         varying vec2 vMainUV1;
@@ -50,7 +50,7 @@
 #endif
 
 #ifdef MAINUV2
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 7) in vec2 vMainUV2;
     #else
         varying vec2 vMainUV2;

+ 8 - 8
src/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.fx

@@ -1,5 +1,5 @@
 #ifdef ENVIRONMENTBRDF
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(set = 2, binding = 1) uniform texture2D environmentBrdfSamplerTexture;
         layout(set = 2, binding = 2) uniform sampler environmentBrdfSamplerSampler;
         #define environmentBrdfSampler sampler2D(environmentBrdfSamplerTexture, environmentBrdfSamplerSampler)
@@ -13,7 +13,7 @@
     #ifdef REFLECTIONMAP_3D
         #define sampleReflection(s, c) textureCube(s, c)
 
-        #ifdef WEBGGPU
+        #ifdef WEBGPU
             layout(set = 2, binding = 3) uniform textureCube reflectionSamplerTexture;
             layout(set = 2, binding = 4) uniform sampler reflectionSamplerSampler;
             #define reflectionSampler samplerCube(reflectionSamplerTexture, reflectionSamplerSampler)
@@ -41,7 +41,7 @@
     #endif
 
     #ifdef REFLECTIONMAP_SKYBOX
-        #ifdef WEBGGPU
+        #ifdef WEBGPU
             layout(location = 4) in vec3 vPositionUVW;
         #else
             varying vec3 vPositionUVW;
@@ -62,7 +62,7 @@
         varying vec2 vAlbedoUV;
     #endif
 
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(set = 2, binding = 5) uniform texture2D albedoSamplerTexture;
         layout(set = 2, binding = 6) uniform sampler albedoSamplerSampler;
         #define albedoSampler sampler2D(albedoSamplerTexture, albedoSamplerSampler)
@@ -80,7 +80,7 @@
         varying vec2 vReflectivityUV;
     #endif
 
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(set = 2, binding = 7) uniform texture2D reflectivitySamplerTexture;
         layout(set = 2, binding = 8) uniform sampler reflectivitySamplerSampler;
         #define reflectivitySampler sampler2D(reflectivitySamplerTexture, reflectivitySamplerSampler)
@@ -98,7 +98,7 @@
         varying vec2 vAmbientUV;
     #endif
 
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(set = 2, binding = 9) uniform texture2D ambientSamplerTexture;
         layout(set = 2, binding = 10) uniform sampler ambientSamplerSampler;
         #define ambientSampler sampler2D(ambientSamplerTexture, ambientSamplerSampler)
@@ -116,7 +116,7 @@
         varying vec2 vEmissiveUV;
     #endif
 
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(set = 2, binding = 11) uniform texture2D emissiveSamplerTexture;
         layout(set = 2, binding = 12) uniform sampler emissiveSamplerSampler;
         #define emissiveSampler sampler2D(emissiveSamplerTexture, emissiveSamplerSampler)
@@ -134,7 +134,7 @@
         varying vec2 vBumpUV;
     #endif
 
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(set = 2, binding = 13) uniform texture2D bumpSamplerTexture;
         layout(set = 2, binding = 14) uniform sampler bumpSamplerSampler;
         #define bumpSampler sampler2D(bumpSamplerTexture, bumpSamplerSampler)

+ 11 - 6
src/Shaders/ShadersInclude/pbrUboDeclaration.fx

@@ -24,9 +24,11 @@ layout(std140, column_major) uniform;
 // }
 
 #ifdef WEBGPU
-layout(set = 0, binding = 0) 
+layout(set = 0, binding = 0) uniform Scene 
+#else
+uniform Scene 
 #endif
-uniform Scene {
+{
     mat4 viewProjection;
 #ifdef MULTIVIEW
 	mat4 viewProjectionR;
@@ -35,9 +37,10 @@ uniform Scene {
 };
 
 #ifdef WEBGPU
-layout(set = 1, binding = 0) 
+layout(set = 1, binding = 0) uniform Material 
+#else
+uniform Material 
 #endif
-uniform Material
 {
     uniform vec2 vAlbedoInfos;
     uniform vec4 vAmbientInfos;
@@ -124,9 +127,11 @@ uniform Material
 };
 
 #ifdef WEBGPU
-layout(set = 2, binding = 0) 
+layout(set = 2, binding = 0) uniform Mesh 
+#else
+uniform Mesh 
 #endif
-uniform Mesh {
+{
     mat4 world;
     float visibility;
 };

+ 14 - 14
src/Shaders/pbr.vertex.fx

@@ -5,14 +5,14 @@
 #define CUSTOM_VERTEX_BEGIN
 
 // Attributes
-#ifdef WEBGGPU
+#ifdef WEBGPU
     layout(location = 0) in vec3 position;
 #else
     attribute vec3 position;
 #endif
 
 #ifdef NORMAL
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 1) in vec3 normal;
     #else
         attribute vec3 normal;
@@ -20,7 +20,7 @@
 #endif
 
 #ifdef TANGENT
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 2) in vec4 tangent;
     #else
         attribute vec4 tangent;
@@ -28,7 +28,7 @@
 #endif
 
 #ifdef UV1
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 3) in vec2 uv;
     #else
         attribute vec2 uv;
@@ -36,7 +36,7 @@
 #endif
 
 #ifdef UV2
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 4) in vec2 uv2;
     #else
         attribute vec2 uv2;
@@ -44,7 +44,7 @@
 #endif
 
 #ifdef VERTEXCOLOR
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 5) in vec4 color;
     #else
         attribute vec4 color;
@@ -63,21 +63,21 @@
 #endif
 
 // Output
-#ifdef WEBGGPU
+#ifdef WEBGPU
     layout(location = 0) out vec3 vPositionW;
 #else
     varying vec3 vPositionW;
 #endif
 
 #ifdef NORMAL
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 1) out vec3 vNormalW;
     #else
         varying vec3 vNormalW;
     #endif
 
     #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
-        #ifdef WEBGGPU
+        #ifdef WEBGPU
             layout(location = 2) out vec3 vEnvironmentIrradiance;
         #else
             varying vec3 vEnvironmentIrradiance;
@@ -88,7 +88,7 @@
 #endif
 
 #ifdef VERTEXCOLOR
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 3) out vec4 vColor;
     #else
         varying vec4 vColor;
@@ -96,7 +96,7 @@
 #endif
 
 #ifdef REFLECTIONMAP_SKYBOX
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 4) out vec3 vPositionUVW;
     #else
         varying vec3 vPositionUVW;
@@ -104,7 +104,7 @@
 #endif
 
 #if DEBUGMODE > 0
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 5) out vec4 vClipSpacePosition;
     #else
         varying vec4 vClipSpacePosition;
@@ -112,7 +112,7 @@
 #endif
 
 #ifdef MAINUV1
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 6) out vec2 vMainUV1;
     #else
         varying vec2 vMainUV1;
@@ -120,7 +120,7 @@
 #endif
 
 #ifdef MAINUV2
-    #ifdef WEBGGPU
+    #ifdef WEBGPU
         layout(location = 7) out vec2 vMainUV2;
     #else
         varying vec2 vMainUV2;