@babylonjs/core 7.32.3 → 7.32.4
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.
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Misc/webRequest.d.ts +4 -0
- package/Misc/webRequest.js +6 -0
- package/Misc/webRequest.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.d.ts +35 -11
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +131 -117
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.js +0 -1
- package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.d.ts +60 -0
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js +166 -0
- package/Rendering/IBLShadows/iblShadowsPluginMaterial.js.map +1 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +97 -56
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +356 -308
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.d.ts +20 -6
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js +67 -35
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +9 -4
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +84 -66
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +31 -6
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +108 -60
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/geometryBufferRenderer.d.ts +15 -0
- package/Rendering/geometryBufferRenderer.js +48 -5
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/instancesDeclaration.js +2 -4
- package/Shaders/ShadersInclude/instancesDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/instancesVertex.js +3 -6
- package/Shaders/ShadersInclude/instancesVertex.js.map +1 -1
- package/Shaders/geometry.fragment.js +5 -1
- package/Shaders/geometry.fragment.js.map +1 -1
- package/Shaders/geometry.vertex.js +3 -3
- package/Shaders/geometry.vertex.js.map +1 -1
- package/Shaders/iblShadowAccumulation.fragment.js +7 -11
- package/Shaders/iblShadowAccumulation.fragment.js.map +1 -1
- package/Shaders/iblShadowGBufferDebug.fragment.js +2 -3
- package/Shaders/iblShadowGBufferDebug.fragment.js.map +1 -1
- package/Shaders/iblShadowSpatialBlur.fragment.js +5 -5
- package/Shaders/iblShadowSpatialBlur.fragment.js.map +1 -1
- package/Shaders/iblShadowVoxelTracing.fragment.js +31 -32
- package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/Shaders/iblShadowsCombine.fragment.js +2 -2
- package/Shaders/iblShadowsCombine.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/instancesDeclaration.js +2 -4
- package/ShadersWGSL/ShadersInclude/instancesDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/instancesVertex.js +3 -6
- package/ShadersWGSL/ShadersInclude/instancesVertex.js.map +1 -1
- package/ShadersWGSL/geometry.fragment.js +7 -1
- package/ShadersWGSL/geometry.fragment.js.map +1 -1
- package/ShadersWGSL/geometry.vertex.js +3 -3
- package/ShadersWGSL/geometry.vertex.js.map +1 -1
- package/ShadersWGSL/iblShadowAccumulation.fragment.js +5 -10
- package/ShadersWGSL/iblShadowAccumulation.fragment.js.map +1 -1
- package/ShadersWGSL/iblShadowGBufferDebug.fragment.js +2 -3
- package/ShadersWGSL/iblShadowGBufferDebug.fragment.js.map +1 -1
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.js +5 -5
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.js.map +1 -1
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +45 -33
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/ShadersWGSL/iblShadowsCombine.fragment.js +6 -2
- package/ShadersWGSL/iblShadowsCombine.fragment.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
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;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,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;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,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;IAcjC;;;OAGG;IACI,YAAY;QACf,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC7B,OAAO,IAAI,CAAC,YAAY,CAAC;SAC5B;aAAM;Y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CAAC,CAAC;YAC/C,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;SACpC;QACD,IAAI,IAAI,CAAC,eAAe,EAAE;YACtB,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;SAClC;QACD,8CAA8C;IAClD,CAAC;CACJ","sourcesContent":["import { Constants } 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 { 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 { 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 * #8R5SSE#222\r\n */\r\nexport class _IblShadowsVoxelRenderer {\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n private _renderPipeline: IblShadowsRenderPipeline;\r\n private _voxelGridRT: 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 private _isVoxelGrid3D: boolean = true;\r\n private _renderInFlight = false;\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._triPlanarVoxelization) {\r\n return this._voxelGridRT;\r\n } else {\r\n return this._voxelGridZaxis;\r\n }\r\n }\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._triPlanarVoxelization === enabled) {\r\n return;\r\n }\r\n this._triPlanarVoxelization = enabled;\r\n this._disposeVoxelTextures();\r\n this._createTextures();\r\n this._renderPipeline.updateVoxelization();\r\n }\r\n\r\n private _voxelizationInProgress: boolean = false;\r\n private _invWorldScaleMatrix: Matrix;\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\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\", { ratio: 1 }, this._scene, {\r\n generateDepthBuffer: true,\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 });\r\n this._voxelSlabDebugRT.noPrePassRenderer = true;\r\n } else {\r\n if (this._voxelSlabDebugRT) {\r\n this._removeVoxelRTs([this._voxelSlabDebugRT]);\r\n }\r\n }\r\n }\r\n\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_R,\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 (this._isVoxelGrid3D) {\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 return;\r\n }\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblVoxelGrid2dArrayDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._voxelDebugPass = new PostProcess(this.debugPassName, this._isVoxelGrid3D ? \"iblVoxelGrid3dDebug\" : \"iblVoxelGrid2dArrayDebug\", 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. More expensive, but can help with artifacts.\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 = triPlanarVoxelization;\r\n this._renderPipeline = iblShadowsRenderPipeline;\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 this._maxDrawBuffers = this._engine.getCaps().maxDrawBuffers || 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 layers: this._isVoxelGrid3D ? undefined : this._voxelResolution,\r\n depth: this._isVoxelGrid3D ? this._voxelResolution : undefined,\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_R,\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._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._voxelGridRT = new ProceduralTexture(\"combinedVoxelGrid\", size, \"iblCombineVoxelGrids\", this._scene, voxelCombinedOptions, false);\r\n this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._voxelGridRT), 1);\r\n this._voxelGridRT.setFloat(\"layer\", 0.0);\r\n this._voxelGridRT.setTexture(\"voxelXaxisSampler\", this._voxelGridXaxis);\r\n this._voxelGridRT.setTexture(\"voxelYaxisSampler\", this._voxelGridYaxis);\r\n this._voxelGridRT.setTexture(\"voxelZaxisSampler\", this._voxelGridZaxis);\r\n // We will render this only after voxelization is completed for the 3 axes.\r\n this._voxelGridRT.autoClear = false;\r\n this._voxelGridRT.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this._voxelGridRT.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\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(this._isVoxelGrid3D ? Constants.TEXTURE_3D : Constants.TEXTURE_2D_ARRAY);\r\n\r\n for (let mrt_index = 0; mrt_index < numSlabs; mrt_index++) {\r\n let layerIndices = new Array(this._maxDrawBuffers).fill(0);\r\n layerIndices = layerIndices.map((value, index) => mrt_index * this._maxDrawBuffers + index);\r\n\r\n let textureNames = new Array(this._maxDrawBuffers).fill(\"\");\r\n textureNames = textureNames.map((value, index) => \"voxel_grid_\" + name + (mrt_index * this._maxDrawBuffers + index));\r\n\r\n const mrt = new MultiRenderTarget(\r\n \"mrt_\" + name + mrt_index,\r\n { width: this._voxelResolution, height: this._voxelResolution, depth: this._isVoxelGrid3D ? this._voxelResolution : undefined },\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._voxelGridRT?.dispose();\r\n }\r\n this._voxelGridZaxis?.dispose();\r\n this._mipArray.forEach((mip) => {\r\n mip.dispose();\r\n });\r\n this._mipArray = [];\r\n this._voxelMrtsXaxis = [];\r\n this._voxelMrtsYaxis = [];\r\n this._voxelMrtsZaxis = [];\r\n }\r\n\r\n private _createVoxelMaterial(): ShaderMaterial {\r\n const isWebGPU = this._engine.isWebGPU;\r\n const voxelMaterial = new ShaderMaterial(\"voxelization\", this._scene, \"iblVoxelGrid\", {\r\n uniforms: [\"world\", \"viewMatrix\", \"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 voxelMaterial.cullBackFaces = false;\r\n voxelMaterial.backFaceCulling = false;\r\n voxelMaterial.depthFunction = Engine.ALWAYS;\r\n return voxelMaterial;\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 }\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]) return true;\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]) return true;\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 excludedMeshes\r\n */\r\n public updateVoxelGrid(excludedMeshes: number[]) {\r\n this._stopVoxelization();\r\n\r\n this._voxelizationInProgress = true;\r\n\r\n if (this._triPlanarVoxelization) {\r\n this._addRTsForRender(this._voxelMrtsXaxis, excludedMeshes, 0);\r\n this._addRTsForRender(this._voxelMrtsYaxis, excludedMeshes, 1);\r\n this._addRTsForRender(this._voxelMrtsZaxis, excludedMeshes, 2);\r\n } else {\r\n this._addRTsForRender(this._voxelMrtsZaxis, excludedMeshes, 2);\r\n }\r\n\r\n // Add the slab debug RT if needed.\r\n if (this._voxelDebugEnabled) {\r\n this._removeVoxelRTs([this._voxelSlabDebugRT]);\r\n this._addRTsForRender([this._voxelSlabDebugRT], [], this._voxelDebugAxis, 1, true);\r\n }\r\n\r\n (this as any).boundVoxelGridRenderFn = this._renderVoxelGrid.bind(this);\r\n this._scene.onAfterRenderTargetsRenderObservable.add((this as any).boundVoxelGridRenderFn);\r\n }\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 this._renderInFlight = false;\r\n (this._scene.prePassRenderer as any)._setEnabled(false);\r\n this._renderTargets.forEach((rt) => {\r\n rt.render();\r\n });\r\n this._stopVoxelization();\r\n\r\n if (this._triPlanarVoxelization) {\r\n this._voxelGridRT.render();\r\n }\r\n this._generateMipMaps();\r\n this._copyMipMaps();\r\n this._voxelizationInProgress = false;\r\n this._scene.onAfterRenderTargetsRenderObservable.removeCallback((this as any).boundVoxelGridRenderFn);\r\n (this._scene.prePassRenderer as any)._setEnabled(true);\r\n } else if (!this._renderInFlight) {\r\n this._renderInFlight = true;\r\n setTimeout(() => {\r\n this._renderVoxelGrid();\r\n }, 16);\r\n }\r\n }\r\n }\r\n\r\n private _addRTsForRender(mrts: RenderTargetTexture[], excludedMeshes: number[], axis: number, shaderType: number = 0, continuousRender: boolean = false) {\r\n const slabSize = 1.0 / this._computeNumberOfSlabs();\r\n const meshes = this._scene.meshes;\r\n\r\n // We need to update the world scale uniform for every mesh being rendered to the voxel grid.\r\n mrts.forEach((mrt, 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 let voxelMaterial: ShaderMaterial;\r\n if (shaderType === 0) {\r\n voxelMaterial = this._createVoxelMaterial();\r\n } else {\r\n const isWebGPU = this._engine.isWebGPU;\r\n voxelMaterial = 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 this._scene.onBeforeRenderObservable.add(() => {\r\n voxelMaterial.setMatrix(\"projection\", this._scene.activeCamera!.getProjectionMatrix());\r\n voxelMaterial.setMatrix(\"cameraViewMatrix\", this._scene.activeCamera!.getViewMatrix());\r\n });\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 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\r\n // Set this material on every mesh in the scene (for this RT)\r\n meshes.forEach((mesh) => {\r\n if (mesh instanceof Mesh && mesh.material && excludedMeshes.indexOf(mesh.uniqueId) === -1) {\r\n mrt.renderList?.push(mesh);\r\n\r\n // TODO - if the mesh already has a voxel material applied, don't create a new one.\r\n // mesh.getMaterialForRenderPass(mrt.renderPassIds)\r\n mrt.setMaterialForRendering(mesh, voxelMaterial);\r\n }\r\n });\r\n });\r\n\r\n // Add the MRT's to render.\r\n if (continuousRender) {\r\n this._scene.customRenderTargets = this._scene.customRenderTargets.concat(mrts);\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,E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AAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAC1D;IACL,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC3I,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,iBAAiB,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;SACpC;QACD,IAAI,IAAI,CAAC,eAAe,EAAE;YACtB,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;SAClC;QACD,8CAA8C;IAClD,CAAC;CACJ","sourcesContent":["import { Constants } 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 { 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 * #8R5SSE#222\r\n */\r\nexport class _IblShadowsVoxelRenderer {\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n private _voxelGridRT: 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 private _isVoxelGrid3D: boolean = true;\r\n private _renderInFlight = false;\r\n private _voxelMaterial: ShaderMaterial;\r\n private _voxelSlabDebugMaterial: ShaderMaterial;\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._triPlanarVoxelization) {\r\n return this._voxelGridRT;\r\n } else {\r\n return this._voxelGridZaxis;\r\n }\r\n }\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._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 (this._isVoxelGrid3D) {\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 return;\r\n }\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblVoxelGrid2dArrayDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._voxelDebugPass = new PostProcess(this.debugPassName, this._isVoxelGrid3D ? \"iblVoxelGrid3dDebug\" : \"iblVoxelGrid2dArrayDebug\", 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. More expensive, but can help with artifacts.\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 = 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 this._maxDrawBuffers = this._engine.getCaps().maxDrawBuffers || 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 layers: this._isVoxelGrid3D ? undefined : this._voxelResolution,\r\n depth: this._isVoxelGrid3D ? this._voxelResolution : undefined,\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_R,\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._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._voxelGridRT = new ProceduralTexture(\"combinedVoxelGrid\", size, \"iblCombineVoxelGrids\", this._scene, voxelCombinedOptions, false);\r\n this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._voxelGridRT), 1);\r\n this._voxelGridRT.setFloat(\"layer\", 0.0);\r\n this._voxelGridRT.setTexture(\"voxelXaxisSampler\", this._voxelGridXaxis);\r\n this._voxelGridRT.setTexture(\"voxelYaxisSampler\", this._voxelGridYaxis);\r\n this._voxelGridRT.setTexture(\"voxelZaxisSampler\", this._voxelGridZaxis);\r\n // We will render this only after voxelization is completed for the 3 axes.\r\n this._voxelGridRT.autoClear = false;\r\n this._voxelGridRT.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this._voxelGridRT.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(this._isVoxelGrid3D ? Constants.TEXTURE_3D : Constants.TEXTURE_2D_ARRAY);\r\n\r\n for (let mrt_index = 0; mrt_index < numSlabs; mrt_index++) {\r\n let layerIndices = new Array(this._maxDrawBuffers).fill(0);\r\n layerIndices = layerIndices.map((value, index) => mrt_index * this._maxDrawBuffers + index);\r\n\r\n let textureNames = new Array(this._maxDrawBuffers).fill(\"\");\r\n textureNames = textureNames.map((value, index) => \"voxel_grid_\" + name + (mrt_index * this._maxDrawBuffers + index));\r\n\r\n const mrt = new MultiRenderTarget(\r\n \"mrt_\" + name + mrt_index,\r\n { width: this._voxelResolution, height: this._voxelResolution, depth: this._isVoxelGrid3D ? this._voxelResolution : undefined },\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._voxelGridRT?.dispose();\r\n }\r\n this._voxelGridZaxis?.dispose();\r\n this._mipArray.forEach((mip) => {\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\", \"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 }\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]) return true;\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]) return true;\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 this._stopVoxelization();\r\n this._includedMeshes = includedMeshes;\r\n this._voxelizationInProgress = true;\r\n\r\n 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._scene.onAfterRenderTargetsRenderObservable.addOnce(this._renderVoxelGrid.bind(this));\r\n }\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 this._renderInFlight = false;\r\n this._renderTargets.forEach((rt) => {\r\n rt.render();\r\n });\r\n this._stopVoxelization();\r\n\r\n if (this._triPlanarVoxelization) {\r\n this._voxelGridRT.render();\r\n }\r\n this._generateMipMaps();\r\n this._copyMipMaps();\r\n this._voxelizationInProgress = false;\r\n this._scene.onAfterRenderTargetsRenderObservable.removeCallback((this as any).boundVoxelGridRenderFn);\r\n } else if (!this._renderInFlight) {\r\n this._renderInFlight = true;\r\n setTimeout(() => {\r\n this._renderVoxelGrid();\r\n }, 16);\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 mrts.forEach((mrt, 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.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 });\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 includedMeshes.forEach((mesh) => {\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 mesh.getChildMeshes().forEach((childMesh) => {\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 mrts.forEach((mrt) => {\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"]}
|
|
@@ -2,6 +2,7 @@ import type { Scene } from "../../scene";
|
|
|
2
2
|
import { Matrix } from "../../Maths/math.vector";
|
|
3
3
|
import { PostProcess } from "../../PostProcesses/postProcess";
|
|
4
4
|
import type { IblShadowsRenderPipeline } from "./iblShadowsRenderPipeline";
|
|
5
|
+
import { ProceduralTexture } from "../../Materials/Textures/Procedurals/proceduralTexture.js";
|
|
5
6
|
/**
|
|
6
7
|
* Build cdf maps for IBL importance sampling during IBL shadow computation.
|
|
7
8
|
* This should not be instanciated directly, as it is part of a scene component
|
|
@@ -65,12 +66,32 @@ export declare class _IblShadowsVoxelTracingPass {
|
|
|
65
66
|
* The thickness of the screen-space shadow
|
|
66
67
|
*/
|
|
67
68
|
set sssThickness(value: number);
|
|
68
|
-
private
|
|
69
|
+
private _outputTexture;
|
|
69
70
|
private _cameraInvView;
|
|
70
71
|
private _cameraInvProj;
|
|
71
72
|
private _invWorldScaleMatrix;
|
|
72
73
|
private _frameId;
|
|
73
74
|
private _sampleDirections;
|
|
75
|
+
private _shadowParameters;
|
|
76
|
+
private _sssParameters;
|
|
77
|
+
private _opacityParameters;
|
|
78
|
+
private _voxelBiasParameters;
|
|
79
|
+
private _voxelNormalBias;
|
|
80
|
+
/**
|
|
81
|
+
* The bias to apply to the voxel sampling in the direction of the surface normal of the geometry.
|
|
82
|
+
*/
|
|
83
|
+
get voxelNormalBias(): number;
|
|
84
|
+
set voxelNormalBias(value: number);
|
|
85
|
+
private _voxelDirectionBias;
|
|
86
|
+
/**
|
|
87
|
+
* The bias to apply to the voxel sampling in the direction of the light.
|
|
88
|
+
*/
|
|
89
|
+
get voxelDirectionBias(): number;
|
|
90
|
+
set voxelDirectionBias(value: number);
|
|
91
|
+
/**
|
|
92
|
+
* Is the effect enabled
|
|
93
|
+
*/
|
|
94
|
+
enabled: boolean;
|
|
74
95
|
/**
|
|
75
96
|
* The number of directions to sample for the voxel tracing.
|
|
76
97
|
*/
|
|
@@ -90,10 +111,10 @@ export declare class _IblShadowsVoxelTracingPass {
|
|
|
90
111
|
/** Enable the debug view for this pass */
|
|
91
112
|
debugEnabled: boolean;
|
|
92
113
|
/**
|
|
93
|
-
*
|
|
94
|
-
* @returns The
|
|
114
|
+
* Returns the output texture of the pass.
|
|
115
|
+
* @returns The output texture.
|
|
95
116
|
*/
|
|
96
|
-
|
|
117
|
+
getOutputTexture(): ProceduralTexture;
|
|
97
118
|
/**
|
|
98
119
|
* Gets the debug pass post process. This will create the resources for the pass
|
|
99
120
|
* if they don't already exist.
|
|
@@ -107,7 +128,6 @@ export declare class _IblShadowsVoxelTracingPass {
|
|
|
107
128
|
get debugPassName(): string;
|
|
108
129
|
/** The default rotation of the environment map will align the shadows with the default lighting orientation */
|
|
109
130
|
private _envRotation;
|
|
110
|
-
private _downscale;
|
|
111
131
|
/**
|
|
112
132
|
* Set the matrix to use for scaling the world space to voxel space
|
|
113
133
|
* @param matrix The matrix to use for scaling the world space to voxel space
|
|
@@ -136,7 +156,12 @@ export declare class _IblShadowsVoxelTracingPass {
|
|
|
136
156
|
*/
|
|
137
157
|
constructor(scene: Scene, iblShadowsRenderPipeline: IblShadowsRenderPipeline);
|
|
138
158
|
private _createTextures;
|
|
139
|
-
private
|
|
159
|
+
private _setBindings;
|
|
160
|
+
/**
|
|
161
|
+
* Called by render pipeline when canvas resized.
|
|
162
|
+
* @param scaleFactor The factor by which to scale the canvas size.
|
|
163
|
+
*/
|
|
164
|
+
resize(scaleFactor?: number): void;
|
|
140
165
|
/**
|
|
141
166
|
* Checks if the pass is ready
|
|
142
167
|
* @returns true if the pass is ready
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import { Matrix,
|
|
2
|
+
import { Matrix, Vector4 } from "../../Maths/math.vector.js";
|
|
3
3
|
import { PostProcess } from "../../PostProcesses/postProcess.js";
|
|
4
|
+
import { GeometryBufferRenderer } from "../../Rendering/geometryBufferRenderer.js";
|
|
5
|
+
import { ProceduralTexture } from "../../Materials/Textures/Procedurals/proceduralTexture.js";
|
|
4
6
|
/**
|
|
5
7
|
* Build cdf maps for IBL importance sampling during IBL shadow computation.
|
|
6
8
|
* This should not be instanciated directly, as it is part of a scene component
|
|
@@ -79,6 +81,24 @@ export class _IblShadowsVoxelTracingPass {
|
|
|
79
81
|
set sssThickness(value) {
|
|
80
82
|
this._sssThickness = value;
|
|
81
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* The bias to apply to the voxel sampling in the direction of the surface normal of the geometry.
|
|
86
|
+
*/
|
|
87
|
+
get voxelNormalBias() {
|
|
88
|
+
return this._voxelNormalBias;
|
|
89
|
+
}
|
|
90
|
+
set voxelNormalBias(value) {
|
|
91
|
+
this._voxelNormalBias = value;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The bias to apply to the voxel sampling in the direction of the light.
|
|
95
|
+
*/
|
|
96
|
+
get voxelDirectionBias() {
|
|
97
|
+
return this._voxelDirectionBias;
|
|
98
|
+
}
|
|
99
|
+
set voxelDirectionBias(value) {
|
|
100
|
+
this._voxelDirectionBias = value;
|
|
101
|
+
}
|
|
82
102
|
/**
|
|
83
103
|
* The number of directions to sample for the voxel tracing.
|
|
84
104
|
*/
|
|
@@ -104,11 +124,11 @@ export class _IblShadowsVoxelTracingPass {
|
|
|
104
124
|
this._envRotation = value;
|
|
105
125
|
}
|
|
106
126
|
/**
|
|
107
|
-
*
|
|
108
|
-
* @returns The
|
|
127
|
+
* Returns the output texture of the pass.
|
|
128
|
+
* @returns The output texture.
|
|
109
129
|
*/
|
|
110
|
-
|
|
111
|
-
return this.
|
|
130
|
+
getOutputTexture() {
|
|
131
|
+
return this._outputTexture;
|
|
112
132
|
}
|
|
113
133
|
/**
|
|
114
134
|
* Gets the debug pass post process. This will create the resources for the pass
|
|
@@ -171,7 +191,7 @@ export class _IblShadowsVoxelTracingPass {
|
|
|
171
191
|
this._debugPassPP.autoClear = false;
|
|
172
192
|
this._debugPassPP.onApplyObservable.add((effect) => {
|
|
173
193
|
// update the caustic texture with what we just rendered.
|
|
174
|
-
effect.
|
|
194
|
+
effect.setTexture("debugSampler", this._outputTexture);
|
|
175
195
|
effect.setVector4("sizeParams", this._debugSizeParams);
|
|
176
196
|
});
|
|
177
197
|
}
|
|
@@ -194,12 +214,21 @@ export class _IblShadowsVoxelTracingPass {
|
|
|
194
214
|
this._invWorldScaleMatrix = Matrix.Identity();
|
|
195
215
|
this._frameId = 0;
|
|
196
216
|
this._sampleDirections = 4;
|
|
217
|
+
this._shadowParameters = new Vector4(0.0, 0.0, 0.0, 0.0);
|
|
218
|
+
this._sssParameters = new Vector4(0.0, 0.0, 0.0, 0.0);
|
|
219
|
+
this._opacityParameters = new Vector4(0.0, 0.0, 0.0, 0.0);
|
|
220
|
+
this._voxelBiasParameters = new Vector4(0.0, 0.0, 0.0, 0.0);
|
|
221
|
+
this._voxelNormalBias = 1.4;
|
|
222
|
+
this._voxelDirectionBias = 1.75;
|
|
223
|
+
/**
|
|
224
|
+
* Is the effect enabled
|
|
225
|
+
*/
|
|
226
|
+
this.enabled = true;
|
|
197
227
|
/** Enable the debug view for this pass */
|
|
198
228
|
this.debugEnabled = false;
|
|
199
229
|
this._debugPassName = "Voxel Tracing Debug Pass";
|
|
200
230
|
/** The default rotation of the environment map will align the shadows with the default lighting orientation */
|
|
201
231
|
this._envRotation = 0.0;
|
|
202
|
-
this._downscale = 1.0;
|
|
203
232
|
this._debugVoxelMarchEnabled = false;
|
|
204
233
|
this._debugSizeParams = new Vector4(0.0, 0.0, 0.0, 0.0);
|
|
205
234
|
this._scene = scene;
|
|
@@ -216,92 +245,111 @@ export class _IblShadowsVoxelTracingPass {
|
|
|
216
245
|
defines += "#define VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION 1u\n";
|
|
217
246
|
}
|
|
218
247
|
const isWebGPU = this._engine.isWebGPU;
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
textureFormat: 7,
|
|
223
|
-
textureType: 0,
|
|
248
|
+
const textureOptions = {
|
|
249
|
+
type: 0,
|
|
250
|
+
format: 5,
|
|
224
251
|
samplingMode: 1,
|
|
225
|
-
|
|
226
|
-
samplers: ["voxelGridSampler", "icdfySampler", "icdfxSampler", "blueNoiseSampler", "worldNormalSampler", "depthSampler", "worldPositionSampler"],
|
|
227
|
-
defines: defines,
|
|
228
|
-
engine: this._engine,
|
|
229
|
-
reusable: false,
|
|
252
|
+
generateDepthBuffer: false,
|
|
230
253
|
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
231
|
-
|
|
232
|
-
if (
|
|
233
|
-
|
|
254
|
+
extraInitializationsAsync: async () => {
|
|
255
|
+
if (isWebGPU) {
|
|
256
|
+
await Promise.all([import("../../ShadersWGSL/iblShadowVoxelTracing.fragment.js")]);
|
|
234
257
|
}
|
|
235
258
|
else {
|
|
236
|
-
|
|
259
|
+
await Promise.all([import("../../Shaders/iblShadowVoxelTracing.fragment.js")]);
|
|
237
260
|
}
|
|
238
261
|
},
|
|
239
262
|
};
|
|
240
|
-
this.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
263
|
+
this._outputTexture = new ProceduralTexture("voxelTracingPass", {
|
|
264
|
+
width: this._engine.getRenderWidth(),
|
|
265
|
+
height: this._engine.getRenderHeight(),
|
|
266
|
+
}, "iblShadowVoxelTracing", this._scene, textureOptions);
|
|
267
|
+
this._outputTexture.refreshRate = -1;
|
|
268
|
+
this._outputTexture.autoClear = false;
|
|
269
|
+
this._outputTexture.defines = defines;
|
|
270
|
+
// Need to set all the textures first so that the effect gets created with the proper uniforms.
|
|
271
|
+
this._setBindings(this._scene.activeCamera);
|
|
272
|
+
let counter = 0;
|
|
273
|
+
this._scene.onBeforeRenderObservable.add(() => {
|
|
274
|
+
counter = 0;
|
|
275
|
+
});
|
|
276
|
+
this._scene.onAfterRenderTargetsRenderObservable.add(() => {
|
|
277
|
+
if (++counter == 2) {
|
|
278
|
+
if (this.enabled && this._outputTexture.isReady()) {
|
|
279
|
+
this._setBindings(this._scene.activeCamera);
|
|
280
|
+
this._outputTexture.render();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
244
283
|
});
|
|
245
284
|
}
|
|
246
|
-
|
|
285
|
+
_setBindings(camera) {
|
|
247
286
|
if (this._scene.useRightHandedSystem) {
|
|
248
|
-
|
|
287
|
+
this._outputTexture.defines = "#define RIGHT_HANDED\n";
|
|
249
288
|
}
|
|
250
|
-
|
|
251
|
-
|
|
289
|
+
this._outputTexture.setMatrix("viewMtx", camera.getViewMatrix());
|
|
290
|
+
this._outputTexture.setMatrix("projMtx", camera.getProjectionMatrix());
|
|
252
291
|
camera.getProjectionMatrix().invertToRef(this._cameraInvProj);
|
|
253
292
|
camera.getViewMatrix().invertToRef(this._cameraInvView);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
293
|
+
this._outputTexture.setMatrix("invProjMtx", this._cameraInvProj);
|
|
294
|
+
this._outputTexture.setMatrix("invViewMtx", this._cameraInvView);
|
|
295
|
+
this._outputTexture.setMatrix("wsNormalizationMtx", this._invWorldScaleMatrix);
|
|
257
296
|
this._frameId++;
|
|
258
|
-
const downscaleSquared = this._downscale * this._downscale;
|
|
259
297
|
let rotation = this._scene.useRightHandedSystem ? -(this._envRotation + 0.5 * Math.PI) : this._envRotation - 0.5 * Math.PI;
|
|
260
298
|
rotation = rotation % (2.0 * Math.PI);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const voxelGrid = this._renderPipeline.
|
|
299
|
+
this._shadowParameters.set(this._sampleDirections, this._frameId, 1.0, rotation);
|
|
300
|
+
this._outputTexture.setVector4("shadowParameters", this._shadowParameters);
|
|
301
|
+
const voxelGrid = this._renderPipeline._getVoxelGridTexture();
|
|
264
302
|
const highestMip = Math.floor(Math.log2(voxelGrid.getSize().width));
|
|
265
|
-
|
|
303
|
+
this._voxelBiasParameters.set(this._voxelNormalBias, this._voxelDirectionBias, highestMip, 0.0);
|
|
304
|
+
this._outputTexture.setVector4("voxelBiasParameters", this._voxelBiasParameters);
|
|
266
305
|
// SSS Options.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
306
|
+
this._sssParameters.set(this._sssSamples, this._sssStride, this._sssMaxDist, this._sssThickness);
|
|
307
|
+
this._outputTexture.setVector4("sssParameters", this._sssParameters);
|
|
308
|
+
this._opacityParameters.set(this._voxelShadowOpacity, this._ssShadowOpacity, 0.0, 0.0);
|
|
309
|
+
this._outputTexture.setVector4("shadowOpacity", this._opacityParameters);
|
|
310
|
+
this._outputTexture.setTexture("voxelGridSampler", voxelGrid);
|
|
311
|
+
this._outputTexture.setTexture("blueNoiseSampler", this._renderPipeline._getNoiseTexture());
|
|
312
|
+
this._outputTexture.setTexture("icdfySampler", this._renderPipeline._getIcdfyTexture());
|
|
313
|
+
this._outputTexture.setTexture("icdfxSampler", this._renderPipeline._getIcdfxTexture());
|
|
273
314
|
if (this._debugVoxelMarchEnabled) {
|
|
274
|
-
|
|
315
|
+
this._outputTexture.defines += "#define VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION 1u\n";
|
|
275
316
|
}
|
|
276
|
-
const
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
const clipDepthIndex = prePassRenderer.getIndex(10);
|
|
280
|
-
const wPositionIndex = prePassRenderer.getIndex(1);
|
|
281
|
-
if (wnormalIndex >= 0)
|
|
282
|
-
effect.setTexture("worldNormalSampler", prePassRenderer.getRenderTarget().textures[wnormalIndex]);
|
|
283
|
-
if (clipDepthIndex >= 0)
|
|
284
|
-
effect.setTexture("depthSampler", prePassRenderer.getRenderTarget().textures[clipDepthIndex]);
|
|
285
|
-
if (wPositionIndex >= 0)
|
|
286
|
-
effect.setTexture("worldPositionSampler", prePassRenderer.getRenderTarget().textures[wPositionIndex]);
|
|
317
|
+
const geometryBufferRenderer = this._scene.geometryBufferRenderer;
|
|
318
|
+
if (!geometryBufferRenderer) {
|
|
319
|
+
return;
|
|
287
320
|
}
|
|
321
|
+
const depthIndex = geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.SCREENSPACE_DEPTH_TEXTURE_TYPE);
|
|
322
|
+
this._outputTexture.setTexture("depthSampler", geometryBufferRenderer.getGBuffer().textures[depthIndex]);
|
|
323
|
+
const wnormalIndex = geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE);
|
|
324
|
+
this._outputTexture.setTexture("worldNormalSampler", geometryBufferRenderer.getGBuffer().textures[wnormalIndex]);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Called by render pipeline when canvas resized.
|
|
328
|
+
* @param scaleFactor The factor by which to scale the canvas size.
|
|
329
|
+
*/
|
|
330
|
+
resize(scaleFactor = 1.0) {
|
|
331
|
+
const newSize = {
|
|
332
|
+
width: Math.max(1.0, Math.floor(this._engine.getRenderWidth() * scaleFactor)),
|
|
333
|
+
height: Math.max(1.0, Math.floor(this._engine.getRenderHeight() * scaleFactor)),
|
|
334
|
+
};
|
|
335
|
+
this._outputTexture.resize(newSize, false);
|
|
288
336
|
}
|
|
289
337
|
/**
|
|
290
338
|
* Checks if the pass is ready
|
|
291
339
|
* @returns true if the pass is ready
|
|
292
340
|
*/
|
|
293
341
|
isReady() {
|
|
294
|
-
return (this.
|
|
342
|
+
return (this._outputTexture.isReady() &&
|
|
295
343
|
!(this._debugPassPP && !this._debugPassPP.isReady()) &&
|
|
296
|
-
this._renderPipeline.
|
|
297
|
-
this._renderPipeline.
|
|
298
|
-
this._renderPipeline.
|
|
344
|
+
this._renderPipeline._getIcdfyTexture().isReady() &&
|
|
345
|
+
this._renderPipeline._getIcdfxTexture().isReady() &&
|
|
346
|
+
this._renderPipeline._getVoxelGridTexture().isReady());
|
|
299
347
|
}
|
|
300
348
|
/**
|
|
301
349
|
* Disposes the associated resources
|
|
302
350
|
*/
|
|
303
351
|
dispose() {
|
|
304
|
-
this.
|
|
352
|
+
this._outputTexture.dispose();
|
|
305
353
|
if (this._debugPassPP) {
|
|
306
354
|
this._debugPassPP.dispose();
|
|
307
355
|
}
|