فهرست منبع

Hack Image Processing WebGPU

Sebastien Vandenberghe 6 سال پیش
والد
کامیت
b24924f10f

+ 12 - 1
src/Materials/PBR/pbrBaseMaterial.ts

@@ -1590,6 +1590,11 @@ export abstract class PBRBaseMaterial extends PushMaterial {
         ubo.addUniform("vSphericalYZ", 3);
         ubo.addUniform("vSphericalZX", 3);
 
+        if (this.getScene().getEngine().isWebGPU) {
+            ubo.addUniform("exposureLinear", 1);
+            ubo.addUniform("contrast", 1);
+        }
+
         ubo.create();
     }
 
@@ -1897,7 +1902,13 @@ export abstract class PBRBaseMaterial extends PushMaterial {
             }
 
             // image processing
-            this._imageProcessingConfiguration!.bind(this._activeEffect);
+            if (scene.getEngine().isWebGPU) {
+                ubo.updateFloat("exposureLinear", this._imageProcessingConfiguration.exposure);
+                ubo.updateFloat("contrast", this._imageProcessingConfiguration.contrast);
+            }
+            else {
+                this._imageProcessingConfiguration!.bind(this._activeEffect);
+            }
 
             // Log. depth
             MaterialHelper.BindLogDepth(defines, this._activeEffect, scene);

+ 5 - 1
src/Shaders/ShadersInclude/imageProcessingDeclaration.fx

@@ -1,4 +1,6 @@
-#ifdef EXPOSURE
+#ifndef WEBGPU
+
+#ifdef EXPOSURE
 	uniform float exposureLinear;
 #endif
 
@@ -25,4 +27,6 @@
 		uniform sampler2D txColorTransform;
 	#endif
 	uniform vec4 colorTransformSettings;
+#endif
+
 #endif

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

@@ -124,6 +124,12 @@ uniform Material
     uniform vec3 vSphericalXY;
     uniform vec3 vSphericalYZ;
     uniform vec3 vSphericalZX;
+
+    // Image Processing WEBGPU Hack
+    #ifdef WEBGPU
+	uniform float exposureLinear;
+	uniform float contrast;
+    #endif
 };
 
 #ifdef WEBGPU