1 |
- {"ast":null,"code":"import _asyncToGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { NodeMaterialBlock } from \"../../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\n/**\n * Block used to output the depth to a shadow map\n */\nexport class ShadowMapBlock extends NodeMaterialBlock {\n /**\n * Create a new ShadowMapBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Fragment);\n this.registerInput(\"worldPosition\", NodeMaterialBlockConnectionPointTypes.Vector4, false);\n this.registerInput(\"viewProjection\", NodeMaterialBlockConnectionPointTypes.Matrix, false);\n this.registerInput(\"worldNormal\", NodeMaterialBlockConnectionPointTypes.AutoDetect, true);\n this.registerOutput(\"depth\", NodeMaterialBlockConnectionPointTypes.Vector3);\n this.worldNormal.addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Color3 | NodeMaterialBlockConnectionPointTypes.Vector3 | NodeMaterialBlockConnectionPointTypes.Vector4);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"ShadowMapBlock\";\n }\n /**\n * Initialize the block and prepare the context for build\n * @param state defines the state that will be used for the build\n */\n initialize(state) {\n state._excludeVariableName(\"vPositionWSM\");\n state._excludeVariableName(\"lightDataSM\");\n state._excludeVariableName(\"biasAndScaleSM\");\n state._excludeVariableName(\"depthValuesSM\");\n state._excludeVariableName(\"clipPos\");\n state._excludeVariableName(\"worldPos\");\n state._excludeVariableName(\"zSM\");\n this._initShaderSourceAsync(state.shaderLanguage);\n }\n _initShaderSourceAsync(shaderLanguage) {\n var _this = this;\n return _asyncToGenerator(function* () {\n _this._codeIsReady = false;\n if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n yield Promise.all([import(\"../../../../ShadersWGSL/ShadersInclude/shadowMapVertexMetric.js\"), import(\"../../../../ShadersWGSL/ShadersInclude/packingFunctions.js\"), import(\"../../../../ShadersWGSL/ShadersInclude/shadowMapFragment.js\")]);\n } else {\n yield Promise.all([import(\"../../../../Shaders/ShadersInclude/shadowMapVertexMetric.js\"), import(\"../../../../Shaders/ShadersInclude/packingFunctions.js\"), import(\"../../../../Shaders/ShadersInclude/shadowMapFragment.js\")]);\n }\n _this._codeIsReady = true;\n _this.onCodeIsReadyObservable.notifyObservers(_this);\n })();\n }\n /**\n * Gets the world position input component\n */\n get worldPosition() {\n return this._inputs[0];\n }\n /**\n * Gets the view x projection input component\n */\n get viewProjection() {\n return this._inputs[1];\n }\n /**\n * Gets the world normal input component\n */\n get worldNormal() {\n return this._inputs[2];\n }\n /**\n * Gets the depth output component\n */\n get depth() {\n return this._outputs[0];\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const comments = `//${this.name}`;\n const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;\n state._emitUniformFromString(\"biasAndScaleSM\", NodeMaterialBlockConnectionPointTypes.Vector3);\n state._emitUniformFromString(\"lightDataSM\", NodeMaterialBlockConnectionPointTypes.Vector3);\n state._emitUniformFromString(\"depthValuesSM\", NodeMaterialBlockConnectionPointTypes.Vector2);\n state._emitFunctionFromInclude(\"packingFunctions\", comments);\n state.compilationString += `${state._declareLocalVar(\"worldPos\", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${this.worldPosition.associatedVariableName};\\n`;\n state.compilationString += `${state._declareLocalVar(\"vPositionWSM\", NodeMaterialBlockConnectionPointTypes.Vector3)};\\n`;\n state.compilationString += `${state._declareLocalVar(\"vDepthMetricSM\", NodeMaterialBlockConnectionPointTypes.Float)} = 0.0;\\n`;\n state.compilationString += `${state._declareLocalVar(\"zSM\", NodeMaterialBlockConnectionPointTypes.Float)};\\n`;\n if (this.worldNormal.isConnected) {\n state.compilationString += `${state._declareLocalVar(\"vNormalW\", NodeMaterialBlockConnectionPointTypes.Vector3)} = ${this.worldNormal.associatedVariableName}.xyz;\\n`;\n state.compilationString += state._emitCodeFromInclude(\"shadowMapVertexNormalBias\", comments);\n }\n state.compilationString += `${state._declareLocalVar(\"clipPos\", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${this.viewProjection.associatedVariableName} * worldPos;\\n`;\n state.compilationString += state._emitCodeFromInclude(\"shadowMapVertexMetric\", comments, {\n replaceStrings: [{\n search: /gl_Position/g,\n replace: \"clipPos\"\n }, {\n search: /vertexOutputs.position/g,\n replace: \"clipPos\"\n }]\n });\n state.compilationString += state._emitCodeFromInclude(\"shadowMapFragment\", comments, {\n replaceStrings: [{\n search: /return;/g,\n replace: \"\"\n }]\n });\n const output = isWebGPU ? \"fragmentOutputs.fragDepth\" : \"gl_FragDepth\";\n state.compilationString += `\n #if SM_DEPTHTEXTURE == 1\n #ifdef IS_NDC_HALF_ZRANGE\n ${output} = (clipPos.z / clipPos.w);\n #else\n ${output} = (clipPos.z / clipPos.w) * 0.5 + 0.5;\n #endif\n #endif\n `;\n state.compilationString += `${state._declareOutput(this.depth)} = vec3${state.fSuffix}(depthSM, 1., 1.);\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.ShadowMapBlock\", ShadowMapBlock);","map":{"version":3,"names":["NodeMaterialBlock","NodeMaterialBlockConnectionPointTypes","NodeMaterialBlockTargets","RegisterClass","ShadowMapBlock","constructor","name","Fragment","registerInput","Vector4","Matrix","AutoDetect","registerOutput","Vector3","worldNormal","addExcludedConnectionPointFromAllowedTypes","Color3","getClassName","initialize","state","_excludeVariableName","_initShaderSourceAsync","shaderLanguage","_this","_asyncToGenerator","_codeIsReady","Promise","all","onCodeIsReadyObservable","notifyObservers","worldPosition","_inputs","viewProjection","depth","_outputs","_buildBlock","comments","isWebGPU","_emitUniformFromString","Vector2","_emitFunctionFromInclude","compilationString","_declareLocalVar","associatedVariableName","Float","isConnected","_emitCodeFromInclude","replaceStrings","search","replace","output","_declareOutput","fSuffix"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/Fragment/shadowMapBlock.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\";\n/**\n * Block used to output the depth to a shadow map\n */\nexport class ShadowMapBlock extends NodeMaterialBlock {\n /**\n * Create a new ShadowMapBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Fragment);\n this.registerInput(\"worldPosition\", NodeMaterialBlockConnectionPointTypes.Vector4, false);\n this.registerInput(\"viewProjection\", NodeMaterialBlockConnectionPointTypes.Matrix, false);\n this.registerInput(\"worldNormal\", NodeMaterialBlockConnectionPointTypes.AutoDetect, true);\n this.registerOutput(\"depth\", NodeMaterialBlockConnectionPointTypes.Vector3);\n this.worldNormal.addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Color3 | NodeMaterialBlockConnectionPointTypes.Vector3 | NodeMaterialBlockConnectionPointTypes.Vector4);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"ShadowMapBlock\";\n }\n /**\n * Initialize the block and prepare the context for build\n * @param state defines the state that will be used for the build\n */\n initialize(state) {\n state._excludeVariableName(\"vPositionWSM\");\n state._excludeVariableName(\"lightDataSM\");\n state._excludeVariableName(\"biasAndScaleSM\");\n state._excludeVariableName(\"depthValuesSM\");\n state._excludeVariableName(\"clipPos\");\n state._excludeVariableName(\"worldPos\");\n state._excludeVariableName(\"zSM\");\n this._initShaderSourceAsync(state.shaderLanguage);\n }\n async _initShaderSourceAsync(shaderLanguage) {\n this._codeIsReady = false;\n if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n await Promise.all([\n import(\"../../../../ShadersWGSL/ShadersInclude/shadowMapVertexMetric.js\"),\n import(\"../../../../ShadersWGSL/ShadersInclude/packingFunctions.js\"),\n import(\"../../../../ShadersWGSL/ShadersInclude/shadowMapFragment.js\"),\n ]);\n }\n else {\n await Promise.all([\n import(\"../../../../Shaders/ShadersInclude/shadowMapVertexMetric.js\"),\n import(\"../../../../Shaders/ShadersInclude/packingFunctions.js\"),\n import(\"../../../../Shaders/ShadersInclude/shadowMapFragment.js\"),\n ]);\n }\n this._codeIsReady = true;\n this.onCodeIsReadyObservable.notifyObservers(this);\n }\n /**\n * Gets the world position input component\n */\n get worldPosition() {\n return this._inputs[0];\n }\n /**\n * Gets the view x projection input component\n */\n get viewProjection() {\n return this._inputs[1];\n }\n /**\n * Gets the world normal input component\n */\n get worldNormal() {\n return this._inputs[2];\n }\n /**\n * Gets the depth output component\n */\n get depth() {\n return this._outputs[0];\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const comments = `//${this.name}`;\n const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;\n state._emitUniformFromString(\"biasAndScaleSM\", NodeMaterialBlockConnectionPointTypes.Vector3);\n state._emitUniformFromString(\"lightDataSM\", NodeMaterialBlockConnectionPointTypes.Vector3);\n state._emitUniformFromString(\"depthValuesSM\", NodeMaterialBlockConnectionPointTypes.Vector2);\n state._emitFunctionFromInclude(\"packingFunctions\", comments);\n state.compilationString += `${state._declareLocalVar(\"worldPos\", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${this.worldPosition.associatedVariableName};\\n`;\n state.compilationString += `${state._declareLocalVar(\"vPositionWSM\", NodeMaterialBlockConnectionPointTypes.Vector3)};\\n`;\n state.compilationString += `${state._declareLocalVar(\"vDepthMetricSM\", NodeMaterialBlockConnectionPointTypes.Float)} = 0.0;\\n`;\n state.compilationString += `${state._declareLocalVar(\"zSM\", NodeMaterialBlockConnectionPointTypes.Float)};\\n`;\n if (this.worldNormal.isConnected) {\n state.compilationString += `${state._declareLocalVar(\"vNormalW\", NodeMaterialBlockConnectionPointTypes.Vector3)} = ${this.worldNormal.associatedVariableName}.xyz;\\n`;\n state.compilationString += state._emitCodeFromInclude(\"shadowMapVertexNormalBias\", comments);\n }\n state.compilationString += `${state._declareLocalVar(\"clipPos\", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${this.viewProjection.associatedVariableName} * worldPos;\\n`;\n state.compilationString += state._emitCodeFromInclude(\"shadowMapVertexMetric\", comments, {\n replaceStrings: [\n {\n search: /gl_Position/g,\n replace: \"clipPos\",\n },\n {\n search: /vertexOutputs.position/g,\n replace: \"clipPos\",\n },\n ],\n });\n state.compilationString += state._emitCodeFromInclude(\"shadowMapFragment\", comments, {\n replaceStrings: [\n {\n search: /return;/g,\n replace: \"\",\n },\n ],\n });\n const output = isWebGPU ? \"fragmentOutputs.fragDepth\" : \"gl_FragDepth\";\n state.compilationString += `\r\n #if SM_DEPTHTEXTURE == 1\r\n #ifdef IS_NDC_HALF_ZRANGE\r\n ${output} = (clipPos.z / clipPos.w);\r\n #else\r\n ${output} = (clipPos.z / clipPos.w) * 0.5 + 0.5;\r\n #endif\r\n #endif\r\n `;\n state.compilationString += `${state._declareOutput(this.depth)} = vec3${state.fSuffix}(depthSM, 1., 1.);\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.ShadowMapBlock\", ShadowMapBlock);\n"],"mappings":";AAAA,SAASA,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,qCAAqC,QAAQ,sDAAsD;AAC5G,SAASC,wBAAwB,QAAQ,yCAAyC;AAClF,SAASC,aAAa,QAAQ,+BAA+B;AAC7D;AACA;AACA;AACA,OAAO,MAAMC,cAAc,SAASJ,iBAAiB,CAAC;EAClD;AACJ;AACA;AACA;EACIK,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,EAAEJ,wBAAwB,CAACK,QAAQ,CAAC;IAC9C,IAAI,CAACC,aAAa,CAAC,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