Browse Source

Fix WebGPU

sebavan 5 years ago
parent
commit
8356d8690a

+ 5 - 0
Tools/Gulp/tasks/gulpTasks-localRun.js

@@ -43,6 +43,11 @@ gulp.task("webserver", function () {
                             req.url = "/Playground/" + req.url.replace(/localDev/ig, "");
                         }
                     }
+                    if (referer.indexOf('/localdevwebgpu/') !== -1 && referer.indexOf(req.originalUrl) === -1) {
+                        if (!fs.existsSync(rootRelativePath + req.originalUrl)) {
+                            req.url = "/Playground/" + req.url.replace(/localdevwebgpu/ig, "");
+                        }
+                    }
                 }
 
                 const pgMath = req.url.match(/\/Playground\/pg\/(.*)/);

+ 8 - 0
src/Engines/WebGPU/webgpuShaderProcessors.ts

@@ -3,6 +3,7 @@ import { IShaderProcessor } from '../Processors/iShaderProcessor';
 import { ShaderProcessingContext } from "../Processors/shaderProcessingOptions";
 import { WebGPUShaderProcessingContext } from './webgpuShaderProcessingContext';
 import { WebGPUConstants } from './webgpuConstants';
+import { ShaderCodeInliner } from '../Processors/shaderCodeInliner';
 
 const _knownUBOs: { [key: string]: { setIndex: number, bindingIndex: number} } = {
     "Scene": { setIndex: 0, bindingIndex: 0 },
@@ -42,6 +43,13 @@ const _gpuTextureViewDimensionByWebGPUTextureType: { [key: string]: GPUTextureVi
 /** @hidden */
 export class WebGPUShaderProcessor implements IShaderProcessor {
 
+    public preProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string {
+        let sci = new ShaderCodeInliner(code);
+        // sci.debug = true;
+        sci.processCode();
+        return sci.code;
+    }
+
     public varyingProcessor(varying: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) {
         const webgpuProcessingContext = processingContext! as WebGPUShaderProcessingContext;
 

+ 0 - 3
src/Materials/PBR/pbrBaseMaterial.ts

@@ -1892,9 +1892,6 @@ export abstract class PBRBaseMaterial extends PushMaterial {
                 ubo.updateFloat2("vDebugMode", this.debugLimit, this.debugFactor);
             }
 
-            // Visibility
-            ubo.updateFloat("visibility", mesh.visibility);
-
             // Textures
             if (scene.texturesEnabled) {
                 if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled) {

+ 0 - 12
src/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.fx

@@ -46,18 +46,6 @@
     uniform sampler2D emissiveSampler;
 #endif
 
-#ifdef BUMP
-    #if BUMPDIRECTUV == 1
-        #define vBumpUV vMainUV1
-    #elif BUMPDIRECTUV == 2
-        #define vBumpUV vMainUV2
-    #else
-        varying vec2 vBumpUV;
-    #endif
-
-    uniform sampler2D bumpSampler;
-#endif
-
 #ifdef OPACITY
     #if OPACITYDIRECTUV == 1
         #define vOpacityUV vMainUV1