{"ast":null,"code":"import { NodeMaterialBlock } from \"../../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { Logger } from \"../../../../Misc/logger.js\";\n/**\n * Block used to write the fragment depth\n */\nexport class FragDepthBlock extends NodeMaterialBlock {\n /**\n * Create a new FragDepthBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Fragment, true);\n this.registerInput(\"depth\", NodeMaterialBlockConnectionPointTypes.Float, true);\n this.registerInput(\"worldPos\", NodeMaterialBlockConnectionPointTypes.Vector4, true);\n this.registerInput(\"viewProjection\", NodeMaterialBlockConnectionPointTypes.Matrix, true);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"FragDepthBlock\";\n }\n /**\n * Gets the depth input component\n */\n get depth() {\n return this._inputs[0];\n }\n /**\n * Gets the worldPos input component\n */\n get worldPos() {\n return this._inputs[1];\n }\n /**\n * Gets the viewProjection input component\n */\n get viewProjection() {\n return this._inputs[2];\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const fragDepth = state.shaderLanguage === 0 /* ShaderLanguage.GLSL */ ? \"gl_FragDepth\" : \"fragmentOutputs.fragDepth\";\n if (this.depth.isConnected) {\n state.compilationString += `${fragDepth} = ${this.depth.associatedVariableName};\\n`;\n } else if (this.worldPos.isConnected && this.viewProjection.isConnected) {\n state.compilationString += `\n ${state._declareLocalVar(\"p\", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${this.viewProjection.associatedVariableName} * ${this.worldPos.associatedVariableName};\n ${state._declareLocalVar(\"v\", NodeMaterialBlockConnectionPointTypes.Float)} = p.z / p.w;\n #ifndef IS_NDC_HALF_ZRANGE\n v = v * 0.5 + 0.5;\n #endif\n ${fragDepth} = v;\n \n `;\n } else {\n Logger.Warn(\"FragDepthBlock: either the depth input or both the worldPos and viewProjection inputs must be connected!\");\n }\n return this;\n }\n}\nRegisterClass(\"BABYLON.FragDepthBlock\", FragDepthBlock);","map":{"version":3,"names":["NodeMaterialBlock","NodeMaterialBlockConnectionPointTypes","NodeMaterialBlockTargets","RegisterClass","Logger","FragDepthBlock","constructor","name","Fragment","registerInput","Float","Vector4","Matrix","getClassName","depth","_inputs","worldPos","viewProjection","_buildBlock","state","fragDepth","shaderLanguage","isConnected","compilationString","associatedVariableName","_declareLocalVar","Warn"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/Fragment/fragDepthBlock.js"],"sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { Logger } from \"../../../../Misc/logger.js\";\n/**\n * Block used to write the fragment depth\n */\nexport class FragDepthBlock extends NodeMaterialBlock {\n /**\n * Create a new FragDepthBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Fragment, true);\n this.registerInput(\"depth\", NodeMaterialBlockConnectionPointTypes.Float, true);\n this.registerInput(\"worldPos\", NodeMaterialBlockConnectionPointTypes.Vector4, true);\n this.registerInput(\"viewProjection\", NodeMaterialBlockConnectionPointTypes.Matrix, true);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"FragDepthBlock\";\n }\n /**\n * Gets the depth input component\n */\n get depth() {\n return this._inputs[0];\n }\n /**\n * Gets the worldPos input component\n */\n get worldPos() {\n return this._inputs[1];\n }\n /**\n * Gets the viewProjection input component\n */\n get viewProjection() {\n return this._inputs[2];\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const fragDepth = state.shaderLanguage === 0 /* ShaderLanguage.GLSL */ ? \"gl_FragDepth\" : \"fragmentOutputs.fragDepth\";\n if (this.depth.isConnected) {\n state.compilationString += `${fragDepth} = ${this.depth.associatedVariableName};\\n`;\n }\n else if (this.worldPos.isConnected && this.viewProjection.isConnected) {\n state.compilationString += `\r\n ${state._declareLocalVar(\"p\", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${this.viewProjection.associatedVariableName} * ${this.worldPos.associatedVariableName};\r\n ${state._declareLocalVar(\"v\", NodeMaterialBlockConnectionPointTypes.Float)} = p.z / p.w;\r\n #ifndef IS_NDC_HALF_ZRANGE\r\n v = v * 0.5 + 0.5;\r\n #endif\r\n ${fragDepth} = v;\r\n \r\n `;\n }\n else {\n Logger.Warn(\"FragDepthBlock: either the depth input or both the worldPos and viewProjection inputs must be connected!\");\n }\n return this;\n }\n}\nRegisterClass(\"BABYLON.FragDepthBlock\", FragDepthBlock);\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,qCAAqC,QAAQ,sDAAsD;AAC5G,SAASC,wBAAwB,QAAQ,yCAAyC;AAClF,SAASC,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,MAAM,QAAQ,4BAA4B;AACnD;AACA;AACA;AACA,OAAO,MAAMC,cAAc,SAASL,iBAAiB,CAAC;EAClD;AACJ;AACA;AACA;EACIM,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,EAAEL,wBAAwB,CAACM,QAAQ,EAAE,IAAI,CAAC;IACpD,IAAI,CAACC,aAAa,CAAC,OAAO,EAAER,qCAAqC,CAACS,KAAK,EAAE,IAAI,CAAC;IAC9E,IAAI,CAACD,aAAa,CAAC,UAAU,EAAER,qCAAqC,CAACU,OAAO,EAAE,IAAI,CAAC;IACnF,IAAI,CAACF,aAAa,CAAC,gBAAgB,EAAER,qCAAqC,CAACW,MAAM,EAAE,IAAI,CAAC;EAC5F;EACA;AACJ;AACA;AACA;EACIC,YAAYA,CAAA,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