{"ast":null,"code":"import { InjectStartingAndEndingCode } from \"../../Misc/codeStringParsingTools.js\";\nconst varyingRegex = /(flat\\s)?\\s*varying\\s*.*/;\n/** @internal */\nexport class NativeShaderProcessor {\n constructor() {\n this.shaderLanguage = 0 /* ShaderLanguage.GLSL */;\n }\n initializeShaders(processingContext) {\n this._nativeProcessingContext = processingContext;\n if (this._nativeProcessingContext) {\n this._nativeProcessingContext.remappedAttributeNames = {};\n this._nativeProcessingContext.injectInVertexMain = \"\";\n }\n }\n attributeProcessor(attribute) {\n if (!this._nativeProcessingContext) {\n return attribute.replace(\"attribute\", \"in\");\n }\n const attribRegex = /\\s*(?:attribute|in)\\s+(\\S+)\\s+(\\S+)\\s*;/gm;\n const match = attribRegex.exec(attribute);\n if (match !== null) {\n const attributeType = match[1];\n const name = match[2];\n const numComponents = this._nativeProcessingContext.vertexBufferKindToNumberOfComponents[name];\n if (numComponents !== undefined) {\n // Special case for an int/ivecX vertex buffer that is used as a float/vecX attribute in the shader.\n const newType = numComponents < 0 ? numComponents === -1 ? \"int\" : \"ivec\" + -numComponents : numComponents === 1 ? \"uint\" : \"uvec\" + numComponents;\n const newName = `_int_${name}_`;\n attribute = attribute.replace(match[0], `in ${newType} ${newName}; ${attributeType} ${name};`);\n this._nativeProcessingContext.injectInVertexMain += `${name} = ${attributeType}(${newName});\\n`;\n this._nativeProcessingContext.remappedAttributeNames[name] = newName;\n } else {\n attribute = attribute.replace(match[0], `in ${attributeType} ${name};`);\n }\n }\n return attribute;\n }\n varyingCheck(varying, _isFragment) {\n return varyingRegex.test(varying);\n }\n varyingProcessor(varying, isFragment) {\n return varying.replace(\"varying\", isFragment ? \"in\" : \"out\");\n }\n postProcessor(code, defines, isFragment) {\n const hasDrawBuffersExtension = code.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;\n // Remove extensions\n const regex = /#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;\n code = code.replace(regex, \"\");\n // Replace instructions\n code = code.replace(/texture2D\\s*\\(/g, \"texture(\");\n if (isFragment) {\n const hasOutput = code.search(/layout *\\(location *= *0\\) *out/g) !== -1;\n code = code.replace(/texture2DLodEXT\\s*\\(/g, \"textureLod(\");\n code = code.replace(/textureCubeLodEXT\\s*\\(/g, \"textureLod(\");\n code = code.replace(/textureCube\\s*\\(/g, \"texture(\");\n code = code.replace(/gl_FragDepthEXT/g, \"gl_FragDepth\");\n code = code.replace(/gl_FragColor/g, \"glFragColor\");\n code = code.replace(/gl_FragData/g, \"glFragData\");\n code = code.replace(/void\\s+?main\\s*\\(/g, (hasDrawBuffersExtension || hasOutput ? \"\" : \"layout(location = 0) out vec4 glFragColor;\\n\") + \"void main(\");\n } else {\n var _this$_nativeProcessi;\n if ((_this$_nativeProcessi = this._nativeProcessingContext) !== null && _this$_nativeProcessi !== void 0 && _this$_nativeProcessi.injectInVertexMain) {\n code = InjectStartingAndEndingCode(code, \"void main\", this._nativeProcessingContext.injectInVertexMain);\n }\n const hasMultiviewExtension = defines.indexOf(\"#define MULTIVIEW\") !== -1;\n if (hasMultiviewExtension) {\n return \"#extension GL_OVR_multiview2 : require\\nlayout (num_views = 2) in;\\n\" + code;\n }\n }\n return code;\n }\n}","map":{"version":3,"names":["InjectStartingAndEndingCode","varyingRegex","NativeShaderProcessor","constructor","shaderLanguage","initializeShaders","processingContext","_nativeProcessingContext","remappedAttributeNames","injectInVertexMain","attributeProcessor","attribute","replace","attribRegex","match","exec","attributeType","name","numComponents","vertexBufferKindToNumberOfComponents","undefined","newType","newName","varyingCheck","varying","_isFragment","test","varyingProcessor","isFragment","postProcessor","code","defines","hasDrawBuffersExtension","search","regex","hasOutput","_this$_nativeProcessi","hasMultiviewExtension","indexOf"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Engines/Native/nativeShaderProcessors.js"],"sourcesContent":["import { InjectStartingAndEndingCode } from \"../../Misc/codeStringParsingTools.js\";\nconst varyingRegex = /(flat\\s)?\\s*varying\\s*.*/;\n/** @internal */\nexport class NativeShaderProcessor {\n constructor() {\n this.shaderLanguage = 0 /* ShaderLanguage.GLSL */;\n }\n initializeShaders(processingContext) {\n this._nativeProcessingContext = processingContext;\n if (this._nativeProcessingContext) {\n this._nativeProcessingContext.remappedAttributeNames = {};\n this._nativeProcessingContext.injectInVertexMain = \"\";\n }\n }\n attributeProcessor(attribute) {\n if (!this._nativeProcessingContext) {\n return attribute.replace(\"attribute\", \"in\");\n }\n const attribRegex = /\\s*(?:attribute|in)\\s+(\\S+)\\s+(\\S+)\\s*;/gm;\n const match = attribRegex.exec(attribute);\n if (match !== null) {\n const attributeType = match[1];\n const name = match[2];\n const numComponents = this._nativeProcessingContext.vertexBufferKindToNumberOfComponents[name];\n if (numComponents !== undefined) {\n // Special case for an int/ivecX vertex buffer that is used as a float/vecX attribute in the shader.\n const newType = numComponents < 0 ? (numComponents === -1 ? \"int\" : \"ivec\" + -numComponents) : numComponents === 1 ? \"uint\" : \"uvec\" + numComponents;\n const newName = `_int_${name}_`;\n attribute = attribute.replace(match[0], `in ${newType} ${newName}; ${attributeType} ${name};`);\n this._nativeProcessingContext.injectInVertexMain += `${name} = ${attributeType}(${newName});\\n`;\n this._nativeProcessingContext.remappedAttributeNames[name] = newName;\n }\n else {\n attribute = attribute.replace(match[0], `in ${attributeType} ${name};`);\n }\n }\n return attribute;\n }\n varyingCheck(varying, _isFragment) {\n return varyingRegex.test(varying);\n }\n varyingProcessor(varying, isFragment) {\n return varying.replace(\"varying\", isFragment ? \"in\" : \"out\");\n }\n postProcessor(code, defines, isFragment) {\n const hasDrawBuffersExtension = code.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;\n // Remove extensions\n const regex = /#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;\n code = code.replace(regex, \"\");\n // Replace instructions\n code = code.replace(/texture2D\\s*\\(/g, \"texture(\");\n if (isFragment) {\n const hasOutput = code.search(/layout *\\(location *= *0\\) *out/g) !== -1;\n code = code.replace(/texture2DLodEXT\\s*\\(/g, \"textureLod(\");\n code = code.replace(/textureCubeLodEXT\\s*\\(/g, \"textureLod(\");\n code = code.replace(/textureCube\\s*\\(/g, \"texture(\");\n code = code.replace(/gl_FragDepthEXT/g, \"gl_FragDepth\");\n code = code.replace(/gl_FragColor/g, \"glFragColor\");\n code = code.replace(/gl_FragData/g, \"glFragData\");\n code = code.replace(/void\\s+?main\\s*\\(/g, (hasDrawBuffersExtension || hasOutput ? \"\" : \"layout(location = 0) out vec4 glFragColor;\\n\") + \"void main(\");\n }\n else {\n if (this._nativeProcessingContext?.injectInVertexMain) {\n code = InjectStartingAndEndingCode(code, \"void main\", this._nativeProcessingContext.injectInVertexMain);\n }\n const hasMultiviewExtension = defines.indexOf(\"#define MULTIVIEW\") !== -1;\n if (hasMultiviewExtension) {\n return \"#extension GL_OVR_multiview2 : require\\nlayout (num_views = 2) in;\\n\" + code;\n }\n }\n return code;\n }\n}\n"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,sCAAsC;AAClF,MAAMC,YAAY,GAAG,0BAA0B;AAC/C;AACA,OAAO,MAAMC,qBAAqB,CAAC;EAC/BC,WAAWA,CAAA,EAAG;IACV,IAAI,CAACC,cAAc,GAAG,CAAC,CAAC;EAC5B;EACAC,iBAAiBA,CAACC,iBAAiB,EAAE;IACjC,IAAI,CAACC,wBAAwB,GAAGD,iBAAiB;IACjD,IAAI,IAAI,CAACC,wBAAwB,EAAE;MAC/B,IAAI,CAACA,wBAAwB,CAACC,sBAAsB,GAAG,CAAC,CAAC;MACzD,IAAI,CAACD,wBAAwB,CAACE,kBAAkB,GAAG,EAAE;IACzD;EACJ;EACAC,kBAAkBA,CAACC,SAAS,EAAE;IAC1B,IAAI,CAAC,IAAI,CAACJ,wBAAwB,EAAE;MAChC,OAAOI,SAAS,CAACC,OAAO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