1 |
- {"ast":null,"code":"import { EffectWrapper } from \"../Materials/effectRenderer.js\";\nimport { Engine } from \"../Engines/engine.js\";\n/**\n * Post process used to calculate the circle of confusion (used for depth of field, for example)\n */\nexport class ThinCircleOfConfusionPostProcess extends EffectWrapper {\n _gatherImports(useWebGPU, list) {\n if (useWebGPU) {\n this._webGPUReady = true;\n list.push(import(\"../ShadersWGSL/circleOfConfusion.fragment.js\"));\n } else {\n list.push(import(\"../Shaders/circleOfConfusion.fragment.js\"));\n }\n }\n /**\n * Constructs a new circle of confusion post process\n * @param name Name of the effect\n * @param engine Engine to use to render the effect. If not provided, the last created engine will be used\n * @param options Options to configure the effect\n */\n constructor(name, engine = null, options) {\n super({\n ...options,\n name,\n engine: engine || Engine.LastCreatedEngine,\n useShaderStore: true,\n useAsPostProcess: true,\n fragmentShader: ThinCircleOfConfusionPostProcess.FragmentUrl,\n uniforms: ThinCircleOfConfusionPostProcess.Uniforms,\n samplers: ThinCircleOfConfusionPostProcess.Samplers,\n defines: options !== null && options !== void 0 && options.depthNotNormalized ? ThinCircleOfConfusionPostProcess.DefinesDepthNotNormalized : undefined\n });\n /**\n * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.\n */\n this.lensSize = 50;\n /**\n * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)\n */\n this.fStop = 1.4;\n /**\n * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)\n */\n this.focusDistance = 2000;\n /**\n * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)\n */\n this.focalLength = 50;\n }\n bind() {\n super.bind();\n const options = this.options;\n const effect = this._drawWrapper.effect;\n if (!options.depthNotNormalized) {\n effect.setFloat2(\"cameraMinMaxZ\", this.camera.minZ, this.camera.maxZ - this.camera.minZ);\n }\n // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html\n const aperture = this.lensSize / this.fStop;\n const cocPrecalculation = aperture * this.focalLength / (this.focusDistance - this.focalLength); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]\n effect.setFloat(\"focusDistance\", this.focusDistance);\n effect.setFloat(\"cocPrecalculation\", cocPrecalculation);\n }\n}\n/**\n * The fragment shader url\n */\nThinCircleOfConfusionPostProcess.FragmentUrl = \"circleOfConfusion\";\n/**\n * The list of uniforms used by the effect\n */\nThinCircleOfConfusionPostProcess.Uniforms = [\"cameraMinMaxZ\", \"focusDistance\", \"cocPrecalculation\"];\n/**\n * The list of samplers used by the effect\n */\nThinCircleOfConfusionPostProcess.Samplers = [\"depthSampler\"];\n/**\n * Defines if the depth is normalized or not\n */\nThinCircleOfConfusionPostProcess.DefinesDepthNotNormalized = \"#define COC_DEPTH_NOT_NORMALIZED\";","map":{"version":3,"names":["EffectWrapper","Engine","ThinCircleOfConfusionPostProcess","_gatherImports","useWebGPU","list","_webGPUReady","push","constructor","name","engine","options","LastCreatedEngine","useShaderStore","useAsPostProcess","fragmentShader","FragmentUrl","uniforms","Uniforms","samplers","Samplers","defines","depthNotNormalized","DefinesDepthNotNormalized","undefined","lensSize","fStop","focusDistance","focalLength","bind","effect","_drawWrapper","setFloat2","camera","minZ","maxZ","aperture","cocPrecalculation","setFloat"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/PostProcesses/thinCircleOfConfusionPostProcess.js"],"sourcesContent":["import { EffectWrapper } from \"../Materials/effectRenderer.js\";\nimport { Engine } from \"../Engines/engine.js\";\n/**\n * Post process used to calculate the circle of confusion (used for depth of field, for example)\n */\nexport class ThinCircleOfConfusionPostProcess extends EffectWrapper {\n _gatherImports(useWebGPU, list) {\n if (useWebGPU) {\n this._webGPUReady = true;\n list.push(import(\"../ShadersWGSL/circleOfConfusion.fragment.js\"));\n }\n else {\n list.push(import(\"../Shaders/circleOfConfusion.fragment.js\"));\n }\n }\n /**\n * Constructs a new circle of confusion post process\n * @param name Name of the effect\n * @param engine Engine to use to render the effect. If not provided, the last created engine will be used\n * @param options Options to configure the effect\n */\n constructor(name, engine = null, options) {\n super({\n ...options,\n name,\n engine: engine || Engine.LastCreatedEngine,\n useShaderStore: true,\n useAsPostProcess: true,\n fragmentShader: ThinCircleOfConfusionPostProcess.FragmentUrl,\n uniforms: ThinCircleOfConfusionPostProcess.Uniforms,\n samplers: ThinCircleOfConfusionPostProcess.Samplers,\n defines: options?.depthNotNormalized ? ThinCircleOfConfusionPostProcess.DefinesDepthNotNormalized : undefined,\n });\n /**\n * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.\n */\n this.lensSize = 50;\n /**\n * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)\n */\n this.fStop = 1.4;\n /**\n * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)\n */\n this.focusDistance = 2000;\n /**\n * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)\n */\n this.focalLength = 50;\n }\n bind() {\n super.bind();\n const options = this.options;\n const effect = this._drawWrapper.effect;\n if (!options.depthNotNormalized) {\n effect.setFloat2(\"cameraMinMaxZ\", this.camera.minZ, this.camera.maxZ - this.camera.minZ);\n }\n // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html\n const aperture = this.lensSize / this.fStop;\n const cocPrecalculation = (aperture * this.focalLength) / (this.focusDistance - this.focalLength); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]\n effect.setFloat(\"focusDistance\", this.focusDistance);\n effect.setFloat(\"cocPrecalculation\", cocPrecalculation);\n }\n}\n/**\n * The fragment shader url\n */\nThinCircleOfConfusionPostProcess.FragmentUrl = \"circleOfConfusion\";\n/**\n * The list of uniforms used by the effect\n */\nThinCircleOfConfusionPostProcess.Uniforms = [\"cameraMinMaxZ\", \"focusDistance\", \"cocPrecalculation\"];\n/**\n * The list of samplers used by the effect\n */\nThinCircleOfConfusionPostProcess.Samplers = [\"depthSampler\"];\n/**\n * Defines if the depth is normalized or not\n */\nThinCircleOfConfusionPostProcess.DefinesDepthNotNormalized = \"#define COC_DEPTH_NOT_NORMALIZED\";\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,gCAAgC;AAC9D,SAASC,MAAM,QAAQ,sBAAsB;AAC7C;AACA;AACA;AACA,OAAO,MAAMC,gCAAgC,SAASF,aAAa,CAAC;EAChEG,cAAcA,CAACC,SAAS,EAAEC,IAAI,EAAE;IAC5B,IAAID,SAAS,EAAE;MACX,IAAI,CAACE,YAAY,GAAG,IAAI;MACxBD,IAAI,CAACE,IAAI,CAAC,MAAM,CAAC,8CAA8C,CAAC,CAAC;IACrE,CAAC,MACI;MACDF,IAAI,CAACE,IAAI,CAAC,MAAM,CAAC,0CAA0C,CAAC,CAAC;IACjE;EACJ;EACA;AACJ;AACA;AACA;AACA;AACA;EACIC,WAAWA,CAACC,IAAI,EAAEC,MAAM,GAAG,IAAI,EAAEC,OAAO,EAAE;IACtC,KAAK,CAAC;MACF,GAAGA,OAAO;MACVF,IAAI;MACJC,MAAM,EAAEA,MAAM,IAAIT,MAAM,CAACW,iBAAiB;MAC1CC,cAAc,EAAE,IAAI;MACpBC,gBAAgB,EAAE,IAAI;MACtBC,cAAc,EAAEb,gCAAgC,CAACc,WAAW;MAC5DC,QAAQ,EAAEf,gCAAgC,CAACgB,QAAQ;MACnDC,QAAQ,EAAEjB,gCAAgC,CAACkB,QAAQ;MACnDC,OAAO,EAAEV,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEW,kBAAkB,GAAGpB,gCAAgC,CAACqB,yBAAyB,GAAGC;IACxG,CAAC,CAAC;IACF;AACR;AACA;IACQ,IAAI,CAACC,QAAQ,GAAG,EAAE;IAClB;AACR;AACA;IACQ,IAAI,CAACC,KAAK,GAAG,GAAG;IAChB;AACR;AACA;IACQ,IAAI,CAACC,aAAa,GAAG,IAAI;I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