@babylonjs/core 8.27.2 → 8.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +6 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/Misc/khronosTextureContainer2.js +1 -0
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/khronosTextureContainer2Worker.d.ts +1 -1
- package/Misc/khronosTextureContainer2Worker.js +3 -0
- package/Misc/khronosTextureContainer2Worker.js.map +1 -1
- package/Rendering/iblCdfGenerator.js +28 -20
- package/Rendering/iblCdfGenerator.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iblCdfGenerator.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/iblCdfGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC;;GAEG;AACH,MAAM,OAAO,eAAe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AAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAC,aAAqC;QACzD,OAAO,aAAa,CAAC,YAAY,EAAE,KAAK,OAAO,CAAC;IACpD,CAAC;;AA3TD;;GAEG;AACW,6CAA6B,GAA2B,CAAC,CAAC,EAAE,EAAE;IACxE,MAAM,WAAW,CAAC,6CAA6C,CAAC,CAAC;AACrE,CAAC,AAF0C,CAEzC","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport { ProceduralTexture } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../PostProcesses/postProcess\";\r\nimport { Vector3, Vector4 } from \"../Maths/math.vector\";\r\nimport { RawTexture } from \"../Materials/Textures/rawTexture\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { CubeTexture } from \"../Materials/Textures/cubeTexture\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { Logger } from \"../Misc/logger\";\r\n\r\n/**\r\n * Build cdf maps to be used for IBL importance sampling.\r\n */\r\nexport class IblCdfGenerator {\r\n private _scene: Nullable<Scene>;\r\n private _engine: AbstractEngine;\r\n\r\n private _cdfyPT: ProceduralTexture;\r\n private _cdfxPT: ProceduralTexture;\r\n private _icdfPT: ProceduralTexture;\r\n private _scaledLuminancePT: ProceduralTexture;\r\n private _dominantDirectionPT: ProceduralTexture;\r\n private _iblSource: Nullable<BaseTexture>;\r\n private _dummyTexture: RawTexture;\r\n\r\n private _cachedDominantDirection: Nullable<Vector3> = null;\r\n\r\n /**\r\n * Returns whether the CDF renderer is supported by the current engine\r\n */\r\n public get isSupported(): boolean {\r\n const engine = EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n return false;\r\n }\r\n return engine.getCaps().texelFetch;\r\n }\r\n\r\n /**\r\n * Gets the IBL source texture being used by the CDF renderer\r\n */\r\n public get iblSource(): Nullable<BaseTexture> {\r\n return this._iblSource;\r\n }\r\n\r\n /**\r\n * Sets the IBL source texture to be used by the CDF renderer.\r\n * This will trigger recreation of the CDF assets.\r\n */\r\n public set iblSource(source: Nullable<BaseTexture>) {\r\n if (this._iblSource === source) {\r\n return;\r\n }\r\n this._disposeTextures();\r\n this._iblSource = source;\r\n if (!source) {\r\n return;\r\n }\r\n if (source.isCube) {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl();\r\n } else {\r\n (source as CubeTexture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n } else {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl();\r\n } else {\r\n (source as Texture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n }\r\n }\r\n\r\n private _recreateAssetsFromNewIbl() {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n\r\n this._createTextures();\r\n\r\n if (this._debugPass) {\r\n // Recreate the debug pass because of the new textures\r\n this._createDebugPass();\r\n }\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) texture\r\n * @returns Return the cumulative distribution function (CDF) texture\r\n */\r\n public getIcdfTexture(): Texture {\r\n return this._icdfPT ? this._icdfPT : this._dummyTexture;\r\n }\r\n\r\n /** Enable the debug view for this pass */\r\n public debugEnabled: boolean = false;\r\n private _debugPass: PostProcess;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 1.0, 1.0);\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n\r\n /**\r\n * The name of the debug pass post process\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n private _debugPassName: string = \"CDF Debug\";\r\n\r\n /**\r\n * Gets the debug pass post process\r\n * @returns The post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._debugPass) {\r\n this._createDebugPass();\r\n }\r\n return this._debugPass;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"IblCdfGeneratorSceneComponentSceneComponent\");\r\n };\r\n\r\n /**\r\n * Instanciates the CDF renderer\r\n * @param sceneOrEngine Scene to attach to\r\n * @returns The CDF renderer\r\n */\r\n constructor(sceneOrEngine: Nullable<Scene | AbstractEngine>) {\r\n if (sceneOrEngine) {\r\n if (IblCdfGenerator._IsScene(sceneOrEngine)) {\r\n this._scene = sceneOrEngine;\r\n } else {\r\n this._engine = sceneOrEngine;\r\n }\r\n } else {\r\n this._scene = EngineStore.LastCreatedScene;\r\n }\r\n if (this._scene) {\r\n this._engine = this._scene.getEngine();\r\n }\r\n if (!this.isSupported) {\r\n Logger.Warn(\"CDF renderer is not supported by the current engine.\");\r\n return;\r\n }\r\n const blackPixels = new Uint16Array([0, 0, 0, 255]);\r\n this._dummyTexture = new RawTexture(blackPixels, 1, 1, Engine.TEXTUREFORMAT_RGBA, sceneOrEngine, false, false, undefined, Constants.TEXTURETYPE_HALF_FLOAT);\r\n if (this._scene) {\r\n IblCdfGenerator._SceneComponentInitialization(this._scene);\r\n }\r\n }\r\n\r\n /**\r\n * Observable that triggers when the CDF renderer is ready\r\n */\r\n public onGeneratedObservable: Observable<void> = new Observable<void>();\r\n\r\n private _createTextures() {\r\n const size: TextureSize = this._iblSource ? { width: this._iblSource.getSize().width, height: this._iblSource.getSize().height } : { width: 1, height: 1 };\r\n if (!this._iblSource) {\r\n this._iblSource = RawTexture.CreateRTexture(\r\n new Uint8Array([255]),\r\n 1,\r\n 1,\r\n this._engine,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n );\r\n this._iblSource.name = \"Placeholder IBL Source\";\r\n }\r\n\r\n if (this._iblSource.isCube) {\r\n size.width *= 4;\r\n size.height *= 2;\r\n // Force the resolution to be a power of 2 because we rely on the\r\n // auto-mipmap generation for the scaled luminance texture to produce\r\n // a 1x1 mip that represents the true average pixel intensity of the IBL.\r\n size.width = 1 << Math.floor(Math.log2(size.width));\r\n size.height = 1 << Math.floor(Math.log2(size.height));\r\n }\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n // Create CDF maps (Cumulative Distribution Function) to assist in importance sampling\r\n const cdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_R,\r\n type: Constants.TEXTURETYPE_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n gammaSpace: false,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../ShadersWGSL/iblCdfx.fragment\"), import(\"../ShadersWGSL/iblCdfy.fragment\"), import(\"../ShadersWGSL/iblScaledLuminance.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/iblCdfx.fragment\"), import(\"../Shaders/iblCdfy.fragment\"), import(\"../Shaders/iblScaledLuminance.fragment\")]);\r\n }\r\n },\r\n };\r\n const icdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n gammaSpace: false,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../ShadersWGSL/iblIcdf.fragment\"), import(\"../ShadersWGSL/iblDominantDirection.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/iblIcdf.fragment\"), import(\"../Shaders/iblDominantDirection.fragment\")]);\r\n }\r\n },\r\n };\r\n this._cdfyPT = new ProceduralTexture(\"cdfyTexture\", { width: size.width, height: size.height + 1 }, \"iblCdfy\", this._scene, cdfOptions, false, false);\r\n this._cdfyPT.autoClear = false;\r\n this._cdfyPT.setTexture(\"iblSource\", this._iblSource);\r\n this._cdfyPT.setInt(\"iblHeight\", size.height);\r\n this._cdfyPT.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n this._cdfyPT.refreshRate = 0;\r\n if (this._iblSource.isCube) {\r\n this._cdfyPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n\r\n this._cdfxPT = new ProceduralTexture(\"cdfxTexture\", { width: size.width + 1, height: 1 }, \"iblCdfx\", this._scene, cdfOptions, false, false);\r\n this._cdfxPT.autoClear = false;\r\n this._cdfxPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._cdfxPT.refreshRate = 0;\r\n this._cdfxPT.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n\r\n this._scaledLuminancePT = new ProceduralTexture(\r\n \"iblScaledLuminance\",\r\n { width: size.width, height: size.height },\r\n \"iblScaledLuminance\",\r\n this._scene,\r\n { ...cdfOptions, samplingMode: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, generateMipMaps: true },\r\n true,\r\n false\r\n );\r\n this._scaledLuminancePT.autoClear = false;\r\n this._scaledLuminancePT.setTexture(\"iblSource\", this._iblSource);\r\n this._scaledLuminancePT.setInt(\"iblHeight\", size.height);\r\n this._scaledLuminancePT.setInt(\"iblWidth\", size.width);\r\n this._scaledLuminancePT.refreshRate = 0;\r\n if (this._iblSource.isCube) {\r\n this._scaledLuminancePT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n this._icdfPT = new ProceduralTexture(\"icdfTexture\", { width: size.width, height: size.height }, \"iblIcdf\", this._scene, icdfOptions, false, false);\r\n this._icdfPT.autoClear = false;\r\n this._icdfPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._icdfPT.setTexture(\"cdfx\", this._cdfxPT);\r\n this._icdfPT.setTexture(\"iblSource\", this._iblSource);\r\n this._icdfPT.setTexture(\"scaledLuminanceSampler\", this._scaledLuminancePT);\r\n this._icdfPT.refreshRate = 0;\r\n this._icdfPT.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n this._icdfPT.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n if (this._iblSource.isCube) {\r\n this._icdfPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n // Once the textures are generated, notify that they are ready to use.\r\n this._icdfPT.onGeneratedObservable.addOnce(() => {\r\n this.onGeneratedObservable.notifyObservers();\r\n });\r\n\r\n this._dominantDirectionPT = new ProceduralTexture(\"iblDominantDirection\", { width: 1, height: 1 }, \"iblDominantDirection\", this._scene, icdfOptions, false, false);\r\n this._dominantDirectionPT.autoClear = false;\r\n this._dominantDirectionPT.setTexture(\"icdfSampler\", this._icdfPT);\r\n this._dominantDirectionPT.refreshRate = 0;\r\n this._dominantDirectionPT.defines = \"#define NUM_SAMPLES 32u\\n\";\r\n }\r\n\r\n private _disposeTextures() {\r\n this._cdfyPT?.dispose();\r\n this._cdfxPT?.dispose();\r\n this._icdfPT?.dispose();\r\n this._scaledLuminancePT?.dispose();\r\n this._dominantDirectionPT?.dispose();\r\n }\r\n\r\n private _createDebugPass() {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n const isWebGPU = this._engine.isWebGPU;\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine: this._engine,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"cdfy\", \"icdf\", \"cdfx\", \"iblSource\"],\r\n defines: this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\",\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../ShadersWGSL/iblCdfDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/iblCdfDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._debugPass = new PostProcess(this._debugPassName, \"iblCdfDebug\", debugOptions);\r\n const debugEffect = this._debugPass.getEffect();\r\n if (debugEffect) {\r\n debugEffect.defines = this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\";\r\n }\r\n if (this._iblSource?.isCube) {\r\n this._debugPass.updateEffect(\"#define IBL_USE_CUBE_MAP\\n\");\r\n }\r\n this._debugPass.onApplyObservable.add((effect) => {\r\n effect.setTexture(\"cdfy\", this._cdfyPT);\r\n effect.setTexture(\"icdf\", this._icdfPT);\r\n effect.setTexture(\"cdfx\", this._cdfxPT);\r\n effect.setTexture(\"iblSource\", this._iblSource);\r\n effect.setFloat4(\"sizeParams\", this._debugSizeParams.x, this._debugSizeParams.y, this._debugSizeParams.z, this._debugSizeParams.w);\r\n });\r\n }\r\n\r\n /**\r\n * Checks if the CDF renderer is ready\r\n * @returns true if the CDF renderer is ready\r\n */\r\n public isReady() {\r\n return (\r\n this._iblSource &&\r\n this._iblSource.name !== \"Placeholder IBL Source\" &&\r\n this._iblSource.isReady() &&\r\n this._cdfyPT &&\r\n this._cdfyPT.isReady() &&\r\n this._icdfPT &&\r\n this._icdfPT.isReady() &&\r\n this._cdfxPT &&\r\n this._cdfxPT.isReady() &&\r\n this._scaledLuminancePT &&\r\n this._scaledLuminancePT.isReady()\r\n );\r\n }\r\n\r\n /**\r\n * Explicitly trigger generation of CDF maps when they are ready to render.\r\n * @returns Promise that resolves when the CDF maps are rendered.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/promise-function-async\r\n public renderWhenReady(): Promise<void> {\r\n this._cachedDominantDirection = null;\r\n // Once the textures are generated, notify that they are ready to use.\r\n this._icdfPT.onGeneratedObservable.addOnce(() => {\r\n this.onGeneratedObservable.notifyObservers();\r\n });\r\n const promises: Array<Promise<void>> = [];\r\n const renderTargets: Array<ProceduralTexture> = [this._cdfyPT, this._cdfxPT, this._scaledLuminancePT, this._icdfPT];\r\n for (const target of renderTargets) {\r\n promises.push(\r\n new Promise((resolve) => {\r\n if (target.isReady()) {\r\n resolve();\r\n } else {\r\n target.getEffect().executeWhenCompiled(() => {\r\n resolve();\r\n });\r\n }\r\n })\r\n );\r\n }\r\n // eslint-disable-next-line github/no-then\r\n return Promise.all(promises).then(() => {\r\n for (const target of renderTargets) {\r\n target.render();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Finds the average direction of the highest intensity areas of the IBL source\r\n * @returns Async promise that resolves to the dominant direction of the IBL source\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async\r\n public findDominantDirection(): Promise<Vector3> {\r\n if (this._cachedDominantDirection) {\r\n return Promise.resolve(this._cachedDominantDirection);\r\n }\r\n return new Promise((resolve) => {\r\n this._dominantDirectionPT.onGeneratedObservable.addOnce(() => {\r\n const data = new Float32Array(4);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._dominantDirectionPT.readPixels(0, 0, data, true)!.then(() => {\r\n const dominantDirection = new Vector3(data[0], data[1], data[2]);\r\n this._cachedDominantDirection = dominantDirection;\r\n resolve(dominantDirection);\r\n });\r\n });\r\n if (this.isReady()) {\r\n if (this._dominantDirectionPT.isReady()) {\r\n this._dominantDirectionPT.render();\r\n } else {\r\n this._dominantDirectionPT.getEffect().executeWhenCompiled(() => {\r\n this._dominantDirectionPT.render();\r\n });\r\n }\r\n } else {\r\n this.onGeneratedObservable.addOnce(() => {\r\n if (this._dominantDirectionPT.isReady()) {\r\n this._dominantDirectionPT.render();\r\n } else {\r\n this._dominantDirectionPT.getEffect().executeWhenCompiled(() => {\r\n this._dominantDirectionPT.render();\r\n });\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Disposes the CDF renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n this._dummyTexture.dispose();\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n this.onGeneratedObservable.clear();\r\n }\r\n\r\n private static _IsScene(sceneOrEngine: Scene | AbstractEngine): sceneOrEngine is Scene {\r\n return sceneOrEngine.getClassName() === \"Scene\";\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"iblCdfGenerator.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/iblCdfGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB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,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAC,aAAqC;QACzD,OAAO,aAAa,CAAC,YAAY,EAAE,KAAK,OAAO,CAAC;IACpD,CAAC;;AAxUD;;GAEG;AACW,6CAA6B,GAA2B,CAAC,CAAC,EAAE,EAAE;IACxE,MAAM,WAAW,CAAC,6CAA6C,CAAC,CAAC;AACrE,CAAC,AAF0C,CAEzC","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport { ProceduralTexture } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../PostProcesses/postProcess\";\r\nimport { Vector3, Vector4 } from \"../Maths/math.vector\";\r\nimport { RawTexture } from \"../Materials/Textures/rawTexture\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { CubeTexture } from \"../Materials/Textures/cubeTexture\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { _RetryWithInterval } from \"../Misc/timingTools\";\r\n\r\n/**\r\n * Build cdf maps to be used for IBL importance sampling.\r\n */\r\nexport class IblCdfGenerator {\r\n private _scene: Nullable<Scene>;\r\n private _engine: AbstractEngine;\r\n\r\n private _cdfyPT: ProceduralTexture;\r\n private _cdfxPT: ProceduralTexture;\r\n private _icdfPT: ProceduralTexture;\r\n private _scaledLuminancePT: ProceduralTexture;\r\n private _dominantDirectionPT: ProceduralTexture;\r\n private _iblSource: Nullable<BaseTexture>;\r\n private _dummyTexture: RawTexture;\r\n\r\n private _cachedDominantDirection: Nullable<Vector3> = null;\r\n\r\n /**\r\n * Returns whether the CDF renderer is supported by the current engine\r\n */\r\n public get isSupported(): boolean {\r\n const engine = EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n return false;\r\n }\r\n return engine.getCaps().texelFetch;\r\n }\r\n\r\n /**\r\n * Gets the IBL source texture being used by the CDF renderer\r\n */\r\n public get iblSource(): Nullable<BaseTexture> {\r\n return this._iblSource;\r\n }\r\n\r\n /**\r\n * Sets the IBL source texture to be used by the CDF renderer.\r\n * This will trigger recreation of the CDF assets.\r\n */\r\n public set iblSource(source: Nullable<BaseTexture>) {\r\n if (this._iblSource === source) {\r\n return;\r\n }\r\n this._disposeTextures();\r\n this._iblSource = source;\r\n if (!source) {\r\n return;\r\n }\r\n if (source.isCube) {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl();\r\n } else {\r\n (source as CubeTexture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n } else {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl();\r\n } else {\r\n (source as Texture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n }\r\n }\r\n\r\n private _recreateAssetsFromNewIbl() {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n\r\n this._createTextures();\r\n\r\n if (this._debugPass) {\r\n // Recreate the debug pass because of the new textures\r\n this._createDebugPass();\r\n }\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) texture\r\n * @returns Return the cumulative distribution function (CDF) texture\r\n */\r\n public getIcdfTexture(): Texture {\r\n return this._icdfPT ? this._icdfPT : this._dummyTexture;\r\n }\r\n\r\n /** Enable the debug view for this pass */\r\n public debugEnabled: boolean = false;\r\n private _debugPass: PostProcess;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 1.0, 1.0);\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n\r\n /**\r\n * The name of the debug pass post process\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n private _debugPassName: string = \"CDF Debug\";\r\n\r\n /**\r\n * Gets the debug pass post process\r\n * @returns The post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._debugPass) {\r\n this._createDebugPass();\r\n }\r\n return this._debugPass;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"IblCdfGeneratorSceneComponentSceneComponent\");\r\n };\r\n\r\n /**\r\n * Instanciates the CDF renderer\r\n * @param sceneOrEngine Scene to attach to\r\n * @returns The CDF renderer\r\n */\r\n constructor(sceneOrEngine: Nullable<Scene | AbstractEngine>) {\r\n if (sceneOrEngine) {\r\n if (IblCdfGenerator._IsScene(sceneOrEngine)) {\r\n this._scene = sceneOrEngine;\r\n } else {\r\n this._engine = sceneOrEngine;\r\n }\r\n } else {\r\n this._scene = EngineStore.LastCreatedScene;\r\n }\r\n if (this._scene) {\r\n this._engine = this._scene.getEngine();\r\n }\r\n if (!this.isSupported) {\r\n Logger.Warn(\"CDF renderer is not supported by the current engine.\");\r\n return;\r\n }\r\n const blackPixels = new Uint16Array([0, 0, 0, 255]);\r\n this._dummyTexture = new RawTexture(blackPixels, 1, 1, Engine.TEXTUREFORMAT_RGBA, sceneOrEngine, false, false, undefined, Constants.TEXTURETYPE_HALF_FLOAT);\r\n if (this._scene) {\r\n IblCdfGenerator._SceneComponentInitialization(this._scene);\r\n }\r\n }\r\n\r\n /**\r\n * Observable that triggers when the CDF renderer is ready\r\n */\r\n public onGeneratedObservable: Observable<void> = new Observable<void>();\r\n\r\n private _createTextures() {\r\n const size: TextureSize = this._iblSource ? { width: this._iblSource.getSize().width, height: this._iblSource.getSize().height } : { width: 1, height: 1 };\r\n if (!this._iblSource) {\r\n this._iblSource = RawTexture.CreateRTexture(\r\n new Uint8Array([255]),\r\n 1,\r\n 1,\r\n this._engine,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n );\r\n this._iblSource.name = \"Placeholder IBL Source\";\r\n }\r\n\r\n if (this._iblSource.isCube) {\r\n size.width *= 4;\r\n size.height *= 2;\r\n // Force the resolution to be a power of 2 because we rely on the\r\n // auto-mipmap generation for the scaled luminance texture to produce\r\n // a 1x1 mip that represents the true average pixel intensity of the IBL.\r\n size.width = 1 << Math.floor(Math.log2(size.width));\r\n size.height = 1 << Math.floor(Math.log2(size.height));\r\n }\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n // Create CDF maps (Cumulative Distribution Function) to assist in importance sampling\r\n const cdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_R,\r\n type: Constants.TEXTURETYPE_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n gammaSpace: false,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../ShadersWGSL/iblCdfx.fragment\"), import(\"../ShadersWGSL/iblCdfy.fragment\"), import(\"../ShadersWGSL/iblScaledLuminance.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/iblCdfx.fragment\"), import(\"../Shaders/iblCdfy.fragment\"), import(\"../Shaders/iblScaledLuminance.fragment\")]);\r\n }\r\n },\r\n };\r\n const icdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n gammaSpace: false,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../ShadersWGSL/iblIcdf.fragment\"), import(\"../ShadersWGSL/iblDominantDirection.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/iblIcdf.fragment\"), import(\"../Shaders/iblDominantDirection.fragment\")]);\r\n }\r\n },\r\n };\r\n this._cdfyPT = new ProceduralTexture(\"cdfyTexture\", { width: size.width, height: size.height + 1 }, \"iblCdfy\", this._scene, cdfOptions, false, false);\r\n this._cdfyPT.autoClear = false;\r\n this._cdfyPT.setTexture(\"iblSource\", this._iblSource);\r\n this._cdfyPT.setInt(\"iblHeight\", size.height);\r\n this._cdfyPT.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n this._cdfyPT.refreshRate = 0;\r\n if (this._iblSource.isCube) {\r\n this._cdfyPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n\r\n this._cdfxPT = new ProceduralTexture(\"cdfxTexture\", { width: size.width + 1, height: 1 }, \"iblCdfx\", this._scene, cdfOptions, false, false);\r\n this._cdfxPT.autoClear = false;\r\n this._cdfxPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._cdfxPT.refreshRate = 0;\r\n this._cdfxPT.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n\r\n this._scaledLuminancePT = new ProceduralTexture(\r\n \"iblScaledLuminance\",\r\n { width: size.width, height: size.height },\r\n \"iblScaledLuminance\",\r\n this._scene,\r\n { ...cdfOptions, samplingMode: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, generateMipMaps: true },\r\n true,\r\n false\r\n );\r\n this._scaledLuminancePT.autoClear = false;\r\n this._scaledLuminancePT.setTexture(\"iblSource\", this._iblSource);\r\n this._scaledLuminancePT.setInt(\"iblHeight\", size.height);\r\n this._scaledLuminancePT.setInt(\"iblWidth\", size.width);\r\n this._scaledLuminancePT.refreshRate = 0;\r\n if (this._iblSource.isCube) {\r\n this._scaledLuminancePT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n this._icdfPT = new ProceduralTexture(\"icdfTexture\", { width: size.width, height: size.height }, \"iblIcdf\", this._scene, icdfOptions, false, false);\r\n this._icdfPT.autoClear = false;\r\n this._icdfPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._icdfPT.setTexture(\"cdfx\", this._cdfxPT);\r\n this._icdfPT.setTexture(\"iblSource\", this._iblSource);\r\n this._icdfPT.setTexture(\"scaledLuminanceSampler\", this._scaledLuminancePT);\r\n this._icdfPT.refreshRate = 0;\r\n this._icdfPT.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n this._icdfPT.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n if (this._iblSource.isCube) {\r\n this._icdfPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n // Once the textures are generated, notify that they are ready to use.\r\n this._icdfPT.onGeneratedObservable.addOnce(() => {\r\n this.onGeneratedObservable.notifyObservers();\r\n });\r\n\r\n this._dominantDirectionPT = new ProceduralTexture(\"iblDominantDirection\", { width: 1, height: 1 }, \"iblDominantDirection\", this._scene, icdfOptions, false, false);\r\n this._dominantDirectionPT.autoClear = false;\r\n this._dominantDirectionPT.setTexture(\"icdfSampler\", this._icdfPT);\r\n this._dominantDirectionPT.refreshRate = 0;\r\n this._dominantDirectionPT.defines = \"#define NUM_SAMPLES 32u\\n\";\r\n }\r\n\r\n private _disposeTextures() {\r\n this._cdfyPT?.dispose();\r\n this._cdfxPT?.dispose();\r\n this._icdfPT?.dispose();\r\n this._scaledLuminancePT?.dispose();\r\n this._dominantDirectionPT?.dispose();\r\n }\r\n\r\n private _createDebugPass() {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n const isWebGPU = this._engine.isWebGPU;\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine: this._engine,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"cdfy\", \"icdf\", \"cdfx\", \"iblSource\"],\r\n defines: this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\",\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../ShadersWGSL/iblCdfDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/iblCdfDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._debugPass = new PostProcess(this._debugPassName, \"iblCdfDebug\", debugOptions);\r\n const debugEffect = this._debugPass.getEffect();\r\n if (debugEffect) {\r\n debugEffect.defines = this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\";\r\n }\r\n if (this._iblSource?.isCube) {\r\n this._debugPass.updateEffect(\"#define IBL_USE_CUBE_MAP\\n\");\r\n }\r\n this._debugPass.onApplyObservable.add((effect) => {\r\n effect.setTexture(\"cdfy\", this._cdfyPT);\r\n effect.setTexture(\"icdf\", this._icdfPT);\r\n effect.setTexture(\"cdfx\", this._cdfxPT);\r\n effect.setTexture(\"iblSource\", this._iblSource);\r\n effect.setFloat4(\"sizeParams\", this._debugSizeParams.x, this._debugSizeParams.y, this._debugSizeParams.z, this._debugSizeParams.w);\r\n });\r\n }\r\n\r\n /**\r\n * Checks if the CDF renderer is ready\r\n * @returns true if the CDF renderer is ready\r\n */\r\n public isReady() {\r\n return (\r\n this._iblSource &&\r\n this._iblSource.name !== \"Placeholder IBL Source\" &&\r\n this._iblSource.isReady() &&\r\n this._cdfyPT &&\r\n this._cdfyPT.isReady() &&\r\n this._icdfPT &&\r\n this._icdfPT.isReady() &&\r\n this._cdfxPT &&\r\n this._cdfxPT.isReady() &&\r\n this._scaledLuminancePT &&\r\n this._scaledLuminancePT.isReady()\r\n );\r\n }\r\n\r\n /**\r\n * Explicitly trigger generation of CDF maps when they are ready to render.\r\n * @returns Promise that resolves when the CDF maps are rendered.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/promise-function-async\r\n public renderWhenReady(): Promise<void> {\r\n this._cachedDominantDirection = null;\r\n\r\n // Even if a IBL source must be set before calling this function, _icdfPT may not yet be created because the creation may be asynchronous (see @set iblSource).\r\n const icdfPTPromise = new Promise((resolve, reject) => {\r\n _RetryWithInterval(\r\n () => !!this._icdfPT,\r\n () => resolve(void 0),\r\n () => reject(new Error(\"Waiting for _icdfPT creation failed\"))\r\n );\r\n });\r\n\r\n // eslint-disable-next-line github/no-then, @typescript-eslint/promise-function-async\r\n return icdfPTPromise.then(() => {\r\n // Once the textures are generated, notify that they are ready to use.\r\n this._icdfPT.onGeneratedObservable.addOnce(() => {\r\n this.onGeneratedObservable.notifyObservers();\r\n });\r\n const promises: Array<Promise<void>> = [];\r\n const renderTargets: Array<ProceduralTexture> = [this._cdfyPT, this._cdfxPT, this._scaledLuminancePT, this._icdfPT];\r\n for (const target of renderTargets) {\r\n promises.push(\r\n new Promise((resolve) => {\r\n if (target.isReady()) {\r\n resolve();\r\n } else {\r\n target.getEffect().executeWhenCompiled(() => {\r\n resolve();\r\n });\r\n }\r\n })\r\n );\r\n }\r\n // eslint-disable-next-line github/no-then\r\n return Promise.all(promises).then(() => {\r\n for (const target of renderTargets) {\r\n target.render();\r\n }\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Finds the average direction of the highest intensity areas of the IBL source\r\n * @returns Async promise that resolves to the dominant direction of the IBL source\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async\r\n public findDominantDirection(): Promise<Vector3> {\r\n if (this._cachedDominantDirection) {\r\n return Promise.resolve(this._cachedDominantDirection);\r\n }\r\n return new Promise((resolve) => {\r\n this._dominantDirectionPT.onGeneratedObservable.addOnce(() => {\r\n const data = new Float32Array(4);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._dominantDirectionPT.readPixels(0, 0, data, true)!.then(() => {\r\n const dominantDirection = new Vector3(data[0], data[1], data[2]);\r\n this._cachedDominantDirection = dominantDirection;\r\n resolve(dominantDirection);\r\n });\r\n });\r\n if (this.isReady()) {\r\n if (this._dominantDirectionPT.isReady()) {\r\n this._dominantDirectionPT.render();\r\n } else {\r\n this._dominantDirectionPT.getEffect().executeWhenCompiled(() => {\r\n this._dominantDirectionPT.render();\r\n });\r\n }\r\n } else {\r\n this.onGeneratedObservable.addOnce(() => {\r\n if (this._dominantDirectionPT.isReady()) {\r\n this._dominantDirectionPT.render();\r\n } else {\r\n this._dominantDirectionPT.getEffect().executeWhenCompiled(() => {\r\n this._dominantDirectionPT.render();\r\n });\r\n }\r\n });\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Disposes the CDF renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n this._dummyTexture.dispose();\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n this.onGeneratedObservable.clear();\r\n }\r\n\r\n private static _IsScene(sceneOrEngine: Scene | AbstractEngine): sceneOrEngine is Scene {\r\n return sceneOrEngine.getClassName() === \"Scene\";\r\n }\r\n}\r\n"]}
|