48693ef974ac40d6bc3c96e2bb1e2c39d5a6d957f4fe64558df374dd4550f7cf.json 14 KB

1
  1. {"ast":null,"code":"import { Camera } from \"../Cameras/camera.js\";\nimport { Halton2DSequence } from \"../Maths/halton2DSequence.js\";\nimport { Engine } from \"../Engines/engine.js\";\nimport { EffectWrapper } from \"../Materials/effectRenderer.js\";\n/**\n * Simple implementation of Temporal Anti-Aliasing (TAA).\n * This can be used to improve image quality for still pictures (screenshots for e.g.).\n */\nexport class ThinTAAPostProcess extends EffectWrapper {\n _gatherImports(useWebGPU, list) {\n if (useWebGPU) {\n this._webGPUReady = true;\n list.push(import(\"../ShadersWGSL/taa.fragment.js\"));\n } else {\n list.push(import(\"../Shaders/taa.fragment.js\"));\n }\n }\n /**\n * Number of accumulated samples (default: 8)\n */\n set samples(samples) {\n if (this._samples === samples) {\n return;\n }\n this._samples = samples;\n this._hs.regenerate(samples);\n }\n get samples() {\n return this._samples;\n }\n /**\n * Whether the TAA is disabled\n */\n get disabled() {\n return this._disabled;\n }\n set disabled(value) {\n if (this._disabled === value) {\n return;\n }\n this._disabled = value;\n this._reset();\n }\n /**\n * The width of the texture in which to render\n */\n get textureWidth() {\n return this._textureWidth;\n }\n set textureWidth(width) {\n if (this._textureWidth === width) {\n return;\n }\n this._textureWidth = width;\n this._reset();\n }\n /**\n * The height of the texture in which to render\n */\n get textureHeight() {\n return this._textureHeight;\n }\n set textureHeight(height) {\n if (this._textureHeight === height) {\n return;\n }\n this._textureHeight = height;\n this._reset();\n }\n /**\n * Constructs a new TAA 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: ThinTAAPostProcess.FragmentUrl,\n uniforms: ThinTAAPostProcess.Uniforms,\n samplers: ThinTAAPostProcess.Samplers\n });\n this._samples = 8;\n /**\n * The factor used to blend the history frame with current frame (default: 0.05)\n */\n this.factor = 0.05;\n this._disabled = false;\n this._textureWidth = 0;\n this._textureHeight = 0;\n /**\n * Disable TAA on camera move (default: true).\n * You generally want to keep this enabled, otherwise you will get a ghost effect when the camera moves (but if it's what you want, go for it!)\n */\n this.disableOnCameraMove = true;\n this._firstUpdate = true;\n this._hs = new Halton2DSequence(this.samples);\n }\n /** @internal */\n _reset() {\n this._hs.setDimensions(this._textureWidth / 2, this._textureHeight / 2);\n this._hs.next();\n this._firstUpdate = true;\n }\n updateProjectionMatrix() {\n if (this.disabled) {\n return;\n }\n if (this.camera && !this.camera.hasMoved) {\n if (this.camera.mode === Camera.PERSPECTIVE_CAMERA) {\n const projMat = this.camera.getProjectionMatrix();\n projMat.setRowFromFloats(2, this._hs.x, this._hs.y, projMat.m[10], projMat.m[11]);\n } else {\n // We must force the update of the projection matrix so that m[12] and m[13] are recomputed, as we modified them the previous frame\n const projMat = this.camera.getProjectionMatrix(true);\n projMat.setRowFromFloats(3, this._hs.x + projMat.m[12], this._hs.y + projMat.m[13], projMat.m[14], projMat.m[15]);\n }\n }\n this._hs.next();\n }\n bind() {\n var _this$camera;\n super.bind();\n if (this.disabled) {\n return;\n }\n const effect = this._drawWrapper.effect;\n effect.setFloat(\"factor\", (_this$camera = this.camera) !== null && _this$camera !== void 0 && _this$camera.hasMoved && this.disableOnCameraMove || this._firstUpdate ? 1 : this.factor);\n this._firstUpdate = false;\n }\n}\n/**\n * The fragment shader url\n */\nThinTAAPostProcess.FragmentUrl = \"taa\";\n/**\n * The list of uniforms used by the effect\n */\nThinTAAPostProcess.Uniforms = [\"factor\"];\n/**\n * The list of samplers used by the effect\n */\nThinTAAPostProcess.Samplers = [\"historySampler\"];","map":{"version":3,"names":["Camera","Halton2DSequence","Engine","EffectWrapper","ThinTAAPostProcess","_gatherImports","useWebGPU","list","_webGPUReady","push","samples","_samples","_hs","regenerate","disabled","_disabled","value","_reset","textureWidth","_textureWidth","width","textureHeight","_textureHeight","height","constructor","name","engine","options","LastCreatedEngine","useShaderStore","useAsPostProcess","fragmentShader","FragmentUrl","uniforms","Uniforms","samplers","Samplers","factor","disableOnCameraMove","_firstUpdate","setDimensions","next","updateProjectionMatrix","camera","hasMoved","mode","PERSPECTIVE_CAMERA","projMat","getProjectionMatrix","setRowFromFloats","x","y","m","bind","_this$camera","effect","_drawWrapper","setFloat"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/PostProcesses/thinTAAPostProcess.js"],"sourcesContent":["import { Camera } from \"../Cameras/camera.js\";\nimport { Halton2DSequence } from \"../Maths/halton2DSequence.js\";\nimport { Engine } from \"../Engines/engine.js\";\nimport { EffectWrapper } from \"../Materials/effectRenderer.js\";\n/**\n * Simple implementation of Temporal Anti-Aliasing (TAA).\n * This can be used to improve image quality for still pictures (screenshots for e.g.).\n */\nexport class ThinTAAPostProcess extends EffectWrapper {\n _gatherImports(useWebGPU, list) {\n if (useWebGPU) {\n this._webGPUReady = true;\n list.push(import(\"../ShadersWGSL/taa.fragment.js\"));\n }\n else {\n list.push(import(\"../Shaders/taa.fragment.js\"));\n }\n }\n /**\n * Number of accumulated samples (default: 8)\n */\n set samples(samples) {\n if (this._samples === samples) {\n return;\n }\n this._samples = samples;\n this._hs.regenerate(samples);\n }\n get samples() {\n return this._samples;\n }\n /**\n * Whether the TAA is disabled\n */\n get disabled() {\n return this._disabled;\n }\n set disabled(value) {\n if (this._disabled === value) {\n return;\n }\n this._disabled = value;\n this._reset();\n }\n /**\n * The width of the texture in which to render\n */\n get textureWidth() {\n return this._textureWidth;\n }\n set textureWidth(width) {\n if (this._textureWidth === width) {\n return;\n }\n this._textureWidth = width;\n this._reset();\n }\n /**\n * The height of the texture in which to render\n */\n get textureHeight() {\n return this._textureHeight;\n }\n set textureHeight(height) {\n if (this._textureHeight === height) {\n return;\n }\n this._textureHeight = height;\n this._reset();\n }\n /**\n * Constructs a new TAA 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: ThinTAAPostProcess.FragmentUrl,\n uniforms: ThinTAAPostProcess.Uniforms,\n samplers: ThinTAAPostProcess.Samplers,\n });\n this._samples = 8;\n /**\n * The factor used to blend the history frame with current frame (default: 0.05)\n */\n this.factor = 0.05;\n this._disabled = false;\n this._textureWidth = 0;\n this._textureHeight = 0;\n /**\n * Disable TAA on camera move (default: true).\n * You generally want to keep this enabled, otherwise you will get a ghost effect when the camera moves (but if it's what you want, go for it!)\n */\n this.disableOnCameraMove = true;\n this._firstUpdate = true;\n this._hs = new Halton2DSequence(this.samples);\n }\n /** @internal */\n _reset() {\n this._hs.setDimensions(this._textureWidth / 2, this._textureHeight / 2);\n this._hs.next();\n this._firstUpdate = true;\n }\n updateProjectionMatrix() {\n if (this.disabled) {\n return;\n }\n if (this.camera && !this.camera.hasMoved) {\n if (this.camera.mode === Camera.PERSPECTIVE_CAMERA) {\n const projMat = this.camera.getProjectionMatrix();\n projMat.setRowFromFloats(2, this._hs.x, this._hs.y, projMat.m[10], projMat.m[11]);\n }\n else {\n // We must force the update of the projection matrix so that m[12] and m[13] are recomputed, as we modified them the previous frame\n const projMat = this.camera.getProjectionMatrix(true);\n projMat.setRowFromFloats(3, this._hs.x + projMat.m[12], this._hs.y + projMat.m[13], projMat.m[14], projMat.m[15]);\n }\n }\n this._hs.next();\n }\n bind() {\n super.bind();\n if (this.disabled) {\n return;\n }\n const effect = this._drawWrapper.effect;\n effect.setFloat(\"factor\", (this.camera?.hasMoved && this.disableOnCameraMove) || this._firstUpdate ? 1 : this.factor);\n this._firstUpdate = false;\n }\n}\n/**\n * The fragment shader url\n */\nThinTAAPostProcess.FragmentUrl = \"taa\";\n/**\n * The list of uniforms used by the effect\n */\nThinTAAPostProcess.Uniforms = [\"factor\"];\n/**\n * The list of samplers used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