Browse Source

Account for highp / lowp keywords when parsing uniforms

Popov72 4 năm trước cách đây
mục cha
commit
14d2d2cb6b

+ 1 - 1
src/Engines/Processors/shaderCodeNode.ts

@@ -28,7 +28,7 @@ export class ShaderCodeNode {
                 } else if (processor.varyingProcessor && StringTools.StartsWith(this.line, "varying")) {
                     value = processor.varyingProcessor(this.line, options.isFragment, options.processingContext);
                 } else if ((processor.uniformProcessor || processor.uniformBufferProcessor) && StringTools.StartsWith(this.line, "uniform") && !options.lookForClosingBracketForUniformBuffer) {
-                    let regex = /uniform\s+(\S+)\s+(\S+)\s*;/;
+                    let regex = /uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/;
 
                     if (regex.test(this.line)) { // uniform
                         if (processor.uniformProcessor) {

+ 1 - 1
src/Engines/WebGPU/webgpuShaderProcessors.ts

@@ -84,7 +84,7 @@ export class WebGPUShaderProcessor implements IShaderProcessor {
     public uniformProcessor(uniform: string, isFragment: boolean, preProcessors: { [key: string]: string }, processingContext: Nullable<ShaderProcessingContext>): string {
         const webgpuProcessingContext = processingContext! as WebGPUShaderProcessingContext;
 
-        const uniformRegex = new RegExp(/\s*uniform\s+(\S+)\s+(\S+)\s*;/gm);
+        const uniformRegex = new RegExp(/\s*uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm);
 
         const match = uniformRegex.exec(uniform);
         if (match != null) {