1 |
- {"ast":null,"code":"import { NodeMaterialBlockConnectionPointTypes } from \"./Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"./Enums/nodeMaterialBlockTargets.js\";\nimport { ShaderStore as EngineShaderStore } from \"../../Engines/shaderStore.js\";\n\n/**\n * Class used to store node based material build state\n */\nexport class NodeMaterialBuildState {\n constructor() {\n /** Gets or sets a boolean indicating if the current state can emit uniform buffers */\n this.supportUniformBuffers = false;\n /**\n * Gets the list of emitted attributes\n */\n this.attributes = [];\n /**\n * Gets the list of emitted uniforms\n */\n this.uniforms = [];\n /**\n * Gets the list of emitted constants\n */\n this.constants = [];\n /**\n * Gets the list of emitted samplers\n */\n this.samplers = [];\n /**\n * Gets the list of emitted functions\n */\n this.functions = {};\n /**\n * Gets the list of emitted extensions\n */\n this.extensions = {};\n /**\n * Gets the list of emitted prePass outputs - if using the prepass\n */\n this.prePassOutput = {};\n /**\n * Gets the list of emitted counters\n */\n this.counters = {};\n /** @internal */\n this._terminalBlocks = new Set();\n /** @internal */\n this._attributeDeclaration = \"\";\n /** @internal */\n this._uniformDeclaration = \"\";\n /** @internal */\n this._constantDeclaration = \"\";\n /** @internal */\n this._samplerDeclaration = \"\";\n /** @internal */\n this._varyingTransfer = \"\";\n /** @internal */\n this._injectAtEnd = \"\";\n this._repeatableContentAnchorIndex = 0;\n /** @internal */\n this._builtCompilationString = \"\";\n /**\n * Gets the emitted compilation strings\n */\n this.compilationString = \"\";\n }\n /**\n * Gets the current shader language to use\n */\n get shaderLanguage() {\n return this.sharedData.nodeMaterial.shaderLanguage;\n }\n /** Gets suffix to add behind type casting */\n get fSuffix() {\n return this.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? \"f\" : \"\";\n }\n /**\n * Finalize the compilation strings\n * @param state defines the current compilation state\n */\n finalize(state) {\n const emitComments = state.sharedData.emitComments;\n const isFragmentMode = this.target === NodeMaterialBlockTargets.Fragment;\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n if (isFragmentMode) {\n this.compilationString = `\\n${emitComments ? \"//Entry point\\n\" : \"\"}@fragment\\nfn main(input: FragmentInputs) -> FragmentOutputs {\\n${this.compilationString}`;\n } else {\n this.compilationString = `\\n${emitComments ? \"//Entry point\\n\" : \"\"}@vertex\\nfn main(input: VertexInputs) -> FragmentInputs{\\n${this.compilationString}`;\n }\n } else {\n this.compilationString = `\\n${emitComments ? \"//Entry point\\n\" : \"\"}void main(void) {\\n${this.compilationString}`;\n }\n if (this._constantDeclaration) {\n this.compilationString = `\\n${emitComments ? \"//Constants\\n\" : \"\"}${this._constantDeclaration}\\n${this.compilationString}`;\n }\n let functionCode = \"\";\n for (const functionName in this.functions) {\n functionCode += this.functions[functionName] + `\\n`;\n }\n this.compilationString = `\\n${functionCode}\\n${this.compilationString}`;\n if (!isFragmentMode && this._varyingTransfer) {\n this.compilationString = `${this.compilationString}\\n${this._varyingTransfer}`;\n }\n if (this._injectAtEnd) {\n this.compilationString = `${this.compilationString}\\n${this._injectAtEnd}`;\n }\n this.compilationString = `${this.compilationString}\\n}`;\n if (this.sharedData.varyingDeclaration) {\n this.compilationString = `\\n${emitComments ? \"//Varyings\\n\" : \"\"}${this.sharedData.varyingDeclaration}\\n${this.compilationString}`;\n }\n if (this._samplerDeclaration) {\n this.compilationString = `\\n${emitComments ? \"//Samplers\\n\" : \"\"}${this._samplerDeclaration}\\n${this.compilationString}`;\n }\n if (this._uniformDeclaration) {\n this.compilationString = `\\n${emitComments ? \"//Uniforms\\n\" : \"\"}${this._uniformDeclaration}\\n${this.compilationString}`;\n }\n if (this._attributeDeclaration && !isFragmentMode) {\n this.compilationString = `\\n${emitComments ? \"//Attributes\\n\" : \"\"}${this._attributeDeclaration}\\n${this.compilationString}`;\n }\n if (this.shaderLanguage !== 1 /* ShaderLanguage.WGSL */) {\n this.compilationString = \"precision highp float;\\n\" + this.compilationString;\n this.compilationString = \"#if defined(WEBGL2) || defined(WEBGPU)\\nprecision highp sampler2DArray;\\n#endif\\n\" + this.compilationString;\n if (isFragmentMode) {\n this.compilationString = \"#if defined(PREPASS)\\r\\n#extension GL_EXT_draw_buffers : require\\r\\nlayout(location = 0) out highp vec4 glFragData[SCENE_MRT_COUNT];\\r\\nhighp vec4 gl_FragColor;\\r\\n#endif\\r\\n\" + this.compilationString;\n }\n for (const extensionName in this.extensions) {\n const extension = this.extensions[extensionName];\n this.compilationString = `\\n${extension}\\n${this.compilationString}`;\n }\n }\n this._builtCompilationString = this.compilationString;\n }\n /** @internal */\n get _repeatableContentAnchor() {\n return `###___ANCHOR${this._repeatableContentAnchorIndex++}___###`;\n }\n /**\n * @internal\n */\n _getFreeVariableName(prefix) {\n prefix = prefix.replace(/[^a-zA-Z_]+/g, \"\");\n if (this.sharedData.variableNames[prefix] === undefined) {\n this.sharedData.variableNames[prefix] = 0;\n // Check reserved words\n if (prefix === \"output\" || prefix === \"texture\") {\n return prefix + this.sharedData.variableNames[prefix];\n }\n return prefix;\n } else {\n this.sharedData.variableNames[prefix]++;\n }\n return prefix + this.sharedData.variableNames[prefix];\n }\n /**\n * @internal\n */\n _getFreeDefineName(prefix) {\n if (this.sharedData.defineNames[prefix] === undefined) {\n this.sharedData.defineNames[prefix] = 0;\n } else {\n this.sharedData.defineNames[prefix]++;\n }\n return prefix + this.sharedData.defineNames[prefix];\n }\n /**\n * @internal\n */\n _excludeVariableName(name) {\n this.sharedData.variableNames[name] = 0;\n }\n /**\n * @internal\n */\n _emit2DSampler(name, define = \"\", force = false) {\n if (this.samplers.indexOf(name) < 0 || force) {\n if (define) {\n this._samplerDeclaration += `#if ${define}\\n`;\n }\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n this._samplerDeclaration += `var ${name + `Sampler`}: sampler;\\n`;\n this._samplerDeclaration += `var ${name}: texture_2d<f32>;\\n`;\n } else {\n this._samplerDeclaration += `uniform sampler2D ${name};\\n`;\n }\n if (define) {\n this._samplerDeclaration += `#endif\\n`;\n }\n if (!force) {\n this.samplers.push(name);\n }\n }\n }\n /**\n * @internal\n */\n _emitCubeSampler(name, define = \"\", force = false) {\n if (this.samplers.indexOf(name) < 0 || force) {\n if (define) {\n this._samplerDeclaration += `#if ${define}\\n`;\n }\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n this._samplerDeclaration += `var ${name + `Sampler`}: sampler;\\n`;\n this._samplerDeclaration += `var ${name}: texture_cube<f32>;\\n`;\n } else {\n this._samplerDeclaration += `uniform samplerCube ${name};\\n`;\n }\n if (define) {\n this._samplerDeclaration += `#endif\\n`;\n }\n if (!force) {\n this.samplers.push(name);\n }\n }\n }\n /**\n * @internal\n */\n _emit2DArraySampler(name) {\n if (this.samplers.indexOf(name) < 0) {\n this._samplerDeclaration += `uniform sampler2DArray ${name};\\n`;\n this.samplers.push(name);\n }\n }\n /**\n * @internal\n */\n _getGLType(type) {\n switch (type) {\n case NodeMaterialBlockConnectionPointTypes.Float:\n return \"float\";\n case NodeMaterialBlockConnectionPointTypes.Int:\n return \"int\";\n case NodeMaterialBlockConnectionPointTypes.Vector2:\n return \"vec2\";\n case NodeMaterialBlockConnectionPointTypes.Color3:\n case NodeMaterialBlockConnectionPointTypes.Vector3:\n return \"vec3\";\n case NodeMaterialBlockConnectionPointTypes.Color4:\n case NodeMaterialBlockConnectionPointTypes.Vector4:\n return \"vec4\";\n case NodeMaterialBlockConnectionPointTypes.Matrix:\n return \"mat4\";\n }\n return \"\";\n }\n /**\n * @internal\n */\n _getShaderType(type) {\n const isWGSL = this.shaderLanguage === 1 /* ShaderLanguage.WGSL */;\n switch (type) {\n case NodeMaterialBlockConnectionPointTypes.Float:\n return isWGSL ? \"f32\" : \"float\";\n case NodeMaterialBlockConnectionPointTypes.Int:\n return isWGSL ? \"i32\" : \"int\";\n case NodeMaterialBlockConnectionPointTypes.Vector2:\n return isWGSL ? \"vec2f\" : \"vec2\";\n case NodeMaterialBlockConnectionPointTypes.Color3:\n case NodeMaterialBlockConnectionPointTypes.Vector3:\n return isWGSL ? \"vec3f\" : \"vec3\";\n case NodeMaterialBlockConnectionPointTypes.Color4:\n case NodeMaterialBlockConnectionPointTypes.Vector4:\n return isWGSL ? \"vec4f\" : \"vec4\";\n case NodeMaterialBlockConnectionPointTypes.Matrix:\n return isWGSL ? \"mat4x4f\" : \"mat4\";\n }\n return \"\";\n }\n /**\n * @internal\n */\n _emitExtension(name, extension, define = \"\") {\n if (this.extensions[name]) {\n return;\n }\n if (define) {\n extension = `#if ${define}\\n${extension}\\n#endif`;\n }\n this.extensions[name] = extension;\n }\n /**\n * @internal\n */\n _emitFunction(name, code, comments) {\n if (this.functions[name]) {\n return;\n }\n if (this.sharedData.emitComments) {\n code = comments + `\\n` + code;\n }\n this.functions[name] = code;\n }\n /**\n * @internal\n */\n _emitCodeFromInclude(includeName, comments, options) {\n const store = EngineShaderStore.GetIncludesShadersStore(this.shaderLanguage);\n if (options && options.repeatKey) {\n return `#include<${includeName}>${options.substitutionVars ? \"(\" + options.substitutionVars + \")\" : \"\"}[0..${options.repeatKey}]\\n`;\n }\n let code = store[includeName] + \"\\n\";\n if (this.sharedData.emitComments) {\n code = comments + `\\n` + code;\n }\n if (!options) {\n return code;\n }\n if (options.replaceStrings) {\n for (let index = 0; index < options.replaceStrings.length; index++) {\n const replaceString = options.replaceStrings[index];\n code = code.replace(replaceString.search, replaceString.replace);\n }\n }\n return code;\n }\n /**\n * @internal\n */\n _emitFunctionFromInclude(includeName, comments, options, storeKey = \"\") {\n const key = includeName + storeKey;\n if (this.functions[key]) {\n return;\n }\n const store = EngineShaderStore.GetIncludesShadersStore(this.shaderLanguage);\n if (!options || !options.removeAttributes && !options.removeUniforms && !options.removeVaryings && !options.removeIfDef && !options.replaceStrings) {\n if (options && options.repeatKey) {\n this.functions[key] = `#include<${includeName}>${options.substitutionVars ? \"(\" + options.substitutionVars + \")\" : \"\"}[0..${options.repeatKey}]\\n`;\n } else {\n this.functions[key] = `#include<${includeName}>${options !== null && options !== void 0 && options.substitutionVars ? \"(\" + (options === null || options === void 0 ? void 0 : options.substitutionVars) + \")\" : \"\"}\\n`;\n }\n if (this.sharedData.emitComments) {\n this.functions[key] = comments + `\\n` + this.functions[key];\n }\n return;\n }\n this.functions[key] = store[includeName];\n if (this.sharedData.emitComments) {\n this.functions[key] = comments + `\\n` + this.functions[key];\n }\n if (options.removeIfDef) {\n this.functions[key] = this.functions[key].replace(/^\\s*?#ifdef.+$/gm, \"\");\n this.functions[key] = this.functions[key].replace(/^\\s*?#endif.*$/gm, \"\");\n this.functions[key] = this.functions[key].replace(/^\\s*?#else.*$/gm, \"\");\n this.functions[key] = this.functions[key].replace(/^\\s*?#elif.*$/gm, \"\");\n }\n if (options.removeAttributes) {\n this.functions[key] = this.functions[key].replace(/\\s*?attribute .+?;/g, \"\\n\");\n }\n if (options.removeUniforms) {\n this.functions[key] = this.functions[key].replace(/\\s*?uniform .*?;/g, \"\\n\");\n }\n if (options.removeVaryings) {\n this.functions[key] = this.functions[key].replace(/\\s*?(varying|in) .+?;/g, \"\\n\");\n }\n if (options.replaceStrings) {\n for (let index = 0; index < options.replaceStrings.length; index++) {\n const replaceString = options.replaceStrings[index];\n this.functions[key] = this.functions[key].replace(replaceString.search, replaceString.replace);\n }\n }\n }\n /**\n * @internal\n */\n _registerTempVariable(name) {\n if (this.sharedData.temps.indexOf(name) !== -1) {\n return false;\n }\n this.sharedData.temps.push(name);\n return true;\n }\n /**\n * @internal\n */\n _emitVaryingFromString(name, type, define = \"\", notDefine = false) {\n if (this.sharedData.varyings.indexOf(name) !== -1) {\n return false;\n }\n this.sharedData.varyings.push(name);\n if (define) {\n if (define.startsWith(\"defined(\")) {\n this.sharedData.varyingDeclaration += `#if ${define}\\n`;\n } else {\n this.sharedData.varyingDeclaration += `${notDefine ? \"#ifndef\" : \"#ifdef\"} ${define}\\n`;\n }\n }\n const shaderType = this._getShaderType(type);\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n this.sharedData.varyingDeclaration += `varying ${name}: ${shaderType};\\n`;\n } else {\n this.sharedData.varyingDeclaration += `varying ${shaderType} ${name};\\n`;\n }\n if (define) {\n this.sharedData.varyingDeclaration += `#endif\\n`;\n }\n return true;\n }\n /**\n * @internal\n */\n _getVaryingName(name) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return (this.target !== NodeMaterialBlockTargets.Fragment ? \"vertexOutputs.\" : \"fragmentInputs.\") + name;\n }\n return name;\n }\n /**\n * @internal\n */\n _emitUniformFromString(name, type, define = \"\", notDefine = false) {\n if (this.uniforms.indexOf(name) !== -1) {\n return;\n }\n this.uniforms.push(name);\n if (define) {\n if (define.startsWith(\"defined(\")) {\n this._uniformDeclaration += `#if ${define}\\n`;\n } else {\n this._uniformDeclaration += `${notDefine ? \"#ifndef\" : \"#ifdef\"} ${define}\\n`;\n }\n }\n const shaderType = this._getShaderType(type);\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n this._uniformDeclaration += `uniform ${name}: ${shaderType};\\n`;\n } else {\n this._uniformDeclaration += `uniform ${shaderType} ${name};\\n`;\n }\n if (define) {\n this._uniformDeclaration += `#endif\\n`;\n }\n }\n /**\n * @internal\n */\n _generateTernary(trueStatement, falseStatement, condition) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `select(${falseStatement}, ${trueStatement}, ${condition})`;\n }\n return `(${condition}) ? ${trueStatement} : ${falseStatement}`;\n }\n /**\n * @internal\n */\n _emitFloat(value) {\n if (value.toString() === value.toFixed(0)) {\n return `${value}.0`;\n }\n return value.toString();\n }\n /**\n * @internal\n */\n _declareOutput(output, isConst) {\n return this._declareLocalVar(output.associatedVariableName, output.type, isConst);\n }\n /**\n * @internal\n */\n _declareLocalVar(name, type, isConst) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `${isConst ? \"const\" : \"var\"} ${name}: ${this._getShaderType(type)}`;\n } else {\n return `${this._getShaderType(type)} ${name}`;\n }\n }\n /**\n * @internal\n */\n _samplerCubeFunc() {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return \"textureSample\";\n }\n return \"textureCube\";\n }\n /**\n * @internal\n */\n _samplerFunc() {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return \"textureSample\";\n }\n return \"texture2D\";\n }\n /**\n * @internal\n */\n _samplerLODFunc() {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return \"textureSampleLevel\";\n }\n return \"texture2DLodEXT\";\n }\n _toLinearSpace(output) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n if (output.type === NodeMaterialBlockConnectionPointTypes.Color3 || output.type === NodeMaterialBlockConnectionPointTypes.Vector3) {\n return `toLinearSpaceVec3(${output.associatedVariableName})`;\n }\n return `toLinearSpace(${output.associatedVariableName})`;\n }\n return `toLinearSpace(${output.associatedVariableName})`;\n }\n /**\n * @internal\n */\n _generateTextureSample(uv, samplerName) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `${this._samplerFunc()}(${samplerName},${samplerName + `Sampler`}, ${uv})`;\n }\n return `${this._samplerFunc()}(${samplerName}, ${uv})`;\n }\n /**\n * @internal\n */\n _generateTextureSampleLOD(uv, samplerName, lod) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `${this._samplerLODFunc()}(${samplerName},${samplerName + `Sampler`}, ${uv}, ${lod})`;\n }\n return `${this._samplerLODFunc()}(${samplerName}, ${uv}, ${lod})`;\n }\n /**\n * @internal\n */\n _generateTextureSampleCube(uv, samplerName) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `${this._samplerCubeFunc()}(${samplerName},${samplerName + `Sampler`}, ${uv})`;\n }\n return `${this._samplerCubeFunc()}(${samplerName}, ${uv})`;\n }\n /**\n * @internal\n */\n _generateTextureSampleCubeLOD(uv, samplerName, lod) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `${this._samplerCubeFunc()}(${samplerName},${samplerName + `Sampler`}, ${uv}, ${lod})`;\n }\n return `${this._samplerCubeFunc()}(${samplerName}, ${uv}, ${lod})`;\n }\n _convertVariableDeclarationToWGSL(type, dest, source) {\n return source.replace(new RegExp(`(${type})\\\\s+(\\\\w+)`, \"g\"), `var $2: ${dest}`);\n }\n _convertVariableConstructorsToWGSL(type, dest, source) {\n return source.replace(new RegExp(`(${type})\\\\(`, \"g\"), ` ${dest}(`);\n }\n _convertOutParametersToWGSL(source) {\n return source.replace(new RegExp(`out\\\\s+var\\\\s+(\\\\w+)\\\\s*:\\\\s*(\\\\w+)`, \"g\"), `$1: ptr<function, $2>`);\n }\n _convertTernaryOperandsToWGSL(source) {\n return source.replace(new RegExp(`\\\\[(.*?)\\\\?(.*?):(.*)\\\\]`, \"g\"), (match, condition, trueCase, falseCase) => `select(${falseCase}, ${trueCase}, ${condition})`);\n }\n _convertModOperatorsToWGSL(source) {\n return source.replace(new RegExp(`mod\\\\((.+?),\\\\s*(.+?)\\\\)`, \"g\"), (match, left, right) => `((${left})%(${right}))`);\n }\n _convertConstToWGSL(source) {\n return source.replace(new RegExp(`const var`, \"g\"), `const`);\n }\n _convertInnerFunctionsToWGSL(source) {\n return source.replace(new RegExp(`inversesqrt`, \"g\"), `inverseSqrt`);\n }\n _convertFunctionsToWGSL(source) {\n const regex = /var\\s+(\\w+)\\s*:\\s*(\\w+)\\((.*)\\)/g;\n let match;\n while ((match = regex.exec(source)) !== null) {\n const funcName = match[1];\n const funcType = match[2];\n const params = match[3]; // All parameters as a single string\n // Processing the parameters to match 'name: type' format\n const formattedParams = params.replace(/var\\s/g, \"\");\n // Constructing the final output string\n source = source.replace(match[0], `fn ${funcName}(${formattedParams}) -> ${funcType}`);\n }\n return source;\n }\n _babylonSLtoWGSL(code) {\n // variable declarations\n code = this._convertVariableDeclarationToWGSL(\"void\", \"voidnull\", code);\n code = this._convertVariableDeclarationToWGSL(\"bool\", \"bool\", code);\n code = this._convertVariableDeclarationToWGSL(\"int\", \"i32\", code);\n code = this._convertVariableDeclarationToWGSL(\"uint\", \"u32\", code);\n code = this._convertVariableDeclarationToWGSL(\"float\", \"f32\", code);\n code = this._convertVariableDeclarationToWGSL(\"vec2\", \"vec2f\", code);\n code = this._convertVariableDeclarationToWGSL(\"vec3\", \"vec3f\", code);\n code = this._convertVariableDeclarationToWGSL(\"vec4\", \"vec4f\", code);\n code = this._convertVariableDeclarationToWGSL(\"mat2\", \"mat2x2f\", code);\n code = this._convertVariableDeclarationToWGSL(\"mat3\", \"mat3x3f\", code);\n code = this._convertVariableDeclarationToWGSL(\"mat4\", \"mat4x4f\", code);\n // Type constructors\n code = this._convertVariableConstructorsToWGSL(\"float\", \"f32\", code);\n code = this._convertVariableConstructorsToWGSL(\"vec2\", \"vec2f\", code);\n code = this._convertVariableConstructorsToWGSL(\"vec3\", \"vec3f\", code);\n code = this._convertVariableConstructorsToWGSL(\"vec4\", \"vec4f\", code);\n code = this._convertVariableConstructorsToWGSL(\"mat2\", \"mat2x2f\", code);\n code = this._convertVariableConstructorsToWGSL(\"mat3\", \"mat3x3f\", code);\n code = this._convertVariableConstructorsToWGSL(\"mat4\", \"mat4x4f\", code);\n // Ternary operands\n code = this._convertTernaryOperandsToWGSL(code);\n // Mod operators\n code = this._convertModOperatorsToWGSL(code);\n // Const\n code = this._convertConstToWGSL(code);\n // Inner functions\n code = this._convertInnerFunctionsToWGSL(code);\n // Out paramters\n code = this._convertOutParametersToWGSL(code);\n code = code.replace(/\\[\\*\\]/g, \"*\");\n // Functions\n code = this._convertFunctionsToWGSL(code);\n // Remove voidnull\n code = code.replace(/\\s->\\svoidnull/g, \"\");\n // Derivatives\n code = code.replace(/dFdx/g, \"dpdx\");\n code = code.replace(/dFdy/g, \"dpdy\");\n return code;\n }\n _convertTernaryOperandsToGLSL(source) {\n return source.replace(new RegExp(`\\\\[(.+?)\\\\?(.+?):(.+)\\\\]`, \"g\"), (match, condition, trueCase, falseCase) => `${condition} ? ${trueCase} : ${falseCase}`);\n }\n _babylonSLtoGLSL(code) {\n /** Remove BSL specifics */\n code = code.replace(/\\[\\*\\]/g, \"\");\n code = this._convertTernaryOperandsToGLSL(code);\n return code;\n }\n}","map":{"version":3,"names":["NodeMaterialBlockConnectionPointTypes","NodeMaterialBlockTargets","ShaderStore","EngineShaderStore","NodeMaterialBuildState","constructor","supportUniformBuffers","attributes","uniforms","constants","samplers","functions","extensions","prePassOutput","counters","_terminalBlocks","Set","_attributeDeclaration","_uniformDeclaration","_constantDeclaration","_samplerDeclaration","_varyingTransfer","_injectAtEnd","_repeatableContentAnchorIndex","_builtCompilationString","compilationString","shaderLanguage","sharedData","nodeMaterial","fSuffix","finalize","state","emitComments","isFragmentMode","target","Fragment","functionCode","functionName","varyingDeclaration","extensionName","extension","_repeatableContentAnchor","_getFreeVariableName","prefix","replace","variableNames","undefined","_getFreeDefineName","defineNames","_excludeVariableName","name","_emit2DSampler","define","force","indexOf","push","_emitCubeSampler","_emit2DArraySampler","_getGLType","type","Float","Int","Vector2","Color3","Vector3","Color4","Vector4","Matrix","_getShaderType","isWGSL","_emitExtension","_emitFunction","code","comments","_emitCodeFromInclude","includeName","options","store","GetIncludesShadersStore","repeatKey","substitutionVars","replaceStrings","index","length","replaceString","search","_emitFunctionFromInclude","storeKey","key","removeAttributes","removeUniforms","removeVaryings","removeIfDef","_registerTempVariable","temps","_emitVaryingFromString","notDefine","varyings","startsWith","shaderType","_getVaryingName","_emitUniformFromString","_generateTernary","trueStatement","falseStatement","condition","_emitFloat","value","toString","toFixed","_declareOutput","output","isConst","_declareLocalVar","associatedVariableName","_samplerCubeFunc","_samplerFunc","_samplerLODFunc","_toLinearSpace","_generateTextureSample","uv","samplerName","_generateTextureSampleLOD","lod","_generateTextureSampleCube","_generateTextureSampleCubeLOD","_convertVariableDeclarationToWGSL","dest","source","RegExp","_convertVariableConstructorsToWGSL","_convertOutParametersToWGSL","_convertTernaryOperandsToWGSL","match","trueCase","falseCase","_convertModOperatorsToWGSL","left","right","_convertConstToWGSL","_convertInnerFunctionsToWGSL","_convertFunctionsToWGSL","regex","exec","funcName","funcType","params","formattedParams","_babylonSLtoWGSL","_convertTernaryOperandsToGLSL","_babylonSLtoGLSL"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/nodeMaterialBuildState.js"],"sourcesContent":["import { NodeMaterialBlockConnectionPointTypes } from \"./Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"./Enums/nodeMaterialBlockTargets.js\";\nimport { ShaderStore as EngineShaderStore } from \"../../Engines/shaderStore.js\";\n\n/**\n * Class used to store node based material build state\n */\nexport class NodeMaterialBuildState {\n constructor() {\n /** Gets or sets a boolean indicating if the current state can emit uniform buffers */\n this.supportUniformBuffers = false;\n /**\n * Gets the list of emitted attributes\n */\n this.attributes = [];\n /**\n * Gets the list of emitted uniforms\n */\n this.uniforms = [];\n /**\n * Gets the list of emitted constants\n */\n this.constants = [];\n /**\n * Gets the list of emitted samplers\n */\n this.samplers = [];\n /**\n * Gets the list of emitted functions\n */\n this.functions = {};\n /**\n * Gets the list of emitted extensions\n */\n this.extensions = {};\n /**\n * Gets the list of emitted prePass outputs - if using the prepass\n */\n this.prePassOutput = {};\n /**\n * Gets the list of emitted counters\n */\n this.counters = {};\n /** @internal */\n this._terminalBlocks = new Set();\n /** @internal */\n this._attributeDeclaration = \"\";\n /** @internal */\n this._uniformDeclaration = \"\";\n /** @internal */\n this._constantDeclaration = \"\";\n /** @internal */\n this._samplerDeclaration = \"\";\n /** @internal */\n this._varyingTransfer = \"\";\n /** @internal */\n this._injectAtEnd = \"\";\n this._repeatableContentAnchorIndex = 0;\n /** @internal */\n this._builtCompilationString = \"\";\n /**\n * Gets the emitted compilation strings\n */\n this.compilationString = \"\";\n }\n /**\n * Gets the current shader language to use\n */\n get shaderLanguage() {\n return this.sharedData.nodeMaterial.shaderLanguage;\n }\n /** Gets suffix to add behind type casting */\n get fSuffix() {\n return this.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? \"f\" : \"\";\n }\n /**\n * Finalize the compilation strings\n * @param state defines the current compilation state\n */\n finalize(state) {\n const emitComments = state.sharedData.emitComments;\n const isFragmentMode = this.target === NodeMaterialBlockTargets.Fragment;\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n if (isFragmentMode) {\n this.compilationString = `\\n${emitComments ? \"//Entry point\\n\" : \"\"}@fragment\\nfn main(input: FragmentInputs) -> FragmentOutputs {\\n${this.compilationString}`;\n }\n else {\n this.compilationString = `\\n${emitComments ? \"//Entry point\\n\" : \"\"}@vertex\\nfn main(input: VertexInputs) -> FragmentInputs{\\n${this.compilationString}`;\n }\n }\n else {\n this.compilationString = `\\n${emitComments ? \"//Entry point\\n\" : \"\"}void main(void) {\\n${this.compilationString}`;\n }\n if (this._constantDeclaration) {\n this.compilationString = `\\n${emitComments ? \"//Constants\\n\" : \"\"}${this._constantDeclaration}\\n${this.compilationString}`;\n }\n let functionCode = \"\";\n for (const functionName in this.functions) {\n functionCode += this.functions[functionName] + `\\n`;\n }\n this.compilationString = `\\n${functionCode}\\n${this.compilationString}`;\n if (!isFragmentMode && this._varyingTransfer) {\n this.compilationString = `${this.compilationString}\\n${this._varyingTransfer}`;\n }\n if (this._injectAtEnd) {\n this.compilationString = `${this.compilationString}\\n${this._injectAtEnd}`;\n }\n this.compilationString = `${this.compilationString}\\n}`;\n if (this.sharedData.varyingDeclaration) {\n this.compilationString = `\\n${emitComments ? \"//Varyings\\n\" : \"\"}${this.sharedData.varyingDeclaration}\\n${this.compilationString}`;\n }\n if (this._samplerDeclaration) {\n this.compilationString = `\\n${emitComments ? \"//Samplers\\n\" : \"\"}${this._samplerDeclaration}\\n${this.compilationString}`;\n }\n if (this._uniformDeclaration) {\n this.compilationString = `\\n${emitComments ? \"//Uniforms\\n\" : \"\"}${this._uniformDeclaration}\\n${this.compilationString}`;\n }\n if (this._attributeDeclaration && !isFragmentMode) {\n this.compilationString = `\\n${emitComments ? \"//Attributes\\n\" : \"\"}${this._attributeDeclaration}\\n${this.compilationString}`;\n }\n if (this.shaderLanguage !== 1 /* ShaderLanguage.WGSL */) {\n this.compilationString = \"precision highp float;\\n\" + this.compilationString;\n this.compilationString = \"#if defined(WEBGL2) || defined(WEBGPU)\\nprecision highp sampler2DArray;\\n#endif\\n\" + this.compilationString;\n if (isFragmentMode) {\n this.compilationString =\n \"#if defined(PREPASS)\\r\\n#extension GL_EXT_draw_buffers : require\\r\\nlayout(location = 0) out highp vec4 glFragData[SCENE_MRT_COUNT];\\r\\nhighp vec4 gl_FragColor;\\r\\n#endif\\r\\n\" +\n this.compilationString;\n }\n for (const extensionName in this.extensions) {\n const extension = this.extensions[extensionName];\n this.compilationString = `\\n${extension}\\n${this.compilationString}`;\n }\n }\n this._builtCompilationString = this.compilationString;\n }\n /** @internal */\n get _repeatableContentAnchor() {\n return `###___ANCHOR${this._repeatableContentAnchorIndex++}___###`;\n }\n /**\n * @internal\n */\n _getFreeVariableName(prefix) {\n prefix = prefix.replace(/[^a-zA-Z_]+/g, \"\");\n if (this.sharedData.variableNames[prefix] === undefined) {\n this.sharedData.variableNames[prefix] = 0;\n // Check reserved words\n if (prefix === \"output\" || prefix === \"texture\") {\n return prefix + this.sharedData.variableNames[prefix];\n }\n return prefix;\n }\n else {\n this.sharedData.variableNames[prefix]++;\n }\n return prefix + this.sharedData.variableNames[prefix];\n }\n /**\n * @internal\n */\n _getFreeDefineName(prefix) {\n if (this.sharedData.defineNames[prefix] === undefined) {\n this.sharedData.defineNames[prefix] = 0;\n }\n else {\n this.sharedData.defineNames[prefix]++;\n }\n return prefix + this.sharedData.defineNames[prefix];\n }\n /**\n * @internal\n */\n _excludeVariableName(name) {\n this.sharedData.variableNames[name] = 0;\n }\n /**\n * @internal\n */\n _emit2DSampler(name, define = \"\", force = false) {\n if (this.samplers.indexOf(name) < 0 || force) {\n if (define) {\n this._samplerDeclaration += `#if ${define}\\n`;\n }\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n this._samplerDeclaration += `var ${name + `Sampler`}: sampler;\\n`;\n this._samplerDeclaration += `var ${name}: texture_2d<f32>;\\n`;\n }\n else {\n this._samplerDeclaration += `uniform sampler2D ${name};\\n`;\n }\n if (define) {\n this._samplerDeclaration += `#endif\\n`;\n }\n if (!force) {\n this.samplers.push(name);\n }\n }\n }\n /**\n * @internal\n */\n _emitCubeSampler(name, define = \"\", force = false) {\n if (this.samplers.indexOf(name) < 0 || force) {\n if (define) {\n this._samplerDeclaration += `#if ${define}\\n`;\n }\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n this._samplerDeclaration += `var ${name + `Sampler`}: sampler;\\n`;\n this._samplerDeclaration += `var ${name}: texture_cube<f32>;\\n`;\n }\n else {\n this._samplerDeclaration += `uniform samplerCube ${name};\\n`;\n }\n if (define) {\n this._samplerDeclaration += `#endif\\n`;\n }\n if (!force) {\n this.samplers.push(name);\n }\n }\n }\n /**\n * @internal\n */\n _emit2DArraySampler(name) {\n if (this.samplers.indexOf(name) < 0) {\n this._samplerDeclaration += `uniform sampler2DArray ${name};\\n`;\n this.samplers.push(name);\n }\n }\n /**\n * @internal\n */\n _getGLType(type) {\n switch (type) {\n case NodeMaterialBlockConnectionPointTypes.Float:\n return \"float\";\n case NodeMaterialBlockConnectionPointTypes.Int:\n return \"int\";\n case NodeMaterialBlockConnectionPointTypes.Vector2:\n return \"vec2\";\n case NodeMaterialBlockConnectionPointTypes.Color3:\n case NodeMaterialBlockConnectionPointTypes.Vector3:\n return \"vec3\";\n case NodeMaterialBlockConnectionPointTypes.Color4:\n case NodeMaterialBlockConnectionPointTypes.Vector4:\n return \"vec4\";\n case NodeMaterialBlockConnectionPointTypes.Matrix:\n return \"mat4\";\n }\n return \"\";\n }\n /**\n * @internal\n */\n _getShaderType(type) {\n const isWGSL = this.shaderLanguage === 1 /* ShaderLanguage.WGSL */;\n switch (type) {\n case NodeMaterialBlockConnectionPointTypes.Float:\n return isWGSL ? \"f32\" : \"float\";\n case NodeMaterialBlockConnectionPointTypes.Int:\n return isWGSL ? \"i32\" : \"int\";\n case NodeMaterialBlockConnectionPointTypes.Vector2:\n return isWGSL ? \"vec2f\" : \"vec2\";\n case NodeMaterialBlockConnectionPointTypes.Color3:\n case NodeMaterialBlockConnectionPointTypes.Vector3:\n return isWGSL ? \"vec3f\" : \"vec3\";\n case NodeMaterialBlockConnectionPointTypes.Color4:\n case NodeMaterialBlockConnectionPointTypes.Vector4:\n return isWGSL ? \"vec4f\" : \"vec4\";\n case NodeMaterialBlockConnectionPointTypes.Matrix:\n return isWGSL ? \"mat4x4f\" : \"mat4\";\n }\n return \"\";\n }\n /**\n * @internal\n */\n _emitExtension(name, extension, define = \"\") {\n if (this.extensions[name]) {\n return;\n }\n if (define) {\n extension = `#if ${define}\\n${extension}\\n#endif`;\n }\n this.extensions[name] = extension;\n }\n /**\n * @internal\n */\n _emitFunction(name, code, comments) {\n if (this.functions[name]) {\n return;\n }\n if (this.sharedData.emitComments) {\n code = comments + `\\n` + code;\n }\n this.functions[name] = code;\n }\n /**\n * @internal\n */\n _emitCodeFromInclude(includeName, comments, options) {\n const store = EngineShaderStore.GetIncludesShadersStore(this.shaderLanguage);\n if (options && options.repeatKey) {\n return `#include<${includeName}>${options.substitutionVars ? \"(\" + options.substitutionVars + \")\" : \"\"}[0..${options.repeatKey}]\\n`;\n }\n let code = store[includeName] + \"\\n\";\n if (this.sharedData.emitComments) {\n code = comments + `\\n` + code;\n }\n if (!options) {\n return code;\n }\n if (options.replaceStrings) {\n for (let index = 0; index < options.replaceStrings.length; index++) {\n const replaceString = options.replaceStrings[index];\n code = code.replace(replaceString.search, replaceString.replace);\n }\n }\n return code;\n }\n /**\n * @internal\n */\n _emitFunctionFromInclude(includeName, comments, options, storeKey = \"\") {\n const key = includeName + storeKey;\n if (this.functions[key]) {\n return;\n }\n const store = EngineShaderStore.GetIncludesShadersStore(this.shaderLanguage);\n if (!options || (!options.removeAttributes && !options.removeUniforms && !options.removeVaryings && !options.removeIfDef && !options.replaceStrings)) {\n if (options && options.repeatKey) {\n this.functions[key] = `#include<${includeName}>${options.substitutionVars ? \"(\" + options.substitutionVars + \")\" : \"\"}[0..${options.repeatKey}]\\n`;\n }\n else {\n this.functions[key] = `#include<${includeName}>${options?.substitutionVars ? \"(\" + options?.substitutionVars + \")\" : \"\"}\\n`;\n }\n if (this.sharedData.emitComments) {\n this.functions[key] = comments + `\\n` + this.functions[key];\n }\n return;\n }\n this.functions[key] = store[includeName];\n if (this.sharedData.emitComments) {\n this.functions[key] = comments + `\\n` + this.functions[key];\n }\n if (options.removeIfDef) {\n this.functions[key] = this.functions[key].replace(/^\\s*?#ifdef.+$/gm, \"\");\n this.functions[key] = this.functions[key].replace(/^\\s*?#endif.*$/gm, \"\");\n this.functions[key] = this.functions[key].replace(/^\\s*?#else.*$/gm, \"\");\n this.functions[key] = this.functions[key].replace(/^\\s*?#elif.*$/gm, \"\");\n }\n if (options.removeAttributes) {\n this.functions[key] = this.functions[key].replace(/\\s*?attribute .+?;/g, \"\\n\");\n }\n if (options.removeUniforms) {\n this.functions[key] = this.functions[key].replace(/\\s*?uniform .*?;/g, \"\\n\");\n }\n if (options.removeVaryings) {\n this.functions[key] = this.functions[key].replace(/\\s*?(varying|in) .+?;/g, \"\\n\");\n }\n if (options.replaceStrings) {\n for (let index = 0; index < options.replaceStrings.length; index++) {\n const replaceString = options.replaceStrings[index];\n this.functions[key] = this.functions[key].replace(replaceString.search, replaceString.replace);\n }\n }\n }\n /**\n * @internal\n */\n _registerTempVariable(name) {\n if (this.sharedData.temps.indexOf(name) !== -1) {\n return false;\n }\n this.sharedData.temps.push(name);\n return true;\n }\n /**\n * @internal\n */\n _emitVaryingFromString(name, type, define = \"\", notDefine = false) {\n if (this.sharedData.varyings.indexOf(name) !== -1) {\n return false;\n }\n this.sharedData.varyings.push(name);\n if (define) {\n if (define.startsWith(\"defined(\")) {\n this.sharedData.varyingDeclaration += `#if ${define}\\n`;\n }\n else {\n this.sharedData.varyingDeclaration += `${notDefine ? \"#ifndef\" : \"#ifdef\"} ${define}\\n`;\n }\n }\n const shaderType = this._getShaderType(type);\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n this.sharedData.varyingDeclaration += `varying ${name}: ${shaderType};\\n`;\n }\n else {\n this.sharedData.varyingDeclaration += `varying ${shaderType} ${name};\\n`;\n }\n if (define) {\n this.sharedData.varyingDeclaration += `#endif\\n`;\n }\n return true;\n }\n /**\n * @internal\n */\n _getVaryingName(name) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return (this.target !== NodeMaterialBlockTargets.Fragment ? \"vertexOutputs.\" : \"fragmentInputs.\") + name;\n }\n return name;\n }\n /**\n * @internal\n */\n _emitUniformFromString(name, type, define = \"\", notDefine = false) {\n if (this.uniforms.indexOf(name) !== -1) {\n return;\n }\n this.uniforms.push(name);\n if (define) {\n if (define.startsWith(\"defined(\")) {\n this._uniformDeclaration += `#if ${define}\\n`;\n }\n else {\n this._uniformDeclaration += `${notDefine ? \"#ifndef\" : \"#ifdef\"} ${define}\\n`;\n }\n }\n const shaderType = this._getShaderType(type);\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n this._uniformDeclaration += `uniform ${name}: ${shaderType};\\n`;\n }\n else {\n this._uniformDeclaration += `uniform ${shaderType} ${name};\\n`;\n }\n if (define) {\n this._uniformDeclaration += `#endif\\n`;\n }\n }\n /**\n * @internal\n */\n _generateTernary(trueStatement, falseStatement, condition) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `select(${falseStatement}, ${trueStatement}, ${condition})`;\n }\n return `(${condition}) ? ${trueStatement} : ${falseStatement}`;\n }\n /**\n * @internal\n */\n _emitFloat(value) {\n if (value.toString() === value.toFixed(0)) {\n return `${value}.0`;\n }\n return value.toString();\n }\n /**\n * @internal\n */\n _declareOutput(output, isConst) {\n return this._declareLocalVar(output.associatedVariableName, output.type, isConst);\n }\n /**\n * @internal\n */\n _declareLocalVar(name, type, isConst) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `${isConst ? \"const\" : \"var\"} ${name}: ${this._getShaderType(type)}`;\n }\n else {\n return `${this._getShaderType(type)} ${name}`;\n }\n }\n /**\n * @internal\n */\n _samplerCubeFunc() {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return \"textureSample\";\n }\n return \"textureCube\";\n }\n /**\n * @internal\n */\n _samplerFunc() {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return \"textureSample\";\n }\n return \"texture2D\";\n }\n /**\n * @internal\n */\n _samplerLODFunc() {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return \"textureSampleLevel\";\n }\n return \"texture2DLodEXT\";\n }\n _toLinearSpace(output) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n if (output.type === NodeMaterialBlockConnectionPointTypes.Color3 || output.type === NodeMaterialBlockConnectionPointTypes.Vector3) {\n return `toLinearSpaceVec3(${output.associatedVariableName})`;\n }\n return `toLinearSpace(${output.associatedVariableName})`;\n }\n return `toLinearSpace(${output.associatedVariableName})`;\n }\n /**\n * @internal\n */\n _generateTextureSample(uv, samplerName) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `${this._samplerFunc()}(${samplerName},${samplerName + `Sampler`}, ${uv})`;\n }\n return `${this._samplerFunc()}(${samplerName}, ${uv})`;\n }\n /**\n * @internal\n */\n _generateTextureSampleLOD(uv, samplerName, lod) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `${this._samplerLODFunc()}(${samplerName},${samplerName + `Sampler`}, ${uv}, ${lod})`;\n }\n return `${this._samplerLODFunc()}(${samplerName}, ${uv}, ${lod})`;\n }\n /**\n * @internal\n */\n _generateTextureSampleCube(uv, samplerName) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `${this._samplerCubeFunc()}(${samplerName},${samplerName + `Sampler`}, ${uv})`;\n }\n return `${this._samplerCubeFunc()}(${samplerName}, ${uv})`;\n }\n /**\n * @internal\n */\n _generateTextureSampleCubeLOD(uv, samplerName, lod) {\n if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n return `${this._samplerCubeFunc()}(${samplerName},${samplerName + `Sampler`}, ${uv}, ${lod})`;\n }\n return `${this._samplerCubeFunc()}(${samplerName}, ${uv}, ${lod})`;\n }\n _convertVariableDeclarationToWGSL(type, dest, source) {\n return source.replace(new RegExp(`(${type})\\\\s+(\\\\w+)`, \"g\"), `var $2: ${dest}`);\n }\n _convertVariableConstructorsToWGSL(type, dest, source) {\n return source.replace(new RegExp(`(${type})\\\\(`, \"g\"), ` ${dest}(`);\n }\n _convertOutParametersToWGSL(source) {\n return source.replace(new RegExp(`out\\\\s+var\\\\s+(\\\\w+)\\\\s*:\\\\s*(\\\\w+)`, \"g\"), `$1: ptr<function, $2>`);\n }\n _convertTernaryOperandsToWGSL(source) {\n return source.replace(new RegExp(`\\\\[(.*?)\\\\?(.*?):(.*)\\\\]`, \"g\"), (match, condition, trueCase, falseCase) => `select(${falseCase}, ${trueCase}, ${condition})`);\n }\n _convertModOperatorsToWGSL(source) {\n return source.replace(new RegExp(`mod\\\\((.+?),\\\\s*(.+?)\\\\)`, \"g\"), (match, left, right) => `((${left})%(${right}))`);\n }\n _convertConstToWGSL(source) {\n return source.replace(new RegExp(`const var`, \"g\"), `const`);\n }\n _convertInnerFunctionsToWGSL(source) {\n return source.replace(new RegExp(`inversesqrt`, \"g\"), `inverseSqrt`);\n }\n _convertFunctionsToWGSL(source) {\n const regex = /var\\s+(\\w+)\\s*:\\s*(\\w+)\\((.*)\\)/g;\n let match;\n while ((match = regex.exec(source)) !== null) {\n const funcName = match[1];\n const funcType = match[2];\n const params = match[3]; // All parameters as a single string\n // Processing the parameters to match 'name: type' format\n const formattedParams = params.replace(/var\\s/g, \"\");\n // Constructing the final output string\n source = source.replace(match[0], `fn ${funcName}(${formattedParams}) -> ${funcType}`);\n }\n return source;\n }\n _babylonSLtoWGSL(code) {\n // variable declarations\n code = this._convertVariableDeclarationToWGSL(\"void\", \"voidnull\", code);\n code = this._convertVariableDeclarationToWGSL(\"bool\", \"bool\", code);\n code = this._convertVariableDeclarationToWGSL(\"int\", \"i32\", code);\n code = this._convertVariableDeclarationToWGSL(\"uint\", \"u32\", code);\n code = this._convertVariableDeclarationToWGSL(\"float\", \"f32\", code);\n code = this._convertVariableDeclarationToWGSL(\"vec2\", \"vec2f\", code);\n code = this._convertVariableDeclarationToWGSL(\"vec3\", \"vec3f\", code);\n code = this._convertVariableDeclarationToWGSL(\"vec4\", \"vec4f\", code);\n code = this._convertVariableDeclarationToWGSL(\"mat2\", \"mat2x2f\", code);\n code = this._convertVariableDeclarationToWGSL(\"mat3\", \"mat3x3f\", code);\n code = this._convertVariableDeclarationToWGSL(\"mat4\", \"mat4x4f\", code);\n // Type constructors\n code = this._convertVariableConstructorsToWGSL(\"float\", \"f32\", code);\n code = this._convertVariableConstructorsToWGSL(\"vec2\", \"vec2f\", code);\n code = this._convertVariableConstructorsToWGSL(\"vec3\", \"vec3f\", code);\n code = this._convertVariableConstructorsToWGSL(\"vec4\", \"vec4f\", code);\n code = this._convertVariableConstructorsToWGSL(\"mat2\", \"mat2x2f\", code);\n code = this._convertVariableConstructorsToWGSL(\"mat3\", \"mat3x3f\", code);\n code = this._convertVariableConstructorsToWGSL(\"mat4\", \"mat4x4f\", code);\n // Ternary operands\n code = this._convertTernaryOperandsToWGSL(code);\n // Mod operators\n code = this._convertModOperatorsToWGSL(code);\n // Const\n code = this._convertConstToWGSL(code);\n // Inner functions\n code = this._convertInnerFunctionsToWGSL(code);\n // Out paramters\n code = this._convertOutParametersToWGSL(code);\n code = code.replace(/\\[\\*\\]/g, \"*\");\n // Functions\n code = this._convertFunctionsToWGSL(code);\n // Remove voidnull\n code = code.replace(/\\s->\\svoidnull/g, \"\");\n // Derivatives\n code = code.replace(/dFdx/g, \"dpdx\");\n code = code.replace(/dFdy/g, \"dpdy\");\n return code;\n }\n _convertTernaryOperandsToGLSL(source) {\n return source.replace(new RegExp(`\\\\[(.+?)\\\\?(.+?):(.+)\\\\]`, \"g\"), (match, condition, trueCase, falseCase) => `${condition} ? ${trueCase} : ${falseCase}`);\n }\n _babylonSLtoGLSL(code) {\n /** Remove BSL specifics */\n code = code.replace(/\\[\\*\\]/g, \"\");\n code = this._convertTernaryOperandsToGLSL(code);\n return code;\n }\n}\n"],"mappings":"AAAA,SAASA,qCAAqC,QAAQ,kDAAkD;AACxG,SAASC,wBAAwB,QAAQ,qCAAqC;AAC9E,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,8BAA8B;;AAE/E;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,CAAC;EAChCC,WAAWA,CAAA,EAAG;IACV;IACA,IAAI,CAACC,qBAAqB,GAAG,KAAK;IAClC;AACR;AACA;IACQ,IAAI,CAACC,UAAU,GAAG,EAAE;IACpB;AACR;AACA;IACQ,IAAI,CAACC,QAAQ,GAAG,EAAE;IAClB;AACR;AACA;IACQ,IAAI,CAACC,SAAS,GAAG,EAAE;IACnB;AACR;AACA;IACQ,IAAI,CAACC,QAAQ,GAAG,EAAE;IAClB;AACR;AACA;IACQ,IAAI,CAACC,SAAS,GAAG,CAAC,CAAC;IACnB;AACR;AACA;IACQ,IAAI,CAACC,UAAU,GAAG,CAAC,CAAC;IACpB;AACR;AACA;IACQ,IAAI,CAACC,aAAa,GAAG,CAAC,CAAC;IACvB;AACR;AACA;IACQ,IAAI,CAACC,QAAQ,GAAG,CAAC,CAAC;IAClB;IACA,IAAI,CAACC,eAAe,GAAG,IAAIC,GAAG,CAAC,CAAC;IAChC;IACA,IAAI,CAACC,qBAAqB,GAAG,EAAE;IAC/B;IACA,IAAI,CAACC,mBAAmB,GAAG,EAAE;IAC7B;IACA,IAAI,CAACC,oBAAoB,GAAG,EAAE;IAC9B;IACA,IAAI,CAACC,mBAAmB,GAAG,EAAE;IA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