1 |
- {"ast":null,"code":"import _asyncToGenerator from \"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { __decorate } from \"../../tslib.es6.js\";\nimport { RawTexture } from \"../../Materials/Textures/rawTexture.js\";\nimport { RenderTargetTexture } from \"../../Materials/Textures/renderTargetTexture.js\";\nimport { PostProcess } from \"../../PostProcesses/postProcess.js\";\nimport { Observable } from \"../../Misc/observable.js\";\nimport { Layer } from \"../../Layers/layer.js\";\nimport { Matrix } from \"../../Maths/math.vector.js\";\nimport { MaterialPluginBase } from \"../../Materials/materialPluginBase.js\";\nimport { PBRBaseMaterial } from \"../../Materials/PBR/pbrBaseMaterial.js\";\nimport { GeometryBufferRenderer } from \"../geometryBufferRenderer.js\";\nimport { BaseTexture } from \"../../Materials/Textures/baseTexture.js\";\nimport { expandToProperty, serialize } from \"../../Misc/decorators.js\";\nimport { MaterialDefines } from \"../../Materials/materialDefines.js\";\nimport { RegisterClass } from \"../../Misc/typeStore.js\";\n/**\n * Class used to manage the global illumination contribution calculated from reflective shadow maps (RSM).\n */\nexport class GIRSMManager {\n /**\n * Enables or disables the manager. Default is false.\n * If disabled, the global illumination won't be calculated and the scene will be rendered normally, without any global illumination contribution.\n */\n get enable() {\n return this._enable;\n }\n set enable(enable) {\n if (this._giRSM.length === 0) {\n enable = false;\n }\n if (enable === this._enable) {\n return;\n }\n this._enable = enable;\n this._debugLayer.isEnabled = this._showOnlyGI && enable;\n this._materialsWithRenderPlugin.forEach(mat => {\n if (mat.pluginManager) {\n const plugin = mat.pluginManager.getPlugin(GIRSMRenderPluginMaterial.Name);\n plugin.isEnabled = enable;\n }\n });\n this.recreateResources(!enable);\n }\n /**\n * Defines if the global illumination contribution should be blurred or not (using a bilateral blur). Default is true.\n */\n get enableBlur() {\n return this._enableBlur;\n }\n set enableBlur(enable) {\n if (enable === this._enableBlur) {\n return;\n }\n this._enableBlur = enable;\n this.recreateResources();\n }\n /**\n * Defines if the blur should be done with a better quality but slower or not. Default is false.\n */\n get useQualityBlur() {\n return this._useQualityBlur;\n }\n set useQualityBlur(enable) {\n if (enable === this._useQualityBlur) {\n return;\n }\n this._useQualityBlur = enable;\n this.recreateResources();\n }\n /**\n * Defines if the blur should be done at full resolution or not. Default is false.\n * If this setting is enabled, upampling will be disabled (ignored) as it is not needed anymore.\n */\n get fullSizeBlur() {\n return this._forceFullSizeBlur;\n }\n set fullSizeBlur(mode) {\n if (this._forceFullSizeBlur === mode) {\n return;\n }\n this._forceFullSizeBlur = mode;\n this.recreateResources();\n }\n /**\n * Defines if the upsampling should be done with a better quality but slower or not. Default is false.\n */\n get useQualityUpsampling() {\n return this._useQualityUpsampling;\n }\n set useQualityUpsampling(enable) {\n if (enable === this._useQualityUpsampling) {\n return;\n }\n this._useQualityUpsampling = enable;\n this.recreateResources();\n }\n /**\n * Defines if the debug layer should be enabled or not. Default is false.\n * Use this setting for debugging purpose, to show the global illumination contribution only.\n */\n get showOnlyGI() {\n return this._showOnlyGI;\n }\n set showOnlyGI(show) {\n if (this._showOnlyGI === show) {\n return;\n }\n this._showOnlyGI = show;\n this._debugLayer.isEnabled = show;\n }\n /**\n * Defines if the depth buffer used by the geometry buffer renderer should be 32 bits or not. Default is false (16 bits).\n */\n get use32BitsDepthBuffer() {\n return this._use32BitsDepthBuffer;\n }\n set use32BitsDepthBuffer(enable) {\n if (this._use32BitsDepthBuffer === enable) {\n return;\n }\n this._use32BitsDepthBuffer = enable;\n this.recreateResources();\n }\n /**\n * Sets the output dimensions of the final process. It should normally be the same as the output dimensions of the screen.\n * @param dimensions The dimensions of the output texture (width and height)\n */\n setOutputDimensions(dimensions) {\n this._outputDimensions = dimensions;\n this.recreateResources();\n }\n /**\n * Sets the dimensions of the GI texture. Try to use the smallest size possible for better performance.\n * @param dimensions The dimensions of the GI texture (width and height)\n */\n setGITextureDimensions(dimensions) {\n this._giTextureDimensions = dimensions;\n this.recreateResources();\n }\n /**\n * Gets or sets the texture type used by the GI texture. Default is 11.\n */\n get giTextureType() {\n return this._giTextureType;\n }\n set giTextureType(textureType) {\n if (this._giTextureType === textureType) {\n return;\n }\n this._giTextureType = textureType;\n this.recreateResources();\n }\n /** Gets the shader language used in this material. */\n get shaderLanguage() {\n return this._shaderLanguage;\n }\n /**\n * Gets the list of GIRSM used by the manager.\n */\n get giRSM() {\n return this._giRSM;\n }\n /**\n * Adds a (list of) GIRSM to the manager.\n * @param rsm The GIRSM (or array of GIRSM) to add to the manager\n */\n addGIRSM(rsm) {\n if (Array.isArray(rsm)) {\n this._giRSM.push(...rsm);\n } else {\n this._giRSM.push(rsm);\n }\n this.recreateResources();\n }\n /**\n * Removes a (list of) GIRSM from the manager.\n * @param rsm The GIRSM (or array of GIRSM) to remove from the manager\n */\n removeGIRSM(rsm) {\n if (Array.isArray(rsm)) {\n for (let i = 0; i < rsm.length; ++i) {\n const idx = this._giRSM.indexOf(rsm[i]);\n if (idx !== -1) {\n this._giRSM.splice(idx, 1);\n }\n }\n } else {\n const idx = this._giRSM.indexOf(rsm);\n if (idx !== -1) {\n this._giRSM.splice(idx, 1);\n }\n }\n if (this._giRSM.length === 0) {\n this.enable = false;\n } else {\n this.recreateResources();\n }\n }\n /**\n * Add a material to the manager. This will enable the global illumination contribution for the material.\n * @param material Material that will be affected by the global illumination contribution. If not provided, all materials of the scene will be affected.\n */\n addMaterial(material) {\n if (material) {\n this._addGISupportToMaterial(material);\n } else {\n this._scene.meshes.forEach(mesh => {\n if (mesh.getTotalVertices() > 0 && mesh.isEnabled() && mesh.material) {\n this._addGISupportToMaterial(mesh.material);\n }\n });\n }\n }\n /**\n * Gets the list of GPU counters used by the manager.\n * GPU timing measurements must be enabled for the counters to be filled (engine.enableGPUTimingMeasurements = true).\n * Only available with WebGPU. You will still get the list of counters with other engines but the values will always be 0.\n */\n get countersGPU() {\n return this._counters;\n }\n /**\n * Recreates the resources used by the manager.\n * You should normally not have to call this method manually, except if you change the useFullTexture property of a GIRSM, because the manager won't track this change.\n * @param disposeGeometryBufferRenderer Defines if the geometry buffer renderer should be disposed and recreated. Default is false.\n */\n recreateResources(disposeGeometryBufferRenderer = false) {\n if (!this._shadersLoaded) {\n this._onShaderLoadedObservable.addOnce(() => {\n this.recreateResources(disposeGeometryBufferRenderer);\n });\n return;\n }\n this._disposePostProcesses(disposeGeometryBufferRenderer);\n this._createPostProcesses();\n this._setPluginParameters();\n }\n /**\n * Generates the sample texture used by the the global illumination calculation process.\n * @param maxSamples The maximum number of samples to generate in the texture. Default value is 2048. The numSamples property of the GIRSM should be less than or equal to this value!\n */\n generateSampleTexture(maxSamples) {\n var _this$_sampleTexture;\n (_this$_sampleTexture = this._sampleTexture) === null || _this$_sampleTexture === void 0 || _this$_sampleTexture.dispose();\n this._maxSamples = maxSamples;\n const data = new Float32Array(this._maxSamples * 4);\n for (let i = 0; i < this._maxSamples; i++) {\n const xi1 = Math.random();\n const xi2 = Math.random();\n const x = xi1 * Math.sin(2 * Math.PI * xi2);\n const y = xi1 * Math.cos(2 * Math.PI * xi2);\n data[i * 4 + 0] = x;\n data[i * 4 + 1] = y;\n data[i * 4 + 2] = xi1 * xi1;\n data[i * 4 + 3] = 1;\n }\n this._sampleTexture = new RawTexture(data, this._maxSamples, 1, 5, this._scene, false, false, 1, 1);\n this._sampleTexture.name = \"GIRSMSamples\";\n }\n /**\n * Disposes the manager.\n */\n dispose() {\n var _this$_debugLayer$tex;\n this._disposePostProcesses(true);\n (_this$_debugLayer$tex = this._debugLayer.texture) === null || _this$_debugLayer$tex === void 0 || _this$_debugLayer$tex.dispose();\n this._debugLayer.dispose();\n this._scene.onBeforeDrawPhaseObservable.remove(this._drawPhaseObserver);\n this._onShaderLoadedObservable.clear();\n }\n /**\n * Creates a new GIRSMManager\n * @param scene The scene\n * @param outputDimensions The dimensions of the output texture (width and height). Should normally be the same as the output dimensions of the screen.\n * @param giTextureDimensions The dimensions of the GI texture (width and height). Try to use the smallest size possible for better performance.\n * @param maxSamples The maximum number of samples to generate in the sample texture. Default value is 2048. The numSamples property of the GIRSM should be less than or equal to this value!\n * @param giTextureType The texture type used by the GI texture. Default is 11.\n */\n constructor(scene, outputDimensions, giTextureDimensions = {\n width: 256,\n height: 256\n }, maxSamples = 2048, giTextureType = 11) {\n this._giRSM = [];\n this._blurRTT = null;\n this._blurPostProcesses = null;\n this._blurXPostprocess = null;\n this._blurYPostprocess = null;\n this._upsamplingXPostprocess = null;\n this._upsamplingYPostprocess = null;\n this._ppGlobalIllumination = [];\n this._firstActivation = true;\n this._geomBufferEnabled = false;\n this._geomBufferEnablePosition = false;\n this._tempMatrix = new Matrix();\n this._enable = false;\n /**\n * Defines if the global illumination calculation is paused or not.\n * Use this setting to pause the global illumination calculation when you know that the scene (camera/mesh/light positions) is not changing anymore to save some GPU power.\n * The scene will still be rendered with the latest global illumination contribution.\n */\n this.pause = false;\n this._enableBlur = true;\n this._useQualityBlur = false;\n /**\n * Defines the depth threshold used by the bilateral blur post-processes (also used by the upsampling, if enabled).\n * You may have to change this value, depending on your scene.\n */\n this.blurDepthThreshold = 0.05;\n /**\n * Defines the normal threshold used by the bilateral blur post-processes (also used by the upsampling, if enabled).\n * You may have to change this value, depending on your scene.\n */\n this.blurNormalThreshold = 0.25;\n /**\n * Defines the kernel size used by the bilateral blur post-processes. Default is 12.\n */\n this.blurKernel = 12;\n this._forceFullSizeBlur = false;\n this._useQualityUpsampling = false;\n /**\n * Defines the kernel size used by the bilateral upsampling post-processes. Default is 6.\n */\n this.upsamplerKernel = 6;\n this._showOnlyGI = false;\n this._use32BitsDepthBuffer = false;\n /** Shader language used by the material */\n this._shaderLanguage = 0 /* ShaderLanguage.GLSL */;\n this._shadersLoaded = false;\n this._onShaderLoadedObservable = new Observable();\n this._scene = scene;\n this._engine = scene.getEngine();\n this._outputDimensions = outputDimensions;\n this._giTextureDimensions = giTextureDimensions;\n this._giTextureType = giTextureType;\n this._materialsWithRenderPlugin = [];\n this._maxSamples = maxSamples;\n this._debugLayer = new Layer(\"debug layer\", null, this._scene, false);\n this._debugLayer.isEnabled = false;\n this._counters = [];\n this._countersRTW = [];\n this._initShaderSourceAsync();\n this.generateSampleTexture(maxSamples);\n this._drawPhaseObserver = this._scene.onBeforeDrawPhaseObservable.add(() => {\n const currentRenderTarget = this._engine._currentRenderTarget;\n let rebindCurrentRenderTarget = false;\n if (this._enable) {\n if (!this.pause) {\n this._scene.postProcessManager.directRender(this._ppGlobalIllumination, this._ppGlobalIllumination[0].inputTexture);\n this._engine.unBindFramebuffer(this._ppGlobalIllumination[0].inputTexture, true);\n this._engine.setAlphaMode(0);\n rebindCurrentRenderTarget = true;\n if (this.enableBlur && this._blurPostProcesses) {\n this._scene.postProcessManager.directRender(this._blurPostProcesses, this._blurRTT.renderTarget, true);\n this._engine.unBindFramebuffer(this._blurRTT.renderTarget, true);\n }\n }\n for (let i = 0; i < this._counters.length; ++i) {\n const rtws = this._countersRTW[i];\n for (let t = 0; t < rtws.length; ++t) {\n if (t === 0) {\n var _rtws$t$gpuTimeInFram, _rtws$t$gpuTimeInFram2;\n this._counters[i].value = this.pause ? 0 : (_rtws$t$gpuTimeInFram = (_rtws$t$gpuTimeInFram2 = rtws[t].gpuTimeInFrame) === null || _rtws$t$gpuTimeInFram2 === void 0 ? void 0 : _rtws$t$gpuTimeInFram2.counter.lastSecAverage) !== null && _rtws$t$gpuTimeInFram !== void 0 ? _rtws$t$gpuTimeInFram : 0;\n } else if (!this.pause) {\n var _rtws$t$gpuTimeInFram3, _rtws$t$gpuTimeInFram4;\n this._counters[i].value += (_rtws$t$gpuTimeInFram3 = (_rtws$t$gpuTimeInFram4 = rtws[t].gpuTimeInFrame) === null || _rtws$t$gpuTimeInFram4 === void 0 ? void 0 : _rtws$t$gpuTimeInFram4.counter.lastSecAverage) !== null && _rtws$t$gpuTimeInFram3 !== void 0 ? _rtws$t$gpuTimeInFram3 : 0;\n }\n }\n }\n if (this._scene.activeCamera) {\n this._engine.setViewport(this._scene.activeCamera.viewport);\n }\n }\n if (rebindCurrentRenderTarget && currentRenderTarget) {\n this._engine.bindFramebuffer(currentRenderTarget);\n }\n });\n }\n _initShaderSourceAsync() {\n var _this = this;\n return _asyncToGenerator(function* () {\n const engine = _this._engine;\n if (engine.isWebGPU) {\n _this._shaderLanguage = 1 /* ShaderLanguage.WGSL */;\n yield Promise.all([import(\"../../ShadersWGSL/bilateralBlur.fragment.js\"), import(\"../../ShadersWGSL/bilateralBlurQuality.fragment.js\"), import(\"../../ShadersWGSL/rsmGlobalIllumination.fragment.js\"), import(\"../../ShadersWGSL/rsmFullGlobalIllumination.fragment.js\")]);\n } else {\n yield Promise.all([import(\"../../Shaders/bilateralBlur.fragment.js\"), import(\"../../Shaders/bilateralBlurQuality.fragment.js\"), import(\"../../Shaders/rsmGlobalIllumination.fragment.js\"), import(\"../../Shaders/rsmFullGlobalIllumination.fragment.js\")]);\n }\n _this._shadersLoaded = true;\n _this._onShaderLoadedObservable.notifyObservers();\n })();\n }\n _disposePostProcesses(disposeGeometryBufferRenderer = false) {\n var _this$_blurRTT, _this$_blurXPostproce, _this$_blurYPostproce, _this$_upsamplingXPos, _this$_upsamplingYPos;\n (_this$_blurRTT = this._blurRTT) === null || _this$_blurRTT === void 0 || _this$_blurRTT.dispose();\n this._blurRTT = null;\n this._blurPostProcesses = [];\n (_this$_blurXPostproce = this._blurXPostprocess) === null || _this$_blurXPostproce === void 0 || _this$_blurXPostproce.dispose();\n this._blurXPostprocess = null;\n (_this$_blurYPostproce = this._blurYPostprocess) === null || _this$_blurYPostproce === void 0 || _this$_blurYPostproce.dispose();\n this._blurYPostprocess = null;\n (_this$_upsamplingXPos = this._upsamplingXPostprocess) === null || _this$_upsamplingXPos === void 0 || _this$_upsamplingXPos.dispose();\n this._upsamplingXPostprocess = null;\n (_this$_upsamplingYPos = this._upsamplingYPostprocess) === null || _this$_upsamplingYPos === void 0 || _this$_upsamplingYPos.dispose();\n this._upsamplingYPostprocess = null;\n for (const ppGlobalIllumination of this._ppGlobalIllumination) {\n ppGlobalIllumination.dispose();\n }\n this._ppGlobalIllumination = [];\n if (disposeGeometryBufferRenderer) {\n if (this._geomBufferEnabled) {\n this._scene.enableGeometryBufferRenderer();\n this._scene.geometryBufferRenderer.enablePosition = this._geomBufferEnablePosition;\n } else {\n this._scene.disableGeometryBufferRenderer();\n }\n }\n this._counters = [];\n this._countersRTW = [];\n }\n _setPluginParameters() {\n if (!this._enable) {\n return;\n }\n this._materialsWithRenderPlugin.forEach(mat => {\n if (mat.pluginManager) {\n const plugin = mat.pluginManager.getPlugin(GIRSMRenderPluginMaterial.Name);\n plugin.textureGIContrib = this.enableBlur ? this._blurRTT.renderTarget.texture : this._ppGlobalIllumination[0].inputTexture.texture;\n plugin.outputTextureWidth = this._outputDimensions.width;\n plugin.outputTextureHeight = this._outputDimensions.height;\n }\n });\n }\n _createPostProcesses() {\n var _this$_debugLayer$tex2;\n if (!this._enable) {\n return;\n }\n const textureFormat = this._giTextureType === 13 ? 4 : 5;\n if (this._firstActivation) {\n var _this$_scene$geometry, _this$_scene$geometry2;\n this._firstActivation = false;\n this._geomBufferEnabled = !!this._scene.geometryBufferRenderer;\n this._geomBufferEnablePosition = (_this$_scene$geometry = (_this$_scene$geometry2 = this._scene.geometryBufferRenderer) === null || _this$_scene$geometry2 === void 0 ? void 0 : _this$_scene$geometry2.enablePosition) !== null && _this$_scene$geometry !== void 0 ? _this$_scene$geometry : false;\n }\n if (!this._geomBufferEnabled) {\n this._scene.disableGeometryBufferRenderer();\n }\n const geometryBufferRenderer = this._scene.enableGeometryBufferRenderer(this._enableBlur ? this._outputDimensions : this._giTextureDimensions, this._use32BitsDepthBuffer ? 14 : 15, GIRSMManager.GeometryBufferTextureTypesAndFormats);\n if (!geometryBufferRenderer) {\n throw new Error(\"Geometry buffer renderer is not supported but is required for GIRSMManager.\");\n }\n geometryBufferRenderer.enablePosition = true;\n if (!this._geomBufferEnabled) {\n geometryBufferRenderer.generateNormalsInWorldSpace = true;\n }\n const decodeGeometryBufferNormals = geometryBufferRenderer.normalsAreUnsigned;\n const normalsAreInWorldSpace = geometryBufferRenderer.generateNormalsInWorldSpace;\n this._counters.push({\n name: \"Geometry buffer renderer\",\n value: 0\n });\n this._countersRTW.push([this._scene.geometryBufferRenderer.getGBuffer().renderTarget]);\n let defines = \"\";\n if (decodeGeometryBufferNormals) {\n defines += \"#define DECODE_NORMAL\\n\";\n }\n if (!normalsAreInWorldSpace) {\n defines += \"#define TRANSFORM_NORMAL\\n\";\n }\n for (let i = 0; i < this._giRSM.length; ++i) {\n const giRSM = this._giRSM[i];\n const rsm = giRSM.rsm;\n const ppGlobalIllumination = new PostProcess(\"RSMGlobalIllumination\" + i, giRSM.useFullTexture ? \"rsmFullGlobalIllumination\" : \"rsmGlobalIllumination\", {\n ...this._giTextureDimensions,\n uniforms: [\"rsmLightMatrix\", \"rsmInfo\", \"rsmInfo2\", \"invView\"],\n samplers: [\"normalSampler\", \"rsmPositionW\", \"rsmNormalW\", \"rsmFlux\", \"rsmSamples\"],\n defines,\n samplingMode: 2,\n engine: this._engine,\n textureType: this._giTextureType,\n textureFormat,\n shaderLanguage: this._shaderLanguage\n });\n this._ppGlobalIllumination.push(ppGlobalIllumination);\n if (i !== 0) {\n ppGlobalIllumination.shareOutputWith(this._ppGlobalIllumination[0]);\n ppGlobalIllumination.alphaMode = 1;\n }\n ppGlobalIllumination.autoClear = false;\n ppGlobalIllumination.externalTextureSamplerBinding = true;\n ppGlobalIllumination.onApplyObservable.add(effect => {\n effect.setTexture(\"textureSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.POSITION_TEXTURE_TYPE)]);\n effect.setTexture(\"normalSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE)]);\n effect.setTexture(\"rsmPositionW\", rsm.positionWorldTexture);\n effect.setTexture(\"rsmNormalW\", rsm.normalWorldTexture);\n effect.setTexture(\"rsmFlux\", rsm.fluxTexture);\n effect.setMatrix(\"rsmLightMatrix\", rsm.lightTransformationMatrix);\n if (!giRSM.useFullTexture) {\n effect.setTexture(\"rsmSamples\", this._sampleTexture);\n effect.setFloat4(\"rsmInfo\", giRSM.numSamples, giRSM.radius, giRSM.intensity, giRSM.edgeArtifactCorrection);\n effect.setFloat4(\"rsmInfo2\", giRSM.noiseFactor, giRSM.rotateSample ? 1 : 0, rsm.fluxTexture.getInternalTexture().width, rsm.fluxTexture.getInternalTexture().height);\n } else {\n effect.setFloat4(\"rsmInfo\", rsm.fluxTexture.getInternalTexture().width, rsm.fluxTexture.getInternalTexture().height, giRSM.intensity, giRSM.edgeArtifactCorrection);\n }\n if (!normalsAreInWorldSpace) {\n this._tempMatrix.copyFrom(this._scene.activeCamera.getViewMatrix());\n this._tempMatrix.invert();\n effect.setMatrix(\"invView\", this._tempMatrix);\n }\n });\n }\n for (const ppGlobalIllumination of this._ppGlobalIllumination) {\n if (!ppGlobalIllumination.inputTexture) {\n ppGlobalIllumination.resize(this._giTextureDimensions.width, this._giTextureDimensions.height);\n }\n }\n this._counters.push({\n name: \"GI generation\",\n value: 0\n });\n this._countersRTW.push([this._ppGlobalIllumination[0].inputTexture]);\n if (this._enableBlur) {\n const blurTextureSize = this._forceFullSizeBlur ? this._outputDimensions : this._giTextureDimensions;\n this._blurRTT = new RenderTargetTexture(\"GIRSMContribution\", this._outputDimensions, this._scene, {\n type: this._giTextureType,\n format: textureFormat,\n generateDepthBuffer: false\n });\n this._blurRTT.wrapU = 0;\n this._blurRTT.wrapV = 0;\n this._blurRTT.updateSamplingMode(1);\n this._blurRTT.skipInitialClear = true;\n const blurRTWs = [];\n this._counters.push({\n name: \"GI blur\",\n value: 0\n });\n this._countersRTW.push(blurRTWs);\n // Bilateral blur\n this._blurXPostprocess = new PostProcess(this._useQualityBlur ? \"BilateralBlur\" : \"BilateralBlurX\", this._useQualityBlur ? \"bilateralBlurQuality\" : \"bilateralBlur\", {\n uniforms: [\"filterSize\", \"blurDir\", \"depthThreshold\", \"normalThreshold\"],\n samplers: [\"depthSampler\", \"normalSampler\"],\n defines: decodeGeometryBufferNormals ? \"#define DECODE_NORMAL\" : undefined,\n size: blurTextureSize,\n samplingMode: 2,\n engine: this._engine,\n textureType: this._giTextureType,\n textureFormat,\n shaderLanguage: this._shaderLanguage\n });\n this._blurXPostprocess.onApplyObservable.add(effect => {\n effect._bindTexture(\"textureSampler\", this._ppGlobalIllumination[0].inputTexture.texture);\n effect.setTexture(\"depthSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.DEPTH_TEXTURE_TYPE)]);\n effect.setTexture(\"normalSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE)]);\n effect.setInt(\"filterSize\", this.blurKernel);\n effect.setFloat2(\"blurDir\", 1 / this._giTextureDimensions.width, this._useQualityBlur ? 1 / this._giTextureDimensions.height : 0);\n effect.setFloat(\"depthThreshold\", this.blurDepthThreshold);\n effect.setFloat(\"normalThreshold\", this.blurNormalThreshold);\n });\n this._blurXPostprocess.externalTextureSamplerBinding = true;\n this._blurXPostprocess.autoClear = false;\n if (!this._useQualityBlur) {\n this._blurYPostprocess = new PostProcess(\"BilateralBlurY\", \"bilateralBlur\", {\n uniforms: [\"filterSize\", \"blurDir\", \"depthThreshold\", \"normalThreshold\"],\n samplers: [\"depthSampler\", \"normalSampler\"],\n defines: decodeGeometryBufferNormals ? \"#define DECODE_NORMAL\" : undefined,\n size: blurTextureSize,\n samplingMode: 2,\n engine: this._engine,\n textureType: this._giTextureType,\n textureFormat,\n shaderLanguage: this._shaderLanguage\n });\n this._blurYPostprocess.autoClear = false;\n this._blurYPostprocess.onApplyObservable.add(effect => {\n effect.setTexture(\"depthSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.DEPTH_TEXTURE_TYPE)]);\n effect.setTexture(\"normalSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE)]);\n effect.setInt(\"filterSize\", this.blurKernel);\n effect.setFloat2(\"blurDir\", 0, 1 / this._giTextureDimensions.height);\n effect.setFloat(\"depthThreshold\", this.blurDepthThreshold);\n effect.setFloat(\"normalThreshold\", this.blurNormalThreshold);\n });\n this._blurYPostprocess.resize(blurTextureSize.width, blurTextureSize.height);\n blurRTWs.push(this._blurYPostprocess.inputTexture);\n }\n this._blurPostProcesses = [this._blurXPostprocess];\n if (this._blurYPostprocess) {\n this._blurPostProcesses.push(this._blurYPostprocess);\n }\n // Bilateral upsampling\n const giFullDimensions = this._giTextureDimensions.width >= this._outputDimensions.width && this._giTextureDimensions.height >= this._outputDimensions.height;\n if (!giFullDimensions && !this._forceFullSizeBlur) {\n const upsamplingRTWs = [];\n this._counters.push({\n name: \"GI upsampling\",\n value: 0\n });\n this._countersRTW.push(upsamplingRTWs);\n this._upsamplingXPostprocess = new PostProcess(this._useQualityUpsampling ? \"BilateralUpsampling\" : \"BilateralUpsamplingX\", this._useQualityUpsampling ? \"bilateralBlurQuality\" : \"bilateralBlur\", {\n uniforms: [\"filterSize\", \"blurDir\", \"depthThreshold\", \"normalThreshold\"],\n samplers: [\"depthSampler\", \"normalSampler\"],\n defines: decodeGeometryBufferNormals ? \"#define DECODE_NORMAL\" : undefined,\n size: blurTextureSize,\n samplingMode: 2,\n engine: this._engine,\n textureType: this._giTextureType,\n textureFormat,\n shaderLanguage: this._shaderLanguage\n });\n this._upsamplingXPostprocess.autoClear = false;\n this._upsamplingXPostprocess.onApplyObservable.add(effect => {\n effect.setTexture(\"depthSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.DEPTH_TEXTURE_TYPE)]);\n effect.setTexture(\"normalSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE)]);\n effect.setInt(\"filterSize\", this.upsamplerKernel);\n effect.setFloat2(\"blurDir\", 1 / this._outputDimensions.width, this._useQualityUpsampling ? 1 / this._outputDimensions.height : 0);\n effect.setFloat(\"depthThreshold\", this.blurDepthThreshold);\n effect.setFloat(\"normalThreshold\", this.blurNormalThreshold);\n });\n this._upsamplingXPostprocess.resize(blurTextureSize.width, blurTextureSize.height);\n blurRTWs.push(this._upsamplingXPostprocess.inputTexture);\n if (!this.useQualityUpsampling) {\n this._upsamplingYPostprocess = new PostProcess(\"BilateralUpsamplingY\", \"bilateralBlur\", {\n uniforms: [\"filterSize\", \"blurDir\", \"depthThreshold\", \"normalThreshold\"],\n samplers: [\"depthSampler\", \"normalSampler\"],\n defines: decodeGeometryBufferNormals ? \"#define DECODE_NORMAL\" : undefined,\n size: this._outputDimensions,\n samplingMode: 2,\n engine: this._engine,\n textureType: this._giTextureType,\n textureFormat,\n shaderLanguage: this._shaderLanguage\n });\n this._upsamplingYPostprocess.autoClear = false;\n this._upsamplingYPostprocess.onApplyObservable.add(effect => {\n effect.setTexture(\"depthSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.DEPTH_TEXTURE_TYPE)]);\n effect.setTexture(\"normalSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE)]);\n effect.setInt(\"filterSize\", this.upsamplerKernel);\n effect.setFloat2(\"blurDir\", 0, 1 / this._outputDimensions.height);\n effect.setFloat(\"depthThreshold\", this.blurDepthThreshold);\n effect.setFloat(\"normalThreshold\", this.blurNormalThreshold);\n });\n this._upsamplingYPostprocess.resize(this._outputDimensions.width, this._outputDimensions.height);\n upsamplingRTWs.push(this._upsamplingYPostprocess.inputTexture);\n }\n upsamplingRTWs.push(this._blurRTT.renderTarget);\n this._blurPostProcesses.push(this._upsamplingXPostprocess);\n if (this._upsamplingYPostprocess) {\n this._blurPostProcesses.push(this._upsamplingYPostprocess);\n }\n } else {\n blurRTWs.push(this._blurRTT.renderTarget);\n }\n }\n (_this$_debugLayer$tex2 = this._debugLayer.texture) === null || _this$_debugLayer$tex2 === void 0 || _this$_debugLayer$tex2.dispose();\n this._debugLayer.texture = new BaseTexture(this._scene, this._enableBlur ? this._blurRTT.renderTarget.texture : this._ppGlobalIllumination[0].inputTexture.texture);\n }\n _addGISupportToMaterial(material) {\n var _material$pluginManag;\n if ((_material$pluginManag = material.pluginManager) !== null && _material$pluginManag !== void 0 && _material$pluginManag.getPlugin(GIRSMRenderPluginMaterial.Name)) {\n return;\n }\n const plugin = new GIRSMRenderPluginMaterial(material);\n if (this._enable && this._ppGlobalIllumination.length > 0) {\n plugin.textureGIContrib = this._ppGlobalIllumination[0].inputTexture.texture;\n plugin.outputTextureWidth = this._outputDimensions.width;\n plugin.outputTextureHeight = this._outputDimensions.height;\n }\n plugin.isEnabled = this._enable;\n this._materialsWithRenderPlugin.push(material);\n }\n}\n/**\n * Defines the default texture types and formats used by the geometry buffer renderer.\n */\nGIRSMManager.GeometryBufferTextureTypesAndFormats = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n 0: {\n textureType: 2,\n textureFormat: 6\n },\n // depth\n // eslint-disable-next-line @typescript-eslint/naming-convention\n 1: {\n textureType: 11,\n textureFormat: 5\n },\n // normal\n // eslint-disable-next-line @typescript-eslint/naming-convention\n 2: {\n textureType: 2,\n textureFormat: 5\n } // position\n};\n/**\n * @internal\n */\nclass MaterialGIRSMRenderDefines extends MaterialDefines {\n constructor() {\n super(...arguments);\n this.RENDER_WITH_GIRSM = false;\n this.RSMCREATE_PROJTEXTURE = false;\n }\n}\n/**\n * Plugin used to render the global illumination contribution.\n */\nexport class GIRSMRenderPluginMaterial extends MaterialPluginBase {\n _markAllSubMeshesAsTexturesDirty() {\n this._enable(this._isEnabled);\n this._internalMarkAllSubMeshesAsTexturesDirty();\n }\n /**\n * Gets a boolean indicating that the plugin is compatible with a give shader language.\n * @returns true if the plugin is compatible with the shader language\n */\n isCompatible() {\n return true;\n }\n constructor(material) {\n super(material, GIRSMRenderPluginMaterial.Name, 310, new MaterialGIRSMRenderDefines());\n this._isEnabled = false;\n /**\n * Defines if the plugin is enabled in the material.\n */\n this.isEnabled = false;\n this._internalMarkAllSubMeshesAsTexturesDirty = material._dirtyCallbacks[1];\n this._isPBR = material instanceof PBRBaseMaterial;\n }\n prepareDefines(defines) {\n defines.RENDER_WITH_GIRSM = this._isEnabled;\n }\n getClassName() {\n return \"GIRSMRenderPluginMaterial\";\n }\n getUniforms() {\n return {\n ubo: [{\n name: \"girsmTextureOutputSize\",\n size: 2,\n type: \"vec2\"\n }],\n fragment: `#ifdef RENDER_WITH_GIRSM\n uniform vec2 girsmTextureOutputSize;\n #endif`\n };\n }\n getSamplers(samplers) {\n samplers.push(\"girsmTextureGIContrib\");\n }\n bindForSubMesh(uniformBuffer) {\n if (this._isEnabled) {\n uniformBuffer.bindTexture(\"girsmTextureGIContrib\", this.textureGIContrib);\n uniformBuffer.updateFloat2(\"girsmTextureOutputSize\", this.outputTextureWidth, this.outputTextureHeight);\n }\n }\n getCustomCode(shaderType, shaderLanguage) {\n let frag;\n if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n frag = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n CUSTOM_FRAGMENT_DEFINITIONS: `\n #ifdef RENDER_WITH_GIRSM\n var girsmTextureGIContribSampler: sampler;\n var girsmTextureGIContrib: texture_2d<f32>;\n\n fn computeIndirect() -> vec3f {\n var uv = fragmentInputs.position.xy / uniforms.girsmTextureOutputSize;\n return textureSample(girsmTextureGIContrib, girsmTextureGIContribSampler, uv).rgb;\n }\n #endif\n `,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION: `\n #ifdef RENDER_WITH_GIRSM\n finalDiffuse += computeIndirect() * surfaceAlbedo.rgb;\n #endif\n `\n };\n if (!this._isPBR) {\n frag[\"CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\"] = `\n #ifdef RENDER_WITH_GIRSM\n color = vec4f(color.rgb + computeIndirect() * baseColor.rgb, color.a);\n #endif\n `;\n }\n } else {\n frag = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n CUSTOM_FRAGMENT_DEFINITIONS: `\n #ifdef RENDER_WITH_GIRSM\n uniform sampler2D girsmTextureGIContrib;\n\n vec3 computeIndirect() {\n vec2 uv = gl_FragCoord.xy / girsmTextureOutputSize;\n return texture2D(girsmTextureGIContrib, uv).rgb;\n }\n #endif\n `,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION: `\n #ifdef RENDER_WITH_GIRSM\n finalDiffuse += computeIndirect() * surfaceAlbedo.rgb;\n #endif\n `\n };\n if (!this._isPBR) {\n frag[\"CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\"] = `\n #ifdef RENDER_WITH_GIRSM\n color.rgb += computeIndirect() * baseColor.rgb;\n #endif\n `;\n }\n }\n return shaderType === \"vertex\" ? null : frag;\n }\n}\n/**\n * Defines the name of the plugin.\n */\nGIRSMRenderPluginMaterial.Name = \"GIRSMRender\";\n__decorate([serialize()], GIRSMRenderPluginMaterial.prototype, \"textureGIContrib\", void 0);\n__decorate([serialize()], GIRSMRenderPluginMaterial.prototype, \"outputTextureWidth\", void 0);\n__decorate([serialize()], GIRSMRenderPluginMaterial.prototype, \"outputTextureHeight\", void 0);\n__decorate([serialize(), expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")], GIRSMRenderPluginMaterial.prototype, \"isEnabled\", void 0);\nRegisterClass(`BABYLON.GIRSMRenderPluginMaterial`, GIRSMRenderPluginMaterial);","map":{"version":3,"names":["__decorate","RawTexture","RenderTargetTexture","PostProcess","Observable","Layer","Matrix","MaterialPluginBase","PBRBaseMaterial","GeometryBufferRenderer","BaseTexture","expandToProperty","serialize","MaterialDefines","RegisterClass","GIRSMManager","enable","_enable","_giRSM","length","_debugLayer","isEnabled","_showOnlyGI","_materialsWithRenderPlugin","forEach","mat","pluginManager","plugin","getPlugin","GIRSMRenderPluginMaterial","Name","recreateResources","enableBlur","_enableBlur","useQualityBlur","_useQualityBlur","fullSizeBlur","_forceFullSizeBlur","mode","useQualityUpsampling","_useQualityUpsampling","showOnlyGI","show","use32BitsDepthBuffer","_use32BitsDepthBuffer","setOutputDimensions","dimensions","_outputDimensions","setGITextureDimensions","_giTextureDimensions","giTextureType","_giTextureType","textureType","shaderLanguage","_shaderLanguage","giRSM","addGIRSM","rsm","Array","isArray","push","removeGIRSM","i","idx","indexOf","splice","addMaterial","material","_addGISupportToMaterial","_scene","meshes","mesh","getTotalVertices","countersGPU","_counters","disposeGeometryBufferRenderer","_shadersLoaded","_onShaderLoadedObservable","addOnce","_disposePostProcesses","_createPostProcesses","_setPluginParameters","generateSampleTexture","maxSamples","_this$_sampleTexture","_sampleTexture","dispose","_maxSamples","data","Float32Array","xi1","Math","random","xi2","x","sin","PI","y","cos","name","_this$_debugLayer$tex","texture","onBeforeDrawPhaseObservable","remove","_drawPhaseObserver","clear","constructor","scene","outputDimensions","giTextureDimensions","width","height","_blurRTT","_blurPostProcesses","_blurXPostprocess","_blurYPostprocess","_upsamplingXPostprocess","_upsamplingYPostprocess","_ppGlobalIllumination","_firstActivation","_geomBufferEnabled","_geomBufferEnablePosition","_tempMatrix","pause","blurDepthThreshold","blurNormalThreshold","blurKernel","upsamplerKernel","_engine","getEngine","_countersRTW","_initShaderSourceAsync","add","currentRenderTarget","_currentRenderTarget","rebindCurrentRenderTarget","postProcessManager","directRender","inputTexture","unBindFramebuffer","setAlphaMode","renderTarget","rtws","t","_rtws$t$gpuTimeInFram","_rtws$t$gpuTimeInFram2","value","gpuTimeInFrame","counter","lastSecAverage","_rtws$t$gpuTimeInFram3","_rtws$t$gpuTimeInFram4","activeCamera","setViewport","viewport","bindFramebuffer","_this","_asyncToGenerator","engine","isWebGPU","Promise","all","notifyObservers","_this$_blurRTT","_this$_blurXPostproce","_this$_blurYPostproce","_this$_upsamplingXPos","_this$_upsamplingYPos","ppGlobalIllumination","enableGeometryBufferRenderer","geometryBufferRenderer","enablePosition","disableGeometryBufferRenderer","textureGIContrib","outputTextureWidth","outputTextureHeight","_this$_debugLayer$tex2","textureFormat","_this$_scene$geometry","_this$_scene$geometry2","GeometryBufferTextureTypesAndFormats","Error","generateNormalsInWorldSpace","decodeGeometryBufferNormals","normalsAreUnsigned","normalsAreInWorldSpace","getGBuffer","defines","useFullTexture","uniforms","samplers","samplingMode","shareOutputWith","alphaMode","autoClear","externalTextureSamplerBinding","onApplyObservable","effect","setTexture","textures","getTextureIndex","POSITION_TEXTURE_TYPE","NORMAL_TEXTURE_TYPE","positionWorldTexture","normalWorldTexture","fluxTexture","setMatrix","lightTransformationMatrix","setFloat4","numSamples","radius","intensity","edgeArtifactCorrection","noiseFactor","rotateSample","getInternalTexture","copyFrom","getViewMatrix","invert","resize","blurTextureSize","type","format","generateDepthBuffer","wrapU","wrapV","updateSamplingMode","skipInitialClear","blurRTWs","undefined","size","_bindTexture","DEPTH_TEXTURE_TYPE","setInt","setFloat2","setFloat","giFullDimensions","upsamplingRTWs","_material$pluginManag","MaterialGIRSMRenderDefines","arguments","RENDER_WITH_GIRSM","RSMCREATE_PROJTEXTURE","_markAllSubMeshesAsTexturesDirty","_isEnabled","_internalMarkAllSubMeshesAsTexturesDirty","isCompatible","_dirtyCallbacks","_isPBR","prepareDefines","getClassName","getUniforms","ubo","fragment","getSamplers","bindForSubMesh","uniformBuffer","bindTexture","updateFloat2","getCustomCode","shaderType","frag","CUSTOM_FRAGMENT_DEFINITIONS","CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION","prototype"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Rendering/GlobalIllumination/giRSMManager.js"],"sourcesContent":["import { __decorate } from \"../../tslib.es6.js\";\nimport { RawTexture } from \"../../Materials/Textures/rawTexture.js\";\nimport { RenderTargetTexture } from \"../../Materials/Textures/renderTargetTexture.js\";\nimport { PostProcess } from \"../../PostProcesses/postProcess.js\";\nimport { Observable } from \"../../Misc/observable.js\";\nimport { Layer } from \"../../Layers/layer.js\";\nimport { Matrix } from \"../../Maths/math.vector.js\";\n\nimport { MaterialPluginBase } from \"../../Materials/materialPluginBase.js\";\nimport { PBRBaseMaterial } from \"../../Materials/PBR/pbrBaseMaterial.js\";\nimport { GeometryBufferRenderer } from \"../geometryBufferRenderer.js\";\nimport { BaseTexture } from \"../../Materials/Textures/baseTexture.js\";\nimport { expandToProperty, serialize } from \"../../Misc/decorators.js\";\nimport { MaterialDefines } from \"../../Materials/materialDefines.js\";\nimport { RegisterClass } from \"../../Misc/typeStore.js\";\n/**\n * Class used to manage the global illumination contribution calculated from reflective shadow maps (RSM).\n */\nexport class GIRSMManager {\n /**\n * Enables or disables the manager. Default is false.\n * If disabled, the global illumination won't be calculated and the scene will be rendered normally, without any global illumination contribution.\n */\n get enable() {\n return this._enable;\n }\n set enable(enable) {\n if (this._giRSM.length === 0) {\n enable = false;\n }\n if (enable === this._enable) {\n return;\n }\n this._enable = enable;\n this._debugLayer.isEnabled = this._showOnlyGI && enable;\n this._materialsWithRenderPlugin.forEach((mat) => {\n if (mat.pluginManager) {\n const plugin = mat.pluginManager.getPlugin(GIRSMRenderPluginMaterial.Name);\n plugin.isEnabled = enable;\n }\n });\n this.recreateResources(!enable);\n }\n /**\n * Defines if the global illumination contribution should be blurred or not (using a bilateral blur). Default is true.\n */\n get enableBlur() {\n return this._enableBlur;\n }\n set enableBlur(enable) {\n if (enable === this._enableBlur) {\n return;\n }\n this._enableBlur = enable;\n this.recreateResources();\n }\n /**\n * Defines if the blur should be done with a better quality but slower or not. Default is false.\n */\n get useQualityBlur() {\n return this._useQualityBlur;\n }\n set useQualityBlur(enable) {\n if (enable === this._useQualityBlur) {\n return;\n }\n this._useQualityBlur = enable;\n this.recreateResources();\n }\n /**\n * Defines if the blur should be done at full resolution or not. Default is false.\n * If this setting is enabled, upampling will be disabled (ignored) as it is not needed anymore.\n */\n get fullSizeBlur() {\n return this._forceFullSizeBlur;\n }\n set fullSizeBlur(mode) {\n if (this._forceFullSizeBlur === mode) {\n return;\n }\n this._forceFullSizeBlur = mode;\n this.recreateResources();\n }\n /**\n * Defines if the upsampling should be done with a better quality but slower or not. Default is false.\n */\n get useQualityUpsampling() {\n return this._useQualityUpsampling;\n }\n set useQualityUpsampling(enable) {\n if (enable === this._useQualityUpsampling) {\n return;\n }\n this._useQualityUpsampling = enable;\n this.recreateResources();\n }\n /**\n * Defines if the debug layer should be enabled or not. Default is false.\n * Use this setting for debugging purpose, to show the global illumination contribution only.\n */\n get showOnlyGI() {\n return this._showOnlyGI;\n }\n set showOnlyGI(show) {\n if (this._showOnlyGI === show) {\n return;\n }\n this._showOnlyGI = show;\n this._debugLayer.isEnabled = show;\n }\n /**\n * Defines if the depth buffer used by the geometry buffer renderer should be 32 bits or not. Default is false (16 bits).\n */\n get use32BitsDepthBuffer() {\n return this._use32BitsDepthBuffer;\n }\n set use32BitsDepthBuffer(enable) {\n if (this._use32BitsDepthBuffer === enable) {\n return;\n }\n this._use32BitsDepthBuffer = enable;\n this.recreateResources();\n }\n /**\n * Sets the output dimensions of the final process. It should normally be the same as the output dimensions of the screen.\n * @param dimensions The dimensions of the output texture (width and height)\n */\n setOutputDimensions(dimensions) {\n this._outputDimensions = dimensions;\n this.recreateResources();\n }\n /**\n * Sets the dimensions of the GI texture. Try to use the smallest size possible for better performance.\n * @param dimensions The dimensions of the GI texture (width and height)\n */\n setGITextureDimensions(dimensions) {\n this._giTextureDimensions = dimensions;\n this.recreateResources();\n }\n /**\n * Gets or sets the texture type used by the GI texture. Default is 11.\n */\n get giTextureType() {\n return this._giTextureType;\n }\n set giTextureType(textureType) {\n if (this._giTextureType === textureType) {\n return;\n }\n this._giTextureType = textureType;\n this.recreateResources();\n }\n /** Gets the shader language used in this material. */\n get shaderLanguage() {\n return this._shaderLanguage;\n }\n /**\n * Gets the list of GIRSM used by the manager.\n */\n get giRSM() {\n return this._giRSM;\n }\n /**\n * Adds a (list of) GIRSM to the manager.\n * @param rsm The GIRSM (or array of GIRSM) to add to the manager\n */\n addGIRSM(rsm) {\n if (Array.isArray(rsm)) {\n this._giRSM.push(...rsm);\n }\n else {\n this._giRSM.push(rsm);\n }\n this.recreateResources();\n }\n /**\n * Removes a (list of) GIRSM from the manager.\n * @param rsm The GIRSM (or array of GIRSM) to remove from the manager\n */\n removeGIRSM(rsm) {\n if (Array.isArray(rsm)) {\n for (let i = 0; i < rsm.length; ++i) {\n const idx = this._giRSM.indexOf(rsm[i]);\n if (idx !== -1) {\n this._giRSM.splice(idx, 1);\n }\n }\n }\n else {\n const idx = this._giRSM.indexOf(rsm);\n if (idx !== -1) {\n this._giRSM.splice(idx, 1);\n }\n }\n if (this._giRSM.length === 0) {\n this.enable = false;\n }\n else {\n this.recreateResources();\n }\n }\n /**\n * Add a material to the manager. This will enable the global illumination contribution for the material.\n * @param material Material that will be affected by the global illumination contribution. If not provided, all materials of the scene will be affected.\n */\n addMaterial(material) {\n if (material) {\n this._addGISupportToMaterial(material);\n }\n else {\n this._scene.meshes.forEach((mesh) => {\n if (mesh.getTotalVertices() > 0 && mesh.isEnabled() && mesh.material) {\n this._addGISupportToMaterial(mesh.material);\n }\n });\n }\n }\n /**\n * Gets the list of GPU counters used by the manager.\n * GPU timing measurements must be enabled for the counters to be filled (engine.enableGPUTimingMeasurements = true).\n * Only available with WebGPU. You will still get the list of counters with other engines but the values will always be 0.\n */\n get countersGPU() {\n return this._counters;\n }\n /**\n * Recreates the resources used by the manager.\n * You should normally not have to call this method manually, except if you change the useFullTexture property of a GIRSM, because the manager won't track this change.\n * @param disposeGeometryBufferRenderer Defines if the geometry buffer renderer should be disposed and recreated. Default is false.\n */\n recreateResources(disposeGeometryBufferRenderer = false) {\n if (!this._shadersLoaded) {\n this._onShaderLoadedObservable.addOnce(() => {\n this.recreateResources(disposeGeometryBufferRenderer);\n });\n return;\n }\n this._disposePostProcesses(disposeGeometryBufferRenderer);\n this._createPostProcesses();\n this._setPluginParameters();\n }\n /**\n * Generates the sample texture used by the the global illumination calculation process.\n * @param maxSamples The maximum number of samples to generate in the texture. Default value is 2048. The numSamples property of the GIRSM should be less than or equal to this value!\n */\n generateSampleTexture(maxSamples) {\n this._sampleTexture?.dispose();\n this._maxSamples = maxSamples;\n const data = new Float32Array(this._maxSamples * 4);\n for (let i = 0; i < this._maxSamples; i++) {\n const xi1 = Math.random();\n const xi2 = Math.random();\n const x = xi1 * Math.sin(2 * Math.PI * xi2);\n const y = xi1 * Math.cos(2 * Math.PI * xi2);\n data[i * 4 + 0] = x;\n data[i * 4 + 1] = y;\n data[i * 4 + 2] = xi1 * xi1;\n data[i * 4 + 3] = 1;\n }\n this._sampleTexture = new RawTexture(data, this._maxSamples, 1, 5, this._scene, false, false, 1, 1);\n this._sampleTexture.name = \"GIRSMSamples\";\n }\n /**\n * Disposes the manager.\n */\n dispose() {\n this._disposePostProcesses(true);\n this._debugLayer.texture?.dispose();\n this._debugLayer.dispose();\n this._scene.onBeforeDrawPhaseObservable.remove(this._drawPhaseObserver);\n this._onShaderLoadedObservable.clear();\n }\n /**\n * Creates a new GIRSMManager\n * @param scene The scene\n * @param outputDimensions The dimensions of the output texture (width and height). Should normally be the same as the output dimensions of the screen.\n * @param giTextureDimensions The dimensions of the GI texture (width and height). Try to use the smallest size possible for better performance.\n * @param maxSamples The maximum number of samples to generate in the sample texture. Default value is 2048. The numSamples property of the GIRSM should be less than or equal to this value!\n * @param giTextureType The texture type used by the GI texture. Default is 11.\n */\n constructor(scene, outputDimensions, giTextureDimensions = { width: 256, height: 256 }, maxSamples = 2048, giTextureType = 11) {\n this._giRSM = [];\n this._blurRTT = null;\n this._blurPostProcesses = null;\n this._blurXPostprocess = null;\n this._blurYPostprocess = null;\n this._upsamplingXPostprocess = null;\n this._upsamplingYPostprocess = null;\n this._ppGlobalIllumination = [];\n this._firstActivation = true;\n this._geomBufferEnabled = false;\n this._geomBufferEnablePosition = false;\n this._tempMatrix = new Matrix();\n this._enable = false;\n /**\n * Defines if the global illumination calculation is paused or not.\n * Use this setting to pause the global illumination calculation when you know that the scene (camera/mesh/light positions) is not changing anymore to save some GPU power.\n * The scene will still be rendered with the latest global illumination contribution.\n */\n this.pause = false;\n this._enableBlur = true;\n this._useQualityBlur = false;\n /**\n * Defines the depth threshold used by the bilateral blur post-processes (also used by the upsampling, if enabled).\n * You may have to change this value, depending on your scene.\n */\n this.blurDepthThreshold = 0.05;\n /**\n * Defines the normal threshold used by the bilateral blur post-processes (also used by the upsampling, if enabled).\n * You may have to change this value, depending on your scene.\n */\n this.blurNormalThreshold = 0.25;\n /**\n * Defines the kernel size used by the bilateral blur post-processes. Default is 12.\n */\n this.blurKernel = 12;\n this._forceFullSizeBlur = false;\n this._useQualityUpsampling = false;\n /**\n * Defines the kernel size used by the bilateral upsampling post-processes. Default is 6.\n */\n this.upsamplerKernel = 6;\n this._showOnlyGI = false;\n this._use32BitsDepthBuffer = false;\n /** Shader language used by the material */\n this._shaderLanguage = 0 /* ShaderLanguage.GLSL */;\n this._shadersLoaded = false;\n this._onShaderLoadedObservable = new Observable();\n this._scene = scene;\n this._engine = scene.getEngine();\n this._outputDimensions = outputDimensions;\n this._giTextureDimensions = giTextureDimensions;\n this._giTextureType = giTextureType;\n this._materialsWithRenderPlugin = [];\n this._maxSamples = maxSamples;\n this._debugLayer = new Layer(\"debug layer\", null, this._scene, false);\n this._debugLayer.isEnabled = false;\n this._counters = [];\n this._countersRTW = [];\n this._initShaderSourceAsync();\n this.generateSampleTexture(maxSamples);\n this._drawPhaseObserver = this._scene.onBeforeDrawPhaseObservable.add(() => {\n const currentRenderTarget = this._engine._currentRenderTarget;\n let rebindCurrentRenderTarget = false;\n if (this._enable) {\n if (!this.pause) {\n this._scene.postProcessManager.directRender(this._ppGlobalIllumination, this._ppGlobalIllumination[0].inputTexture);\n this._engine.unBindFramebuffer(this._ppGlobalIllumination[0].inputTexture, true);\n this._engine.setAlphaMode(0);\n rebindCurrentRenderTarget = true;\n if (this.enableBlur && this._blurPostProcesses) {\n this._scene.postProcessManager.directRender(this._blurPostProcesses, this._blurRTT.renderTarget, true);\n this._engine.unBindFramebuffer(this._blurRTT.renderTarget, true);\n }\n }\n for (let i = 0; i < this._counters.length; ++i) {\n const rtws = this._countersRTW[i];\n for (let t = 0; t < rtws.length; ++t) {\n if (t === 0) {\n this._counters[i].value = this.pause ? 0 : (rtws[t].gpuTimeInFrame?.counter.lastSecAverage ?? 0);\n }\n else if (!this.pause) {\n this._counters[i].value += rtws[t].gpuTimeInFrame?.counter.lastSecAverage ?? 0;\n }\n }\n }\n if (this._scene.activeCamera) {\n this._engine.setViewport(this._scene.activeCamera.viewport);\n }\n }\n if (rebindCurrentRenderTarget && currentRenderTarget) {\n this._engine.bindFramebuffer(currentRenderTarget);\n }\n });\n }\n async _initShaderSourceAsync() {\n const engine = this._engine;\n if (engine.isWebGPU) {\n this._shaderLanguage = 1 /* ShaderLanguage.WGSL */;\n await Promise.all([\n import(\"../../ShadersWGSL/bilateralBlur.fragment.js\"),\n import(\"../../ShadersWGSL/bilateralBlurQuality.fragment.js\"),\n import(\"../../ShadersWGSL/rsmGlobalIllumination.fragment.js\"),\n import(\"../../ShadersWGSL/rsmFullGlobalIllumination.fragment.js\"),\n ]);\n }\n else {\n await Promise.all([\n import(\"../../Shaders/bilateralBlur.fragment.js\"),\n import(\"../../Shaders/bilateralBlurQuality.fragment.js\"),\n import(\"../../Shaders/rsmGlobalIllumination.fragment.js\"),\n import(\"../../Shaders/rsmFullGlobalIllumination.fragment.js\"),\n ]);\n }\n this._shadersLoaded = true;\n this._onShaderLoadedObservable.notifyObservers();\n }\n _disposePostProcesses(disposeGeometryBufferRenderer = false) {\n this._blurRTT?.dispose();\n this._blurRTT = null;\n this._blurPostProcesses = [];\n this._blurXPostprocess?.dispose();\n this._blurXPostprocess = null;\n this._blurYPostprocess?.dispose();\n this._blurYPostprocess = null;\n this._upsamplingXPostprocess?.dispose();\n this._upsamplingXPostprocess = null;\n this._upsamplingYPostprocess?.dispose();\n this._upsamplingYPostprocess = null;\n for (const ppGlobalIllumination of this._ppGlobalIllumination) {\n ppGlobalIllumination.dispose();\n }\n this._ppGlobalIllumination = [];\n if (disposeGeometryBufferRenderer) {\n if (this._geomBufferEnabled) {\n this._scene.enableGeometryBufferRenderer();\n this._scene.geometryBufferRenderer.enablePosition = this._geomBufferEnablePosition;\n }\n else {\n this._scene.disableGeometryBufferRenderer();\n }\n }\n this._counters = [];\n this._countersRTW = [];\n }\n _setPluginParameters() {\n if (!this._enable) {\n return;\n }\n this._materialsWithRenderPlugin.forEach((mat) => {\n if (mat.pluginManager) {\n const plugin = mat.pluginManager.getPlugin(GIRSMRenderPluginMaterial.Name);\n plugin.textureGIContrib = this.enableBlur ? this._blurRTT.renderTarget.texture : this._ppGlobalIllumination[0].inputTexture.texture;\n plugin.outputTextureWidth = this._outputDimensions.width;\n plugin.outputTextureHeight = this._outputDimensions.height;\n }\n });\n }\n _createPostProcesses() {\n if (!this._enable) {\n return;\n }\n const textureFormat = this._giTextureType === 13 ? 4 : 5;\n if (this._firstActivation) {\n this._firstActivation = false;\n this._geomBufferEnabled = !!this._scene.geometryBufferRenderer;\n this._geomBufferEnablePosition = this._scene.geometryBufferRenderer?.enablePosition ?? false;\n }\n if (!this._geomBufferEnabled) {\n this._scene.disableGeometryBufferRenderer();\n }\n const geometryBufferRenderer = this._scene.enableGeometryBufferRenderer(this._enableBlur ? this._outputDimensions : this._giTextureDimensions, this._use32BitsDepthBuffer ? 14 : 15, GIRSMManager.GeometryBufferTextureTypesAndFormats);\n if (!geometryBufferRenderer) {\n throw new Error(\"Geometry buffer renderer is not supported but is required for GIRSMManager.\");\n }\n geometryBufferRenderer.enablePosition = true;\n if (!this._geomBufferEnabled) {\n geometryBufferRenderer.generateNormalsInWorldSpace = true;\n }\n const decodeGeometryBufferNormals = geometryBufferRenderer.normalsAreUnsigned;\n const normalsAreInWorldSpace = geometryBufferRenderer.generateNormalsInWorldSpace;\n this._counters.push({ name: \"Geometry buffer renderer\", value: 0 });\n this._countersRTW.push([this._scene.geometryBufferRenderer.getGBuffer().renderTarget]);\n let defines = \"\";\n if (decodeGeometryBufferNormals) {\n defines += \"#define DECODE_NORMAL\\n\";\n }\n if (!normalsAreInWorldSpace) {\n defines += \"#define TRANSFORM_NORMAL\\n\";\n }\n for (let i = 0; i < this._giRSM.length; ++i) {\n const giRSM = this._giRSM[i];\n const rsm = giRSM.rsm;\n const ppGlobalIllumination = new PostProcess(\"RSMGlobalIllumination\" + i, giRSM.useFullTexture ? \"rsmFullGlobalIllumination\" : \"rsmGlobalIllumination\", {\n ...this._giTextureDimensions,\n uniforms: [\"rsmLightMatrix\", \"rsmInfo\", \"rsmInfo2\", \"invView\"],\n samplers: [\"normalSampler\", \"rsmPositionW\", \"rsmNormalW\", \"rsmFlux\", \"rsmSamples\"],\n defines,\n samplingMode: 2,\n engine: this._engine,\n textureType: this._giTextureType,\n textureFormat,\n shaderLanguage: this._shaderLanguage,\n });\n this._ppGlobalIllumination.push(ppGlobalIllumination);\n if (i !== 0) {\n ppGlobalIllumination.shareOutputWith(this._ppGlobalIllumination[0]);\n ppGlobalIllumination.alphaMode = 1;\n }\n ppGlobalIllumination.autoClear = false;\n ppGlobalIllumination.externalTextureSamplerBinding = true;\n ppGlobalIllumination.onApplyObservable.add((effect) => {\n effect.setTexture(\"textureSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.POSITION_TEXTURE_TYPE)]);\n effect.setTexture(\"normalSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE)]);\n effect.setTexture(\"rsmPositionW\", rsm.positionWorldTexture);\n effect.setTexture(\"rsmNormalW\", rsm.normalWorldTexture);\n effect.setTexture(\"rsmFlux\", rsm.fluxTexture);\n effect.setMatrix(\"rsmLightMatrix\", rsm.lightTransformationMatrix);\n if (!giRSM.useFullTexture) {\n effect.setTexture(\"rsmSamples\", this._sampleTexture);\n effect.setFloat4(\"rsmInfo\", giRSM.numSamples, giRSM.radius, giRSM.intensity, giRSM.edgeArtifactCorrection);\n effect.setFloat4(\"rsmInfo2\", giRSM.noiseFactor, giRSM.rotateSample ? 1 : 0, rsm.fluxTexture.getInternalTexture().width, rsm.fluxTexture.getInternalTexture().height);\n }\n else {\n effect.setFloat4(\"rsmInfo\", rsm.fluxTexture.getInternalTexture().width, rsm.fluxTexture.getInternalTexture().height, giRSM.intensity, giRSM.edgeArtifactCorrection);\n }\n if (!normalsAreInWorldSpace) {\n this._tempMatrix.copyFrom(this._scene.activeCamera.getViewMatrix());\n this._tempMatrix.invert();\n effect.setMatrix(\"invView\", this._tempMatrix);\n }\n });\n }\n for (const ppGlobalIllumination of this._ppGlobalIllumination) {\n if (!ppGlobalIllumination.inputTexture) {\n ppGlobalIllumination.resize(this._giTextureDimensions.width, this._giTextureDimensions.height);\n }\n }\n this._counters.push({ name: \"GI generation\", value: 0 });\n this._countersRTW.push([this._ppGlobalIllumination[0].inputTexture]);\n if (this._enableBlur) {\n const blurTextureSize = this._forceFullSizeBlur ? this._outputDimensions : this._giTextureDimensions;\n this._blurRTT = new RenderTargetTexture(\"GIRSMContribution\", this._outputDimensions, this._scene, {\n type: this._giTextureType,\n format: textureFormat,\n generateDepthBuffer: false,\n });\n this._blurRTT.wrapU = 0;\n this._blurRTT.wrapV = 0;\n this._blurRTT.updateSamplingMode(1);\n this._blurRTT.skipInitialClear = true;\n const blurRTWs = [];\n this._counters.push({ name: \"GI blur\", value: 0 });\n this._countersRTW.push(blurRTWs);\n // Bilateral blur\n this._blurXPostprocess = new PostProcess(this._useQualityBlur ? \"BilateralBlur\" : \"BilateralBlurX\", this._useQualityBlur ? \"bilateralBlurQuality\" : \"bilateralBlur\", {\n uniforms: [\"filterSize\", \"blurDir\", \"depthThreshold\", \"normalThreshold\"],\n samplers: [\"depthSampler\", \"normalSampler\"],\n defines: decodeGeometryBufferNormals ? \"#define DECODE_NORMAL\" : undefined,\n size: blurTextureSize,\n samplingMode: 2,\n engine: this._engine,\n textureType: this._giTextureType,\n textureFormat,\n shaderLanguage: this._shaderLanguage,\n });\n this._blurXPostprocess.onApplyObservable.add((effect) => {\n effect._bindTexture(\"textureSampler\", this._ppGlobalIllumination[0].inputTexture.texture);\n effect.setTexture(\"depthSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.DEPTH_TEXTURE_TYPE)]);\n effect.setTexture(\"normalSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE)]);\n effect.setInt(\"filterSize\", this.blurKernel);\n effect.setFloat2(\"blurDir\", 1 / this._giTextureDimensions.width, this._useQualityBlur ? 1 / this._giTextureDimensions.height : 0);\n effect.setFloat(\"depthThreshold\", this.blurDepthThreshold);\n effect.setFloat(\"normalThreshold\", this.blurNormalThreshold);\n });\n this._blurXPostprocess.externalTextureSamplerBinding = true;\n this._blurXPostprocess.autoClear = false;\n if (!this._useQualityBlur) {\n this._blurYPostprocess = new PostProcess(\"BilateralBlurY\", \"bilateralBlur\", {\n uniforms: [\"filterSize\", \"blurDir\", \"depthThreshold\", \"normalThreshold\"],\n samplers: [\"depthSampler\", \"normalSampler\"],\n defines: decodeGeometryBufferNormals ? \"#define DECODE_NORMAL\" : undefined,\n size: blurTextureSize,\n samplingMode: 2,\n engine: this._engine,\n textureType: this._giTextureType,\n textureFormat,\n shaderLanguage: this._shaderLanguage,\n });\n this._blurYPostprocess.autoClear = false;\n this._blurYPostprocess.onApplyObservable.add((effect) => {\n effect.setTexture(\"depthSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.DEPTH_TEXTURE_TYPE)]);\n effect.setTexture(\"normalSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE)]);\n effect.setInt(\"filterSize\", this.blurKernel);\n effect.setFloat2(\"blurDir\", 0, 1 / this._giTextureDimensions.height);\n effect.setFloat(\"depthThreshold\", this.blurDepthThreshold);\n effect.setFloat(\"normalThreshold\", this.blurNormalThreshold);\n });\n this._blurYPostprocess.resize(blurTextureSize.width, blurTextureSize.height);\n blurRTWs.push(this._blurYPostprocess.inputTexture);\n }\n this._blurPostProcesses = [this._blurXPostprocess];\n if (this._blurYPostprocess) {\n this._blurPostProcesses.push(this._blurYPostprocess);\n }\n // Bilateral upsampling\n const giFullDimensions = this._giTextureDimensions.width >= this._outputDimensions.width && this._giTextureDimensions.height >= this._outputDimensions.height;\n if (!giFullDimensions && !this._forceFullSizeBlur) {\n const upsamplingRTWs = [];\n this._counters.push({ name: \"GI upsampling\", value: 0 });\n this._countersRTW.push(upsamplingRTWs);\n this._upsamplingXPostprocess = new PostProcess(this._useQualityUpsampling ? \"BilateralUpsampling\" : \"BilateralUpsamplingX\", this._useQualityUpsampling ? \"bilateralBlurQuality\" : \"bilateralBlur\", {\n uniforms: [\"filterSize\", \"blurDir\", \"depthThreshold\", \"normalThreshold\"],\n samplers: [\"depthSampler\", \"normalSampler\"],\n defines: decodeGeometryBufferNormals ? \"#define DECODE_NORMAL\" : undefined,\n size: blurTextureSize,\n samplingMode: 2,\n engine: this._engine,\n textureType: this._giTextureType,\n textureFormat,\n shaderLanguage: this._shaderLanguage,\n });\n this._upsamplingXPostprocess.autoClear = false;\n this._upsamplingXPostprocess.onApplyObservable.add((effect) => {\n effect.setTexture(\"depthSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.DEPTH_TEXTURE_TYPE)]);\n effect.setTexture(\"normalSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE)]);\n effect.setInt(\"filterSize\", this.upsamplerKernel);\n effect.setFloat2(\"blurDir\", 1 / this._outputDimensions.width, this._useQualityUpsampling ? 1 / this._outputDimensions.height : 0);\n effect.setFloat(\"depthThreshold\", this.blurDepthThreshold);\n effect.setFloat(\"normalThreshold\", this.blurNormalThreshold);\n });\n this._upsamplingXPostprocess.resize(blurTextureSize.width, blurTextureSize.height);\n blurRTWs.push(this._upsamplingXPostprocess.inputTexture);\n if (!this.useQualityUpsampling) {\n this._upsamplingYPostprocess = new PostProcess(\"BilateralUpsamplingY\", \"bilateralBlur\", {\n uniforms: [\"filterSize\", \"blurDir\", \"depthThreshold\", \"normalThreshold\"],\n samplers: [\"depthSampler\", \"normalSampler\"],\n defines: decodeGeometryBufferNormals ? \"#define DECODE_NORMAL\" : undefined,\n size: this._outputDimensions,\n samplingMode: 2,\n engine: this._engine,\n textureType: this._giTextureType,\n textureFormat,\n shaderLanguage: this._shaderLanguage,\n });\n this._upsamplingYPostprocess.autoClear = false;\n this._upsamplingYPostprocess.onApplyObservable.add((effect) => {\n effect.setTexture(\"depthSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.DEPTH_TEXTURE_TYPE)]);\n effect.setTexture(\"normalSampler\", geometryBufferRenderer.getGBuffer().textures[geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE)]);\n effect.setInt(\"filterSize\", this.upsamplerKernel);\n effect.setFloat2(\"blurDir\", 0, 1 / this._outputDimensions.height);\n effect.setFloat(\"depthThreshold\", this.blurDepthThreshold);\n effect.setFloat(\"normalThreshold\", this.blurNormalThreshold);\n });\n this._upsamplingYPostprocess.resize(this._outputDimensions.width, this._outputDimensions.height);\n upsamplingRTWs.push(this._upsamplingYPostprocess.inputTexture);\n }\n upsamplingRTWs.push(this._blurRTT.renderTarget);\n this._blurPostProcesses.push(this._upsamplingXPostprocess);\n if (this._upsamplingYPostprocess) {\n this._blurPostProcesses.push(this._upsamplingYPostprocess);\n }\n }\n else {\n blurRTWs.push(this._blurRTT.renderTarget);\n }\n }\n this._debugLayer.texture?.dispose();\n this._debugLayer.texture = new BaseTexture(this._scene, this._enableBlur ? this._blurRTT.renderTarget.texture : this._ppGlobalIllumination[0].inputTexture.texture);\n }\n _addGISupportToMaterial(material) {\n if (material.pluginManager?.getPlugin(GIRSMRenderPluginMaterial.Name)) {\n return;\n }\n const plugin = new GIRSMRenderPluginMaterial(material);\n if (this._enable && this._ppGlobalIllumination.length > 0) {\n plugin.textureGIContrib = this._ppGlobalIllumination[0].inputTexture.texture;\n plugin.outputTextureWidth = this._outputDimensions.width;\n plugin.outputTextureHeight = this._outputDimensions.height;\n }\n plugin.isEnabled = this._enable;\n this._materialsWithRenderPlugin.push(material);\n }\n}\n/**\n * Defines the default texture types and formats used by the geometry buffer renderer.\n */\nGIRSMManager.GeometryBufferTextureTypesAndFormats = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n 0: { textureType: 2, textureFormat: 6 }, // depth\n // eslint-disable-next-line @typescript-eslint/naming-convention\n 1: { textureType: 11, textureFormat: 5 }, // normal\n // eslint-disable-next-line @typescript-eslint/naming-convention\n 2: { textureType: 2, textureFormat: 5 }, // position\n};\n/**\n * @internal\n */\nclass MaterialGIRSMRenderDefines extends MaterialDefines {\n constructor() {\n super(...arguments);\n this.RENDER_WITH_GIRSM = false;\n this.RSMCREATE_PROJTEXTURE = false;\n }\n}\n/**\n * Plugin used to render the global illumination contribution.\n */\nexport class GIRSMRenderPluginMaterial extends MaterialPluginBase {\n _markAllSubMeshesAsTexturesDirty() {\n this._enable(this._isEnabled);\n this._internalMarkAllSubMeshesAsTexturesDirty();\n }\n /**\n * Gets a boolean indicating that the plugin is compatible with a give shader language.\n * @returns true if the plugin is compatible with the shader language\n */\n isCompatible() {\n return true;\n }\n constructor(material) {\n super(material, GIRSMRenderPluginMaterial.Name, 310, new MaterialGIRSMRenderDefines());\n this._isEnabled = false;\n /**\n * Defines if the plugin is enabled in the material.\n */\n this.isEnabled = false;\n this._internalMarkAllSubMeshesAsTexturesDirty = material._dirtyCallbacks[1];\n this._isPBR = material instanceof PBRBaseMaterial;\n }\n prepareDefines(defines) {\n defines.RENDER_WITH_GIRSM = this._isEnabled;\n }\n getClassName() {\n return \"GIRSMRenderPluginMaterial\";\n }\n getUniforms() {\n return {\n ubo: [{ name: \"girsmTextureOutputSize\", size: 2, type: \"vec2\" }],\n fragment: `#ifdef RENDER_WITH_GIRSM\r\n uniform vec2 girsmTextureOutputSize;\r\n #endif`,\n };\n }\n getSamplers(samplers) {\n samplers.push(\"girsmTextureGIContrib\");\n }\n bindForSubMesh(uniformBuffer) {\n if (this._isEnabled) {\n uniformBuffer.bindTexture(\"girsmTextureGIContrib\", this.textureGIContrib);\n uniformBuffer.updateFloat2(\"girsmTextureOutputSize\", this.outputTextureWidth, this.outputTextureHeight);\n }\n }\n getCustomCode(shaderType, shaderLanguage) {\n let frag;\n if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n frag = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n CUSTOM_FRAGMENT_DEFINITIONS: `\r\n #ifdef RENDER_WITH_GIRSM\r\n var girsmTextureGIContribSampler: sampler;\r\n var girsmTextureGIContrib: texture_2d<f32>;\r\n\r\n fn computeIndirect() -> vec3f {\r\n var uv = fragmentInputs.position.xy / uniforms.girsmTextureOutputSize;\r\n return textureSample(girsmTextureGIContrib, girsmTextureGIContribSampler, uv).rgb;\r\n }\r\n #endif\r\n `,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION: `\r\n #ifdef RENDER_WITH_GIRSM\r\n finalDiffuse += computeIndirect() * surfaceAlbedo.rgb;\r\n #endif\r\n `,\n };\n if (!this._isPBR) {\n frag[\"CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\"] = `\r\n #ifdef RENDER_WITH_GIRSM\r\n color = vec4f(color.rgb + computeIndirect() * baseColor.rgb, color.a);\r\n #endif\r\n `;\n }\n }\n else {\n frag = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n CUSTOM_FRAGMENT_DEFINITIONS: `\r\n #ifdef RENDER_WITH_GIRSM\r\n uniform sampler2D girsmTextureGIContrib;\r\n\r\n vec3 computeIndirect() {\r\n vec2 uv = gl_FragCoord.xy / girsmTextureOutputSize;\r\n return texture2D(girsmTextureGIContrib, uv).rgb;\r\n }\r\n #endif\r\n `,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION: `\r\n #ifdef RENDER_WITH_GIRSM\r\n finalDiffuse += computeIndirect() * surfaceAlbedo.rgb;\r\n #endif\r\n `,\n };\n if (!this._isPBR) {\n frag[\"CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\"] = `\r\n #ifdef RENDER_WITH_GIRSM\r\n color.rgb += computeIndirect() * baseColor.rgb;\r\n #endif\r\n `;\n }\n }\n return shaderType === \"vertex\" ? null : frag;\n }\n}\n/**\n * Defines the name of the plugin.\n */\nGIRSMRenderPluginMaterial.Name = \"GIRSMRender\";\n__decorate([\n serialize()\n], GIRSMRenderPluginMaterial.prototype, \"textureGIContrib\", void 0);\n__decorate([\n serialize()\n], GIRSMRenderPluginMaterial.prototype, \"outputTextureWidth\", void 0);\n__decorate([\n serialize()\n], GIRSMRenderPluginMaterial.prototype, \"outputTextureHeight\", void 0);\n__decorate([\n serialize(),\n expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\n], GIRSMRenderPluginMaterial.prototype, \"isEnabled\", void 0);\nRegisterClass(`BABYLON.GIRSMRenderPluginMaterial`, GIRSMRenderPluginMaterial);\n"],"mappings":";AAAA,SAASA,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,UAAU,QAAQ,wCAAwC;AACnE,SAASC,mBAAmB,QAAQ,iDAAiD;AACrF,SAASC,WAAW,QAAQ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QACH;QACAC,2BAA2B,EAAE;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;QACG;QACAC,4CAA4C,EAAE;AAC9D;AACA;AACA;AACA;MACY,CAAC;MACD,IAAI,CAAC,IAAI,CAACf,MAAM,EAAE;QACda,IAAI,CAAC,kCAAkC,CAAC,GAAG;AAC3D;AACA;AACA;AACA,aAAa;MACD;IACJ;IACA,OAAOD,UAAU,KAAK,QAAQ,GAAG,IAAI,GAAGC,IAAI;EAChD;AACJ;AACA;AACA;AACA;AACAxO,yBAAyB,CAACC,IAAI,GAAG,aAAa;AAC9C9B,UAAU,CAAC,CACPY,SAAS,CAAC,CAAC,CACd,EAAEiB,yBAAyB,CAAC2O,SAAS,EAAE,kBAAkB,EAAE,KAAK,CAAC,CAAC;AACnExQ,UAAU,CAAC,CACPY,SAAS,CAAC,CAAC,CACd,EAAEiB,yBAAyB,CAAC2O,SAAS,EAAE,oBAAoB,EAAE,KAAK,CAAC,CAAC;AACrExQ,UAAU,CAAC,CACPY,SAAS,CAAC,CAAC,CACd,EAAEiB,yBAAyB,CAAC2O,SAAS,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAC;AACtExQ,UAAU,CAAC,CACPY,SAAS,CAAC,CAAC,EACXD,gBAAgB,CAAC,kCAAkC,CAAC,CACvD,EAAEkB,yBAAyB,CAAC2O,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;AAC5D1P,aAAa,CAAC,mCAAmC,EAAEe,yBAAyB,CAAC","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}
|