@onerjs/core 8.44.8 → 8.45.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/Engines/WebGPU/webgpuShaderProcessingContext.d.ts +1 -0
  2. package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
  3. package/Engines/WebGPU/webgpuShaderProcessor.d.ts +1 -1
  4. package/Engines/WebGPU/webgpuShaderProcessor.js +2 -2
  5. package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
  6. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +20 -2
  7. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  8. package/Engines/engine.d.ts +25 -0
  9. package/Engines/engineCapabilities.d.ts +2 -0
  10. package/Engines/engineCapabilities.js.map +1 -1
  11. package/Engines/nullEngine.js +1 -0
  12. package/Engines/nullEngine.js.map +1 -1
  13. package/Engines/thinEngine.js +3 -0
  14. package/Engines/thinEngine.js.map +1 -1
  15. package/Engines/thinNativeEngine.js +1 -0
  16. package/Engines/thinNativeEngine.js.map +1 -1
  17. package/Engines/webgpuEngine.js +1 -0
  18. package/Engines/webgpuEngine.js.map +1 -1
  19. package/Gizmos/boundingBoxGizmo.d.ts +2 -0
  20. package/Gizmos/boundingBoxGizmo.js +56 -7
  21. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  22. package/Layers/thinEffectLayer.js +1 -2
  23. package/Layers/thinEffectLayer.js.map +1 -1
  24. package/Materials/Textures/renderTargetTexture.d.ts +2 -2
  25. package/Materials/Textures/renderTargetTexture.js +2 -2
  26. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  27. package/Misc/stringTools.js +20 -14
  28. package/Misc/stringTools.js.map +1 -1
  29. package/Misc/thinMinMaxReducer.js +4 -3
  30. package/Misc/thinMinMaxReducer.js.map +1 -1
  31. package/PostProcesses/thinAnaglyphPostProcess.js +2 -2
  32. package/PostProcesses/thinAnaglyphPostProcess.js.map +1 -1
  33. package/PostProcesses/thinBlackAndWhitePostProcess.js +2 -2
  34. package/PostProcesses/thinBlackAndWhitePostProcess.js.map +1 -1
  35. package/PostProcesses/thinBloomMergePostProcess.js +2 -2
  36. package/PostProcesses/thinBloomMergePostProcess.js.map +1 -1
  37. package/PostProcesses/thinBlurPostProcess.js +2 -2
  38. package/PostProcesses/thinBlurPostProcess.js.map +1 -1
  39. package/PostProcesses/thinChromaticAberrationPostProcess.js +2 -2
  40. package/PostProcesses/thinChromaticAberrationPostProcess.js.map +1 -1
  41. package/PostProcesses/thinCircleOfConfusionPostProcess.js +2 -2
  42. package/PostProcesses/thinCircleOfConfusionPostProcess.js.map +1 -1
  43. package/PostProcesses/thinConvolutionPostProcess.js +2 -2
  44. package/PostProcesses/thinConvolutionPostProcess.js.map +1 -1
  45. package/PostProcesses/thinCustomPostProcess.js +2 -2
  46. package/PostProcesses/thinCustomPostProcess.js.map +1 -1
  47. package/PostProcesses/thinDepthOfFieldMergePostProcess.js +2 -2
  48. package/PostProcesses/thinDepthOfFieldMergePostProcess.js.map +1 -1
  49. package/PostProcesses/thinExtractHighlightsPostProcess.js +2 -2
  50. package/PostProcesses/thinExtractHighlightsPostProcess.js.map +1 -1
  51. package/PostProcesses/thinFXAAPostProcess.js +2 -2
  52. package/PostProcesses/thinFXAAPostProcess.js.map +1 -1
  53. package/PostProcesses/thinFilterPostProcess.js +2 -2
  54. package/PostProcesses/thinFilterPostProcess.js.map +1 -1
  55. package/PostProcesses/thinGrainPostProcess.js +2 -2
  56. package/PostProcesses/thinGrainPostProcess.js.map +1 -1
  57. package/PostProcesses/thinImageProcessingPostProcess.js +1 -2
  58. package/PostProcesses/thinImageProcessingPostProcess.js.map +1 -1
  59. package/PostProcesses/thinPassPostProcess.js +4 -4
  60. package/PostProcesses/thinPassPostProcess.js.map +1 -1
  61. package/PostProcesses/thinSSAO2BlurPostProcess.js +2 -2
  62. package/PostProcesses/thinSSAO2BlurPostProcess.js.map +1 -1
  63. package/PostProcesses/thinSSAO2CombinePostProcess.js +2 -2
  64. package/PostProcesses/thinSSAO2CombinePostProcess.js.map +1 -1
  65. package/PostProcesses/thinSSRBlurCombinerPostProcess.js +2 -2
  66. package/PostProcesses/thinSSRBlurCombinerPostProcess.js.map +1 -1
  67. package/PostProcesses/thinSSRBlurPostProcess.js +2 -2
  68. package/PostProcesses/thinSSRBlurPostProcess.js.map +1 -1
  69. package/PostProcesses/thinScreenSpaceCurvaturePostProcess.js +2 -2
  70. package/PostProcesses/thinScreenSpaceCurvaturePostProcess.js.map +1 -1
  71. package/PostProcesses/thinSharpenPostProcess.js +2 -2
  72. package/PostProcesses/thinSharpenPostProcess.js.map +1 -1
  73. package/PostProcesses/thinTonemapPostProcess.js +2 -2
  74. package/PostProcesses/thinTonemapPostProcess.js.map +1 -1
  75. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -3
  76. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  77. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +1 -2
  78. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  79. package/Rendering/iblCdfGenerator.js +1 -2
  80. package/Rendering/iblCdfGenerator.js.map +1 -1
  81. package/Rendering/objectRenderer.d.ts +8 -2
  82. package/Rendering/objectRenderer.js +8 -2
  83. package/Rendering/objectRenderer.js.map +1 -1
  84. package/XR/features/WebXRControllerPointerSelection.d.ts +25 -0
  85. package/XR/features/WebXRControllerPointerSelection.js +76 -0
  86. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  87. package/XR/features/WebXRControllerTeleportation.d.ts +13 -0
  88. package/XR/features/WebXRControllerTeleportation.js +38 -11
  89. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  90. package/package.json +1 -1
  91. package/scene.js +6 -0
  92. package/scene.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"iblShadowsVoxelRenderer.js","sourceRoot":"","sources":["../../../../../dev/core/src/R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} from \"../../Engines/constants\";\r\nimport { Engine } from \"../../Engines/engine\";\r\nimport { ShaderMaterial } from \"../../Materials/shaderMaterial\";\r\nimport { MultiRenderTarget } from \"../../Materials/Textures/multiRenderTarget\";\r\nimport { RenderTargetTexture } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport type { RenderTargetTextureOptions } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport type { TextureSize } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport { Color4 } from \"../../Maths/math.color\";\r\nimport { Matrix, Vector3, Vector4 } from \"../../Maths/math.vector\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../../PostProcesses/postProcess\";\r\nimport { ProceduralTexture } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../../Materials/effectRenderer\";\r\nimport type { IblShadowsRenderPipeline } from \"./iblShadowsRenderPipeline\";\r\nimport type { RenderTargetWrapper } from \"core/Engines\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Voxel-based shadow rendering for IBL's.\r\n * This should not be instanciated directly, as it is part of a scene component\r\n * @internal\r\n * @see https://playground.babylonjs.com/#8R5SSE#222\r\n */\r\nexport class _IblShadowsVoxelRenderer {\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n\r\n // WebGPU, single-pass voxelization.\r\n // See https://playground.babylonjs.com/#XSNYAU#133\r\n private _voxelGrid: RenderTargetTexture;\r\n private _voxelGridRT: RenderTargetTexture;\r\n\r\n // WebGL voxelization, including tri-planar voxelization.\r\n private _combinedVoxelGridPT: ProceduralTexture;\r\n private _voxelGridXaxis: RenderTargetTexture;\r\n private _voxelGridYaxis: RenderTargetTexture;\r\n private _voxelGridZaxis: RenderTargetTexture;\r\n private _voxelMrtsXaxis: MultiRenderTarget[] = [];\r\n private _voxelMrtsYaxis: MultiRenderTarget[] = [];\r\n private _voxelMrtsZaxis: MultiRenderTarget[] = [];\r\n\r\n private _voxelMaterial: ShaderMaterial;\r\n private _voxelSlabDebugMaterial: ShaderMaterial;\r\n private _voxelClearColor: Color4 = new Color4(0, 0, 0, 1);\r\n\r\n /**\r\n * Return the voxel grid texture.\r\n * @returns The voxel grid texture.\r\n */\r\n public getVoxelGrid(): ProceduralTexture | RenderTargetTexture {\r\n if (this._engine.isWebGPU) {\r\n return this._voxelGrid;\r\n } else if (this._triPlanarVoxelization) {\r\n return this._combinedVoxelGridPT;\r\n } else {\r\n return this._voxelGridZaxis;\r\n }\r\n }\r\n\r\n /**\r\n * Observable that triggers when the voxelization is complete\r\n */\r\n public onVoxelizationCompleteObservable: Observable<void> = new Observable<void>();\r\n\r\n /**\r\n * The debug pass post process\r\n * @returns The debug pass post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._voxelDebugPass) {\r\n this._createDebugPass();\r\n }\r\n return this._voxelDebugPass;\r\n }\r\n\r\n private _maxDrawBuffers: number;\r\n private _renderTargets: RenderTargetTexture[] = [];\r\n\r\n private _triPlanarVoxelization: boolean = true;\r\n\r\n /**\r\n * Whether to use tri-planar voxelization. More expensive, but can help with artifacts.\r\n */\r\n public get triPlanarVoxelization(): boolean {\r\n return this._triPlanarVoxelization;\r\n }\r\n\r\n /**\r\n * Whether to use tri-planar voxelization. More expensive, but can help with artifacts.\r\n */\r\n public set triPlanarVoxelization(enabled: boolean) {\r\n if (this._engine.isWebGPU) {\r\n // WebGPU only supports tri-planar voxelization.\r\n this._triPlanarVoxelization = true;\r\n return;\r\n }\r\n if (this._triPlanarVoxelization === enabled) {\r\n return;\r\n }\r\n this._triPlanarVoxelization = enabled;\r\n this._disposeVoxelTextures();\r\n this._createTextures();\r\n }\r\n\r\n private _voxelizationInProgress: boolean = false;\r\n private _invWorldScaleMatrix: Matrix = Matrix.Identity();\r\n\r\n /**\r\n * Set the matrix to use for scaling the world space to voxel space\r\n * @param matrix The matrix to use for scaling the world space to voxel space\r\n */\r\n public setWorldScaleMatrix(matrix: Matrix) {\r\n this._invWorldScaleMatrix = matrix;\r\n }\r\n /**\r\n * @returns Whether voxelization is currently happening.\r\n */\r\n public isVoxelizationInProgress(): boolean {\r\n return this._voxelizationInProgress;\r\n }\r\n\r\n private _voxelResolution: number = 64;\r\n private _voxelResolutionExp: number = 6;\r\n\r\n /**\r\n * Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n */\r\n public get voxelResolutionExp(): number {\r\n return this._voxelResolutionExp;\r\n }\r\n\r\n /**\r\n * Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n */\r\n public set voxelResolutionExp(resolutionExp: number) {\r\n if (this._voxelResolutionExp === resolutionExp && this._voxelGridZaxis) {\r\n return;\r\n }\r\n this._voxelResolutionExp = Math.round(Math.min(Math.max(resolutionExp, 3), 9));\r\n this._voxelResolution = Math.pow(2.0, this._voxelResolutionExp);\r\n this._disposeVoxelTextures();\r\n this._createTextures();\r\n }\r\n\r\n private _copyMipEffectRenderer: EffectRenderer;\r\n private _copyMipEffectWrapper: EffectWrapper;\r\n private _mipArray: ProceduralTexture[] = [];\r\n\r\n private _voxelSlabDebugRT: RenderTargetTexture;\r\n private _voxelDebugPass: PostProcess;\r\n private _voxelDebugEnabled: boolean = false;\r\n\r\n /**\r\n * Shows only the voxels that were rendered along a particular axis (while using triPlanarVoxelization).\r\n * If not set, the combined voxel grid will be shown.\r\n * Note: This only works when the debugMipNumber is set to 0 because we don't generate mips for each axis.\r\n * @param axis The axis to show (0 = x, 1 = y, 2 = z)\r\n */\r\n public set voxelDebugAxis(axis: number) {\r\n this._voxelDebugAxis = axis;\r\n }\r\n\r\n public get voxelDebugAxis(): number {\r\n return this._voxelDebugAxis;\r\n }\r\n private _voxelDebugAxis: number = -1;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _includedMeshes: Mesh[] = [];\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n private _debugMipNumber: number = 0;\r\n /**\r\n * The mip level to show in the debug display\r\n * @param mipNum The mip level to show in the debug display\r\n */\r\n public setDebugMipNumber(mipNum: number) {\r\n this._debugMipNumber = mipNum;\r\n }\r\n private _debugPassName: string = \"Voxelization Debug Pass\";\r\n /**\r\n * Sets the name of the debug pass\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n\r\n /**\r\n * Enable or disable the debug view for this pass\r\n */\r\n public get voxelDebugEnabled(): boolean {\r\n return this._voxelDebugEnabled;\r\n }\r\n\r\n public set voxelDebugEnabled(enabled: boolean) {\r\n if (this._voxelDebugEnabled === enabled) {\r\n return;\r\n }\r\n this._voxelDebugEnabled = enabled;\r\n if (enabled) {\r\n this._voxelSlabDebugRT = new RenderTargetTexture(\"voxelSlabDebug\", { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() }, this._scene, {\r\n generateDepthBuffer: true,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n });\r\n this._voxelSlabDebugRT.noPrePassRenderer = true;\r\n }\r\n if (this._voxelSlabDebugRT) {\r\n this._removeVoxelRTs([this._voxelSlabDebugRT]);\r\n }\r\n // Add the slab debug RT if needed.\r\n if (this._voxelDebugEnabled) {\r\n this._addRTsForRender([this._voxelSlabDebugRT], this._includedMeshes, this._voxelDebugAxis, 1, true);\r\n this._setDebugBindingsBound = this._setDebugBindings.bind(this);\r\n this._scene.onBeforeRenderObservable.add(this._setDebugBindingsBound);\r\n } else {\r\n this._scene.onBeforeRenderObservable.removeCallback(this._setDebugBindingsBound);\r\n }\r\n }\r\n\r\n private _setDebugBindingsBound: () => void;\r\n /**\r\n * Creates the debug post process effect for this pass\r\n */\r\n private _createDebugPass() {\r\n const isWebGPU = this._engine.isWebGPU;\r\n if (!this._voxelDebugPass) {\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RGBA,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n uniforms: [\"sizeParams\", \"mipNumber\"],\r\n samplers: [\"voxelTexture\", \"voxelSlabTexture\"],\r\n engine: this._engine,\r\n reusable: false,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblVoxelGrid3dDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblVoxelGrid3dDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._voxelDebugPass = new PostProcess(this.debugPassName, \"iblVoxelGrid3dDebug\", debugOptions);\r\n this._voxelDebugPass.onApplyObservable.add((effect) => {\r\n if (this._voxelDebugAxis === 0) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridXaxis);\r\n } else if (this._voxelDebugAxis === 1) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridYaxis);\r\n } else if (this._voxelDebugAxis === 2) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridZaxis);\r\n } else {\r\n effect.setTexture(\"voxelTexture\", this.getVoxelGrid());\r\n }\r\n effect.setTexture(\"voxelSlabTexture\", this._voxelSlabDebugRT);\r\n effect.setVector4(\"sizeParams\", this._debugSizeParams);\r\n effect.setFloat(\"mipNumber\", this._debugMipNumber);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Instanciates the voxel renderer\r\n * @param scene Scene to attach to\r\n * @param iblShadowsRenderPipeline The render pipeline this pass is associated with\r\n * @param resolutionExp Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n * @param triPlanarVoxelization Whether to use tri-planar voxelization. Only applies to WebGL. Voxelization will take longer but will reduce missing geometry.\r\n * @returns The voxel renderer\r\n */\r\n constructor(scene: Scene, iblShadowsRenderPipeline: IblShadowsRenderPipeline, resolutionExp: number = 6, triPlanarVoxelization: boolean = true) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine() as Engine;\r\n this._triPlanarVoxelization = this._engine.isWebGPU || triPlanarVoxelization;\r\n if (!this._engine.getCaps().drawBuffersExtension) {\r\n Logger.Error(\"Can't do voxel rendering without the draw buffers extension.\");\r\n }\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n // Round down to a power of 2 so it evenly divides the power-of-2 voxel resolution,\r\n // preventing out-of-bounds layer indices in the last MRT slab.\r\n const rawMaxDrawBuffers = this._engine.getCaps().maxDrawBuffers || 0;\r\n this._maxDrawBuffers = rawMaxDrawBuffers >= 1 ? 1 << Math.floor(Math.log2(rawMaxDrawBuffers)) : 0;\r\n\r\n this._copyMipEffectRenderer = new EffectRenderer(this._engine);\r\n this._copyMipEffectWrapper = new EffectWrapper({\r\n engine: this._engine,\r\n fragmentShader: \"copyTexture3DLayerToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"layerNum\"],\r\n samplerNames: [\"textureSampler\"],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/copyTexture3DLayerToTexture.fragment\");\r\n } else {\r\n await import(\"../../Shaders/copyTexture3DLayerToTexture.fragment\");\r\n }\r\n },\r\n });\r\n\r\n this.voxelResolutionExp = resolutionExp;\r\n }\r\n\r\n private _generateMipMaps() {\r\n const iterations = Math.ceil(Math.log2(this._voxelResolution));\r\n for (let i = 1; i < iterations + 1; i++) {\r\n this._generateMipMap(i);\r\n }\r\n }\r\n\r\n private _generateMipMap(lodLevel: number) {\r\n // Generate a mip map for the given level by triggering the render of the procedural mip texture.\r\n const mipTarget = this._mipArray[lodLevel - 1];\r\n if (!mipTarget) {\r\n return;\r\n }\r\n mipTarget.setTexture(\"srcMip\", lodLevel === 1 ? this.getVoxelGrid() : this._mipArray[lodLevel - 2]);\r\n mipTarget.render();\r\n }\r\n\r\n private _copyMipMaps() {\r\n const iterations = Math.ceil(Math.log2(this._voxelResolution));\r\n for (let i = 1; i < iterations + 1; i++) {\r\n this._copyMipMap(i);\r\n }\r\n }\r\n\r\n private _copyMipMap(lodLevel: number) {\r\n // Now, copy this mip into the mip chain of the voxel grid.\r\n // TODO - this currently isn't working. \"textureSampler\" isn't being properly set to mipTarget.\r\n const mipTarget = this._mipArray[lodLevel - 1];\r\n if (!mipTarget) {\r\n return;\r\n }\r\n const voxelGrid = this.getVoxelGrid();\r\n let rt: RenderTargetWrapper;\r\n if (voxelGrid instanceof RenderTargetTexture && voxelGrid.renderTarget) {\r\n rt = voxelGrid.renderTarget;\r\n } else {\r\n rt = (voxelGrid as any)._rtWrapper;\r\n }\r\n if (rt) {\r\n this._copyMipEffectRenderer.saveStates();\r\n const bindSize = mipTarget.getSize().width;\r\n\r\n // Render to each layer of the voxel grid.\r\n for (let layer = 0; layer < bindSize; layer++) {\r\n this._engine.bindFramebuffer(rt, 0, bindSize, bindSize, true, lodLevel, layer);\r\n this._copyMipEffectRenderer.applyEffectWrapper(this._copyMipEffectWrapper);\r\n this._copyMipEffectWrapper.effect.setTexture(\"textureSampler\", mipTarget);\r\n this._copyMipEffectWrapper.effect.setInt(\"layerNum\", layer);\r\n this._copyMipEffectRenderer.draw();\r\n this._engine.unBindFramebuffer(rt, true);\r\n }\r\n this._copyMipEffectRenderer.restoreStates();\r\n }\r\n }\r\n\r\n private _computeNumberOfSlabs(): number {\r\n return Math.ceil(this._voxelResolution / this._maxDrawBuffers);\r\n }\r\n\r\n private _createTextures() {\r\n const isWebGPU = this._engine.isWebGPU;\r\n const size: TextureSize = {\r\n width: this._voxelResolution,\r\n height: this._voxelResolution,\r\n depth: this._voxelResolution,\r\n };\r\n const voxelAxisOptions: RenderTargetTextureOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n };\r\n\r\n // We can render up to maxDrawBuffers voxel slices of the grid per render.\r\n // We call this a slab.\r\n const numSlabs = this._computeNumberOfSlabs();\r\n const voxelCombinedOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: true,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_R,\r\n samplingMode: Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/iblCombineVoxelGrids.fragment\");\r\n } else {\r\n await import(\"../../Shaders/iblCombineVoxelGrids.fragment\");\r\n }\r\n },\r\n };\r\n if (this._engine.isWebGPU) {\r\n this._voxelGrid = new RenderTargetTexture(\"voxelGrid\", size, this._scene, {\r\n ...voxelCombinedOptions,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n creationFlags: Constants.TEXTURE_CREATIONFLAG_STORAGE,\r\n });\r\n this._voxelGridRT = new RenderTargetTexture(\r\n \"voxelGridRT\",\r\n { width: Math.min(size.width * 2.0, 2048), height: Math.min(size.height * 2.0, 2048) },\r\n this._scene,\r\n voxelAxisOptions\r\n );\r\n } else if (this._triPlanarVoxelization) {\r\n this._voxelGridXaxis = new RenderTargetTexture(\"voxelGridXaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelGridYaxis = new RenderTargetTexture(\"voxelGridYaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelGridZaxis = new RenderTargetTexture(\"voxelGridZaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelMrtsXaxis = this._createVoxelMRTs(\"x_axis_\", this._voxelGridXaxis, numSlabs);\r\n this._voxelMrtsYaxis = this._createVoxelMRTs(\"y_axis_\", this._voxelGridYaxis, numSlabs);\r\n this._voxelMrtsZaxis = this._createVoxelMRTs(\"z_axis_\", this._voxelGridZaxis, numSlabs);\r\n\r\n this._combinedVoxelGridPT = new ProceduralTexture(\"combinedVoxelGrid\", size, \"iblCombineVoxelGrids\", this._scene, voxelCombinedOptions, false);\r\n this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._combinedVoxelGridPT), 1);\r\n this._combinedVoxelGridPT.setFloat(\"layer\", 0.0);\r\n this._combinedVoxelGridPT.setTexture(\"voxelXaxisSampler\", this._voxelGridXaxis);\r\n this._combinedVoxelGridPT.setTexture(\"voxelYaxisSampler\", this._voxelGridYaxis);\r\n this._combinedVoxelGridPT.setTexture(\"voxelZaxisSampler\", this._voxelGridZaxis);\r\n // We will render this only after voxelization is completed for the 3 axes.\r\n this._combinedVoxelGridPT.autoClear = false;\r\n this._combinedVoxelGridPT.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this._combinedVoxelGridPT.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n } else {\r\n this._voxelGridZaxis = new RenderTargetTexture(\"voxelGridZaxis\", size, this._scene, voxelCombinedOptions);\r\n this._voxelMrtsZaxis = this._createVoxelMRTs(\"z_axis_\", this._voxelGridZaxis, numSlabs);\r\n }\r\n\r\n const generateVoxelMipOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_R,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/iblGenerateVoxelMip.fragment\");\r\n } else {\r\n await import(\"../../Shaders/iblGenerateVoxelMip.fragment\");\r\n }\r\n },\r\n };\r\n this._mipArray = new Array(Math.ceil(Math.log2(this._voxelResolution)));\r\n for (let mipIdx = 1; mipIdx <= this._mipArray.length; mipIdx++) {\r\n const mipDim = this._voxelResolution >> mipIdx;\r\n const mipSize: TextureSize = { width: mipDim, height: mipDim, depth: mipDim };\r\n this._mipArray[mipIdx - 1] = new ProceduralTexture(\"voxelMip\" + mipIdx, mipSize, \"iblGenerateVoxelMip\", this._scene, generateVoxelMipOptions, false);\r\n this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._mipArray[mipIdx - 1]), 1);\r\n\r\n const mipTarget = this._mipArray[mipIdx - 1];\r\n mipTarget.autoClear = false;\r\n mipTarget.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n mipTarget.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n mipTarget.setTexture(\"srcMip\", mipIdx > 1 ? this._mipArray[mipIdx - 2] : this.getVoxelGrid());\r\n mipTarget.setInt(\"layerNum\", 0);\r\n }\r\n\r\n this._createVoxelMaterials();\r\n }\r\n\r\n private _createVoxelMRTs(name: string, voxelRT: RenderTargetTexture, numSlabs: number): MultiRenderTarget[] {\r\n voxelRT.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n voxelRT.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n voxelRT.noPrePassRenderer = true;\r\n const mrtArray: MultiRenderTarget[] = [];\r\n const targetTypes = new Array(this._maxDrawBuffers).fill(Constants.TEXTURE_3D);\r\n\r\n for (let mrtIndex = 0; mrtIndex < numSlabs; mrtIndex++) {\r\n let layerIndices = new Array(this._maxDrawBuffers).fill(0);\r\n layerIndices = layerIndices.map((value, index) => mrtIndex * this._maxDrawBuffers + index);\r\n\r\n let textureNames = new Array(this._maxDrawBuffers).fill(\"\");\r\n textureNames = textureNames.map((value, index) => \"voxel_grid_\" + name + (mrtIndex * this._maxDrawBuffers + index));\r\n\r\n const mrt = new MultiRenderTarget(\r\n \"mrt_\" + name + mrtIndex,\r\n { width: this._voxelResolution, height: this._voxelResolution, depth: this._voxelResolution },\r\n this._maxDrawBuffers, // number of draw buffers\r\n this._scene,\r\n {\r\n types: new Array(this._maxDrawBuffers).fill(Constants.TEXTURETYPE_UNSIGNED_BYTE),\r\n samplingModes: new Array(this._maxDrawBuffers).fill(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE),\r\n generateMipMaps: false,\r\n targetTypes,\r\n formats: new Array(this._maxDrawBuffers).fill(Constants.TEXTUREFORMAT_R),\r\n faceIndex: new Array(this._maxDrawBuffers).fill(0),\r\n layerIndex: layerIndices,\r\n layerCounts: new Array(this._maxDrawBuffers).fill(this._voxelResolution),\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n },\r\n textureNames\r\n );\r\n\r\n mrt.clearColor = new Color4(0, 0, 0, 1);\r\n mrt.noPrePassRenderer = true;\r\n for (let i = 0; i < this._maxDrawBuffers; i++) {\r\n mrt.setInternalTexture(voxelRT.getInternalTexture()!, i);\r\n }\r\n\r\n mrtArray.push(mrt);\r\n }\r\n return mrtArray;\r\n }\r\n\r\n private _disposeVoxelTextures() {\r\n this._stopVoxelization();\r\n for (let i = 0; i < this._voxelMrtsZaxis.length; i++) {\r\n if (this._triPlanarVoxelization) {\r\n this._voxelMrtsXaxis[i].dispose(true);\r\n this._voxelMrtsYaxis[i].dispose(true);\r\n }\r\n this._voxelMrtsZaxis[i].dispose(true);\r\n }\r\n if (this._triPlanarVoxelization) {\r\n this._voxelGridXaxis?.dispose();\r\n this._voxelGridYaxis?.dispose();\r\n this._combinedVoxelGridPT?.dispose();\r\n }\r\n this._voxelGridZaxis?.dispose();\r\n for (const mip of this._mipArray) {\r\n mip.dispose();\r\n }\r\n this._voxelMaterial?.dispose();\r\n this._voxelSlabDebugMaterial?.dispose();\r\n this._mipArray = [];\r\n this._voxelMrtsXaxis = [];\r\n this._voxelMrtsYaxis = [];\r\n this._voxelMrtsZaxis = [];\r\n }\r\n\r\n private _createVoxelMaterials(): void {\r\n const isWebGPU = this._engine.isWebGPU;\r\n this._voxelMaterial = new ShaderMaterial(\"voxelization\", this._scene, \"iblVoxelGrid\", {\r\n uniforms: [\"world\", \"viewMatrix\", \"invTransWorld\", \"invWorldScale\", \"nearPlane\", \"farPlane\", \"stepSize\"],\r\n defines: [\"MAX_DRAW_BUFFERS \" + this._maxDrawBuffers],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblVoxelGrid.fragment\"), import(\"../../ShadersWGSL/iblVoxelGrid.vertex\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblVoxelGrid.fragment\"), import(\"../../Shaders/iblVoxelGrid.vertex\")]);\r\n }\r\n },\r\n });\r\n this._voxelMaterial.cullBackFaces = false;\r\n this._voxelMaterial.backFaceCulling = false;\r\n this._voxelMaterial.depthFunction = Engine.ALWAYS;\r\n\r\n this._voxelSlabDebugMaterial = new ShaderMaterial(\"voxelSlabDebug\", this._scene, \"iblVoxelSlabDebug\", {\r\n uniforms: [\"world\", \"viewMatrix\", \"cameraViewMatrix\", \"projection\", \"invWorldScale\", \"nearPlane\", \"farPlane\", \"stepSize\"],\r\n defines: [\"MAX_DRAW_BUFFERS \" + this._maxDrawBuffers],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblVoxelSlabDebug.fragment\"), import(\"../../ShadersWGSL/iblVoxelSlabDebug.vertex\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblVoxelSlabDebug.fragment\"), import(\"../../Shaders/iblVoxelSlabDebug.vertex\")]);\r\n }\r\n },\r\n });\r\n }\r\n\r\n private _setDebugBindings() {\r\n this._voxelSlabDebugMaterial.setMatrix(\"projection\", this._scene.activeCamera!.getProjectionMatrix());\r\n this._voxelSlabDebugMaterial.setMatrix(\"cameraViewMatrix\", this._scene.activeCamera!.getViewMatrix());\r\n }\r\n\r\n /**\r\n * Checks if the voxel renderer is ready to voxelize scene\r\n * @returns true if the voxel renderer is ready to voxelize scene\r\n */\r\n public isReady() {\r\n let allReady = this.getVoxelGrid().isReady();\r\n for (let i = 0; i < this._mipArray.length; i++) {\r\n const mipReady = this._mipArray[i].isReady();\r\n allReady &&= mipReady;\r\n }\r\n\r\n if (!allReady || this._voxelizationInProgress) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * If the MRT's are already in the list of render targets, this will\r\n * remove them so that they don't get rendered again.\r\n */\r\n private _stopVoxelization() {\r\n // If the MRT's are already in the list of render targets, remove them.\r\n this._removeVoxelRTs(this._voxelMrtsXaxis);\r\n this._removeVoxelRTs(this._voxelMrtsYaxis);\r\n this._removeVoxelRTs(this._voxelMrtsZaxis);\r\n this._removeVoxelRTs([this._voxelGridRT]);\r\n }\r\n\r\n private _removeVoxelRTs(rts: RenderTargetTexture[]) {\r\n // const currentRTs = this._scene.customRenderTargets;\r\n const rtIdx = this._renderTargets.findIndex((rt) => {\r\n if (rt === rts[0]) {\r\n return true;\r\n }\r\n return false;\r\n });\r\n if (rtIdx >= 0) {\r\n this._renderTargets.splice(rtIdx, rts.length);\r\n } else {\r\n const rtIdx = this._scene.customRenderTargets.findIndex((rt) => {\r\n if (rt === rts[0]) {\r\n return true;\r\n }\r\n return false;\r\n });\r\n if (rtIdx >= 0) {\r\n this._scene.customRenderTargets.splice(rtIdx, rts.length);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Renders voxel grid of scene for IBL shadows\r\n * @param includedMeshes\r\n */\r\n public updateVoxelGrid(includedMeshes: Mesh[]) {\r\n if (this._voxelizationInProgress) {\r\n return;\r\n }\r\n this._stopVoxelization();\r\n this._includedMeshes = includedMeshes;\r\n this._voxelizationInProgress = true;\r\n\r\n if (this._engine.isWebGPU) {\r\n this._voxelGridRT.renderList = includedMeshes;\r\n this._addRTsForRender([this._voxelGridRT], includedMeshes, 0);\r\n } else if (this._triPlanarVoxelization) {\r\n this._addRTsForRender(this._voxelMrtsXaxis, includedMeshes, 0);\r\n this._addRTsForRender(this._voxelMrtsYaxis, includedMeshes, 1);\r\n this._addRTsForRender(this._voxelMrtsZaxis, includedMeshes, 2);\r\n } else {\r\n this._addRTsForRender(this._voxelMrtsZaxis, includedMeshes, 2);\r\n }\r\n if (this._voxelDebugEnabled) {\r\n this._addRTsForRender([this._voxelSlabDebugRT], includedMeshes, this._voxelDebugAxis, 1, true);\r\n }\r\n this._renderVoxelGridBound = this._renderVoxelGrid.bind(this);\r\n this._scene.onAfterRenderObservable.add(this._renderVoxelGridBound);\r\n }\r\n\r\n private _renderVoxelGridBound: () => void;\r\n\r\n private _renderVoxelGrid() {\r\n if (this._voxelizationInProgress) {\r\n let allReady = this.getVoxelGrid().isReady();\r\n for (let i = 0; i < this._mipArray.length; i++) {\r\n const mipReady = this._mipArray[i].isReady();\r\n allReady &&= mipReady;\r\n }\r\n for (let i = 0; i < this._renderTargets.length; i++) {\r\n const rttReady = this._renderTargets[i].isReadyForRendering();\r\n allReady &&= rttReady;\r\n }\r\n if (allReady) {\r\n if (this._engine.isWebGPU) {\r\n // Clear the voxel grid storage texture.\r\n // Need to clear each layer individually.\r\n // Would a compute shader be faster here to clear all layers in one go?\r\n if (this._voxelGrid && this._voxelGrid.renderTarget) {\r\n for (let layer = 0; layer < this._voxelResolution; layer++) {\r\n this._engine.bindFramebuffer(this._voxelGrid.renderTarget, 0, undefined, undefined, true, 0, layer);\r\n this._engine.clear(this._voxelClearColor, true, false, false);\r\n this._engine.unBindFramebuffer(this._voxelGrid.renderTarget, true);\r\n }\r\n }\r\n }\r\n for (const rt of this._renderTargets) {\r\n rt.render();\r\n }\r\n this._stopVoxelization();\r\n\r\n if (this._triPlanarVoxelization && !this._engine.isWebGPU) {\r\n this._combinedVoxelGridPT.render();\r\n }\r\n this._generateMipMaps();\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._copyMipEffectWrapper.effect.whenCompiledAsync().then(() => {\r\n this._copyMipMaps();\r\n this._scene.onAfterRenderObservable.removeCallback(this._renderVoxelGridBound);\r\n this._voxelizationInProgress = false;\r\n this.onVoxelizationCompleteObservable.notifyObservers();\r\n });\r\n }\r\n }\r\n }\r\n\r\n private _addRTsForRender(mrts: RenderTargetTexture[], includedMeshes: Mesh[], axis: number, shaderType: number = 0, continuousRender: boolean = false) {\r\n const slabSize = 1.0 / this._computeNumberOfSlabs();\r\n let voxelMaterial: ShaderMaterial;\r\n if (shaderType === 0) {\r\n voxelMaterial = this._voxelMaterial;\r\n } else {\r\n voxelMaterial = this._voxelSlabDebugMaterial;\r\n }\r\n\r\n // We need to update the world scale uniform for every mesh being rendered to the voxel grid.\r\n for (let mrtIndex = 0; mrtIndex < mrts.length; mrtIndex++) {\r\n const mrt = mrts[mrtIndex];\r\n mrt.renderList = [];\r\n const nearPlane = mrtIndex * slabSize;\r\n const farPlane = (mrtIndex + 1) * slabSize;\r\n const stepSize = slabSize / this._maxDrawBuffers;\r\n\r\n const cameraPosition = new Vector3(0, 0, 0);\r\n let targetPosition = new Vector3(0, 0, 1);\r\n if (axis === 0) {\r\n targetPosition = new Vector3(1, 0, 0);\r\n } else if (axis === 1) {\r\n targetPosition = new Vector3(0, 1, 0);\r\n }\r\n let upDirection = new Vector3(0, 1, 0);\r\n if (axis === 1) {\r\n upDirection = new Vector3(1, 0, 0);\r\n }\r\n mrt.onBeforeRenderObservable.clear();\r\n mrt.onBeforeRenderObservable.add(() => {\r\n voxelMaterial.setMatrix(\"viewMatrix\", Matrix.LookAtLH(cameraPosition, targetPosition, upDirection));\r\n voxelMaterial.setMatrix(\"invWorldScale\", this._invWorldScaleMatrix);\r\n voxelMaterial.setFloat(\"nearPlane\", nearPlane);\r\n voxelMaterial.setFloat(\"farPlane\", farPlane);\r\n voxelMaterial.setFloat(\"stepSize\", stepSize);\r\n if (this._engine.isWebGPU) {\r\n this._voxelMaterial.useVertexPulling = true;\r\n this._voxelMaterial.setTexture(\"voxel_storage\", this.getVoxelGrid());\r\n }\r\n });\r\n\r\n // Set this material on every mesh in the scene (for this RT)\r\n if (includedMeshes.length === 0) {\r\n return;\r\n }\r\n for (const mesh of includedMeshes) {\r\n if (mesh) {\r\n if (mesh.subMeshes && mesh.subMeshes.length > 0) {\r\n mrt.renderList?.push(mesh);\r\n mrt.setMaterialForRendering(mesh, voxelMaterial);\r\n }\r\n const meshes = mesh.getChildMeshes();\r\n for (const childMesh of meshes) {\r\n if (childMesh.subMeshes && childMesh.subMeshes.length > 0) {\r\n mrt.renderList?.push(childMesh);\r\n mrt.setMaterialForRendering(childMesh, voxelMaterial);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Add the MRT's to render.\r\n if (continuousRender) {\r\n for (const mrt of mrts) {\r\n if (this._scene.customRenderTargets.indexOf(mrt) === -1) {\r\n this._scene.customRenderTargets.push(mrt);\r\n }\r\n }\r\n } else {\r\n this._renderTargets = this._renderTargets.concat(mrts);\r\n }\r\n }\r\n\r\n /**\r\n * Called by the pipeline to resize resources.\r\n */\r\n public resize() {\r\n this._voxelSlabDebugRT?.resize({ width: this._scene.getEngine().getRenderWidth(), height: this._scene.getEngine().getRenderHeight() });\r\n }\r\n\r\n /**\r\n * Disposes the voxel renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeVoxelTextures();\r\n if (this._voxelSlabDebugRT) {\r\n this._removeVoxelRTs([this._voxelSlabDebugRT]);\r\n this._voxelSlabDebugRT.dispose();\r\n }\r\n if (this._voxelDebugPass) {\r\n this._voxelDebugPass.dispose();\r\n }\r\n // TODO - dispose all created voxel materials.\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"iblShadowsVoxelRenderer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsVoxelRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAGnF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGnE,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAE3F,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAK/E;;;;;GAKG;AACH,MAAM,OAAO,wBAAwB;IAsBjC;;;OAGG;IACI,YAAY;QACf,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,UAAU,CAAC;QAC3B,CA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AiB,EAAE,CAAC;YACzB,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;QACrC,CAAC;QACD,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QACnC,CAAC;QACD,8CAA8C;IAClD,CAAC;CACJ","sourcesContent":["import { Constants } from \"../../Engines/constants\";\r\nimport type { Engine } from \"../../Engines/engine\";\r\nimport { ShaderMaterial } from \"../../Materials/shaderMaterial\";\r\nimport { MultiRenderTarget } from \"../../Materials/Textures/multiRenderTarget\";\r\nimport { RenderTargetTexture } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport type { RenderTargetTextureOptions } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport type { TextureSize } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport { Color4 } from \"../../Maths/math.color\";\r\nimport { Matrix, Vector3, Vector4 } from \"../../Maths/math.vector\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../../PostProcesses/postProcess\";\r\nimport { ProceduralTexture } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../../Materials/effectRenderer\";\r\nimport type { IblShadowsRenderPipeline } from \"./iblShadowsRenderPipeline\";\r\nimport type { RenderTargetWrapper } from \"core/Engines\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Voxel-based shadow rendering for IBL's.\r\n * This should not be instanciated directly, as it is part of a scene component\r\n * @internal\r\n * @see https://playground.babylonjs.com/#8R5SSE#222\r\n */\r\nexport class _IblShadowsVoxelRenderer {\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n\r\n // WebGPU, single-pass voxelization.\r\n // See https://playground.babylonjs.com/#XSNYAU#133\r\n private _voxelGrid: RenderTargetTexture;\r\n private _voxelGridRT: RenderTargetTexture;\r\n\r\n // WebGL voxelization, including tri-planar voxelization.\r\n private _combinedVoxelGridPT: ProceduralTexture;\r\n private _voxelGridXaxis: RenderTargetTexture;\r\n private _voxelGridYaxis: RenderTargetTexture;\r\n private _voxelGridZaxis: RenderTargetTexture;\r\n private _voxelMrtsXaxis: MultiRenderTarget[] = [];\r\n private _voxelMrtsYaxis: MultiRenderTarget[] = [];\r\n private _voxelMrtsZaxis: MultiRenderTarget[] = [];\r\n\r\n private _voxelMaterial: ShaderMaterial;\r\n private _voxelSlabDebugMaterial: ShaderMaterial;\r\n private _voxelClearColor: Color4 = new Color4(0, 0, 0, 1);\r\n\r\n /**\r\n * Return the voxel grid texture.\r\n * @returns The voxel grid texture.\r\n */\r\n public getVoxelGrid(): ProceduralTexture | RenderTargetTexture {\r\n if (this._engine.isWebGPU) {\r\n return this._voxelGrid;\r\n } else if (this._triPlanarVoxelization) {\r\n return this._combinedVoxelGridPT;\r\n } else {\r\n return this._voxelGridZaxis;\r\n }\r\n }\r\n\r\n /**\r\n * Observable that triggers when the voxelization is complete\r\n */\r\n public onVoxelizationCompleteObservable: Observable<void> = new Observable<void>();\r\n\r\n /**\r\n * The debug pass post process\r\n * @returns The debug pass post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._voxelDebugPass) {\r\n this._createDebugPass();\r\n }\r\n return this._voxelDebugPass;\r\n }\r\n\r\n private _maxDrawBuffers: number;\r\n private _renderTargets: RenderTargetTexture[] = [];\r\n\r\n private _triPlanarVoxelization: boolean = true;\r\n\r\n /**\r\n * Whether to use tri-planar voxelization. More expensive, but can help with artifacts.\r\n */\r\n public get triPlanarVoxelization(): boolean {\r\n return this._triPlanarVoxelization;\r\n }\r\n\r\n /**\r\n * Whether to use tri-planar voxelization. More expensive, but can help with artifacts.\r\n */\r\n public set triPlanarVoxelization(enabled: boolean) {\r\n if (this._engine.isWebGPU) {\r\n // WebGPU only supports tri-planar voxelization.\r\n this._triPlanarVoxelization = true;\r\n return;\r\n }\r\n if (this._triPlanarVoxelization === enabled) {\r\n return;\r\n }\r\n this._triPlanarVoxelization = enabled;\r\n this._disposeVoxelTextures();\r\n this._createTextures();\r\n }\r\n\r\n private _voxelizationInProgress: boolean = false;\r\n private _invWorldScaleMatrix: Matrix = Matrix.Identity();\r\n\r\n /**\r\n * Set the matrix to use for scaling the world space to voxel space\r\n * @param matrix The matrix to use for scaling the world space to voxel space\r\n */\r\n public setWorldScaleMatrix(matrix: Matrix) {\r\n this._invWorldScaleMatrix = matrix;\r\n }\r\n /**\r\n * @returns Whether voxelization is currently happening.\r\n */\r\n public isVoxelizationInProgress(): boolean {\r\n return this._voxelizationInProgress;\r\n }\r\n\r\n private _voxelResolution: number = 64;\r\n private _voxelResolutionExp: number = 6;\r\n\r\n /**\r\n * Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n */\r\n public get voxelResolutionExp(): number {\r\n return this._voxelResolutionExp;\r\n }\r\n\r\n /**\r\n * Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n */\r\n public set voxelResolutionExp(resolutionExp: number) {\r\n if (this._voxelResolutionExp === resolutionExp && this._voxelGridZaxis) {\r\n return;\r\n }\r\n this._voxelResolutionExp = Math.round(Math.min(Math.max(resolutionExp, 3), 9));\r\n this._voxelResolution = Math.pow(2.0, this._voxelResolutionExp);\r\n this._disposeVoxelTextures();\r\n this._createTextures();\r\n }\r\n\r\n private _copyMipEffectRenderer: EffectRenderer;\r\n private _copyMipEffectWrapper: EffectWrapper;\r\n private _mipArray: ProceduralTexture[] = [];\r\n\r\n private _voxelSlabDebugRT: RenderTargetTexture;\r\n private _voxelDebugPass: PostProcess;\r\n private _voxelDebugEnabled: boolean = false;\r\n\r\n /**\r\n * Shows only the voxels that were rendered along a particular axis (while using triPlanarVoxelization).\r\n * If not set, the combined voxel grid will be shown.\r\n * Note: This only works when the debugMipNumber is set to 0 because we don't generate mips for each axis.\r\n * @param axis The axis to show (0 = x, 1 = y, 2 = z)\r\n */\r\n public set voxelDebugAxis(axis: number) {\r\n this._voxelDebugAxis = axis;\r\n }\r\n\r\n public get voxelDebugAxis(): number {\r\n return this._voxelDebugAxis;\r\n }\r\n private _voxelDebugAxis: number = -1;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _includedMeshes: Mesh[] = [];\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n private _debugMipNumber: number = 0;\r\n /**\r\n * The mip level to show in the debug display\r\n * @param mipNum The mip level to show in the debug display\r\n */\r\n public setDebugMipNumber(mipNum: number) {\r\n this._debugMipNumber = mipNum;\r\n }\r\n private _debugPassName: string = \"Voxelization Debug Pass\";\r\n /**\r\n * Sets the name of the debug pass\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n\r\n /**\r\n * Enable or disable the debug view for this pass\r\n */\r\n public get voxelDebugEnabled(): boolean {\r\n return this._voxelDebugEnabled;\r\n }\r\n\r\n public set voxelDebugEnabled(enabled: boolean) {\r\n if (this._voxelDebugEnabled === enabled) {\r\n return;\r\n }\r\n this._voxelDebugEnabled = enabled;\r\n if (enabled) {\r\n this._voxelSlabDebugRT = new RenderTargetTexture(\"voxelSlabDebug\", { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() }, this._scene, {\r\n generateDepthBuffer: true,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n });\r\n this._voxelSlabDebugRT.noPrePassRenderer = true;\r\n }\r\n if (this._voxelSlabDebugRT) {\r\n this._removeVoxelRTs([this._voxelSlabDebugRT]);\r\n }\r\n // Add the slab debug RT if needed.\r\n if (this._voxelDebugEnabled) {\r\n this._addRTsForRender([this._voxelSlabDebugRT], this._includedMeshes, this._voxelDebugAxis, 1, true);\r\n this._setDebugBindingsBound = this._setDebugBindings.bind(this);\r\n this._scene.onBeforeRenderObservable.add(this._setDebugBindingsBound);\r\n } else {\r\n this._scene.onBeforeRenderObservable.removeCallback(this._setDebugBindingsBound);\r\n }\r\n }\r\n\r\n private _setDebugBindingsBound: () => void;\r\n /**\r\n * Creates the debug post process effect for this pass\r\n */\r\n private _createDebugPass() {\r\n const isWebGPU = this._engine.isWebGPU;\r\n if (!this._voxelDebugPass) {\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RGBA,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n uniforms: [\"sizeParams\", \"mipNumber\"],\r\n samplers: [\"voxelTexture\", \"voxelSlabTexture\"],\r\n engine: this._engine,\r\n reusable: false,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblVoxelGrid3dDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblVoxelGrid3dDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._voxelDebugPass = new PostProcess(this.debugPassName, \"iblVoxelGrid3dDebug\", debugOptions);\r\n this._voxelDebugPass.onApplyObservable.add((effect) => {\r\n if (this._voxelDebugAxis === 0) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridXaxis);\r\n } else if (this._voxelDebugAxis === 1) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridYaxis);\r\n } else if (this._voxelDebugAxis === 2) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridZaxis);\r\n } else {\r\n effect.setTexture(\"voxelTexture\", this.getVoxelGrid());\r\n }\r\n effect.setTexture(\"voxelSlabTexture\", this._voxelSlabDebugRT);\r\n effect.setVector4(\"sizeParams\", this._debugSizeParams);\r\n effect.setFloat(\"mipNumber\", this._debugMipNumber);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Instanciates the voxel renderer\r\n * @param scene Scene to attach to\r\n * @param iblShadowsRenderPipeline The render pipeline this pass is associated with\r\n * @param resolutionExp Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n * @param triPlanarVoxelization Whether to use tri-planar voxelization. Only applies to WebGL. Voxelization will take longer but will reduce missing geometry.\r\n * @returns The voxel renderer\r\n */\r\n constructor(scene: Scene, iblShadowsRenderPipeline: IblShadowsRenderPipeline, resolutionExp: number = 6, triPlanarVoxelization: boolean = true) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine() as Engine;\r\n this._triPlanarVoxelization = this._engine.isWebGPU || triPlanarVoxelization;\r\n if (!this._engine.getCaps().drawBuffersExtension) {\r\n Logger.Error(\"Can't do voxel rendering without the draw buffers extension.\");\r\n }\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n // Round down to a power of 2 so it evenly divides the power-of-2 voxel resolution,\r\n // preventing out-of-bounds layer indices in the last MRT slab.\r\n const rawMaxDrawBuffers = this._engine.getCaps().maxDrawBuffers || 0;\r\n this._maxDrawBuffers = rawMaxDrawBuffers >= 1 ? 1 << Math.floor(Math.log2(rawMaxDrawBuffers)) : 0;\r\n\r\n this._copyMipEffectRenderer = new EffectRenderer(this._engine);\r\n this._copyMipEffectWrapper = new EffectWrapper({\r\n engine: this._engine,\r\n fragmentShader: \"copyTexture3DLayerToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"layerNum\"],\r\n samplerNames: [\"textureSampler\"],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/copyTexture3DLayerToTexture.fragment\");\r\n } else {\r\n await import(\"../../Shaders/copyTexture3DLayerToTexture.fragment\");\r\n }\r\n },\r\n });\r\n\r\n this.voxelResolutionExp = resolutionExp;\r\n }\r\n\r\n private _generateMipMaps() {\r\n const iterations = Math.ceil(Math.log2(this._voxelResolution));\r\n for (let i = 1; i < iterations + 1; i++) {\r\n this._generateMipMap(i);\r\n }\r\n }\r\n\r\n private _generateMipMap(lodLevel: number) {\r\n // Generate a mip map for the given level by triggering the render of the procedural mip texture.\r\n const mipTarget = this._mipArray[lodLevel - 1];\r\n if (!mipTarget) {\r\n return;\r\n }\r\n mipTarget.setTexture(\"srcMip\", lodLevel === 1 ? this.getVoxelGrid() : this._mipArray[lodLevel - 2]);\r\n mipTarget.render();\r\n }\r\n\r\n private _copyMipMaps() {\r\n const iterations = Math.ceil(Math.log2(this._voxelResolution));\r\n for (let i = 1; i < iterations + 1; i++) {\r\n this._copyMipMap(i);\r\n }\r\n }\r\n\r\n private _copyMipMap(lodLevel: number) {\r\n // Now, copy this mip into the mip chain of the voxel grid.\r\n // TODO - this currently isn't working. \"textureSampler\" isn't being properly set to mipTarget.\r\n const mipTarget = this._mipArray[lodLevel - 1];\r\n if (!mipTarget) {\r\n return;\r\n }\r\n const voxelGrid = this.getVoxelGrid();\r\n let rt: RenderTargetWrapper;\r\n if (voxelGrid instanceof RenderTargetTexture && voxelGrid.renderTarget) {\r\n rt = voxelGrid.renderTarget;\r\n } else {\r\n rt = (voxelGrid as any)._rtWrapper;\r\n }\r\n if (rt) {\r\n this._copyMipEffectRenderer.saveStates();\r\n const bindSize = mipTarget.getSize().width;\r\n\r\n // Render to each layer of the voxel grid.\r\n for (let layer = 0; layer < bindSize; layer++) {\r\n this._engine.bindFramebuffer(rt, 0, bindSize, bindSize, true, lodLevel, layer);\r\n this._copyMipEffectRenderer.applyEffectWrapper(this._copyMipEffectWrapper);\r\n this._copyMipEffectWrapper.effect.setTexture(\"textureSampler\", mipTarget);\r\n this._copyMipEffectWrapper.effect.setInt(\"layerNum\", layer);\r\n this._copyMipEffectRenderer.draw();\r\n this._engine.unBindFramebuffer(rt, true);\r\n }\r\n this._copyMipEffectRenderer.restoreStates();\r\n }\r\n }\r\n\r\n private _computeNumberOfSlabs(): number {\r\n return Math.ceil(this._voxelResolution / this._maxDrawBuffers);\r\n }\r\n\r\n private _createTextures() {\r\n const isWebGPU = this._engine.isWebGPU;\r\n const size: TextureSize = {\r\n width: this._voxelResolution,\r\n height: this._voxelResolution,\r\n depth: this._voxelResolution,\r\n };\r\n const voxelAxisOptions: RenderTargetTextureOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n };\r\n\r\n // We can render up to maxDrawBuffers voxel slices of the grid per render.\r\n // We call this a slab.\r\n const numSlabs = this._computeNumberOfSlabs();\r\n const voxelCombinedOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: true,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_R,\r\n samplingMode: Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/iblCombineVoxelGrids.fragment\");\r\n } else {\r\n await import(\"../../Shaders/iblCombineVoxelGrids.fragment\");\r\n }\r\n },\r\n };\r\n if (this._engine.isWebGPU) {\r\n this._voxelGrid = new RenderTargetTexture(\"voxelGrid\", size, this._scene, {\r\n ...voxelCombinedOptions,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n creationFlags: Constants.TEXTURE_CREATIONFLAG_STORAGE,\r\n });\r\n this._voxelGridRT = new RenderTargetTexture(\r\n \"voxelGridRT\",\r\n { width: Math.min(size.width * 2.0, 2048), height: Math.min(size.height * 2.0, 2048) },\r\n this._scene,\r\n voxelAxisOptions\r\n );\r\n } else if (this._triPlanarVoxelization) {\r\n this._voxelGridXaxis = new RenderTargetTexture(\"voxelGridXaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelGridYaxis = new RenderTargetTexture(\"voxelGridYaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelGridZaxis = new RenderTargetTexture(\"voxelGridZaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelMrtsXaxis = this._createVoxelMRTs(\"x_axis_\", this._voxelGridXaxis, numSlabs);\r\n this._voxelMrtsYaxis = this._createVoxelMRTs(\"y_axis_\", this._voxelGridYaxis, numSlabs);\r\n this._voxelMrtsZaxis = this._createVoxelMRTs(\"z_axis_\", this._voxelGridZaxis, numSlabs);\r\n\r\n this._combinedVoxelGridPT = new ProceduralTexture(\"combinedVoxelGrid\", size, \"iblCombineVoxelGrids\", this._scene, voxelCombinedOptions, false);\r\n this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._combinedVoxelGridPT), 1);\r\n this._combinedVoxelGridPT.setFloat(\"layer\", 0.0);\r\n this._combinedVoxelGridPT.setTexture(\"voxelXaxisSampler\", this._voxelGridXaxis);\r\n this._combinedVoxelGridPT.setTexture(\"voxelYaxisSampler\", this._voxelGridYaxis);\r\n this._combinedVoxelGridPT.setTexture(\"voxelZaxisSampler\", this._voxelGridZaxis);\r\n // We will render this only after voxelization is completed for the 3 axes.\r\n this._combinedVoxelGridPT.autoClear = false;\r\n this._combinedVoxelGridPT.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this._combinedVoxelGridPT.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n } else {\r\n this._voxelGridZaxis = new RenderTargetTexture(\"voxelGridZaxis\", size, this._scene, voxelCombinedOptions);\r\n this._voxelMrtsZaxis = this._createVoxelMRTs(\"z_axis_\", this._voxelGridZaxis, numSlabs);\r\n }\r\n\r\n const generateVoxelMipOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_R,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/iblGenerateVoxelMip.fragment\");\r\n } else {\r\n await import(\"../../Shaders/iblGenerateVoxelMip.fragment\");\r\n }\r\n },\r\n };\r\n this._mipArray = new Array(Math.ceil(Math.log2(this._voxelResolution)));\r\n for (let mipIdx = 1; mipIdx <= this._mipArray.length; mipIdx++) {\r\n const mipDim = this._voxelResolution >> mipIdx;\r\n const mipSize: TextureSize = { width: mipDim, height: mipDim, depth: mipDim };\r\n this._mipArray[mipIdx - 1] = new ProceduralTexture(\"voxelMip\" + mipIdx, mipSize, \"iblGenerateVoxelMip\", this._scene, generateVoxelMipOptions, false);\r\n this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._mipArray[mipIdx - 1]), 1);\r\n\r\n const mipTarget = this._mipArray[mipIdx - 1];\r\n mipTarget.autoClear = false;\r\n mipTarget.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n mipTarget.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n mipTarget.setTexture(\"srcMip\", mipIdx > 1 ? this._mipArray[mipIdx - 2] : this.getVoxelGrid());\r\n mipTarget.setInt(\"layerNum\", 0);\r\n }\r\n\r\n this._createVoxelMaterials();\r\n }\r\n\r\n private _createVoxelMRTs(name: string, voxelRT: RenderTargetTexture, numSlabs: number): MultiRenderTarget[] {\r\n voxelRT.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n voxelRT.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n voxelRT.noPrePassRenderer = true;\r\n const mrtArray: MultiRenderTarget[] = [];\r\n const targetTypes = new Array(this._maxDrawBuffers).fill(Constants.TEXTURE_3D);\r\n\r\n for (let mrtIndex = 0; mrtIndex < numSlabs; mrtIndex++) {\r\n let layerIndices = new Array(this._maxDrawBuffers).fill(0);\r\n layerIndices = layerIndices.map((value, index) => mrtIndex * this._maxDrawBuffers + index);\r\n\r\n let textureNames = new Array(this._maxDrawBuffers).fill(\"\");\r\n textureNames = textureNames.map((value, index) => \"voxel_grid_\" + name + (mrtIndex * this._maxDrawBuffers + index));\r\n\r\n const mrt = new MultiRenderTarget(\r\n \"mrt_\" + name + mrtIndex,\r\n { width: this._voxelResolution, height: this._voxelResolution, depth: this._voxelResolution },\r\n this._maxDrawBuffers, // number of draw buffers\r\n this._scene,\r\n {\r\n types: new Array(this._maxDrawBuffers).fill(Constants.TEXTURETYPE_UNSIGNED_BYTE),\r\n samplingModes: new Array(this._maxDrawBuffers).fill(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE),\r\n generateMipMaps: false,\r\n targetTypes,\r\n formats: new Array(this._maxDrawBuffers).fill(Constants.TEXTUREFORMAT_R),\r\n faceIndex: new Array(this._maxDrawBuffers).fill(0),\r\n layerIndex: layerIndices,\r\n layerCounts: new Array(this._maxDrawBuffers).fill(this._voxelResolution),\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n },\r\n textureNames\r\n );\r\n\r\n mrt.clearColor = new Color4(0, 0, 0, 1);\r\n mrt.noPrePassRenderer = true;\r\n for (let i = 0; i < this._maxDrawBuffers; i++) {\r\n mrt.setInternalTexture(voxelRT.getInternalTexture()!, i);\r\n }\r\n\r\n mrtArray.push(mrt);\r\n }\r\n return mrtArray;\r\n }\r\n\r\n private _disposeVoxelTextures() {\r\n this._stopVoxelization();\r\n for (let i = 0; i < this._voxelMrtsZaxis.length; i++) {\r\n if (this._triPlanarVoxelization) {\r\n this._voxelMrtsXaxis[i].dispose(true);\r\n this._voxelMrtsYaxis[i].dispose(true);\r\n }\r\n this._voxelMrtsZaxis[i].dispose(true);\r\n }\r\n if (this._triPlanarVoxelization) {\r\n this._voxelGridXaxis?.dispose();\r\n this._voxelGridYaxis?.dispose();\r\n this._combinedVoxelGridPT?.dispose();\r\n }\r\n this._voxelGridZaxis?.dispose();\r\n for (const mip of this._mipArray) {\r\n mip.dispose();\r\n }\r\n this._voxelMaterial?.dispose();\r\n this._voxelSlabDebugMaterial?.dispose();\r\n this._mipArray = [];\r\n this._voxelMrtsXaxis = [];\r\n this._voxelMrtsYaxis = [];\r\n this._voxelMrtsZaxis = [];\r\n }\r\n\r\n private _createVoxelMaterials(): void {\r\n const isWebGPU = this._engine.isWebGPU;\r\n this._voxelMaterial = new ShaderMaterial(\"voxelization\", this._scene, \"iblVoxelGrid\", {\r\n uniforms: [\"world\", \"viewMatrix\", \"invTransWorld\", \"invWorldScale\", \"nearPlane\", \"farPlane\", \"stepSize\"],\r\n defines: [\"MAX_DRAW_BUFFERS \" + this._maxDrawBuffers],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblVoxelGrid.fragment\"), import(\"../../ShadersWGSL/iblVoxelGrid.vertex\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblVoxelGrid.fragment\"), import(\"../../Shaders/iblVoxelGrid.vertex\")]);\r\n }\r\n },\r\n });\r\n this._voxelMaterial.cullBackFaces = false;\r\n this._voxelMaterial.backFaceCulling = false;\r\n this._voxelMaterial.depthFunction = Constants.ALWAYS;\r\n\r\n this._voxelSlabDebugMaterial = new ShaderMaterial(\"voxelSlabDebug\", this._scene, \"iblVoxelSlabDebug\", {\r\n uniforms: [\"world\", \"viewMatrix\", \"cameraViewMatrix\", \"projection\", \"invWorldScale\", \"nearPlane\", \"farPlane\", \"stepSize\"],\r\n defines: [\"MAX_DRAW_BUFFERS \" + this._maxDrawBuffers],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblVoxelSlabDebug.fragment\"), import(\"../../ShadersWGSL/iblVoxelSlabDebug.vertex\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblVoxelSlabDebug.fragment\"), import(\"../../Shaders/iblVoxelSlabDebug.vertex\")]);\r\n }\r\n },\r\n });\r\n }\r\n\r\n private _setDebugBindings() {\r\n this._voxelSlabDebugMaterial.setMatrix(\"projection\", this._scene.activeCamera!.getProjectionMatrix());\r\n this._voxelSlabDebugMaterial.setMatrix(\"cameraViewMatrix\", this._scene.activeCamera!.getViewMatrix());\r\n }\r\n\r\n /**\r\n * Checks if the voxel renderer is ready to voxelize scene\r\n * @returns true if the voxel renderer is ready to voxelize scene\r\n */\r\n public isReady() {\r\n let allReady = this.getVoxelGrid().isReady();\r\n for (let i = 0; i < this._mipArray.length; i++) {\r\n const mipReady = this._mipArray[i].isReady();\r\n allReady &&= mipReady;\r\n }\r\n\r\n if (!allReady || this._voxelizationInProgress) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * If the MRT's are already in the list of render targets, this will\r\n * remove them so that they don't get rendered again.\r\n */\r\n private _stopVoxelization() {\r\n // If the MRT's are already in the list of render targets, remove them.\r\n this._removeVoxelRTs(this._voxelMrtsXaxis);\r\n this._removeVoxelRTs(this._voxelMrtsYaxis);\r\n this._removeVoxelRTs(this._voxelMrtsZaxis);\r\n this._removeVoxelRTs([this._voxelGridRT]);\r\n }\r\n\r\n private _removeVoxelRTs(rts: RenderTargetTexture[]) {\r\n // const currentRTs = this._scene.customRenderTargets;\r\n const rtIdx = this._renderTargets.findIndex((rt) => {\r\n if (rt === rts[0]) {\r\n return true;\r\n }\r\n return false;\r\n });\r\n if (rtIdx >= 0) {\r\n this._renderTargets.splice(rtIdx, rts.length);\r\n } else {\r\n const rtIdx = this._scene.customRenderTargets.findIndex((rt) => {\r\n if (rt === rts[0]) {\r\n return true;\r\n }\r\n return false;\r\n });\r\n if (rtIdx >= 0) {\r\n this._scene.customRenderTargets.splice(rtIdx, rts.length);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Renders voxel grid of scene for IBL shadows\r\n * @param includedMeshes\r\n */\r\n public updateVoxelGrid(includedMeshes: Mesh[]) {\r\n if (this._voxelizationInProgress) {\r\n return;\r\n }\r\n this._stopVoxelization();\r\n this._includedMeshes = includedMeshes;\r\n this._voxelizationInProgress = true;\r\n\r\n if (this._engine.isWebGPU) {\r\n this._voxelGridRT.renderList = includedMeshes;\r\n this._addRTsForRender([this._voxelGridRT], includedMeshes, 0);\r\n } else if (this._triPlanarVoxelization) {\r\n this._addRTsForRender(this._voxelMrtsXaxis, includedMeshes, 0);\r\n this._addRTsForRender(this._voxelMrtsYaxis, includedMeshes, 1);\r\n this._addRTsForRender(this._voxelMrtsZaxis, includedMeshes, 2);\r\n } else {\r\n this._addRTsForRender(this._voxelMrtsZaxis, includedMeshes, 2);\r\n }\r\n if (this._voxelDebugEnabled) {\r\n this._addRTsForRender([this._voxelSlabDebugRT], includedMeshes, this._voxelDebugAxis, 1, true);\r\n }\r\n this._renderVoxelGridBound = this._renderVoxelGrid.bind(this);\r\n this._scene.onAfterRenderObservable.add(this._renderVoxelGridBound);\r\n }\r\n\r\n private _renderVoxelGridBound: () => void;\r\n\r\n private _renderVoxelGrid() {\r\n if (this._voxelizationInProgress) {\r\n let allReady = this.getVoxelGrid().isReady();\r\n for (let i = 0; i < this._mipArray.length; i++) {\r\n const mipReady = this._mipArray[i].isReady();\r\n allReady &&= mipReady;\r\n }\r\n for (let i = 0; i < this._renderTargets.length; i++) {\r\n const rttReady = this._renderTargets[i].isReadyForRendering();\r\n allReady &&= rttReady;\r\n }\r\n if (allReady) {\r\n if (this._engine.isWebGPU) {\r\n // Clear the voxel grid storage texture.\r\n // Need to clear each layer individually.\r\n // Would a compute shader be faster here to clear all layers in one go?\r\n if (this._voxelGrid && this._voxelGrid.renderTarget) {\r\n for (let layer = 0; layer < this._voxelResolution; layer++) {\r\n this._engine.bindFramebuffer(this._voxelGrid.renderTarget, 0, undefined, undefined, true, 0, layer);\r\n this._engine.clear(this._voxelClearColor, true, false, false);\r\n this._engine.unBindFramebuffer(this._voxelGrid.renderTarget, true);\r\n }\r\n }\r\n }\r\n for (const rt of this._renderTargets) {\r\n rt.render();\r\n }\r\n this._stopVoxelization();\r\n\r\n if (this._triPlanarVoxelization && !this._engine.isWebGPU) {\r\n this._combinedVoxelGridPT.render();\r\n }\r\n this._generateMipMaps();\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._copyMipEffectWrapper.effect.whenCompiledAsync().then(() => {\r\n this._copyMipMaps();\r\n this._scene.onAfterRenderObservable.removeCallback(this._renderVoxelGridBound);\r\n this._voxelizationInProgress = false;\r\n this.onVoxelizationCompleteObservable.notifyObservers();\r\n });\r\n }\r\n }\r\n }\r\n\r\n private _addRTsForRender(mrts: RenderTargetTexture[], includedMeshes: Mesh[], axis: number, shaderType: number = 0, continuousRender: boolean = false) {\r\n const slabSize = 1.0 / this._computeNumberOfSlabs();\r\n let voxelMaterial: ShaderMaterial;\r\n if (shaderType === 0) {\r\n voxelMaterial = this._voxelMaterial;\r\n } else {\r\n voxelMaterial = this._voxelSlabDebugMaterial;\r\n }\r\n\r\n // We need to update the world scale uniform for every mesh being rendered to the voxel grid.\r\n for (let mrtIndex = 0; mrtIndex < mrts.length; mrtIndex++) {\r\n const mrt = mrts[mrtIndex];\r\n mrt.renderList = [];\r\n const nearPlane = mrtIndex * slabSize;\r\n const farPlane = (mrtIndex + 1) * slabSize;\r\n const stepSize = slabSize / this._maxDrawBuffers;\r\n\r\n const cameraPosition = new Vector3(0, 0, 0);\r\n let targetPosition = new Vector3(0, 0, 1);\r\n if (axis === 0) {\r\n targetPosition = new Vector3(1, 0, 0);\r\n } else if (axis === 1) {\r\n targetPosition = new Vector3(0, 1, 0);\r\n }\r\n let upDirection = new Vector3(0, 1, 0);\r\n if (axis === 1) {\r\n upDirection = new Vector3(1, 0, 0);\r\n }\r\n mrt.onBeforeRenderObservable.clear();\r\n mrt.onBeforeRenderObservable.add(() => {\r\n voxelMaterial.setMatrix(\"viewMatrix\", Matrix.LookAtLH(cameraPosition, targetPosition, upDirection));\r\n voxelMaterial.setMatrix(\"invWorldScale\", this._invWorldScaleMatrix);\r\n voxelMaterial.setFloat(\"nearPlane\", nearPlane);\r\n voxelMaterial.setFloat(\"farPlane\", farPlane);\r\n voxelMaterial.setFloat(\"stepSize\", stepSize);\r\n if (this._engine.isWebGPU) {\r\n this._voxelMaterial.useVertexPulling = true;\r\n this._voxelMaterial.setTexture(\"voxel_storage\", this.getVoxelGrid());\r\n }\r\n });\r\n\r\n // Set this material on every mesh in the scene (for this RT)\r\n if (includedMeshes.length === 0) {\r\n return;\r\n }\r\n for (const mesh of includedMeshes) {\r\n if (mesh) {\r\n if (mesh.subMeshes && mesh.subMeshes.length > 0) {\r\n mrt.renderList?.push(mesh);\r\n mrt.setMaterialForRendering(mesh, voxelMaterial);\r\n }\r\n const meshes = mesh.getChildMeshes();\r\n for (const childMesh of meshes) {\r\n if (childMesh.subMeshes && childMesh.subMeshes.length > 0) {\r\n mrt.renderList?.push(childMesh);\r\n mrt.setMaterialForRendering(childMesh, voxelMaterial);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Add the MRT's to render.\r\n if (continuousRender) {\r\n for (const mrt of mrts) {\r\n if (this._scene.customRenderTargets.indexOf(mrt) === -1) {\r\n this._scene.customRenderTargets.push(mrt);\r\n }\r\n }\r\n } else {\r\n this._renderTargets = this._renderTargets.concat(mrts);\r\n }\r\n }\r\n\r\n /**\r\n * Called by the pipeline to resize resources.\r\n */\r\n public resize() {\r\n this._voxelSlabDebugRT?.resize({ width: this._scene.getEngine().getRenderWidth(), height: this._scene.getEngine().getRenderHeight() });\r\n }\r\n\r\n /**\r\n * Disposes the voxel renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeVoxelTextures();\r\n if (this._voxelSlabDebugRT) {\r\n this._removeVoxelRTs([this._voxelSlabDebugRT]);\r\n this._voxelSlabDebugRT.dispose();\r\n }\r\n if (this._voxelDebugPass) {\r\n this._voxelDebugPass.dispose();\r\n }\r\n // TODO - dispose all created voxel materials.\r\n }\r\n}\r\n"]}
@@ -5,7 +5,6 @@ import { PostProcess } from "../PostProcesses/postProcess.js";
5
5
  import { Vector3, Vector4 } from "../Maths/math.vector.js";
6
6
  import { RawTexture } from "../Materials/Textures/rawTexture.js";
7
7
  import { Observable } from "../Misc/observable.js";
8
- import { Engine } from "../Engines/engine.js";
9
8
  import { _WarnImport } from "../Misc/devTools.js";
10
9
  import { EngineStore } from "../Engines/engineStore.js";
11
10
  import { Logger } from "../Misc/logger.js";
@@ -137,7 +136,7 @@ export class IblCdfGenerator {
137
136
  return;
138
137
  }
139
138
  const blackPixels = new Uint16Array([0, 0, 0, 255]);
140
- this._dummyTexture = new RawTexture(blackPixels, 1, 1, Engine.TEXTUREFORMAT_RGBA, sceneOrEngine, false, false, undefined, 2);
139
+ this._dummyTexture = new RawTexture(blackPixels, 1, 1, 5, sceneOrEngine, false, false, undefined, 2);
141
140
  if (this._scene) {
142
141
  IblCdfGenerator._SceneComponentInitialization(this._scene);
143
142
  }
@@ -1 +1 @@
1
- {"version":3,"file":"iblCdfGenerator.js","sourceRo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CAAC,OAAO,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAC,aAAqC;QACzD,OAAO,aAAa,CAAC,YAAY,EAAE,KAAK,OAAO,CAAC;IACpD,CAAC;;AAxUD;;GAEG;AACW,6CAA6B,GAA2B,CAAC,CAAC,EAAE,EAAE;IACxE,MAAM,WAAW,CAAC,6CAA6C,CAAC,CAAC;AACrE,CAAC,AAF0C,CAEzC","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport { ProceduralTexture } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../PostProcesses/postProcess\";\r\nimport { Vector3, Vector4 } from \"../Maths/math.vector\";\r\nimport { RawTexture } from \"../Materials/Textures/rawTexture\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { CubeTexture } from \"../Materials/Textures/cubeTexture\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { _RetryWithInterval } from \"../Misc/timingTools\";\r\n\r\n/**\r\n * Build cdf maps to be used for IBL importance sampling.\r\n */\r\nexport class IblCdfGenerator {\r\n private _scene: Nullable<Scene>;\r\n private _engine: AbstractEngine;\r\n\r\n private _cdfyPT: ProceduralTexture;\r\n private _cdfxPT: ProceduralTexture;\r\n private _icdfPT: ProceduralTexture;\r\n private _scaledLuminancePT: ProceduralTexture;\r\n private _dominantDirectionPT: ProceduralTexture;\r\n private _iblSource: Nullable<BaseTexture>;\r\n private _dummyTexture: RawTexture;\r\n\r\n private _cachedDominantDirection: Nullable<Vector3> = null;\r\n\r\n /**\r\n * Returns whether the CDF renderer is supported by the current engine\r\n */\r\n public get isSupported(): boolean {\r\n const engine = EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n return false;\r\n }\r\n return engine.getCaps().texelFetch;\r\n }\r\n\r\n /**\r\n * Gets the IBL source texture being used by the CDF renderer\r\n */\r\n public get iblSource(): Nullable<BaseTexture> {\r\n return this._iblSource;\r\n }\r\n\r\n /**\r\n * Sets the IBL source texture to be used by the CDF renderer.\r\n * This will trigger recreation of the CDF assets.\r\n */\r\n public set iblSource(source: Nullable<BaseTexture>) {\r\n if (this._iblSource === source) {\r\n return;\r\n }\r\n this._disposeTextures();\r\n this._iblSource = source;\r\n if (!source) {\r\n return;\r\n }\r\n if (source.isCube) {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl();\r\n } else {\r\n (source as CubeTexture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n } else {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl();\r\n } else {\r\n (source as Texture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n }\r\n }\r\n\r\n private _recreateAssetsFromNewIbl() {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n\r\n this._createTextures();\r\n\r\n if (this._debugPass) {\r\n // Recreate the debug pass because of the new textures\r\n this._createDebugPass();\r\n }\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) texture\r\n * @returns Return the cumulative distribution function (CDF) texture\r\n */\r\n public getIcdfTexture(): Texture {\r\n return this._icdfPT ? this._icdfPT : this._dummyTexture;\r\n }\r\n\r\n /** Enable the debug view for this pass */\r\n public debugEnabled: boolean = false;\r\n private _debugPass: PostProcess;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 1.0, 1.0);\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n\r\n /**\r\n * The name of the debug pass post process\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n private _debugPassName: string = \"CDF Debug\";\r\n\r\n /**\r\n * Gets the debug pass post process\r\n * @returns The post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._debugPass) {\r\n this._createDebugPass();\r\n }\r\n return this._debugPass;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"IblCdfGeneratorSceneComponentSceneComponent\");\r\n };\r\n\r\n /**\r\n * Instanciates the CDF renderer\r\n * @param sceneOrEngine Scene to attach to\r\n * @returns The CDF renderer\r\n */\r\n constructor(sceneOrEngine: Nullable<Scene | AbstractEngine>) {\r\n if (sceneOrEngine) {\r\n if (IblCdfGenerator._IsScene(sceneOrEngine)) {\r\n this._scene = sceneOrEngine;\r\n } else {\r\n this._engine = sceneOrEngine;\r\n }\r\n } else {\r\n this._scene = EngineStore.LastCreatedScene;\r\n }\r\n if (this._scene) {\r\n this._engine = this._scene.getEngine();\r\n }\r\n if (!this.isSupported) {\r\n Logger.Warn(\"CDF renderer is not supported by the current engine.\");\r\n return;\r\n }\r\n const blackPixels = new Uint16Array([0, 0, 0, 255]);\r\n this._dummyTexture = new RawTexture(blackPixels, 1, 1, Engine.TEXTUREFORMAT_RGBA, sceneOrEngine, false, false, undefined, Constants.TEXTURETYPE_HALF_FLOAT);\r\n if (this._scene) {\r\n IblCdfGenerator._SceneComponentInitialization(this._scene);\r\n }\r\n }\r\n\r\n /**\r\n * Observable that triggers when the CDF renderer is ready\r\n */\r\n public onGeneratedObservable: Observable<void> = new Observable<void>();\r\n\r\n private _createTextures() {\r\n const size: TextureSize = this._iblSource ? { width: this._iblSource.getSize().width, height: this._iblSource.getSize().height } : { width: 1, height: 1 };\r\n if (!this._iblSource) {\r\n this._iblSource = RawTexture.CreateRTexture(\r\n new Uint8Array([255]),\r\n 1,\r\n 1,\r\n this._engine,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n );\r\n this._iblSource.name = \"Placeholder IBL Source\";\r\n }\r\n\r\n if (this._iblSource.isCube) {\r\n size.width *= 4;\r\n size.height *= 2;\r\n // Force the resolution to be a power of 2 because we rely on the\r\n // auto-mipmap generation for the scaled luminance texture to produce\r\n // a 1x1 mip that represents the true average pixel intensity of the IBL.\r\n size.width = 1 << Math.floor(Math.log2(size.width));\r\n size.height = 1 << Math.floor(Math.log2(size.height));\r\n }\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n // Create CDF maps (Cumulative Distribution Function) to assist in importance sampling\r\n const cdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_R,\r\n type: Constants.TEXTURETYPE_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n gammaSpace: false,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../ShadersWGSL/iblCdfx.fragment\"), import(\"../ShadersWGSL/iblCdfy.fragment\"), import(\"../ShadersWGSL/iblScaledLuminance.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/iblCdfx.fragment\"), import(\"../Shaders/iblCdfy.fragment\"), import(\"../Shaders/iblScaledLuminance.fragment\")]);\r\n }\r\n },\r\n };\r\n const icdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n gammaSpace: false,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../ShadersWGSL/iblIcdf.fragment\"), import(\"../ShadersWGSL/iblDominantDirection.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/iblIcdf.fragment\"), import(\"../Shaders/iblDominantDirection.fragment\")]);\r\n }\r\n },\r\n };\r\n this._cdfyPT = new ProceduralTexture(\"cdfyTexture\", { width: size.width, height: size.height + 1 }, \"iblCdfy\", this._scene, cdfOptions, false, false);\r\n this._cdfyPT.autoClear = false;\r\n this._cdfyPT.setTexture(\"iblSource\", this._iblSource);\r\n this._cdfyPT.setInt(\"iblHeight\", size.height);\r\n this._cdfyPT.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n this._cdfyPT.refreshRate = 0;\r\n if (this._iblSource.isCube) {\r\n this._cdfyPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n\r\n this._cdfxPT = new ProceduralTexture(\"cdfxTexture\", { width: size.width + 1, height: 1 }, \"iblCdfx\", this._scene, cdfOptions, false, false);\r\n this._cdfxPT.autoClear = false;\r\n this._cdfxPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._cdfxPT.refreshRate = 0;\r\n this._cdfxPT.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n\r\n this._scaledLuminancePT = new ProceduralTexture(\r\n \"iblScaledLuminance\",\r\n { width: size.width, height: size.height },\r\n \"iblScaledLuminance\",\r\n this._scene,\r\n { ...cdfOptions, samplingMode: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, generateMipMaps: true },\r\n true,\r\n false\r\n );\r\n this._scaledLuminancePT.autoClear = false;\r\n this._scaledLuminancePT.setTexture(\"iblSource\", this._iblSource);\r\n this._scaledLuminancePT.setInt(\"iblHeight\", size.height);\r\n this._scaledLuminancePT.setInt(\"iblWidth\", size.width);\r\n this._scaledLuminancePT.refreshRate = 0;\r\n if (this._iblSource.isCube) {\r\n this._scaledLuminancePT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n this._icdfPT = new ProceduralTexture(\"icdfTexture\", { width: size.width, height: size.height }, \"iblIcdf\", this._scene, icdfOptions, false, false);\r\n this._icdfPT.autoClear = false;\r\n this._icdfPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._icdfPT.setTexture(\"cdfx\", this._cdfxPT);\r\n this._icdfPT.setTexture(\"iblSource\", this._iblSource);\r\n this._icdfPT.setTexture(\"scaledLuminanceSampler\", this._scaledLuminancePT);\r\n this._icdfPT.refreshRate = 0;\r\n this._icdfPT.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n this._icdfPT.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n if (this._iblSource.isCube) {\r\n this._icdfPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n // Once the textures are generated, notify that they are ready to use.\r\n this._icdfPT.onGeneratedObservable.addOnce(() => {\r\n this.onGeneratedObservable.notifyObservers();\r\n });\r\n\r\n this._dominantDirectionPT = new ProceduralTexture(\"iblDominantDirection\", { width: 1, height: 1 }, \"iblDominantDirection\", this._scene, icdfOptions, false, false);\r\n this._dominantDirectionPT.autoClear = false;\r\n this._dominantDirectionPT.setTexture(\"icdfSampler\", this._icdfPT);\r\n this._dominantDirectionPT.refreshRate = 0;\r\n this._dominantDirectionPT.defines = \"#define NUM_SAMPLES 32u\\n\";\r\n }\r\n\r\n private _disposeTextures() {\r\n this._cdfyPT?.dispose();\r\n this._cdfxPT?.dispose();\r\n this._icdfPT?.dispose();\r\n this._scaledLuminancePT?.dispose();\r\n this._dominantDirectionPT?.dispose();\r\n }\r\n\r\n private _createDebugPass() {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n const isWebGPU = this._engine.isWebGPU;\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine: this._engine,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"cdfy\", \"icdf\", \"cdfx\", \"iblSource\"],\r\n defines: this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\",\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../ShadersWGSL/iblCdfDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/iblCdfDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._debugPass = new PostProcess(this._debugPassName, \"iblCdfDebug\", debugOptions);\r\n const debugEffect = this._debugPass.getEffect();\r\n if (debugEffect) {\r\n debugEffect.defines = this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\";\r\n }\r\n if (this._iblSource?.isCube) {\r\n this._debugPass.updateEffect(\"#define IBL_USE_CUBE_MAP\\n\");\r\n }\r\n this._debugPass.onApplyObservable.add((effect) => {\r\n effect.setTexture(\"cdfy\", this._cdfyPT);\r\n effect.setTexture(\"icdf\", this._icdfPT);\r\n effect.setTexture(\"cdfx\", this._cdfxPT);\r\n effect.setTexture(\"iblSource\", this._iblSource);\r\n effect.setFloat4(\"sizeParams\", this._debugSizeParams.x, this._debugSizeParams.y, this._debugSizeParams.z, this._debugSizeParams.w);\r\n });\r\n }\r\n\r\n /**\r\n * Checks if the CDF renderer is ready\r\n * @returns true if the CDF renderer is ready\r\n */\r\n public isReady() {\r\n return (\r\n this._iblSource &&\r\n this._iblSource.name !== \"Placeholder IBL Source\" &&\r\n this._iblSource.isReady() &&\r\n this._cdfyPT &&\r\n this._cdfyPT.isReady() &&\r\n this._icdfPT &&\r\n this._icdfPT.isReady() &&\r\n this._cdfxPT &&\r\n this._cdfxPT.isReady() &&\r\n this._scaledLuminancePT &&\r\n this._scaledLuminancePT.isReady()\r\n );\r\n }\r\n\r\n /**\r\n * Explicitly trigger generation of CDF maps when they are ready to render.\r\n * @returns Promise that resolves when the CDF maps are rendered.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/promise-function-async\r\n public renderWhenReady(): Promise<void> {\r\n this._cachedDominantDirection = null;\r\n\r\n // Even if a IBL source must be set before calling this function, _icdfPT may not yet be created because the creation may be asynchronous (see @set iblSource).\r\n const icdfPTPromise = new Promise((resolve, reject) => {\r\n _RetryWithInterval(\r\n () => !!this._icdfPT,\r\n () => resolve(void 0),\r\n () => reject(new Error(\"Waiting for _icdfPT creation failed\"))\r\n );\r\n });\r\n\r\n // eslint-disable-next-line github/no-then, @typescript-eslint/promise-function-async\r\n return icdfPTPromise.then(() => {\r\n // Once the textures are generated, notify that they are ready to use.\r\n this._icdfPT.onGeneratedObservable.addOnce(() => {\r\n this.onGeneratedObservable.notifyObservers();\r\n });\r\n const promises: Array<Promise<void>> = [];\r\n const renderTargets: Array<ProceduralTexture> = [this._cdfyPT, this._cdfxPT, this._scaledLuminancePT, this._icdfPT];\r\n for (const target of renderTargets) {\r\n promises.push(\r\n new Promise((resolve) => {\r\n if (target.isReady()) {\r\n resolve();\r\n } else {\r\n target.getEffect().executeWhenCompiled(() => {\r\n resolve();\r\n });\r\n }\r\n })\r\n );\r\n }\r\n // eslint-disable-next-line github/no-then\r\n return Promise.all(promises).then(() => {\r\n for (const target of renderTargets) {\r\n target.render();\r\n }\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Finds the average direction of the highest intensity areas of the IBL source\r\n * @returns Async promise that resolves to the dominant direction of the IBL source\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async\r\n public findDominantDirection(): Promise<Vector3> {\r\n if (this._cachedDominantDirection) {\r\n return Promise.resolve(this._cachedDominantDirection);\r\n }\r\n return new Promise((resolve) => {\r\n this._dominantDirectionPT.onGeneratedObservable.addOnce(() => {\r\n const data = new Float32Array(4);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._dominantDirectionPT.readPixels(0, 0, data, true)!.then(() => {\r\n const dominantDirection = new Vector3(data[0], data[1], data[2]);\r\n this._cachedDominantDirection = dominantDirection;\r\n resolve(dominantDirection);\r\n });\r\n });\r\n if (this.isReady()) {\r\n if (this._dominantDirectionPT.isReady()) {\r\n this._dominantDirectionPT.render();\r\n } else {\r\n this._dominantDirectionPT.getEffect().executeWhenCompiled(() => {\r\n this._dominantDirectionPT.render();\r\n });\r\n }\r\n } else {\r\n this.onGeneratedObservable.addOnce(() => {\r\n if (this._dominantDirectionPT.isReady()) {\r\n this._dominantDirectionPT.render();\r\n } else {\r\n this._dominantDirectionPT.getEffect().executeWhenCompiled(() => {\r\n this._dominantDirectionPT.render();\r\n });\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Disposes the CDF renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n this._dummyTexture.dispose();\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n this.onGeneratedObservable.clear();\r\n }\r\n\r\n private static _IsScene(sceneOrEngine: Scene | AbstractEngine): sceneOrEngine is Scene {\r\n return sceneOrEngine.getClassName() === \"Scene\";\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"iblCdfGenerator.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/iblCdfGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,eAAe;IAcxB;;OAEG;IACH,IAAW,WAAW;QAClB,MAAM,MAAM,GAAG,WAAW,CAAC,iBAAiB,CAAC;QAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS,CAAC,MAA6B;QAC9C,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;YAC7B,OAAO;QACX,CAAC;QACD,IAAI,CA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IACI,OAAO;QACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAC,aAAqC;QACzD,OAAO,aAAa,CAAC,YAAY,EAAE,KAAK,OAAO,CAAC;IACpD,CAAC;;AAxUD;;GAEG;AACW,6CAA6B,GAA2B,CAAC,CAAC,EAAE,EAAE;IACxE,MAAM,WAAW,CAAC,6CAA6C,CAAC,CAAC;AACrE,CAAC,AAF0C,CAEzC","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport { ProceduralTexture } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../PostProcesses/postProcess\";\r\nimport { Vector3, Vector4 } from \"../Maths/math.vector\";\r\nimport { RawTexture } from \"../Materials/Textures/rawTexture\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { CubeTexture } from \"../Materials/Textures/cubeTexture\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { _RetryWithInterval } from \"../Misc/timingTools\";\r\n\r\n/**\r\n * Build cdf maps to be used for IBL importance sampling.\r\n */\r\nexport class IblCdfGenerator {\r\n private _scene: Nullable<Scene>;\r\n private _engine: AbstractEngine;\r\n\r\n private _cdfyPT: ProceduralTexture;\r\n private _cdfxPT: ProceduralTexture;\r\n private _icdfPT: ProceduralTexture;\r\n private _scaledLuminancePT: ProceduralTexture;\r\n private _dominantDirectionPT: ProceduralTexture;\r\n private _iblSource: Nullable<BaseTexture>;\r\n private _dummyTexture: RawTexture;\r\n\r\n private _cachedDominantDirection: Nullable<Vector3> = null;\r\n\r\n /**\r\n * Returns whether the CDF renderer is supported by the current engine\r\n */\r\n public get isSupported(): boolean {\r\n const engine = EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n return false;\r\n }\r\n return engine.getCaps().texelFetch;\r\n }\r\n\r\n /**\r\n * Gets the IBL source texture being used by the CDF renderer\r\n */\r\n public get iblSource(): Nullable<BaseTexture> {\r\n return this._iblSource;\r\n }\r\n\r\n /**\r\n * Sets the IBL source texture to be used by the CDF renderer.\r\n * This will trigger recreation of the CDF assets.\r\n */\r\n public set iblSource(source: Nullable<BaseTexture>) {\r\n if (this._iblSource === source) {\r\n return;\r\n }\r\n this._disposeTextures();\r\n this._iblSource = source;\r\n if (!source) {\r\n return;\r\n }\r\n if (source.isCube) {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl();\r\n } else {\r\n (source as CubeTexture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n } else {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl();\r\n } else {\r\n (source as Texture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n }\r\n }\r\n\r\n private _recreateAssetsFromNewIbl() {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n\r\n this._createTextures();\r\n\r\n if (this._debugPass) {\r\n // Recreate the debug pass because of the new textures\r\n this._createDebugPass();\r\n }\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) texture\r\n * @returns Return the cumulative distribution function (CDF) texture\r\n */\r\n public getIcdfTexture(): Texture {\r\n return this._icdfPT ? this._icdfPT : this._dummyTexture;\r\n }\r\n\r\n /** Enable the debug view for this pass */\r\n public debugEnabled: boolean = false;\r\n private _debugPass: PostProcess;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 1.0, 1.0);\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n\r\n /**\r\n * The name of the debug pass post process\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n private _debugPassName: string = \"CDF Debug\";\r\n\r\n /**\r\n * Gets the debug pass post process\r\n * @returns The post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._debugPass) {\r\n this._createDebugPass();\r\n }\r\n return this._debugPass;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"IblCdfGeneratorSceneComponentSceneComponent\");\r\n };\r\n\r\n /**\r\n * Instanciates the CDF renderer\r\n * @param sceneOrEngine Scene to attach to\r\n * @returns The CDF renderer\r\n */\r\n constructor(sceneOrEngine: Nullable<Scene | AbstractEngine>) {\r\n if (sceneOrEngine) {\r\n if (IblCdfGenerator._IsScene(sceneOrEngine)) {\r\n this._scene = sceneOrEngine;\r\n } else {\r\n this._engine = sceneOrEngine;\r\n }\r\n } else {\r\n this._scene = EngineStore.LastCreatedScene;\r\n }\r\n if (this._scene) {\r\n this._engine = this._scene.getEngine();\r\n }\r\n if (!this.isSupported) {\r\n Logger.Warn(\"CDF renderer is not supported by the current engine.\");\r\n return;\r\n }\r\n const blackPixels = new Uint16Array([0, 0, 0, 255]);\r\n this._dummyTexture = new RawTexture(blackPixels, 1, 1, Constants.TEXTUREFORMAT_RGBA, sceneOrEngine, false, false, undefined, Constants.TEXTURETYPE_HALF_FLOAT);\r\n if (this._scene) {\r\n IblCdfGenerator._SceneComponentInitialization(this._scene);\r\n }\r\n }\r\n\r\n /**\r\n * Observable that triggers when the CDF renderer is ready\r\n */\r\n public onGeneratedObservable: Observable<void> = new Observable<void>();\r\n\r\n private _createTextures() {\r\n const size: TextureSize = this._iblSource ? { width: this._iblSource.getSize().width, height: this._iblSource.getSize().height } : { width: 1, height: 1 };\r\n if (!this._iblSource) {\r\n this._iblSource = RawTexture.CreateRTexture(\r\n new Uint8Array([255]),\r\n 1,\r\n 1,\r\n this._engine,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n );\r\n this._iblSource.name = \"Placeholder IBL Source\";\r\n }\r\n\r\n if (this._iblSource.isCube) {\r\n size.width *= 4;\r\n size.height *= 2;\r\n // Force the resolution to be a power of 2 because we rely on the\r\n // auto-mipmap generation for the scaled luminance texture to produce\r\n // a 1x1 mip that represents the true average pixel intensity of the IBL.\r\n size.width = 1 << Math.floor(Math.log2(size.width));\r\n size.height = 1 << Math.floor(Math.log2(size.height));\r\n }\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n // Create CDF maps (Cumulative Distribution Function) to assist in importance sampling\r\n const cdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_R,\r\n type: Constants.TEXTURETYPE_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n gammaSpace: false,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../ShadersWGSL/iblCdfx.fragment\"), import(\"../ShadersWGSL/iblCdfy.fragment\"), import(\"../ShadersWGSL/iblScaledLuminance.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/iblCdfx.fragment\"), import(\"../Shaders/iblCdfy.fragment\"), import(\"../Shaders/iblScaledLuminance.fragment\")]);\r\n }\r\n },\r\n };\r\n const icdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n gammaSpace: false,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../ShadersWGSL/iblIcdf.fragment\"), import(\"../ShadersWGSL/iblDominantDirection.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/iblIcdf.fragment\"), import(\"../Shaders/iblDominantDirection.fragment\")]);\r\n }\r\n },\r\n };\r\n this._cdfyPT = new ProceduralTexture(\"cdfyTexture\", { width: size.width, height: size.height + 1 }, \"iblCdfy\", this._scene, cdfOptions, false, false);\r\n this._cdfyPT.autoClear = false;\r\n this._cdfyPT.setTexture(\"iblSource\", this._iblSource);\r\n this._cdfyPT.setInt(\"iblHeight\", size.height);\r\n this._cdfyPT.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n this._cdfyPT.refreshRate = 0;\r\n if (this._iblSource.isCube) {\r\n this._cdfyPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n\r\n this._cdfxPT = new ProceduralTexture(\"cdfxTexture\", { width: size.width + 1, height: 1 }, \"iblCdfx\", this._scene, cdfOptions, false, false);\r\n this._cdfxPT.autoClear = false;\r\n this._cdfxPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._cdfxPT.refreshRate = 0;\r\n this._cdfxPT.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n\r\n this._scaledLuminancePT = new ProceduralTexture(\r\n \"iblScaledLuminance\",\r\n { width: size.width, height: size.height },\r\n \"iblScaledLuminance\",\r\n this._scene,\r\n { ...cdfOptions, samplingMode: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, generateMipMaps: true },\r\n true,\r\n false\r\n );\r\n this._scaledLuminancePT.autoClear = false;\r\n this._scaledLuminancePT.setTexture(\"iblSource\", this._iblSource);\r\n this._scaledLuminancePT.setInt(\"iblHeight\", size.height);\r\n this._scaledLuminancePT.setInt(\"iblWidth\", size.width);\r\n this._scaledLuminancePT.refreshRate = 0;\r\n if (this._iblSource.isCube) {\r\n this._scaledLuminancePT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n this._icdfPT = new ProceduralTexture(\"icdfTexture\", { width: size.width, height: size.height }, \"iblIcdf\", this._scene, icdfOptions, false, false);\r\n this._icdfPT.autoClear = false;\r\n this._icdfPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._icdfPT.setTexture(\"cdfx\", this._cdfxPT);\r\n this._icdfPT.setTexture(\"iblSource\", this._iblSource);\r\n this._icdfPT.setTexture(\"scaledLuminanceSampler\", this._scaledLuminancePT);\r\n this._icdfPT.refreshRate = 0;\r\n this._icdfPT.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n this._icdfPT.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n if (this._iblSource.isCube) {\r\n this._icdfPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n // Once the textures are generated, notify that they are ready to use.\r\n this._icdfPT.onGeneratedObservable.addOnce(() => {\r\n this.onGeneratedObservable.notifyObservers();\r\n });\r\n\r\n this._dominantDirectionPT = new ProceduralTexture(\"iblDominantDirection\", { width: 1, height: 1 }, \"iblDominantDirection\", this._scene, icdfOptions, false, false);\r\n this._dominantDirectionPT.autoClear = false;\r\n this._dominantDirectionPT.setTexture(\"icdfSampler\", this._icdfPT);\r\n this._dominantDirectionPT.refreshRate = 0;\r\n this._dominantDirectionPT.defines = \"#define NUM_SAMPLES 32u\\n\";\r\n }\r\n\r\n private _disposeTextures() {\r\n this._cdfyPT?.dispose();\r\n this._cdfxPT?.dispose();\r\n this._icdfPT?.dispose();\r\n this._scaledLuminancePT?.dispose();\r\n this._dominantDirectionPT?.dispose();\r\n }\r\n\r\n private _createDebugPass() {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n const isWebGPU = this._engine.isWebGPU;\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine: this._engine,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"cdfy\", \"icdf\", \"cdfx\", \"iblSource\"],\r\n defines: this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\",\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../ShadersWGSL/iblCdfDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/iblCdfDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._debugPass = new PostProcess(this._debugPassName, \"iblCdfDebug\", debugOptions);\r\n const debugEffect = this._debugPass.getEffect();\r\n if (debugEffect) {\r\n debugEffect.defines = this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\";\r\n }\r\n if (this._iblSource?.isCube) {\r\n this._debugPass.updateEffect(\"#define IBL_USE_CUBE_MAP\\n\");\r\n }\r\n this._debugPass.onApplyObservable.add((effect) => {\r\n effect.setTexture(\"cdfy\", this._cdfyPT);\r\n effect.setTexture(\"icdf\", this._icdfPT);\r\n effect.setTexture(\"cdfx\", this._cdfxPT);\r\n effect.setTexture(\"iblSource\", this._iblSource);\r\n effect.setFloat4(\"sizeParams\", this._debugSizeParams.x, this._debugSizeParams.y, this._debugSizeParams.z, this._debugSizeParams.w);\r\n });\r\n }\r\n\r\n /**\r\n * Checks if the CDF renderer is ready\r\n * @returns true if the CDF renderer is ready\r\n */\r\n public isReady() {\r\n return (\r\n this._iblSource &&\r\n this._iblSource.name !== \"Placeholder IBL Source\" &&\r\n this._iblSource.isReady() &&\r\n this._cdfyPT &&\r\n this._cdfyPT.isReady() &&\r\n this._icdfPT &&\r\n this._icdfPT.isReady() &&\r\n this._cdfxPT &&\r\n this._cdfxPT.isReady() &&\r\n this._scaledLuminancePT &&\r\n this._scaledLuminancePT.isReady()\r\n );\r\n }\r\n\r\n /**\r\n * Explicitly trigger generation of CDF maps when they are ready to render.\r\n * @returns Promise that resolves when the CDF maps are rendered.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/promise-function-async\r\n public renderWhenReady(): Promise<void> {\r\n this._cachedDominantDirection = null;\r\n\r\n // Even if a IBL source must be set before calling this function, _icdfPT may not yet be created because the creation may be asynchronous (see @set iblSource).\r\n const icdfPTPromise = new Promise((resolve, reject) => {\r\n _RetryWithInterval(\r\n () => !!this._icdfPT,\r\n () => resolve(void 0),\r\n () => reject(new Error(\"Waiting for _icdfPT creation failed\"))\r\n );\r\n });\r\n\r\n // eslint-disable-next-line github/no-then, @typescript-eslint/promise-function-async\r\n return icdfPTPromise.then(() => {\r\n // Once the textures are generated, notify that they are ready to use.\r\n this._icdfPT.onGeneratedObservable.addOnce(() => {\r\n this.onGeneratedObservable.notifyObservers();\r\n });\r\n const promises: Array<Promise<void>> = [];\r\n const renderTargets: Array<ProceduralTexture> = [this._cdfyPT, this._cdfxPT, this._scaledLuminancePT, this._icdfPT];\r\n for (const target of renderTargets) {\r\n promises.push(\r\n new Promise((resolve) => {\r\n if (target.isReady()) {\r\n resolve();\r\n } else {\r\n target.getEffect().executeWhenCompiled(() => {\r\n resolve();\r\n });\r\n }\r\n })\r\n );\r\n }\r\n // eslint-disable-next-line github/no-then\r\n return Promise.all(promises).then(() => {\r\n for (const target of renderTargets) {\r\n target.render();\r\n }\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Finds the average direction of the highest intensity areas of the IBL source\r\n * @returns Async promise that resolves to the dominant direction of the IBL source\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async\r\n public findDominantDirection(): Promise<Vector3> {\r\n if (this._cachedDominantDirection) {\r\n return Promise.resolve(this._cachedDominantDirection);\r\n }\r\n return new Promise((resolve) => {\r\n this._dominantDirectionPT.onGeneratedObservable.addOnce(() => {\r\n const data = new Float32Array(4);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._dominantDirectionPT.readPixels(0, 0, data, true)!.then(() => {\r\n const dominantDirection = new Vector3(data[0], data[1], data[2]);\r\n this._cachedDominantDirection = dominantDirection;\r\n resolve(dominantDirection);\r\n });\r\n });\r\n if (this.isReady()) {\r\n if (this._dominantDirectionPT.isReady()) {\r\n this._dominantDirectionPT.render();\r\n } else {\r\n this._dominantDirectionPT.getEffect().executeWhenCompiled(() => {\r\n this._dominantDirectionPT.render();\r\n });\r\n }\r\n } else {\r\n this.onGeneratedObservable.addOnce(() => {\r\n if (this._dominantDirectionPT.isReady()) {\r\n this._dominantDirectionPT.render();\r\n } else {\r\n this._dominantDirectionPT.getEffect().executeWhenCompiled(() => {\r\n this._dominantDirectionPT.render();\r\n });\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Disposes the CDF renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n this._dummyTexture.dispose();\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n this.onGeneratedObservable.clear();\r\n }\r\n\r\n private static _IsScene(sceneOrEngine: Scene | AbstractEngine): sceneOrEngine is Scene {\r\n return sceneOrEngine.getClassName() === \"Scene\";\r\n }\r\n}\r\n"]}
@@ -142,11 +142,17 @@ export declare class ObjectRenderer {
142
142
  */
143
143
  customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
144
144
  /**
145
- * An event triggered before rendering the objects
145
+ * An event triggered before rendering the objects.
146
+ * Note: This observable is also triggered during readiness checks (e.g. when calling scene.isReady()),
147
+ * in which case the render target is not bound to the output. Observers should avoid performing
148
+ * GPU state changes (such as clearing or modifying the framebuffer) unless the render target is actually bound.
146
149
  */
147
150
  readonly onBeforeRenderObservable: Observable<number>;
148
151
  /**
149
- * An event triggered after rendering the objects
152
+ * An event triggered after rendering the objects.
153
+ * Note: This observable is also triggered during readiness checks (e.g. when calling scene.isReady()),
154
+ * in which case the render target is not bound to the output. Observers should avoid performing
155
+ * GPU state changes (such as clearing or modifying the framebuffer) unless the render target is actually bound.
150
156
  */
151
157
  readonly onAfterRenderObservable: Observable<number>;
152
158
  /**
@@ -243,11 +243,17 @@ export class ObjectRenderer {
243
243
  this.dontSetTransformationMatrix = false;
244
244
  this._disableDepthPrePass = false;
245
245
  /**
246
- * An event triggered before rendering the objects
246
+ * An event triggered before rendering the objects.
247
+ * Note: This observable is also triggered during readiness checks (e.g. when calling scene.isReady()),
248
+ * in which case the render target is not bound to the output. Observers should avoid performing
249
+ * GPU state changes (such as clearing or modifying the framebuffer) unless the render target is actually bound.
247
250
  */
248
251
  this.onBeforeRenderObservable = new Observable();
249
252
  /**
250
- * An event triggered after rendering the objects
253
+ * An event triggered after rendering the objects.
254
+ * Note: This observable is also triggered during readiness checks (e.g. when calling scene.isReady()),
255
+ * in which case the render target is not bound to the output. Observers should avoid performing
256
+ * GPU state changes (such as clearing or modifying the framebuffer) unless the render target is actually bound.
251
257
  */
252
258
  this.onAfterRenderObservable = new Observable();
253
259
  /**