4bc895cf264c37ee9cd829a277b3a28739a563f266a128ef8d3141e63b2604e2.json 8.7 KB

1
  1. {"ast":null,"code":"import { FrameGraphTask } from \"../../frameGraphTask.js\";\n/**\n * Task which applies a post process.\n */\nexport class FrameGraphPostProcessTask extends FrameGraphTask {\n /**\n * Constructs a new post process task.\n * @param name Name of the task.\n * @param frameGraph The frame graph this task is associated with.\n * @param postProcess The post process to apply.\n */\n constructor(name, frameGraph, postProcess) {\n super(name, frameGraph);\n /**\n * The sampling mode to use for the source texture.\n */\n this.sourceSamplingMode = 2;\n this.postProcess = postProcess;\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\n }\n isReady() {\n return this.postProcess.isReady();\n }\n record(skipCreationOfDisabledPasses = false, additionalExecute, additionalBindings) {\n if (this.sourceTexture === undefined) {\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture is required`);\n }\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\n sourceTextureCreationOptions.options.samples = 1;\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture, this.name, sourceTextureCreationOptions);\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.outputTexture);\n this._outputWidth = outputTextureDescription.size.width;\n this._outputHeight = outputTextureDescription.size.height;\n const pass = this._frameGraph.addRenderPass(this.name);\n pass.useTexture(this.sourceTexture);\n pass.setRenderTarget(this.outputTexture);\n pass.setExecuteFunc(context => {\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\n additionalExecute === null || additionalExecute === void 0 || additionalExecute(context);\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\n context.bindTextureHandle(this._postProcessDrawWrapper.effect, \"textureSampler\", this.sourceTexture);\n additionalBindings === null || additionalBindings === void 0 || additionalBindings(context);\n this.postProcess.bind();\n });\n });\n if (!skipCreationOfDisabledPasses) {\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\n passDisabled.setRenderTarget(this.outputTexture);\n passDisabled.setExecuteFunc(context => {\n context.copyTexture(this.sourceTexture);\n });\n }\n return pass;\n }\n dispose() {\n this.postProcess.dispose();\n super.dispose();\n }\n}","map":{"version":3,"names":["FrameGraphTask","FrameGraphPostProcessTask","constructor","name","frameGraph","postProcess","sourceSamplingMode","_postProcessDrawWrapper","drawWrapper","outputTexture","_frameGraph","textureManager","createDanglingHandle","isReady","record","skipCreationOfDisabledPasses","additionalExecute","additionalBindings","sourceTexture","undefined","Error","sourceTextureCreationOptions","getTextureCreationOptions","options","samples","resolveDanglingHandle","destinationTexture","outputTextureDescription","getTextureDescription","_outputWidth","size","width","_outputHeight","height","pass","addRenderPass","useTexture","setRenderTarget","setExecuteFunc","context","setTextureSamplingMode","applyFullScreenEffect","bindTextureHandle","effect","bind","passDisabled","copyTexture","dispose"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/FrameGraph/Tasks/PostProcesses/postProcessTask.js"],"sourcesContent":["\nimport { FrameGraphTask } from \"../../frameGraphTask.js\";\n/**\n * Task which applies a post process.\n */\nexport class FrameGraphPostProcessTask extends FrameGraphTask {\n /**\n * Constructs a new post process task.\n * @param name Name of the task.\n * @param frameGraph The frame graph this task is associated with.\n * @param postProcess The post process to apply.\n */\n constructor(name, frameGraph, postProcess) {\n super(name, frameGraph);\n /**\n * The sampling mode to use for the source texture.\n */\n this.sourceSamplingMode = 2;\n this.postProcess = postProcess;\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\n }\n isReady() {\n return this.postProcess.isReady();\n }\n record(skipCreationOfDisabledPasses = false, additionalExecute, additionalBindings) {\n if (this.sourceTexture === undefined) {\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture is required`);\n }\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\n sourceTextureCreationOptions.options.samples = 1;\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture, this.name, sourceTextureCreationOptions);\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.outputTexture);\n this._outputWidth = outputTextureDescription.size.width;\n this._outputHeight = outputTextureDescription.size.height;\n const pass = this._frameGraph.addRenderPass(this.name);\n pass.useTexture(this.sourceTexture);\n pass.setRenderTarget(this.outputTexture);\n pass.setExecuteFunc((context) => {\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\n additionalExecute?.(context);\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\n context.bindTextureHandle(this._postProcessDrawWrapper.effect, \"textureSampler\", this.sourceTexture);\n additionalBindings?.(context);\n this.postProcess.bind();\n });\n });\n if (!skipCreationOfDisabledPasses) {\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\n passDisabled.setRenderTarget(this.outputTexture);\n passDisabled.setExecuteFunc((context) => {\n context.copyTexture(this.sourceTexture);\n });\n }\n return pass;\n }\n dispose() {\n this.postProcess.dispose();\n super.dispose();\n }\n}\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,yBAAyB;AACxD;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,SAASD,cAAc,CAAC;EAC1D;AACJ;AACA;AACA;AACA;AACA;EACIE,WAAWA,CAACC,IAAI,EAAEC,UAAU,EAAEC,WAAW,EAAE;IACvC,KAAK,CAACF,IAAI,EAAEC,UAAU,CAAC;IACvB;AACR;AACA;IACQ,IAAI,CAACE,kBAAkB,GAAG,CAAC;IAC3B,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACE,uBAAuB,GAAG,IAAI,CAACF,WAAW,CAACG,WAAW;IAC3D,IAAI,CAACC,aAAa,GAAG,IAAI,CAACC,WAAW,CAACC,cAAc,CAACC,oBAAoB,CAAC,CAAC;EAC/E;EACAC,OAAOA,CAAA,EAAG;IACN,OAAO,IAAI,CAACR,WAAW,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