@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.
Files changed (65) hide show
  1. package/Engines/abstractEngine.js +2 -2
  2. package/Engines/abstractEngine.js.map +1 -1
  3. package/Misc/webRequest.d.ts +4 -0
  4. package/Misc/webRequest.js +6 -0
  5. package/Misc/webRequest.js.map +1 -1
  6. package/Rendering/IBLShadows/iblShadowsAccumulationPass.d.ts +35 -11
  7. package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +131 -117
  8. package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
  9. package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.js +0 -1
  10. package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.js.map +1 -1
  11. package/Rendering/IBLShadows/iblShadowsPluginMaterial.d.ts +60 -0
  12. package/Rendering/IBLShadows/iblShadowsPluginMaterial.js +166 -0
  13. package/Rendering/IBLShadows/iblShadowsPluginMaterial.js.map +1 -0
  14. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +97 -56
  15. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +356 -308
  16. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  17. package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.d.ts +20 -6
  18. package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js +67 -35
  19. package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js.map +1 -1
  20. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +9 -4
  21. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +84 -66
  22. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  23. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +31 -6
  24. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +108 -60
  25. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
  26. package/Rendering/geometryBufferRenderer.d.ts +15 -0
  27. package/Rendering/geometryBufferRenderer.js +48 -5
  28. package/Rendering/geometryBufferRenderer.js.map +1 -1
  29. package/Shaders/ShadersInclude/instancesDeclaration.js +2 -4
  30. package/Shaders/ShadersInclude/instancesDeclaration.js.map +1 -1
  31. package/Shaders/ShadersInclude/instancesVertex.js +3 -6
  32. package/Shaders/ShadersInclude/instancesVertex.js.map +1 -1
  33. package/Shaders/geometry.fragment.js +5 -1
  34. package/Shaders/geometry.fragment.js.map +1 -1
  35. package/Shaders/geometry.vertex.js +3 -3
  36. package/Shaders/geometry.vertex.js.map +1 -1
  37. package/Shaders/iblShadowAccumulation.fragment.js +7 -11
  38. package/Shaders/iblShadowAccumulation.fragment.js.map +1 -1
  39. package/Shaders/iblShadowGBufferDebug.fragment.js +2 -3
  40. package/Shaders/iblShadowGBufferDebug.fragment.js.map +1 -1
  41. package/Shaders/iblShadowSpatialBlur.fragment.js +5 -5
  42. package/Shaders/iblShadowSpatialBlur.fragment.js.map +1 -1
  43. package/Shaders/iblShadowVoxelTracing.fragment.js +31 -32
  44. package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
  45. package/Shaders/iblShadowsCombine.fragment.js +2 -2
  46. package/Shaders/iblShadowsCombine.fragment.js.map +1 -1
  47. package/ShadersWGSL/ShadersInclude/instancesDeclaration.js +2 -4
  48. package/ShadersWGSL/ShadersInclude/instancesDeclaration.js.map +1 -1
  49. package/ShadersWGSL/ShadersInclude/instancesVertex.js +3 -6
  50. package/ShadersWGSL/ShadersInclude/instancesVertex.js.map +1 -1
  51. package/ShadersWGSL/geometry.fragment.js +7 -1
  52. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  53. package/ShadersWGSL/geometry.vertex.js +3 -3
  54. package/ShadersWGSL/geometry.vertex.js.map +1 -1
  55. package/ShadersWGSL/iblShadowAccumulation.fragment.js +5 -10
  56. package/ShadersWGSL/iblShadowAccumulation.fragment.js.map +1 -1
  57. package/ShadersWGSL/iblShadowGBufferDebug.fragment.js +2 -3
  58. package/ShadersWGSL/iblShadowGBufferDebug.fragment.js.map +1 -1
  59. package/ShadersWGSL/iblShadowSpatialBlur.fragment.js +5 -5
  60. package/ShadersWGSL/iblShadowSpatialBlur.fragment.js.map +1 -1
  61. package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +45 -33
  62. package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -1
  63. package/ShadersWGSL/iblShadowsCombine.fragment.js +6 -2
  64. package/ShadersWGSL/iblShadowsCombine.fragment.js.map +1 -1
  65. package/package.json +1 -1
@@ -185,7 +185,6 @@ export class _IblShadowsImportanceSamplingRenderer {
185
185
  this._icdfyPT?.dispose();
186
186
  this._cdfxPT?.dispose();
187
187
  this._icdfxPT?.dispose();
188
- this._iblSource?.dispose();
189
188
  }
190
189
  _createDebugPass() {
191
190
  if (this._debugPass) {
@@ -1 +1 @@
1
- {"version":3,"file":"iblShadowsImportanceSamplingRenderer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIpD,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAE3F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD;;;;GAIG;AACH,MAAM,OAAO,qCAAqC;IAU9C;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS,CAAC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AI,CAAC,OAAO,CAAC,OAAO,EAAE;YACtB,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAC1B,CAAC;IACN,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;SAC7B;IACL,CAAC;CACJ","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 { 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\n\r\n/**\r\n * Build cdf maps for IBL importance sampling during IBL shadow computation.\r\n * This should not be instanciated directly, as it is part of a scene component\r\n * @internal\r\n */\r\nexport class _IblShadowsImportanceSamplingRenderer {\r\n private _scene: Scene;\r\n private _engine: AbstractEngine;\r\n\r\n private _cdfyPT: ProceduralTexture;\r\n private _icdfyPT: ProceduralTexture;\r\n private _cdfxPT: ProceduralTexture;\r\n private _icdfxPT: ProceduralTexture;\r\n private _iblSource: BaseTexture;\r\n\r\n /**\r\n * Gets the IBL source texture being used by the importance sampling renderer\r\n */\r\n public get iblSource(): BaseTexture {\r\n return this._iblSource;\r\n }\r\n\r\n /**\r\n * Sets the IBL source texture to be used by the importance sampling renderer.\r\n * This will trigger recreation of the importance sampling assets.\r\n */\r\n public set iblSource(source: 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.isCube) {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl(source);\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(source);\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(source: BaseTexture) {\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 // Once the textures are generated, notify that they are ready to use.\r\n this._icdfxPT.onGeneratedObservable.addOnce(() => {\r\n this.onReadyObservable.notifyObservers();\r\n });\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) Y texture\r\n * @returns Return the cumulative distribution function (CDF) Y texture\r\n */\r\n public getIcdfyTexture(): ProceduralTexture {\r\n return this._icdfyPT;\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) X texture\r\n * @returns Return the cumulative distribution function (CDF) X texture\r\n */\r\n public getIcdfxTexture(): ProceduralTexture {\r\n return this._icdfxPT;\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, 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\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 = \"Importance Sample 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 * Instanciates the importance sampling renderer\r\n * @param scene Scene to attach to\r\n * @returns The importance sampling renderer\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n }\r\n\r\n /**\r\n * Observable that triggers when the importance sampling renderer is ready\r\n */\r\n public onReadyObservable: Observable<void> = new Observable<void>();\r\n\r\n private _createTextures() {\r\n const size: TextureSize = this._iblSource ? this._iblSource.getSize() : { 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._scene,\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 }\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 extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblShadowsCdfx.fragment\"), import(\"../../ShadersWGSL/iblShadowsCdfy.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblShadowsCdfx.fragment\"), import(\"../../Shaders/iblShadowsCdfy.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_R,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\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 Promise.all([import(\"../../ShadersWGSL/iblShadowsIcdfx.fragment\"), import(\"../../ShadersWGSL/iblShadowsIcdfy.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblShadowsIcdfx.fragment\"), import(\"../../Shaders/iblShadowsIcdfy.fragment\")]);\r\n }\r\n },\r\n };\r\n this._cdfyPT = new ProceduralTexture(\"cdfyTexture\", { width: size.width, height: size.height + 1 }, \"iblShadowsCdfy\", this._scene, cdfOptions, false, false);\r\n this._cdfyPT.autoClear = false;\r\n this._cdfyPT.setTexture(\"iblSource\", this._iblSource as Texture);\r\n this._cdfyPT.setInt(\"iblHeight\", size.height);\r\n if (this._iblSource.isCube) {\r\n this._cdfyPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n this._cdfyPT.refreshRate = 0;\r\n this._icdfyPT = new ProceduralTexture(\"icdfyTexture\", { width: size.width, height: size.height }, \"iblShadowsIcdfy\", this._scene, icdfOptions, false, false);\r\n this._icdfyPT.autoClear = false;\r\n this._icdfyPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._icdfyPT.refreshRate = 0;\r\n this._cdfxPT = new ProceduralTexture(\"cdfxTexture\", { width: size.width + 1, height: 1 }, \"iblShadowsCdfx\", 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._icdfxPT = new ProceduralTexture(\"icdfxTexture\", { width: size.width, height: 1 }, \"iblShadowsIcdfx\", this._scene, icdfOptions, false, false);\r\n this._icdfxPT.autoClear = false;\r\n this._icdfxPT.setTexture(\"cdfx\", this._cdfxPT);\r\n this._icdfxPT.refreshRate = 0;\r\n }\r\n\r\n private _disposeTextures() {\r\n this._cdfyPT?.dispose();\r\n this._icdfyPT?.dispose();\r\n this._cdfxPT?.dispose();\r\n this._icdfxPT?.dispose();\r\n this._iblSource?.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._scene.getEngine().getRenderWidth(),\r\n height: this._scene.getEngine().getRenderHeight(),\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine: this._engine,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"cdfy\", \"icdfy\", \"cdfx\", \"icdfx\", \"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/iblShadowsImportanceSamplingDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblShadowsImportanceSamplingDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._debugPass = new PostProcess(this._debugPassName, \"iblShadowsImportanceSamplingDebug\", 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(\"icdfy\", this._icdfyPT);\r\n effect.setTexture(\"cdfx\", this._cdfxPT);\r\n effect.setTexture(\"icdfx\", this._icdfxPT);\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 importance sampling renderer is ready\r\n * @returns true if the importance sampling 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._icdfyPT &&\r\n this._icdfyPT.isReady() &&\r\n this._cdfxPT &&\r\n this._cdfxPT.isReady() &&\r\n this._icdfxPT &&\r\n this._icdfxPT.isReady()\r\n );\r\n }\r\n\r\n /**\r\n * Disposes the importance sampling renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"iblShadowsImportanceSamplingRenderer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAA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AE,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACvI,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACI,OAAO;QACV,OAAO,CACH,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,wBAAwB;YACjD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;YACzB,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACtB,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YACvB,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACtB,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAC1B,CAAC;IACN,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;SAC7B;IACL,CAAC;CACJ","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 { 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\n\r\n/**\r\n * Build cdf maps for IBL importance sampling during IBL shadow computation.\r\n * This should not be instanciated directly, as it is part of a scene component\r\n * @internal\r\n */\r\nexport class _IblShadowsImportanceSamplingRenderer {\r\n private _scene: Scene;\r\n private _engine: AbstractEngine;\r\n\r\n private _cdfyPT: ProceduralTexture;\r\n private _icdfyPT: ProceduralTexture;\r\n private _cdfxPT: ProceduralTexture;\r\n private _icdfxPT: ProceduralTexture;\r\n private _iblSource: BaseTexture;\r\n\r\n /**\r\n * Gets the IBL source texture being used by the importance sampling renderer\r\n */\r\n public get iblSource(): BaseTexture {\r\n return this._iblSource;\r\n }\r\n\r\n /**\r\n * Sets the IBL source texture to be used by the importance sampling renderer.\r\n * This will trigger recreation of the importance sampling assets.\r\n */\r\n public set iblSource(source: 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.isCube) {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl(source);\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(source);\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(source: BaseTexture) {\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 // Once the textures are generated, notify that they are ready to use.\r\n this._icdfxPT.onGeneratedObservable.addOnce(() => {\r\n this.onReadyObservable.notifyObservers();\r\n });\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) Y texture\r\n * @returns Return the cumulative distribution function (CDF) Y texture\r\n */\r\n public getIcdfyTexture(): ProceduralTexture {\r\n return this._icdfyPT;\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) X texture\r\n * @returns Return the cumulative distribution function (CDF) X texture\r\n */\r\n public getIcdfxTexture(): ProceduralTexture {\r\n return this._icdfxPT;\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, 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\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 = \"Importance Sample 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 * Instanciates the importance sampling renderer\r\n * @param scene Scene to attach to\r\n * @returns The importance sampling renderer\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n }\r\n\r\n /**\r\n * Observable that triggers when the importance sampling renderer is ready\r\n */\r\n public onReadyObservable: Observable<void> = new Observable<void>();\r\n\r\n private _createTextures() {\r\n const size: TextureSize = this._iblSource ? this._iblSource.getSize() : { 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._scene,\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 }\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 extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblShadowsCdfx.fragment\"), import(\"../../ShadersWGSL/iblShadowsCdfy.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblShadowsCdfx.fragment\"), import(\"../../Shaders/iblShadowsCdfy.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_R,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\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 Promise.all([import(\"../../ShadersWGSL/iblShadowsIcdfx.fragment\"), import(\"../../ShadersWGSL/iblShadowsIcdfy.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblShadowsIcdfx.fragment\"), import(\"../../Shaders/iblShadowsIcdfy.fragment\")]);\r\n }\r\n },\r\n };\r\n this._cdfyPT = new ProceduralTexture(\"cdfyTexture\", { width: size.width, height: size.height + 1 }, \"iblShadowsCdfy\", this._scene, cdfOptions, false, false);\r\n this._cdfyPT.autoClear = false;\r\n this._cdfyPT.setTexture(\"iblSource\", this._iblSource as Texture);\r\n this._cdfyPT.setInt(\"iblHeight\", size.height);\r\n if (this._iblSource.isCube) {\r\n this._cdfyPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n this._cdfyPT.refreshRate = 0;\r\n this._icdfyPT = new ProceduralTexture(\"icdfyTexture\", { width: size.width, height: size.height }, \"iblShadowsIcdfy\", this._scene, icdfOptions, false, false);\r\n this._icdfyPT.autoClear = false;\r\n this._icdfyPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._icdfyPT.refreshRate = 0;\r\n this._cdfxPT = new ProceduralTexture(\"cdfxTexture\", { width: size.width + 1, height: 1 }, \"iblShadowsCdfx\", 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._icdfxPT = new ProceduralTexture(\"icdfxTexture\", { width: size.width, height: 1 }, \"iblShadowsIcdfx\", this._scene, icdfOptions, false, false);\r\n this._icdfxPT.autoClear = false;\r\n this._icdfxPT.setTexture(\"cdfx\", this._cdfxPT);\r\n this._icdfxPT.refreshRate = 0;\r\n }\r\n\r\n private _disposeTextures() {\r\n this._cdfyPT?.dispose();\r\n this._icdfyPT?.dispose();\r\n this._cdfxPT?.dispose();\r\n this._icdfxPT?.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._scene.getEngine().getRenderWidth(),\r\n height: this._scene.getEngine().getRenderHeight(),\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine: this._engine,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"cdfy\", \"icdfy\", \"cdfx\", \"icdfx\", \"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/iblShadowsImportanceSamplingDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblShadowsImportanceSamplingDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._debugPass = new PostProcess(this._debugPassName, \"iblShadowsImportanceSamplingDebug\", 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(\"icdfy\", this._icdfyPT);\r\n effect.setTexture(\"cdfx\", this._cdfxPT);\r\n effect.setTexture(\"icdfx\", this._icdfxPT);\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 importance sampling renderer is ready\r\n * @returns true if the importance sampling 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._icdfyPT &&\r\n this._icdfyPT.isReady() &&\r\n this._cdfxPT &&\r\n this._cdfxPT.isReady() &&\r\n this._icdfxPT &&\r\n this._icdfxPT.isReady()\r\n );\r\n }\r\n\r\n /**\r\n * Disposes the importance sampling renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n }\r\n}\r\n"]}
@@ -0,0 +1,60 @@
1
+ import { MaterialDefines } from "../../Materials/materialDefines.js";
2
+ import { MaterialPluginBase } from "../../Materials/materialPluginBase.js";
3
+ import type { InternalTexture } from "../../Materials/Textures/internalTexture.js";
4
+ import type { Material } from "../../Materials/material.js";
5
+ import type { StandardMaterial } from "../../Materials/standardMaterial.js";
6
+ import { PBRBaseMaterial } from "../../Materials/PBR/pbrBaseMaterial.js";
7
+ import type { UniformBuffer } from "../../Materials/uniformBuffer.js";
8
+ import { ShaderLanguage } from "../../Materials/shaderLanguage.js";
9
+ /**
10
+ * @internal
11
+ */
12
+ declare class MaterialIBLShadowsRenderDefines extends MaterialDefines {
13
+ RENDER_WITH_IBL_SHADOWS: boolean;
14
+ }
15
+ /**
16
+ * Plugin used to render the contribution from IBL shadows.
17
+ */
18
+ export declare class IBLShadowsPluginMaterial extends MaterialPluginBase {
19
+ /**
20
+ * Defines the name of the plugin.
21
+ */
22
+ static readonly Name = "IBLShadowsPluginMaterial";
23
+ /**
24
+ * The texture containing the contribution from IBL shadows.
25
+ */
26
+ iblShadowsTexture: InternalTexture;
27
+ /**
28
+ * The opacity of the shadows.
29
+ */
30
+ shadowOpacity: number;
31
+ private _isEnabled;
32
+ /**
33
+ * Defines if the plugin is enabled in the material.
34
+ */
35
+ isEnabled: boolean;
36
+ protected _markAllSubMeshesAsTexturesDirty(): void;
37
+ private _internalMarkAllSubMeshesAsTexturesDirty;
38
+ /**
39
+ * Gets a boolean indicating that the plugin is compatible with a give shader language.
40
+ * @returns true if the plugin is compatible with the shader language
41
+ */
42
+ isCompatible(): boolean;
43
+ constructor(material: Material | StandardMaterial | PBRBaseMaterial);
44
+ prepareDefines(defines: MaterialIBLShadowsRenderDefines): void;
45
+ getClassName(): string;
46
+ getUniforms(): {
47
+ ubo: {
48
+ name: string;
49
+ size: number;
50
+ type: string;
51
+ }[];
52
+ fragment: string;
53
+ };
54
+ getSamplers(samplers: string[]): void;
55
+ bindForSubMesh(uniformBuffer: UniformBuffer): void;
56
+ getCustomCode(shaderType: string, shaderLanguage: ShaderLanguage): {
57
+ [name: string]: string;
58
+ } | null;
59
+ }
60
+ export {};
@@ -0,0 +1,166 @@
1
+ import { __decorate } from "../../tslib.es6.js";
2
+ import { MaterialDefines } from "../../Materials/materialDefines.js";
3
+ import { MaterialPluginBase } from "../../Materials/materialPluginBase.js";
4
+
5
+ import { PBRBaseMaterial } from "../../Materials/PBR/pbrBaseMaterial.js";
6
+ import { expandToProperty, serialize } from "../../Misc/decorators.js";
7
+ import { RegisterClass } from "../../Misc/typeStore.js";
8
+ /**
9
+ * @internal
10
+ */
11
+ class MaterialIBLShadowsRenderDefines extends MaterialDefines {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.RENDER_WITH_IBL_SHADOWS = false;
15
+ }
16
+ }
17
+ /**
18
+ * Plugin used to render the contribution from IBL shadows.
19
+ */
20
+ export class IBLShadowsPluginMaterial extends MaterialPluginBase {
21
+ _markAllSubMeshesAsTexturesDirty() {
22
+ this._enable(this._isEnabled);
23
+ this._internalMarkAllSubMeshesAsTexturesDirty();
24
+ }
25
+ /**
26
+ * Gets a boolean indicating that the plugin is compatible with a give shader language.
27
+ * @returns true if the plugin is compatible with the shader language
28
+ */
29
+ isCompatible() {
30
+ return true;
31
+ }
32
+ constructor(material) {
33
+ super(material, IBLShadowsPluginMaterial.Name, 310, new MaterialIBLShadowsRenderDefines());
34
+ /**
35
+ * The opacity of the shadows.
36
+ */
37
+ this.shadowOpacity = 1.0;
38
+ this._isEnabled = false;
39
+ /**
40
+ * Defines if the plugin is enabled in the material.
41
+ */
42
+ this.isEnabled = false;
43
+ this._internalMarkAllSubMeshesAsTexturesDirty = material._dirtyCallbacks[1];
44
+ }
45
+ prepareDefines(defines) {
46
+ defines.RENDER_WITH_IBL_SHADOWS = this._isEnabled;
47
+ }
48
+ getClassName() {
49
+ return "IBLShadowsPluginMaterial";
50
+ }
51
+ getUniforms() {
52
+ return {
53
+ ubo: [
54
+ { name: "renderTargetSize", size: 2, type: "vec2" },
55
+ { name: "shadowOpacity", size: 1, type: "float" },
56
+ ],
57
+ fragment: `#ifdef RENDER_WITH_IBL_SHADOWS
58
+ uniform vec2 renderTargetSize;
59
+ uniform float shadowOpacity;
60
+ #endif`,
61
+ };
62
+ }
63
+ getSamplers(samplers) {
64
+ samplers.push("iblShadowsTexture");
65
+ }
66
+ bindForSubMesh(uniformBuffer) {
67
+ if (this._isEnabled) {
68
+ uniformBuffer.bindTexture("iblShadowsTexture", this.iblShadowsTexture);
69
+ uniformBuffer.updateFloat2("renderTargetSize", this._material.getScene().getEngine().getRenderWidth(), this._material.getScene().getEngine().getRenderHeight());
70
+ uniformBuffer.updateFloat("shadowOpacity", this.shadowOpacity);
71
+ }
72
+ }
73
+ getCustomCode(shaderType, shaderLanguage) {
74
+ let frag;
75
+ if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
76
+ frag = {
77
+ // eslint-disable-next-line @typescript-eslint/naming-convention
78
+ CUSTOM_FRAGMENT_DEFINITIONS: `
79
+ #ifdef RENDER_WITH_IBL_SHADOWS
80
+ var iblShadowsTextureSampler: sampler;
81
+ var iblShadowsTexture: texture_2d<f32>;
82
+
83
+ fn computeIndirectShadow() -> vec2f {
84
+ var uv = fragmentInputs.position.xy / uniforms.renderTargetSize;
85
+ var shadowValue: vec2f = textureSample(iblShadowsTexture, iblShadowsTextureSampler, uv).rg;
86
+ return mix(shadowValue, vec2f(1.0), 1.0 - uniforms.shadowOpacity);
87
+ }
88
+ #endif
89
+ `,
90
+ };
91
+ if (this._material instanceof PBRBaseMaterial) {
92
+ // eslint-disable-next-line @typescript-eslint/naming-convention
93
+ frag["CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION"] = `
94
+ #ifdef RENDER_WITH_IBL_SHADOWS
95
+ #ifdef REFLECTION
96
+ var shadowValue: vec2f = computeIndirectShadow();
97
+ finalIrradiance *= vec3f(shadowValue.x);
98
+ finalRadianceScaled *= vec3f(mix(pow(shadowValue.y, 4.0), shadowValue.x, roughness));
99
+ #endif
100
+ #endif
101
+ `;
102
+ }
103
+ else {
104
+ frag["CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR"] = `
105
+ #ifdef RENDER_WITH_IBL_SHADOWS
106
+ var shadowValue: vec2f = computeIndirectShadow();
107
+ color *= toGammaSpace(vec4f(shadowValue.x, shadowValue.x, shadowValue.x, 1.0f));
108
+ #endif
109
+ `;
110
+ }
111
+ }
112
+ else {
113
+ frag = {
114
+ // eslint-disable-next-line @typescript-eslint/naming-convention
115
+ CUSTOM_FRAGMENT_DEFINITIONS: `
116
+ #ifdef RENDER_WITH_IBL_SHADOWS
117
+ uniform sampler2D iblShadowsTexture;
118
+
119
+ vec2 computeIndirectShadow() {
120
+ vec2 uv = gl_FragCoord.xy / renderTargetSize;
121
+ vec2 shadowValue = texture2D(iblShadowsTexture, uv).rg;
122
+ return mix(shadowValue.rg, vec2(1.0), 1.0 - shadowOpacity);
123
+ }
124
+ #endif
125
+ `,
126
+ };
127
+ if (this._material instanceof PBRBaseMaterial) {
128
+ // eslint-disable-next-line @typescript-eslint/naming-convention
129
+ frag["CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION"] = `
130
+ #ifdef RENDER_WITH_IBL_SHADOWS
131
+ #ifdef REFLECTION
132
+ vec2 shadowValue = computeIndirectShadow();
133
+ finalIrradiance *= shadowValue.x;
134
+ finalRadianceScaled *= mix(pow(shadowValue.y, 4.0), shadowValue.x, roughness);
135
+ #endif
136
+ #endif
137
+ `;
138
+ }
139
+ else {
140
+ frag["CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR"] = `
141
+ #ifdef RENDER_WITH_IBL_SHADOWS
142
+ vec2 shadowValue = computeIndirectShadow();
143
+ color.rgb *= toGammaSpace(shadowValue.x);
144
+ #endif
145
+ `;
146
+ }
147
+ }
148
+ return shaderType === "vertex" ? null : frag;
149
+ }
150
+ }
151
+ /**
152
+ * Defines the name of the plugin.
153
+ */
154
+ IBLShadowsPluginMaterial.Name = "IBLShadowsPluginMaterial";
155
+ __decorate([
156
+ serialize()
157
+ ], IBLShadowsPluginMaterial.prototype, "iblShadowsTexture", void 0);
158
+ __decorate([
159
+ serialize()
160
+ ], IBLShadowsPluginMaterial.prototype, "shadowOpacity", void 0);
161
+ __decorate([
162
+ serialize(),
163
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
164
+ ], IBLShadowsPluginMaterial.prototype, "isEnabled", void 0);
165
+ RegisterClass(`BABYLON.IBLShadowsPluginMaterial`, IBLShadowsPluginMaterial);
166
+ //# sourceMappingURL=iblShadowsPluginMaterial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iblShadowsPluginMaterial.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsPluginMaterial.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,2CAAuC;AACjE,OAAO,EAAE,kBAAkB,EAAE,8CAA0C;AAGvE,OAAO,EAAE,SAAS,EAAE,mCAA+B;AAEnD,OAAO,EAAE,eAAe,EAAE,+CAA2C;AAErE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,iCAA6B;AACnE,OAAO,EAAE,aAAa,EAAE,gCAA4B;AAGpD;;GAEG;AACH,MAAM,+BAAgC,SAAQ,eAAe;IAA7D;;QACW,4BAAuB,GAAG,KAAK,CAAC;IAC3C,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,kBAAkB;IA0BlD,gCAAgC;QACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CAA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efines } from \"core/Materials/materialDefines\";\r\nimport { MaterialPluginBase } from \"core/Materials/materialPluginBase\";\r\nimport type { InternalTexture } from \"core/Materials/Textures/internalTexture\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport { PBRBaseMaterial } from \"core/Materials/PBR/pbrBaseMaterial\";\r\nimport type { UniformBuffer } from \"core/Materials/uniformBuffer\";\r\nimport { expandToProperty, serialize } from \"core/Misc/decorators\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n/**\r\n * @internal\r\n */\r\nclass MaterialIBLShadowsRenderDefines extends MaterialDefines {\r\n public RENDER_WITH_IBL_SHADOWS = false;\r\n}\r\n\r\n/**\r\n * Plugin used to render the contribution from IBL shadows.\r\n */\r\nexport class IBLShadowsPluginMaterial extends MaterialPluginBase {\r\n /**\r\n * Defines the name of the plugin.\r\n */\r\n public static readonly Name = \"IBLShadowsPluginMaterial\";\r\n\r\n /**\r\n * The texture containing the contribution from IBL shadows.\r\n */\r\n @serialize()\r\n public iblShadowsTexture: InternalTexture;\r\n\r\n /**\r\n * The opacity of the shadows.\r\n */\r\n @serialize()\r\n public shadowOpacity: number = 1.0;\r\n\r\n private _isEnabled = false;\r\n /**\r\n * Defines if the plugin is enabled in the material.\r\n */\r\n @serialize()\r\n @expandToProperty(\"_markAllSubMeshesAsTexturesDirty\")\r\n public isEnabled = false;\r\n\r\n protected _markAllSubMeshesAsTexturesDirty(): void {\r\n this._enable(this._isEnabled);\r\n this._internalMarkAllSubMeshesAsTexturesDirty();\r\n }\r\n\r\n private _internalMarkAllSubMeshesAsTexturesDirty: () => void;\r\n\r\n /**\r\n * Gets a boolean indicating that the plugin is compatible with a give shader language.\r\n * @returns true if the plugin is compatible with the shader language\r\n */\r\n public override isCompatible(): boolean {\r\n return true;\r\n }\r\n\r\n constructor(material: Material | StandardMaterial | PBRBaseMaterial) {\r\n super(material, IBLShadowsPluginMaterial.Name, 310, new MaterialIBLShadowsRenderDefines());\r\n this._internalMarkAllSubMeshesAsTexturesDirty = material._dirtyCallbacks[Constants.MATERIAL_TextureDirtyFlag];\r\n }\r\n\r\n public override prepareDefines(defines: MaterialIBLShadowsRenderDefines) {\r\n defines.RENDER_WITH_IBL_SHADOWS = this._isEnabled;\r\n }\r\n\r\n public override getClassName() {\r\n return \"IBLShadowsPluginMaterial\";\r\n }\r\n\r\n public override getUniforms() {\r\n return {\r\n ubo: [\r\n { name: \"renderTargetSize\", size: 2, type: \"vec2\" },\r\n { name: \"shadowOpacity\", size: 1, type: \"float\" },\r\n ],\r\n fragment: `#ifdef RENDER_WITH_IBL_SHADOWS\r\n uniform vec2 renderTargetSize;\r\n uniform float shadowOpacity;\r\n #endif`,\r\n };\r\n }\r\n\r\n public override getSamplers(samplers: string[]) {\r\n samplers.push(\"iblShadowsTexture\");\r\n }\r\n\r\n public override bindForSubMesh(uniformBuffer: UniformBuffer) {\r\n if (this._isEnabled) {\r\n uniformBuffer.bindTexture(\"iblShadowsTexture\", this.iblShadowsTexture);\r\n uniformBuffer.updateFloat2(\"renderTargetSize\", this._material.getScene().getEngine().getRenderWidth(), this._material.getScene().getEngine().getRenderHeight());\r\n uniformBuffer.updateFloat(\"shadowOpacity\", this.shadowOpacity);\r\n }\r\n }\r\n\r\n public override getCustomCode(shaderType: string, shaderLanguage: ShaderLanguage) {\r\n let frag: { [name: string]: string };\r\n\r\n if (shaderLanguage === ShaderLanguage.WGSL) {\r\n frag = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_FRAGMENT_DEFINITIONS: `\r\n #ifdef RENDER_WITH_IBL_SHADOWS\r\n var iblShadowsTextureSampler: sampler;\r\n var iblShadowsTexture: texture_2d<f32>;\r\n\r\n fn computeIndirectShadow() -> vec2f {\r\n var uv = fragmentInputs.position.xy / uniforms.renderTargetSize;\r\n var shadowValue: vec2f = textureSample(iblShadowsTexture, iblShadowsTextureSampler, uv).rg;\r\n return mix(shadowValue, vec2f(1.0), 1.0 - uniforms.shadowOpacity);\r\n }\r\n #endif\r\n `,\r\n };\r\n\r\n if (this._material instanceof PBRBaseMaterial) {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n frag[\"CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION\"] = `\r\n #ifdef RENDER_WITH_IBL_SHADOWS\r\n #ifdef REFLECTION\r\n var shadowValue: vec2f = computeIndirectShadow();\r\n finalIrradiance *= vec3f(shadowValue.x);\r\n finalRadianceScaled *= vec3f(mix(pow(shadowValue.y, 4.0), shadowValue.x, roughness));\r\n #endif\r\n #endif\r\n `;\r\n } else {\r\n frag[\"CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\"] = `\r\n #ifdef RENDER_WITH_IBL_SHADOWS\r\n var shadowValue: vec2f = computeIndirectShadow();\r\n color *= toGammaSpace(vec4f(shadowValue.x, shadowValue.x, shadowValue.x, 1.0f));\r\n #endif\r\n `;\r\n }\r\n } else {\r\n frag = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_FRAGMENT_DEFINITIONS: `\r\n #ifdef RENDER_WITH_IBL_SHADOWS\r\n uniform sampler2D iblShadowsTexture;\r\n\r\n vec2 computeIndirectShadow() {\r\n vec2 uv = gl_FragCoord.xy / renderTargetSize;\r\n vec2 shadowValue = texture2D(iblShadowsTexture, uv).rg;\r\n return mix(shadowValue.rg, vec2(1.0), 1.0 - shadowOpacity);\r\n }\r\n #endif\r\n `,\r\n };\r\n\r\n if (this._material instanceof PBRBaseMaterial) {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n frag[\"CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION\"] = `\r\n #ifdef RENDER_WITH_IBL_SHADOWS\r\n #ifdef REFLECTION\r\n vec2 shadowValue = computeIndirectShadow();\r\n finalIrradiance *= shadowValue.x;\r\n finalRadianceScaled *= mix(pow(shadowValue.y, 4.0), shadowValue.x, roughness);\r\n #endif\r\n #endif\r\n `;\r\n } else {\r\n frag[\"CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\"] = `\r\n #ifdef RENDER_WITH_IBL_SHADOWS\r\n vec2 shadowValue = computeIndirectShadow();\r\n color.rgb *= toGammaSpace(shadowValue.x);\r\n #endif\r\n `;\r\n }\r\n }\r\n\r\n return shaderType === \"vertex\" ? null : frag;\r\n }\r\n}\r\n\r\nRegisterClass(`BABYLON.IBLShadowsPluginMaterial`, IBLShadowsPluginMaterial);\r\n"]}
@@ -1,10 +1,12 @@
1
- import type { AbstractMesh } from "../../Meshes/abstractMesh";
1
+ import type { Mesh } from "../../Meshes/mesh";
2
2
  import type { Scene } from "../../scene";
3
3
  import type { BaseTexture } from "../../Materials/Textures/baseTexture";
4
4
  import { Texture } from "../../Materials/Textures/texture";
5
- import { PrePassRenderer } from "../prePassRenderer";
6
5
  import { PostProcessRenderPipeline } from "../../PostProcesses/RenderPipeline/postProcessRenderPipeline";
7
6
  import type { Camera } from "../../Cameras/camera.js";
7
+ import { RawTexture } from "../../Materials/Textures/rawTexture.js";
8
+ import type { Material } from "../../Materials/material.js";
9
+ import { Observable } from "../../Misc/observable.js";
8
10
  interface IblShadowsSettings {
9
11
  /**
10
12
  * The exponent of the resolution of the voxel shadow grid. Higher resolutions will result in sharper
@@ -30,6 +32,11 @@ interface IblShadowsSettings {
30
32
  * bits of missing geometry.
31
33
  */
32
34
  triPlanarVoxelization: boolean;
35
+ /**
36
+ * A multiplier for the render size of the shadows. Used for rendering lower-resolution shadows
37
+ * to increase performance. Should be a value between 0 and 1.
38
+ */
39
+ shadowRenderSizeFactor: number;
33
40
  /**
34
41
  * Separate control for the opacity of the voxel shadows.
35
42
  */
@@ -51,11 +58,11 @@ interface IblShadowsSettings {
51
58
  * The maximum distance a shadow can be cast in screen space. This should usually be kept small
52
59
  * as screenspace shadows are mostly useful for small details.
53
60
  */
54
- ssShadowMaxDist: number;
61
+ ssShadowDistanceScale: number;
55
62
  /**
56
63
  * Screen-space shadow thickness. This value controls the perceived thickness of the SS shadows.
57
64
  */
58
- ssShadowThickness: number;
65
+ ssShadowThicknessScale: number;
59
66
  }
60
67
  /**
61
68
  * Voxel-based shadow rendering for IBL's.
@@ -66,83 +73,85 @@ export declare class IblShadowsRenderPipeline extends PostProcessRenderPipeline
66
73
  * The scene that this pipeline is attached to
67
74
  */
68
75
  scene: Scene;
69
- private _voxelizationDirty;
70
- private _boundsNeedUpdate;
71
76
  private _allowDebugPasses;
72
77
  private _debugPasses;
73
- private _shadowCompositePP;
74
- private _prePassEffectConfiguration;
75
- private _excludedMeshes;
78
+ private _geometryBufferRenderer;
79
+ private _shadowCastingMeshes;
76
80
  private _voxelRenderer;
77
81
  private _importanceSamplingRenderer;
78
82
  private _voxelTracingPass;
79
83
  private _spatialBlurPass;
80
84
  private _accumulationPass;
81
85
  private _noiseTexture;
86
+ /**
87
+ * Raw texture to be used before final data is available.
88
+ * @internal
89
+ */
90
+ _dummyTexture2d: RawTexture;
91
+ private _dummyTexture3d;
82
92
  private _shadowOpacity;
83
93
  private _enabled;
94
+ private _materialsWithRenderPlugin;
95
+ /**
96
+ * Observable that triggers when the shadow renderer is ready
97
+ */
98
+ onShadowTextureReadyObservable: Observable<void>;
99
+ /**
100
+ * Observable that triggers when a new IBL is set and the importance sampling is ready
101
+ */
102
+ onNewIblReadyObservable: Observable<void>;
84
103
  /**
85
104
  * The current world-space size of that the voxel grid covers in the scene.
86
105
  */
87
106
  voxelGridSize: number;
88
107
  /**
89
- * How dark the shadows appear. 1.0 is full opacity, 0.0 is no shadows.
108
+ * Reset the shadow accumulation.
90
109
  */
91
- get shadowOpacity(): number;
110
+ resetAccumulation(): void;
92
111
  /**
93
112
  * How dark the shadows appear. 1.0 is full opacity, 0.0 is no shadows.
94
113
  */
114
+ get shadowOpacity(): number;
95
115
  set shadowOpacity(value: number);
116
+ private _renderSizeFactor;
96
117
  /**
97
- * How dark the voxel shadows appear. 1.0 is full opacity, 0.0 is no shadows.
118
+ * A multiplier for the render size of the shadows. Used for rendering lower-resolution shadows.
98
119
  */
99
- get voxelShadowOpacity(): number;
120
+ get shadowRenderSizeFactor(): number;
121
+ set shadowRenderSizeFactor(value: number);
100
122
  /**
101
123
  * How dark the voxel shadows appear. 1.0 is full opacity, 0.0 is no shadows.
102
124
  */
125
+ get voxelShadowOpacity(): number;
103
126
  set voxelShadowOpacity(value: number);
104
127
  /**
105
128
  * How dark the screen-space shadows appear. 1.0 is full opacity, 0.0 is no shadows.
106
129
  */
107
130
  get ssShadowOpacity(): number;
108
- /**
109
- * How dark the screen-space shadows appear. 1.0 is full opacity, 0.0 is no shadows.
110
- */
111
131
  set ssShadowOpacity(value: number);
112
132
  /**
113
133
  * The number of samples used in the screen space shadow pass.
114
134
  */
115
135
  get ssShadowSamples(): number;
116
- /**
117
- * The number of samples used in the screen space shadow pass.
118
- */
119
136
  set ssShadowSamples(value: number);
120
137
  /**
121
138
  * The stride of the screen-space shadow pass. This controls the distance between samples.
122
139
  */
123
140
  get ssShadowStride(): number;
124
- /**
125
- * The stride of the screen-space shadow pass. This controls the distance between samples.
126
- */
127
141
  set ssShadowStride(value: number);
142
+ private _sssMaxDistScale;
128
143
  /**
129
- * The maximum distance a shadow can be cast in screen space. This should usually be kept small
130
- * as screenspace shadows are mostly useful for small details.
131
- */
132
- get ssShadowMaxDist(): number;
133
- /**
134
- * The maximum distance a shadow can be cast in screen space. This should usually be kept small
135
- * as screenspace shadows are mostly useful for small details.
136
- */
137
- set ssShadowMaxDist(value: number);
138
- /**
139
- * Screen-space shadow thickness. This value controls the perceived thickness of the SS shadows.
144
+ * A scale for the maximum distance a shadow can be cast in screen space.
145
+ * The absolute distance for SS shadows is derived from the voxel size and this scalar.
140
146
  */
141
- get ssShadowThickness(): number;
147
+ get ssShadowDistanceScale(): number;
148
+ set ssShadowDistanceScale(value: number);
149
+ private _sssThicknessScale;
142
150
  /**
143
151
  * Screen-space shadow thickness. This value controls the perceived thickness of the SS shadows.
144
152
  */
145
- set ssShadowThickness(value: number);
153
+ get ssShadowThicknessScale(): number;
154
+ set ssShadowThicknessScale(value: number);
146
155
  /**
147
156
  * Set the IBL image to be used for shadowing. It can be either a cubemap
148
157
  * or a 2D equirectangular texture.
@@ -152,18 +161,45 @@ export declare class IblShadowsRenderPipeline extends PostProcessRenderPipeline
152
161
  /**
153
162
  * Returns the texture containing the voxel grid data
154
163
  * @returns The texture containing the voxel grid data
164
+ * @internal
155
165
  */
156
- getVoxelGridTexture(): Texture;
166
+ _getVoxelGridTexture(): Texture;
157
167
  /**
158
168
  * Returns the texture containing the importance sampling CDF data for the IBL shadow pipeline
159
169
  * @returns The texture containing the importance sampling CDF data for the IBL shadow pipeline
170
+ * @internal
160
171
  */
161
- getIcdfyTexture(): Texture;
172
+ _getIcdfyTexture(): Texture;
162
173
  /**
163
174
  * Returns the texture containing the importance sampling CDF data for the IBL shadow pipeline
164
175
  * @returns The texture containing the importance sampling CDF data for the IBL shadow pipeline
176
+ * @internal
177
+ */
178
+ _getIcdfxTexture(): Texture;
179
+ /**
180
+ * Returns the noise texture.
181
+ * @returns The noise texture.
182
+ * @internal
183
+ */
184
+ _getNoiseTexture(): Texture;
185
+ /**
186
+ * Returns the voxel-tracing texture.
187
+ * @returns The voxel-tracing texture.
188
+ * @internal
189
+ */
190
+ _getVoxelTracingTexture(): Texture;
191
+ /**
192
+ * Returns the spatial blur texture.
193
+ * @returns The spatial blur texture.
194
+ * @internal
165
195
  */
166
- getIcdfxTexture(): Texture;
196
+ _getSpatialBlurTexture(): Texture;
197
+ /**
198
+ * Returns the accumulated shadow texture.
199
+ * @returns The accumulated shadow texture.
200
+ * @internal
201
+ */
202
+ _getAccumulatedTexture(): Texture;
167
203
  private _gbufferDebugPass;
168
204
  private _gbufferDebugEnabled;
169
205
  private _gBufferDebugSizeParams;
@@ -230,15 +266,15 @@ export declare class IblShadowsRenderPipeline extends PostProcessRenderPipeline
230
266
  */
231
267
  set accumulationPassDebugEnabled(enabled: boolean);
232
268
  /**
233
- * Add a mesh in the exclusion list to prevent it to be handled by the IBL shadow pipeline
234
- * @param mesh The mesh to exclude from the IBL shadow pipeline
269
+ * Add a mesh to be used for shadow casting in the IBL shadow pipeline
270
+ * @param mesh A mesh or list of meshes that you want to cast shadows
235
271
  */
236
- addExcludedMesh(mesh: AbstractMesh): void;
272
+ addShadowCastingMesh(mesh: Mesh | Mesh[]): void;
237
273
  /**
238
- * Remove a mesh from the exclusion list of the IBL shadow pipeline
239
- * @param mesh The mesh to remove
274
+ * Remove a mesh from the shadow-casting list.
275
+ * @param mesh The mesh or list of meshes that you don't want to cast shadows.
240
276
  */
241
- removeExcludedMesh(mesh: AbstractMesh): void;
277
+ removeShadowCastingMesh(mesh: Mesh | Mesh[]): void;
242
278
  /**
243
279
  * The exponent of the resolution of the voxel shadow grid. Higher resolutions will result in sharper
244
280
  * shadows but are more expensive to compute and require more memory.
@@ -300,8 +336,6 @@ export declare class IblShadowsRenderPipeline extends PostProcessRenderPipeline
300
336
  */
301
337
  toggleShadow(enabled: boolean): void;
302
338
  private _handleResize;
303
- private _createShadowCombinePostProcess;
304
- private _createEffectPasses;
305
339
  private _getGBufferDebugPass;
306
340
  private _createDebugPasses;
307
341
  private _disposeEffectPasses;
@@ -316,23 +350,30 @@ export declare class IblShadowsRenderPipeline extends PostProcessRenderPipeline
316
350
  * to be recalculated. This will also trigger a re-voxelization.
317
351
  */
318
352
  updateSceneBounds(): void;
319
- private _updateBeforeRender;
320
- private _listenForCameraChanges;
321
353
  /**
322
- * Links to the prepass renderer
323
- * @param prePassRenderer The scene PrePassRenderer
324
- * @returns true if the pre pass is setup
354
+ * Update the SS shadow max distance and thickness based on the voxel grid size and resolution.
355
+ * The max distance should be just a little larger than the world size of a single voxel.
356
+ */
357
+ private _updateSSShadowParams;
358
+ /**
359
+ * Apply the shadows to a material or array of materials.
360
+ * @param material Material that will be affected by the shadows. If not provided, all materials of the scene will be affected.
325
361
  */
326
- setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
362
+ addShadowReceivingMaterial(material?: Material | Material[]): void;
363
+ /**
364
+ * Remove a material from receiving shadows
365
+ * @param material The material that will no longer receive shadows
366
+ */
367
+ removeShadowReceivingMaterial(material: Material | Material[]): void;
368
+ protected _addShadowSupportToMaterial(material: Material): void;
369
+ protected _setPluginParameters(): void;
370
+ private _updateBeforeRender;
371
+ private _listenForCameraChanges;
327
372
  /**
328
373
  * Checks if the IBL shadow pipeline is ready to render shadows
329
374
  * @returns true if the IBL shadow pipeline is ready to render the shadows
330
375
  */
331
376
  isReady(): boolean;
332
- /**
333
- * Renders accumulated shadows for IBL
334
- */
335
- update(): void;
336
377
  /**
337
378
  * Get the class name
338
379
  * @returns "IBLShadowsRenderPipeline"