1 |
- {"ast":null,"code":"import { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes.js\";\nimport { FrameGraphObjectRendererTask } from \"./objectRendererTask.js\";\nimport { ThinTAAPostProcess } from \"../../../PostProcesses/thinTAAPostProcess.js\";\n\n/**\n * Task used to render objects to a texture with Temporal Anti-Aliasing (TAA).\n */\nexport class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTask {\n /**\n * Constructs a new TAA object renderer task.\n * @param name The name of the task\n * @param frameGraph The frame graph the task belongs to.\n * @param scene The scene the frame graph is associated with.\n * @param options The options of the object renderer.\n */\n constructor(name, frameGraph, scene, options) {\n super(name, frameGraph, scene, options);\n this.postProcess = new ThinTAAPostProcess(`${name} post-process`, scene.getEngine());\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\n }\n record() {\n if (this.destinationTexture === undefined || this.objectList === undefined) {\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\n }\n if (this.destinationTexture === backbufferColorTextureHandle || this.depthTexture === backbufferDepthStencilTextureHandle) {\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the back buffer color/depth textures are not allowed. Use regular textures instead.`);\n }\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\n let depthEnabled = false;\n if (this.depthTexture !== undefined) {\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\n }\n depthEnabled = true;\n }\n this.postProcess.camera = this.camera;\n this.postProcess.textureWidth = outputTextureDescription.size.width;\n this.postProcess.textureHeight = outputTextureDescription.size.height;\n const textureCreationOptions = {\n size: outputTextureDescription.size,\n options: {\n createMipMaps: outputTextureDescription.options.createMipMaps,\n types: [2],\n formats: [5],\n samples: 1,\n useSRGBBuffers: [false],\n creationFlags: [0],\n labels: [\"\"]\n },\n sizeIsPercentage: false,\n isHistoryTexture: true\n };\n const pingPongHandle = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} history`, textureCreationOptions);\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, pingPongHandle);\n if (this.depthTexture !== undefined) {\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\n }\n this._textureWidth = outputTextureDescription.size.width;\n this._textureHeight = outputTextureDescription.size.height;\n let pingPongRenderTargetWrapper;\n const pass = this._frameGraph.addRenderPass(this.name);\n pass.setRenderTarget(this.destinationTexture);\n pass.setRenderTargetDepth(this.depthTexture);\n pass.setExecuteFunc(context => {\n this._renderer.renderList = this.objectList.meshes;\n this._renderer.particleSystemList = this.objectList.particleSystems;\n this.postProcess.updateProjectionMatrix();\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\n // We define the active camera and transformation matrices ourselves, otherwise this will be done by calling context.render, in which case\n // getProjectionMatrix will be called with a \"true\" parameter, forcing recalculation of the projection matrix and losing our changes.\n if (!this.postProcess.disabled) {\n this._scene.activeCamera = this.camera;\n this._scene.setTransformMatrix(this.camera.getViewMatrix(), this.camera.getProjectionMatrix());\n }\n context.render(this._renderer, this._textureWidth, this._textureHeight);\n this._scene.activeCamera = null;\n pingPongRenderTargetWrapper = pingPongRenderTargetWrapper || context.createRenderTarget(`${this.name} ping/pong`, pingPongHandle);\n context.bindRenderTarget(pingPongRenderTargetWrapper, \"frame graph - TAA merge with history texture\");\n if (!this.postProcess.disabled) {\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\n this.postProcess.bind();\n context.bindTextureHandle(this._postProcessDrawWrapper.effect, \"textureSampler\", this.destinationTexture);\n context.bindTextureHandle(this._postProcessDrawWrapper.effect, \"historySampler\", pingPongHandle);\n });\n } else {\n context.copyTexture(this.destinationTexture);\n }\n });\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\n passDisabled.setRenderTarget(this.outputTexture);\n passDisabled.setRenderTargetDepth(this.depthTexture);\n passDisabled.setExecuteFunc(context => {\n context.copyTexture(this.destinationTexture);\n });\n if (this.dependencies !== undefined) {\n for (const handle of this.dependencies) {\n pass.useTexture(handle);\n passDisabled.useTexture(handle);\n }\n }\n }\n}","map":{"version":3,"names":["backbufferColorTextureHandle","backbufferDepthStencilTextureHandle","FrameGraphObjectRendererTask","ThinTAAPostProcess","FrameGraphTAAObjectRendererTask","constructor","name","frameGraph","scene","options","postProcess","getEngine","_postProcessDrawWrapper","drawWrapper","record","destinationTexture","undefined","objectList","Error","depthTexture","outputTextureDescription","_frameGraph","textureManager","getTextureDescription","depthEnabled","depthTextureDescription","samples","camera","textureWidth","size","width","textureHeight","height","textureCreationOptions","createMipMaps","types","formats","useSRGBBuffers","creationFlags","labels","sizeIsPercentage","isHistoryTexture","pingPongHandle","createRenderTargetTexture","resolveDanglingHandle","outputTexture","outputDepthTexture","_textureWidth","_textureHeight","pingPongRenderTargetWrapper","pass","addRenderPass","setRenderTarget","setRenderTargetDepth","setExecuteFunc","context","_renderer","renderList","meshes","particleSystemList","particleSystems","updateProjectionMatrix","setDepthStates","depthTest","depthWrite","disabled","_scene","activeCamera","setTransformMatrix","getViewMatrix","getProjectionMatrix","render","createRenderTarget","bindRenderTarget","applyFullScreenEffect","bind","bindTextureHandle","effect","copyTexture","passDisabled","dependencies","handle","useTexture"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js"],"sourcesContent":["import { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes.js\";\nimport { FrameGraphObjectRendererTask } from \"./objectRendererTask.js\";\nimport { ThinTAAPostProcess } from \"../../../PostProcesses/thinTAAPostProcess.js\";\n\n/**\n * Task used to render objects to a texture with Temporal Anti-Aliasing (TAA).\n */\nexport class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTask {\n /**\n * Constructs a new TAA object renderer task.\n * @param name The name of the task\n * @param frameGraph The frame graph the task belongs to.\n * @param scene The scene the frame graph is associated with.\n * @param options The options of the object renderer.\n */\n constructor(name, frameGraph, scene, options) {\n super(name, frameGraph, scene, options);\n this.postProcess = new ThinTAAPostProcess(`${name} post-process`, scene.getEngine());\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\n }\n record() {\n if (this.destinationTexture === undefined || this.objectList === undefined) {\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\n }\n if (this.destinationTexture === backbufferColorTextureHandle || this.depthTexture === backbufferDepthStencilTextureHandle) {\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the back buffer color/depth textures are not allowed. Use regular textures instead.`);\n }\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\n let depthEnabled = false;\n if (this.depthTexture !== undefined) {\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\n }\n depthEnabled = true;\n }\n this.postProcess.camera = this.camera;\n this.postProcess.textureWidth = outputTextureDescription.size.width;\n this.postProcess.textureHeight = outputTextureDescription.size.height;\n const textureCreationOptions = {\n size: outputTextureDescription.size,\n options: {\n createMipMaps: outputTextureDescription.options.createMipMaps,\n types: [2],\n formats: [5],\n samples: 1,\n useSRGBBuffers: [false],\n creationFlags: [0],\n labels: [\"\"],\n },\n sizeIsPercentage: false,\n isHistoryTexture: true,\n };\n const pingPongHandle = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} history`, textureCreationOptions);\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, pingPongHandle);\n if (this.depthTexture !== undefined) {\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\n }\n this._textureWidth = outputTextureDescription.size.width;\n this._textureHeight = outputTextureDescription.size.height;\n let pingPongRenderTargetWrapper;\n const pass = this._frameGraph.addRenderPass(this.name);\n pass.setRenderTarget(this.destinationTexture);\n pass.setRenderTargetDepth(this.depthTexture);\n pass.setExecuteFunc((context) => {\n this._renderer.renderList = this.objectList.meshes;\n this._renderer.particleSystemList = this.objectList.particleSystems;\n this.postProcess.updateProjectionMatrix();\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\n // We define the active camera and transformation matrices ourselves, otherwise this will be done by calling context.render, in which case\n // getProjectionMatrix will be called with a \"true\" parameter, forcing recalculation of the projection matrix and losing our changes.\n if (!this.postProcess.disabled) {\n this._scene.activeCamera = this.camera;\n this._scene.setTransformMatrix(this.camera.getViewMatrix(), this.camera.getProjectionMatrix());\n }\n context.render(this._renderer, this._textureWidth, this._textureHeight);\n this._scene.activeCamera = null;\n pingPongRenderTargetWrapper = pingPongRenderTargetWrapper || context.createRenderTarget(`${this.name} ping/pong`, pingPongHandle);\n context.bindRenderTarget(pingPongRenderTargetWrapper, \"frame graph - TAA merge with history texture\");\n if (!this.postProcess.disabled) {\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\n this.postProcess.bind();\n context.bindTextureHandle(this._postProcessDrawWrapper.effect, \"textureSampler\", this.destinationTexture);\n context.bindTextureHandle(this._postProcessDrawWrapper.effect, \"historySampler\", pingPongHandle);\n });\n }\n else {\n context.copyTexture(this.destinationTexture);\n }\n });\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\n passDisabled.setRenderTarget(this.outputTexture);\n passDisabled.setRenderTargetDepth(this.depthTexture);\n passDisabled.setExecuteFunc((context) => {\n context.copyTexture(this.destinationTexture);\n });\n if (this.dependencies !== undefined) {\n for (const handle of this.dependencies) {\n pass.useTexture(handle);\n passDisabled.useTexture(handle);\n }\n }\n }\n}\n"],"mappings":"AAAA,SAASA,4BAA4B,EAAEC,mCAAmC,QAAQ,0BAA0B;AAC5G,SAASC,4BAA4B,QAA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