@babylonjs/core 7.40.3 → 7.40.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Audio/sound.js +5 -10
- package/Audio/sound.js.map +1 -1
- package/Compute/computeEffect.js +6 -14
- package/Compute/computeEffect.js.map +1 -1
- package/Compute/computeShader.js +2 -9
- package/Compute/computeShader.js.map +1 -1
- package/Culling/Helper/computeShaderBoundingHelper.js +5 -6
- package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -1
- package/Engines/abstractEngine.d.ts +7 -0
- package/Engines/abstractEngine.js +7 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.js +6 -8
- package/Engines/engine.js.map +1 -1
- package/Engines/thinEngine.js +6 -1
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +6 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/frameGraph.js +4 -9
- package/FrameGraph/frameGraph.js.map +1 -1
- package/Layers/effectLayer.js +2 -0
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.js +4 -0
- package/Layers/glowLayer.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +5 -0
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +33 -0
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +2 -4
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +4 -0
- package/Materials/Node/nodeMaterial.js +15 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +2 -4
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +3 -2
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/colorGradingTexture.js +5 -2
- package/Materials/Textures/colorGradingTexture.js.map +1 -1
- package/Materials/effect.functions.d.ts +0 -1
- package/Materials/effect.functions.js +0 -19
- package/Materials/effect.functions.js.map +1 -1
- package/Materials/effect.js +3 -2
- package/Materials/effect.js.map +1 -1
- package/Materials/effect.webgl.functions.js +2 -1
- package/Materials/effect.webgl.functions.js.map +1 -1
- package/Materials/material.d.ts +4 -0
- package/Materials/material.js +8 -0
- package/Materials/material.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +5 -0
- package/Meshes/abstractMesh.js +15 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/mesh.vertexData.functions.d.ts +6 -0
- package/Meshes/mesh.vertexData.functions.js +65 -0
- package/Meshes/mesh.vertexData.functions.js.map +1 -0
- package/Misc/bitArray.d.ts +26 -0
- package/Misc/bitArray.js +53 -0
- package/Misc/bitArray.js.map +1 -0
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/screenshotTools.js +7 -9
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/timingTools.d.ts +4 -0
- package/Misc/timingTools.js +38 -0
- package/Misc/timingTools.js.map +1 -1
- package/Misc/webRequest.d.ts +1 -1
- package/Misc/webRequest.js +1 -1
- package/Misc/webRequest.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +7 -5
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/iblCdfGenerator.d.ts +14 -19
- package/Rendering/iblCdfGenerator.js +64 -57
- package/Rendering/iblCdfGenerator.js.map +1 -1
- package/Rendering/index.d.ts +6 -6
- package/Rendering/index.js +6 -6
- package/Rendering/index.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +6 -6
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +1 -0
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js +2 -3
- package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +2 -3
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/{iblIcdfx.fragment.d.ts → iblCdfDebug.fragment.d.ts} +1 -1
- package/Shaders/{importanceSamplingDebug.fragment.js → iblCdfDebug.fragment.js} +12 -11
- package/Shaders/iblCdfDebug.fragment.js.map +1 -0
- package/Shaders/iblCdfy.fragment.d.ts +1 -0
- package/Shaders/iblCdfy.fragment.js +4 -4
- package/Shaders/iblCdfy.fragment.js.map +1 -1
- package/Shaders/iblIcdf.fragment.d.ts +6 -0
- package/Shaders/iblIcdf.fragment.js +43 -0
- package/Shaders/iblIcdf.fragment.js.map +1 -0
- package/Shaders/iblScaledLuminance.fragment.d.ts +6 -0
- package/Shaders/iblScaledLuminance.fragment.js +25 -0
- package/Shaders/iblScaledLuminance.fragment.js.map +1 -0
- package/Shaders/iblShadowVoxelTracing.fragment.js +2 -2
- package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/Shaders/pbr.fragment.js +2 -4
- package/Shaders/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +8 -6
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/helperFunctions.js +1 -0
- package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +4 -8
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js +4 -8
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/{iblIcdfy.fragment.d.ts → iblCdfDebug.fragment.d.ts} +1 -1
- package/ShadersWGSL/{importanceSamplingDebug.fragment.js → iblCdfDebug.fragment.js} +11 -10
- package/ShadersWGSL/iblCdfDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblCdfy.fragment.js +8 -7
- package/ShadersWGSL/iblCdfy.fragment.js.map +1 -1
- package/ShadersWGSL/iblIcdf.fragment.d.ts +6 -0
- package/ShadersWGSL/iblIcdf.fragment.js +43 -0
- package/ShadersWGSL/iblIcdf.fragment.js.map +1 -0
- package/ShadersWGSL/iblScaledLuminance.fragment.d.ts +6 -0
- package/ShadersWGSL/iblScaledLuminance.fragment.js +24 -0
- package/ShadersWGSL/iblScaledLuminance.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +3 -3
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +4 -8
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/package.json +1 -1
- package/Shaders/iblIcdfx.fragment.js +0 -19
- package/Shaders/iblIcdfx.fragment.js.map +0 -1
- package/Shaders/iblIcdfy.fragment.d.ts +0 -5
- package/Shaders/iblIcdfy.fragment.js +0 -19
- package/Shaders/iblIcdfy.fragment.js.map +0 -1
- package/Shaders/importanceSamplingDebug.fragment.d.ts +0 -5
- package/Shaders/importanceSamplingDebug.fragment.js.map +0 -1
- package/ShadersWGSL/iblIcdfx.fragment.d.ts +0 -5
- package/ShadersWGSL/iblIcdfx.fragment.js +0 -18
- package/ShadersWGSL/iblIcdfx.fragment.js.map +0 -1
- package/ShadersWGSL/iblIcdfy.fragment.js +0 -17
- package/ShadersWGSL/iblIcdfy.fragment.js.map +0 -1
- package/ShadersWGSL/importanceSamplingDebug.fragment.d.ts +0 -5
- package/ShadersWGSL/importanceSamplingDebug.fragment.js.map +0 -1
package/Misc/webRequest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webRequest.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/webRequest.ts"],"names":[],"mappings":"AAOA,gBAAgB;AAChB,gEAAgE;AAChE,SAAS,oBAAoB;IACzB,4GAA4G;IAC5G,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC3D,OAAO,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IACxC,CAAC;SAAM,CAAC;QACJ,OAAO,IAAI,cAAc,EAAE,CAAC;IAChC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,UAAU;IAAvB;QACqB,SAAI,GAAG,oBAAoB,EAAE,CAAC;QA0BvC,gBAAW,GAAW,EAAE,CAAC;IAkLrC,CAAC;IA1LG;;;OAGG;IACI,MAAM,KAAK,wBAAwB;QACtC,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,sBAAsB,CAAC,MAAM,GAAG,CAAC,CAAC;IACnH,CAAC;IAID;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAEO,2BAA2B;QAC/B,IAAI,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YACzD,OAAO;QACX,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,UAAU,CAAC,oBAAoB,EAAE,CAAC;YAChD,MAAM,GAAG,GAAG,UAAU,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;YACjD,IAAI,GAAG,EAAE,CAAC;gBACN,IAAI,CAAC,IAAI,C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AAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,gBAAgB,CAAC,IAAY,EAAE,KAAa;QACxC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;;AAzMD;;;GAGG;AACW,+BAAoB,GAA8B,EAAE,AAAhC,CAAiC;AAEnE;;GAEG;AACW,iCAAsB,GAAG,IAAI,KAAK,EAAkD,AAA9D,CAA+D;AAEnG;;GAEG;AACW,+CAAoC,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import type { IWebRequest } from \"./interfaces/iWebRequest\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { INative } from \"../Engines/Native/nativeInterfaces\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare const _native: INative;\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction createXMLHttpRequest(): XMLHttpRequest {\r\n // If running in Babylon Native, then defer to the native XMLHttpRequest, which has the same public contract\r\n if (typeof _native !== \"undefined\" && _native.XMLHttpRequest) {\r\n return new _native.XMLHttpRequest();\r\n } else {\r\n return new XMLHttpRequest();\r\n }\r\n}\r\n\r\n/**\r\n * Extended version of XMLHttpRequest with support for customizations (headers, ...)\r\n */\r\nexport class WebRequest implements IWebRequest {\r\n private readonly _xhr = createXMLHttpRequest();\r\n\r\n /**\r\n * Custom HTTP Request Headers to be sent with XMLHttpRequests\r\n * i.e. when loading files, where the server/service expects an Authorization header\r\n */\r\n public static CustomRequestHeaders: { [key: string]: string } = {};\r\n\r\n /**\r\n * Add callback functions in this array to update all the requests before they get sent to the network\r\n */\r\n public static CustomRequestModifiers = new Array<(request: XMLHttpRequest, url: string) => void>();\r\n\r\n /**\r\n * If set to true, requests to Babylon.js CDN requests will not be modified\r\n */\r\n public static SkipRequestModificationForBabylonCDN = true;\r\n\r\n /**\r\n * This function can be called to check if there are request modifiers for network requests\r\n * @returns true if there are any custom requests available\r\n */\r\n public static get IsCustomRequestAvailable(): boolean {\r\n return Object.keys(WebRequest.CustomRequestHeaders).length > 0 || WebRequest.CustomRequestModifiers.length > 0;\r\n }\r\n\r\n private _requestURL: string = \"\";\r\n\r\n /**\r\n * Returns the requested URL once open has been called\r\n */\r\n public get requestURL(): string {\r\n return this._requestURL;\r\n }\r\n\r\n private _injectCustomRequestHeaders(): void {\r\n if (this._shouldSkipRequestModifications(this._requestURL)) {\r\n return;\r\n }\r\n for (const key in WebRequest.CustomRequestHeaders) {\r\n const val = WebRequest.CustomRequestHeaders[key];\r\n if (val) {\r\n this._xhr.setRequestHeader(key, val);\r\n }\r\n }\r\n }\r\n\r\n private _shouldSkipRequestModifications(url: string): boolean {\r\n return WebRequest.SkipRequestModificationForBabylonCDN && (url.includes(\"preview.babylonjs.com\") || url.includes(\"cdn.babylonjs.com\"));\r\n }\r\n\r\n /**\r\n * Gets or sets a function to be called when loading progress changes\r\n */\r\n public get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null {\r\n return this._xhr.onprogress;\r\n }\r\n\r\n public set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null) {\r\n this._xhr.onprogress = value;\r\n }\r\n\r\n /**\r\n * Returns client's state\r\n */\r\n public get readyState(): number {\r\n return this._xhr.readyState;\r\n }\r\n\r\n /**\r\n * Returns client's status\r\n */\r\n public get status(): number {\r\n return this._xhr.status;\r\n }\r\n\r\n /**\r\n * Returns client's status as a text\r\n */\r\n public get statusText(): string {\r\n return this._xhr.statusText;\r\n }\r\n\r\n /**\r\n * Returns client's response\r\n */\r\n public get response(): any {\r\n return this._xhr.response;\r\n }\r\n\r\n /**\r\n * Returns client's response url\r\n */\r\n public get responseURL(): string {\r\n return this._xhr.responseURL;\r\n }\r\n\r\n /**\r\n * Returns client's response as text\r\n */\r\n public get responseText(): string {\r\n return this._xhr.responseText;\r\n }\r\n\r\n /**\r\n * Gets or sets the expected response type\r\n */\r\n public get responseType(): XMLHttpRequestResponseType {\r\n return this._xhr.responseType;\r\n }\r\n\r\n public set responseType(value: XMLHttpRequestResponseType) {\r\n this._xhr.responseType = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the timeout value in milliseconds\r\n */\r\n public get timeout(): number {\r\n return this._xhr.timeout;\r\n }\r\n\r\n public set timeout(value: number) {\r\n this._xhr.timeout = value;\r\n }\r\n\r\n /** @internal */\r\n public addEventListener<K extends keyof XMLHttpRequestEventMap>(\r\n type: K,\r\n listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any,\r\n options?: boolean | AddEventListenerOptions\r\n ): void;\r\n public addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void {\r\n this._xhr.addEventListener(type, listener, options);\r\n }\r\n\r\n /** @internal */\r\n public removeEventListener<K extends keyof XMLHttpRequestEventMap>(\r\n type: K,\r\n listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any,\r\n options?: boolean | EventListenerOptions\r\n ): void;\r\n public removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void {\r\n this._xhr.removeEventListener(type, listener, options);\r\n }\r\n\r\n /**\r\n * Cancels any network activity\r\n */\r\n public abort() {\r\n this._xhr.abort();\r\n }\r\n\r\n /**\r\n * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD\r\n * @param body defines an optional request body\r\n */\r\n public send(body?: Document | XMLHttpRequestBodyInit | null): void {\r\n if (WebRequest.CustomRequestHeaders) {\r\n this._injectCustomRequestHeaders();\r\n }\r\n\r\n this._xhr.send(body);\r\n }\r\n\r\n /**\r\n * Sets the request method, request URL\r\n * @param method defines the method to use (GET, POST, etc..)\r\n * @param url defines the url to connect with\r\n */\r\n public open(method: string, url: string): void {\r\n for (const update of WebRequest.CustomRequestModifiers) {\r\n if (this._shouldSkipRequestModifications(url)) {\r\n return;\r\n }\r\n update(this._xhr, url);\r\n }\r\n\r\n // Clean url\r\n url = url.replace(\"file:http:\", \"http:\");\r\n url = url.replace(\"file:https:\", \"https:\");\r\n\r\n this._requestURL = url;\r\n\r\n this._xhr.open(method, url, true);\r\n }\r\n\r\n /**\r\n * Sets the value of a request header.\r\n * @param name The name of the header whose value is to be set\r\n * @param value The value to set as the body of the header\r\n */\r\n setRequestHeader(name: string, value: string): void {\r\n this._xhr.setRequestHeader(name, value);\r\n }\r\n\r\n /**\r\n * Get the string containing the text of a particular header's value.\r\n * @param name The name of the header\r\n * @returns The string containing the text of the given header name\r\n */\r\n getResponseHeader(name: string): Nullable<string> {\r\n return this._xhr.getResponseHeader(name);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webRequest.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/webRequest.ts"],"names":[],"mappings":"AAOA,gBAAgB;AAChB,gEAAgE;AAChE,SAAS,oBAAoB;IACzB,4GAA4G;IAC5G,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC3D,OAAO,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IACxC,CAAC;SAAM,CAAC;QACJ,OAAO,IAAI,cAAc,EAAE,CAAC;IAChC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,UAAU;IAAvB;QACqB,SAAI,GAAG,oBAAoB,EAAE,CAAC;QA0BvC,gBAAW,GAAW,EAAE,CAAC;IAkLrC,CAAC;IA1LG;;;OAGG;IACI,MAAM,KAAK,wBAAwB;QACtC,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,sBAAsB,CAAC,MAAM,GAAG,CAAC,CAAC;IACnH,CAA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AAC,+BAA+B,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC5C,OAAO;YACX,CAAC;YACD,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC;QACxC,CAAC;QAED,YAAY;QACZ,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAE3C,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC;QAEvB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,gBAAgB,CAAC,IAAY,EAAE,KAAa;QACxC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;;AAzMD;;;GAGG;AACW,+BAAoB,GAA8B,EAAE,AAAhC,CAAiC;AAEnE;;GAEG;AACW,iCAAsB,GAAG,IAAI,KAAK,EAA2D,AAAvE,CAAwE;AAE5G;;GAEG;AACW,+CAAoC,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import type { IWebRequest } from \"./interfaces/iWebRequest\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { INative } from \"../Engines/Native/nativeInterfaces\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare const _native: INative;\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction createXMLHttpRequest(): XMLHttpRequest {\r\n // If running in Babylon Native, then defer to the native XMLHttpRequest, which has the same public contract\r\n if (typeof _native !== \"undefined\" && _native.XMLHttpRequest) {\r\n return new _native.XMLHttpRequest();\r\n } else {\r\n return new XMLHttpRequest();\r\n }\r\n}\r\n\r\n/**\r\n * Extended version of XMLHttpRequest with support for customizations (headers, ...)\r\n */\r\nexport class WebRequest implements IWebRequest {\r\n private readonly _xhr = createXMLHttpRequest();\r\n\r\n /**\r\n * Custom HTTP Request Headers to be sent with XMLHttpRequests\r\n * i.e. when loading files, where the server/service expects an Authorization header\r\n */\r\n public static CustomRequestHeaders: { [key: string]: string } = {};\r\n\r\n /**\r\n * Add callback functions in this array to update all the requests before they get sent to the network\r\n */\r\n public static CustomRequestModifiers = new Array<(request: XMLHttpRequest, url: string) => string | void>();\r\n\r\n /**\r\n * If set to true, requests to Babylon.js CDN requests will not be modified\r\n */\r\n public static SkipRequestModificationForBabylonCDN = true;\r\n\r\n /**\r\n * This function can be called to check if there are request modifiers for network requests\r\n * @returns true if there are any custom requests available\r\n */\r\n public static get IsCustomRequestAvailable(): boolean {\r\n return Object.keys(WebRequest.CustomRequestHeaders).length > 0 || WebRequest.CustomRequestModifiers.length > 0;\r\n }\r\n\r\n private _requestURL: string = \"\";\r\n\r\n /**\r\n * Returns the requested URL once open has been called\r\n */\r\n public get requestURL(): string {\r\n return this._requestURL;\r\n }\r\n\r\n private _injectCustomRequestHeaders(): void {\r\n if (this._shouldSkipRequestModifications(this._requestURL)) {\r\n return;\r\n }\r\n for (const key in WebRequest.CustomRequestHeaders) {\r\n const val = WebRequest.CustomRequestHeaders[key];\r\n if (val) {\r\n this._xhr.setRequestHeader(key, val);\r\n }\r\n }\r\n }\r\n\r\n private _shouldSkipRequestModifications(url: string): boolean {\r\n return WebRequest.SkipRequestModificationForBabylonCDN && (url.includes(\"preview.babylonjs.com\") || url.includes(\"cdn.babylonjs.com\"));\r\n }\r\n\r\n /**\r\n * Gets or sets a function to be called when loading progress changes\r\n */\r\n public get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null {\r\n return this._xhr.onprogress;\r\n }\r\n\r\n public set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null) {\r\n this._xhr.onprogress = value;\r\n }\r\n\r\n /**\r\n * Returns client's state\r\n */\r\n public get readyState(): number {\r\n return this._xhr.readyState;\r\n }\r\n\r\n /**\r\n * Returns client's status\r\n */\r\n public get status(): number {\r\n return this._xhr.status;\r\n }\r\n\r\n /**\r\n * Returns client's status as a text\r\n */\r\n public get statusText(): string {\r\n return this._xhr.statusText;\r\n }\r\n\r\n /**\r\n * Returns client's response\r\n */\r\n public get response(): any {\r\n return this._xhr.response;\r\n }\r\n\r\n /**\r\n * Returns client's response url\r\n */\r\n public get responseURL(): string {\r\n return this._xhr.responseURL;\r\n }\r\n\r\n /**\r\n * Returns client's response as text\r\n */\r\n public get responseText(): string {\r\n return this._xhr.responseText;\r\n }\r\n\r\n /**\r\n * Gets or sets the expected response type\r\n */\r\n public get responseType(): XMLHttpRequestResponseType {\r\n return this._xhr.responseType;\r\n }\r\n\r\n public set responseType(value: XMLHttpRequestResponseType) {\r\n this._xhr.responseType = value;\r\n }\r\n\r\n /**\r\n * Gets or sets the timeout value in milliseconds\r\n */\r\n public get timeout(): number {\r\n return this._xhr.timeout;\r\n }\r\n\r\n public set timeout(value: number) {\r\n this._xhr.timeout = value;\r\n }\r\n\r\n /** @internal */\r\n public addEventListener<K extends keyof XMLHttpRequestEventMap>(\r\n type: K,\r\n listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any,\r\n options?: boolean | AddEventListenerOptions\r\n ): void;\r\n public addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void {\r\n this._xhr.addEventListener(type, listener, options);\r\n }\r\n\r\n /** @internal */\r\n public removeEventListener<K extends keyof XMLHttpRequestEventMap>(\r\n type: K,\r\n listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any,\r\n options?: boolean | EventListenerOptions\r\n ): void;\r\n public removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void {\r\n this._xhr.removeEventListener(type, listener, options);\r\n }\r\n\r\n /**\r\n * Cancels any network activity\r\n */\r\n public abort() {\r\n this._xhr.abort();\r\n }\r\n\r\n /**\r\n * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD\r\n * @param body defines an optional request body\r\n */\r\n public send(body?: Document | XMLHttpRequestBodyInit | null): void {\r\n if (WebRequest.CustomRequestHeaders) {\r\n this._injectCustomRequestHeaders();\r\n }\r\n\r\n this._xhr.send(body);\r\n }\r\n\r\n /**\r\n * Sets the request method, request URL\r\n * @param method defines the method to use (GET, POST, etc..)\r\n * @param url defines the url to connect with\r\n */\r\n public open(method: string, url: string): void {\r\n for (const update of WebRequest.CustomRequestModifiers) {\r\n if (this._shouldSkipRequestModifications(url)) {\r\n return;\r\n }\r\n url = update(this._xhr, url) || url;\r\n }\r\n\r\n // Clean url\r\n url = url.replace(\"file:http:\", \"http:\");\r\n url = url.replace(\"file:https:\", \"https:\");\r\n\r\n this._requestURL = url;\r\n\r\n this._xhr.open(method, url, true);\r\n }\r\n\r\n /**\r\n * Sets the value of a request header.\r\n * @param name The name of the header whose value is to be set\r\n * @param value The value to set as the body of the header\r\n */\r\n setRequestHeader(name: string, value: string): void {\r\n this._xhr.setRequestHeader(name, value);\r\n }\r\n\r\n /**\r\n * Get the string containing the text of a particular header's value.\r\n * @param name The name of the header\r\n * @returns The string containing the text of the given header name\r\n */\r\n getResponseHeader(name: string): Nullable<string> {\r\n return this._xhr.getResponseHeader(name);\r\n }\r\n}\r\n"]}
|
|
@@ -294,7 +294,11 @@ export class _IblShadowsVoxelTracingPass {
|
|
|
294
294
|
this._outputTexture.setMatrix("invViewMtx", this._cameraInvView);
|
|
295
295
|
this._outputTexture.setMatrix("wsNormalizationMtx", this._invWorldScaleMatrix);
|
|
296
296
|
this._frameId++;
|
|
297
|
-
let rotation =
|
|
297
|
+
let rotation = 0.0;
|
|
298
|
+
if (this._scene.environmentTexture) {
|
|
299
|
+
rotation = this._scene.environmentTexture.rotationY ?? 0;
|
|
300
|
+
}
|
|
301
|
+
rotation = this._scene.useRightHandedSystem ? -(rotation + 0.5 * Math.PI) : rotation - 0.5 * Math.PI;
|
|
298
302
|
rotation = rotation % (2.0 * Math.PI);
|
|
299
303
|
this._shadowParameters.set(this._sampleDirections, this._frameId, 1.0, rotation);
|
|
300
304
|
this._outputTexture.setVector4("shadowParameters", this._shadowParameters);
|
|
@@ -311,8 +315,7 @@ export class _IblShadowsVoxelTracingPass {
|
|
|
311
315
|
this._outputTexture.setTexture("blueNoiseSampler", this._renderPipeline._getNoiseTexture());
|
|
312
316
|
const cdfGenerator = this._scene.iblCdfGenerator;
|
|
313
317
|
if (cdfGenerator) {
|
|
314
|
-
this._outputTexture.setTexture("
|
|
315
|
-
this._outputTexture.setTexture("icdfxSampler", cdfGenerator.getIcdfxTexture());
|
|
318
|
+
this._outputTexture.setTexture("icdfSampler", cdfGenerator.getIcdfTexture());
|
|
316
319
|
}
|
|
317
320
|
if (this._debugVoxelMarchEnabled) {
|
|
318
321
|
this._outputTexture.defines += "#define VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION 1u\n";
|
|
@@ -345,8 +348,7 @@ export class _IblShadowsVoxelTracingPass {
|
|
|
345
348
|
return (this._outputTexture.isReady() &&
|
|
346
349
|
!(this._debugPassPP && !this._debugPassPP.isReady()) &&
|
|
347
350
|
this._scene.iblCdfGenerator &&
|
|
348
|
-
this._scene.iblCdfGenerator.
|
|
349
|
-
this._scene.iblCdfGenerator.getIcdfxTexture().isReady() &&
|
|
351
|
+
this._scene.iblCdfGenerator.getIcdfTexture().isReady() &&
|
|
350
352
|
this._renderPipeline._getVoxelGridTexture().isReady());
|
|
351
353
|
}
|
|
352
354
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iblShadowsVoxelTracingPass.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsVoxelTracingPass.ts"],"names":[],"mappings":"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AC,OAAO,EAAE,CAAC;YACpD,IAAI,CAAC,MAAM,CAAC,eAAe;YAC3B,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC,OAAO,EAAE;YACvD,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC,OAAO,EAAE;YACvD,IAAI,CAAC,eAAgB,CAAC,oBAAoB,EAAE,CAAC,OAAO,EAAE,CACzD,CAAC;IACN,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { Constants } from \"../../Engines/constants\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Matrix, Vector4 } from \"../../Maths/math.vector\";\r\nimport { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../../PostProcesses/postProcess\";\r\nimport type { IblShadowsRenderPipeline } from \"./iblShadowsRenderPipeline\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { GeometryBufferRenderer } from \"../../Rendering/geometryBufferRenderer\";\r\nimport { ProceduralTexture } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\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 _IblShadowsVoxelTracingPass {\r\n private _scene: Scene;\r\n private _engine: AbstractEngine;\r\n private _renderPipeline: IblShadowsRenderPipeline;\r\n private _voxelShadowOpacity: number = 1.0;\r\n /**\r\n * The opacity of the shadow cast from the voxel grid\r\n */\r\n public get voxelShadowOpacity(): number {\r\n return this._voxelShadowOpacity;\r\n }\r\n /**\r\n * The opacity of the shadow cast from the voxel grid\r\n */\r\n public set voxelShadowOpacity(value: number) {\r\n this._voxelShadowOpacity = value;\r\n }\r\n private _sssSamples: number = 16;\r\n private _sssStride: number = 8;\r\n private _sssMaxDist: number = 0.05;\r\n private _sssThickness: number = 0.5;\r\n\r\n private _ssShadowOpacity: number = 1.0;\r\n /**\r\n * The opacity of the screen-space shadow\r\n */\r\n public get ssShadowOpacity(): number {\r\n return this._ssShadowOpacity;\r\n }\r\n /**\r\n * The opacity of the screen-space shadow\r\n */\r\n public set ssShadowOpacity(value: number) {\r\n this._ssShadowOpacity = value;\r\n }\r\n\r\n /**\r\n * The number of samples used in the screen space shadow pass.\r\n */\r\n public get sssSamples(): number {\r\n return this._sssSamples;\r\n }\r\n\r\n /**\r\n * The number of samples used in the screen space shadow pass.\r\n */\r\n public set sssSamples(value: number) {\r\n this._sssSamples = value;\r\n }\r\n\r\n /**\r\n * The stride used in the screen space shadow pass. This controls the distance between samples.\r\n */\r\n public get sssStride(): number {\r\n return this._sssStride;\r\n }\r\n\r\n /**\r\n * The stride used in the screen space shadow pass. This controls the distance between samples.\r\n */\r\n public set sssStride(value: number) {\r\n this._sssStride = value;\r\n }\r\n\r\n /**\r\n * The maximum distance that the screen-space shadow will be able to occlude.\r\n */\r\n public get sssMaxDist(): number {\r\n return this._sssMaxDist;\r\n }\r\n\r\n /**\r\n * The maximum distance that the screen-space shadow will be able to occlude.\r\n */\r\n public set sssMaxDist(value: number) {\r\n this._sssMaxDist = value;\r\n }\r\n\r\n /**\r\n * The thickness of the screen-space shadow\r\n */\r\n public get sssThickness(): number {\r\n return this._sssThickness;\r\n }\r\n\r\n /**\r\n * The thickness of the screen-space shadow\r\n */\r\n public set sssThickness(value: number) {\r\n this._sssThickness = value;\r\n }\r\n\r\n private _outputTexture: ProceduralTexture;\r\n private _cameraInvView: Matrix = Matrix.Identity();\r\n private _cameraInvProj: Matrix = Matrix.Identity();\r\n private _invWorldScaleMatrix: Matrix = Matrix.Identity();\r\n private _frameId: number = 0;\r\n private _sampleDirections: number = 4;\r\n private _shadowParameters: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _sssParameters: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _opacityParameters: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _voxelBiasParameters: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _voxelNormalBias: number = 1.4;\r\n /**\r\n * The bias to apply to the voxel sampling in the direction of the surface normal of the geometry.\r\n */\r\n public get voxelNormalBias(): number {\r\n return this._voxelNormalBias;\r\n }\r\n public set voxelNormalBias(value: number) {\r\n this._voxelNormalBias = value;\r\n }\r\n\r\n private _voxelDirectionBias: number = 1.75;\r\n /**\r\n * The bias to apply to the voxel sampling in the direction of the light.\r\n */\r\n public get voxelDirectionBias(): number {\r\n return this._voxelDirectionBias;\r\n }\r\n public set voxelDirectionBias(value: number) {\r\n this._voxelDirectionBias = value;\r\n }\r\n\r\n /**\r\n * Is the effect enabled\r\n */\r\n public enabled: boolean = true;\r\n\r\n /**\r\n * The number of directions to sample for the voxel tracing.\r\n */\r\n public get sampleDirections(): number {\r\n return this._sampleDirections;\r\n }\r\n\r\n /**\r\n * The number of directions to sample for the voxel tracing.\r\n */\r\n public set sampleDirections(value: number) {\r\n this._sampleDirections = value;\r\n }\r\n\r\n /**\r\n * The current rotation of the environment map, in radians.\r\n */\r\n public get envRotation(): number {\r\n return this._envRotation;\r\n }\r\n\r\n /**\r\n * The current rotation of the environment map, in radians.\r\n */\r\n public set envRotation(value: number) {\r\n this._envRotation = value;\r\n }\r\n\r\n /** Enable the debug view for this pass */\r\n public debugEnabled: boolean = false;\r\n\r\n /**\r\n * Returns the output texture of the pass.\r\n * @returns The output texture.\r\n */\r\n public getOutputTexture(): ProceduralTexture {\r\n return this._outputTexture;\r\n }\r\n\r\n /**\r\n * Gets the debug pass post process. This will create the resources for the pass\r\n * if they don't already exist.\r\n * @returns The post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._debugPassPP) {\r\n this._createDebugPass();\r\n }\r\n return this._debugPassPP;\r\n }\r\n\r\n private _debugPassName: string = \"Voxel Tracing Debug Pass\";\r\n\r\n /**\r\n * The name of the debug pass\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n\r\n /** The default rotation of the environment map will align the shadows with the default lighting orientation */\r\n private _envRotation: number = 0.0;\r\n\r\n /**\r\n * Set the matrix to use for scaling the world space to voxel space\r\n * @param matrix The matrix to use for scaling the world space to voxel space\r\n */\r\n public setWorldScaleMatrix(matrix: Matrix) {\r\n this._invWorldScaleMatrix = matrix;\r\n }\r\n\r\n private _debugVoxelMarchEnabled: boolean = false;\r\n private _debugPassPP: 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 * Creates the debug post process effect for this pass\r\n */\r\n private _createDebugPass() {\r\n const isWebGPU = this._engine.isWebGPU;\r\n if (!this._debugPassPP) {\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"debugSampler\"],\r\n engine: this._engine,\r\n reusable: false,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblShadowDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblShadowDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._debugPassPP = new PostProcess(this.debugPassName, \"iblShadowDebug\", debugOptions);\r\n this._debugPassPP.autoClear = false;\r\n this._debugPassPP.onApplyObservable.add((effect) => {\r\n // update the caustic texture with what we just rendered.\r\n effect.setTexture(\"debugSampler\", this._outputTexture);\r\n effect.setVector4(\"sizeParams\", this._debugSizeParams);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Instantiates the shadow voxel-tracing pass\r\n * @param scene Scene to attach to\r\n * @param iblShadowsRenderPipeline The IBL shadows render pipeline\r\n * @returns The shadow voxel-tracing pass\r\n */\r\n constructor(scene: Scene, iblShadowsRenderPipeline: IblShadowsRenderPipeline) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this._renderPipeline = iblShadowsRenderPipeline;\r\n this._createTextures();\r\n }\r\n\r\n private _createTextures() {\r\n let defines = \"\";\r\n if (this._scene.useRightHandedSystem) {\r\n defines += \"#define RIGHT_HANDED\\n\";\r\n }\r\n if (this._debugVoxelMarchEnabled) {\r\n defines += \"#define VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION 1u\\n\";\r\n }\r\n const isWebGPU = this._engine.isWebGPU;\r\n const textureOptions: IProceduralTextureCreationOptions = {\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n generateDepthBuffer: false,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblShadowVoxelTracing.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblShadowVoxelTracing.fragment\")]);\r\n }\r\n },\r\n };\r\n this._outputTexture = new ProceduralTexture(\r\n \"voxelTracingPass\",\r\n {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n },\r\n \"iblShadowVoxelTracing\",\r\n this._scene,\r\n textureOptions\r\n );\r\n this._outputTexture.refreshRate = -1;\r\n this._outputTexture.autoClear = false;\r\n this._outputTexture.defines = defines;\r\n // Need to set all the textures first so that the effect gets created with the proper uniforms.\r\n this._setBindings(this._scene.activeCamera!);\r\n\r\n let counter = 0;\r\n this._scene.onBeforeRenderObservable.add(() => {\r\n counter = 0;\r\n });\r\n this._scene.onAfterRenderTargetsRenderObservable.add(() => {\r\n if (++counter == 2) {\r\n if (this.enabled && this._outputTexture.isReady()) {\r\n this._setBindings(this._scene.activeCamera!);\r\n this._outputTexture.render();\r\n }\r\n }\r\n });\r\n }\r\n\r\n private _setBindings(camera: Camera) {\r\n if (this._scene.useRightHandedSystem) {\r\n this._outputTexture.defines = \"#define RIGHT_HANDED\\n\";\r\n }\r\n this._outputTexture.setMatrix(\"viewMtx\", camera.getViewMatrix());\r\n this._outputTexture.setMatrix(\"projMtx\", camera.getProjectionMatrix());\r\n camera.getProjectionMatrix().invertToRef(this._cameraInvProj);\r\n camera.getViewMatrix().invertToRef(this._cameraInvView);\r\n this._outputTexture.setMatrix(\"invProjMtx\", this._cameraInvProj);\r\n this._outputTexture.setMatrix(\"invViewMtx\", this._cameraInvView);\r\n this._outputTexture.setMatrix(\"wsNormalizationMtx\", this._invWorldScaleMatrix);\r\n\r\n this._frameId++;\r\n\r\n let rotation = this._scene.useRightHandedSystem ? -(this._envRotation + 0.5 * Math.PI) : this._envRotation - 0.5 * Math.PI;\r\n rotation = rotation % (2.0 * Math.PI);\r\n this._shadowParameters.set(this._sampleDirections, this._frameId, 1.0, rotation);\r\n this._outputTexture.setVector4(\"shadowParameters\", this._shadowParameters);\r\n const voxelGrid = this._renderPipeline!._getVoxelGridTexture();\r\n const highestMip = Math.floor(Math.log2(voxelGrid!.getSize().width));\r\n this._voxelBiasParameters.set(this._voxelNormalBias, this._voxelDirectionBias, highestMip, 0.0);\r\n this._outputTexture.setVector4(\"voxelBiasParameters\", this._voxelBiasParameters);\r\n\r\n // SSS Options.\r\n this._sssParameters.set(this._sssSamples, this._sssStride, this._sssMaxDist, this._sssThickness);\r\n this._outputTexture.setVector4(\"sssParameters\", this._sssParameters);\r\n this._opacityParameters.set(this._voxelShadowOpacity, this._ssShadowOpacity, 0.0, 0.0);\r\n this._outputTexture.setVector4(\"shadowOpacity\", this._opacityParameters);\r\n this._outputTexture.setTexture(\"voxelGridSampler\", voxelGrid);\r\n this._outputTexture.setTexture(\"blueNoiseSampler\", this._renderPipeline!._getNoiseTexture());\r\n const cdfGenerator = this._scene.iblCdfGenerator;\r\n if (cdfGenerator) {\r\n this._outputTexture.setTexture(\"icdfySampler\", cdfGenerator.getIcdfyTexture());\r\n this._outputTexture.setTexture(\"icdfxSampler\", cdfGenerator.getIcdfxTexture());\r\n }\r\n if (this._debugVoxelMarchEnabled) {\r\n this._outputTexture.defines += \"#define VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION 1u\\n\";\r\n }\r\n\r\n const geometryBufferRenderer = this._scene.geometryBufferRenderer;\r\n if (!geometryBufferRenderer) {\r\n return;\r\n }\r\n const depthIndex = geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.SCREENSPACE_DEPTH_TEXTURE_TYPE);\r\n this._outputTexture.setTexture(\"depthSampler\", geometryBufferRenderer.getGBuffer().textures[depthIndex]);\r\n const wnormalIndex = geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE);\r\n this._outputTexture.setTexture(\"worldNormalSampler\", geometryBufferRenderer.getGBuffer().textures[wnormalIndex]);\r\n }\r\n\r\n /**\r\n * Called by render pipeline when canvas resized.\r\n * @param scaleFactor The factor by which to scale the canvas size.\r\n */\r\n public resize(scaleFactor: number = 1.0) {\r\n const newSize = {\r\n width: Math.max(1.0, Math.floor(this._engine.getRenderWidth() * scaleFactor)),\r\n height: Math.max(1.0, Math.floor(this._engine.getRenderHeight() * scaleFactor)),\r\n };\r\n this._outputTexture.resize(newSize, false);\r\n }\r\n\r\n /**\r\n * Checks if the pass is ready\r\n * @returns true if the pass is ready\r\n */\r\n public isReady() {\r\n return (\r\n this._outputTexture.isReady() &&\r\n !(this._debugPassPP && !this._debugPassPP.isReady()) &&\r\n this._scene.iblCdfGenerator &&\r\n this._scene.iblCdfGenerator.getIcdfyTexture().isReady() &&\r\n this._scene.iblCdfGenerator.getIcdfxTexture().isReady() &&\r\n this._renderPipeline!._getVoxelGridTexture().isReady()\r\n );\r\n }\r\n\r\n /**\r\n * Disposes the associated resources\r\n */\r\n public dispose() {\r\n this._outputTexture.dispose();\r\n if (this._debugPassPP) {\r\n this._debugPassPP.dispose();\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"iblShadowsVoxelTracingPass.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsVoxelTracingPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAK9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,kEAA8D;AAI1F;;;;GAIG;AACH,MAAM,OAAO,2BAA2B;IAKpC;;OAEG;IACH,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IACD;;OAEG;IACH,IAAW,kBAAkB,CAAC,KAAa;QACvC,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC;IACrC,CAAC;IAOD;;OAEG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IACD;;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QACxG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,oBAAoB,EAAE,sBAAsB,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;IACrH,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,cAAsB,GAAG;QACnC,MAAM,OAAO,GAAG;YACZ,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,WAAW,CAAC,CAAC;YAC7E,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,WAAW,CAAC,CAAC;SAClF,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACI,OAAO;QACV,OAAO,CACH,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;YAC7B,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YACpD,IAAI,CAAC,MAAM,CAAC,eAAe;YAC3B,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE;YACtD,IAAI,CAAC,eAAgB,CAAC,oBAAoB,EAAE,CAAC,OAAO,EAAE,CACzD,CAAC;IACN,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { Constants } from \"../../Engines/constants\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Matrix, Vector4 } from \"../../Maths/math.vector\";\r\nimport { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../../PostProcesses/postProcess\";\r\nimport type { IblShadowsRenderPipeline } from \"./iblShadowsRenderPipeline\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { GeometryBufferRenderer } from \"../../Rendering/geometryBufferRenderer\";\r\nimport { ProceduralTexture } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { CubeTexture } from \"../../Materials/Textures/cubeTexture\";\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 _IblShadowsVoxelTracingPass {\r\n private _scene: Scene;\r\n private _engine: AbstractEngine;\r\n private _renderPipeline: IblShadowsRenderPipeline;\r\n private _voxelShadowOpacity: number = 1.0;\r\n /**\r\n * The opacity of the shadow cast from the voxel grid\r\n */\r\n public get voxelShadowOpacity(): number {\r\n return this._voxelShadowOpacity;\r\n }\r\n /**\r\n * The opacity of the shadow cast from the voxel grid\r\n */\r\n public set voxelShadowOpacity(value: number) {\r\n this._voxelShadowOpacity = value;\r\n }\r\n private _sssSamples: number = 16;\r\n private _sssStride: number = 8;\r\n private _sssMaxDist: number = 0.05;\r\n private _sssThickness: number = 0.5;\r\n\r\n private _ssShadowOpacity: number = 1.0;\r\n /**\r\n * The opacity of the screen-space shadow\r\n */\r\n public get ssShadowOpacity(): number {\r\n return this._ssShadowOpacity;\r\n }\r\n /**\r\n * The opacity of the screen-space shadow\r\n */\r\n public set ssShadowOpacity(value: number) {\r\n this._ssShadowOpacity = value;\r\n }\r\n\r\n /**\r\n * The number of samples used in the screen space shadow pass.\r\n */\r\n public get sssSamples(): number {\r\n return this._sssSamples;\r\n }\r\n\r\n /**\r\n * The number of samples used in the screen space shadow pass.\r\n */\r\n public set sssSamples(value: number) {\r\n this._sssSamples = value;\r\n }\r\n\r\n /**\r\n * The stride used in the screen space shadow pass. This controls the distance between samples.\r\n */\r\n public get sssStride(): number {\r\n return this._sssStride;\r\n }\r\n\r\n /**\r\n * The stride used in the screen space shadow pass. This controls the distance between samples.\r\n */\r\n public set sssStride(value: number) {\r\n this._sssStride = value;\r\n }\r\n\r\n /**\r\n * The maximum distance that the screen-space shadow will be able to occlude.\r\n */\r\n public get sssMaxDist(): number {\r\n return this._sssMaxDist;\r\n }\r\n\r\n /**\r\n * The maximum distance that the screen-space shadow will be able to occlude.\r\n */\r\n public set sssMaxDist(value: number) {\r\n this._sssMaxDist = value;\r\n }\r\n\r\n /**\r\n * The thickness of the screen-space shadow\r\n */\r\n public get sssThickness(): number {\r\n return this._sssThickness;\r\n }\r\n\r\n /**\r\n * The thickness of the screen-space shadow\r\n */\r\n public set sssThickness(value: number) {\r\n this._sssThickness = value;\r\n }\r\n\r\n private _outputTexture: ProceduralTexture;\r\n private _cameraInvView: Matrix = Matrix.Identity();\r\n private _cameraInvProj: Matrix = Matrix.Identity();\r\n private _invWorldScaleMatrix: Matrix = Matrix.Identity();\r\n private _frameId: number = 0;\r\n private _sampleDirections: number = 4;\r\n private _shadowParameters: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _sssParameters: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _opacityParameters: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _voxelBiasParameters: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _voxelNormalBias: number = 1.4;\r\n /**\r\n * The bias to apply to the voxel sampling in the direction of the surface normal of the geometry.\r\n */\r\n public get voxelNormalBias(): number {\r\n return this._voxelNormalBias;\r\n }\r\n public set voxelNormalBias(value: number) {\r\n this._voxelNormalBias = value;\r\n }\r\n\r\n private _voxelDirectionBias: number = 1.75;\r\n /**\r\n * The bias to apply to the voxel sampling in the direction of the light.\r\n */\r\n public get voxelDirectionBias(): number {\r\n return this._voxelDirectionBias;\r\n }\r\n public set voxelDirectionBias(value: number) {\r\n this._voxelDirectionBias = value;\r\n }\r\n\r\n /**\r\n * Is the effect enabled\r\n */\r\n public enabled: boolean = true;\r\n\r\n /**\r\n * The number of directions to sample for the voxel tracing.\r\n */\r\n public get sampleDirections(): number {\r\n return this._sampleDirections;\r\n }\r\n\r\n /**\r\n * The number of directions to sample for the voxel tracing.\r\n */\r\n public set sampleDirections(value: number) {\r\n this._sampleDirections = value;\r\n }\r\n\r\n /**\r\n * The current rotation of the environment map, in radians.\r\n */\r\n public get envRotation(): number {\r\n return this._envRotation;\r\n }\r\n\r\n /**\r\n * The current rotation of the environment map, in radians.\r\n */\r\n public set envRotation(value: number) {\r\n this._envRotation = value;\r\n }\r\n\r\n /** Enable the debug view for this pass */\r\n public debugEnabled: boolean = false;\r\n\r\n /**\r\n * Returns the output texture of the pass.\r\n * @returns The output texture.\r\n */\r\n public getOutputTexture(): ProceduralTexture {\r\n return this._outputTexture;\r\n }\r\n\r\n /**\r\n * Gets the debug pass post process. This will create the resources for the pass\r\n * if they don't already exist.\r\n * @returns The post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._debugPassPP) {\r\n this._createDebugPass();\r\n }\r\n return this._debugPassPP;\r\n }\r\n\r\n private _debugPassName: string = \"Voxel Tracing Debug Pass\";\r\n\r\n /**\r\n * The name of the debug pass\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n\r\n /** The default rotation of the environment map will align the shadows with the default lighting orientation */\r\n private _envRotation: number = 0.0;\r\n\r\n /**\r\n * Set the matrix to use for scaling the world space to voxel space\r\n * @param matrix The matrix to use for scaling the world space to voxel space\r\n */\r\n public setWorldScaleMatrix(matrix: Matrix) {\r\n this._invWorldScaleMatrix = matrix;\r\n }\r\n\r\n private _debugVoxelMarchEnabled: boolean = false;\r\n private _debugPassPP: 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 * Creates the debug post process effect for this pass\r\n */\r\n private _createDebugPass() {\r\n const isWebGPU = this._engine.isWebGPU;\r\n if (!this._debugPassPP) {\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"debugSampler\"],\r\n engine: this._engine,\r\n reusable: false,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblShadowDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblShadowDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._debugPassPP = new PostProcess(this.debugPassName, \"iblShadowDebug\", debugOptions);\r\n this._debugPassPP.autoClear = false;\r\n this._debugPassPP.onApplyObservable.add((effect) => {\r\n // update the caustic texture with what we just rendered.\r\n effect.setTexture(\"debugSampler\", this._outputTexture);\r\n effect.setVector4(\"sizeParams\", this._debugSizeParams);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Instantiates the shadow voxel-tracing pass\r\n * @param scene Scene to attach to\r\n * @param iblShadowsRenderPipeline The IBL shadows render pipeline\r\n * @returns The shadow voxel-tracing pass\r\n */\r\n constructor(scene: Scene, iblShadowsRenderPipeline: IblShadowsRenderPipeline) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this._renderPipeline = iblShadowsRenderPipeline;\r\n this._createTextures();\r\n }\r\n\r\n private _createTextures() {\r\n let defines = \"\";\r\n if (this._scene.useRightHandedSystem) {\r\n defines += \"#define RIGHT_HANDED\\n\";\r\n }\r\n if (this._debugVoxelMarchEnabled) {\r\n defines += \"#define VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION 1u\\n\";\r\n }\r\n const isWebGPU = this._engine.isWebGPU;\r\n const textureOptions: IProceduralTextureCreationOptions = {\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n generateDepthBuffer: false,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblShadowVoxelTracing.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblShadowVoxelTracing.fragment\")]);\r\n }\r\n },\r\n };\r\n this._outputTexture = new ProceduralTexture(\r\n \"voxelTracingPass\",\r\n {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n },\r\n \"iblShadowVoxelTracing\",\r\n this._scene,\r\n textureOptions\r\n );\r\n this._outputTexture.refreshRate = -1;\r\n this._outputTexture.autoClear = false;\r\n this._outputTexture.defines = defines;\r\n // Need to set all the textures first so that the effect gets created with the proper uniforms.\r\n this._setBindings(this._scene.activeCamera!);\r\n\r\n let counter = 0;\r\n this._scene.onBeforeRenderObservable.add(() => {\r\n counter = 0;\r\n });\r\n this._scene.onAfterRenderTargetsRenderObservable.add(() => {\r\n if (++counter == 2) {\r\n if (this.enabled && this._outputTexture.isReady()) {\r\n this._setBindings(this._scene.activeCamera!);\r\n this._outputTexture.render();\r\n }\r\n }\r\n });\r\n }\r\n\r\n private _setBindings(camera: Camera) {\r\n if (this._scene.useRightHandedSystem) {\r\n this._outputTexture.defines = \"#define RIGHT_HANDED\\n\";\r\n }\r\n this._outputTexture.setMatrix(\"viewMtx\", camera.getViewMatrix());\r\n this._outputTexture.setMatrix(\"projMtx\", camera.getProjectionMatrix());\r\n camera.getProjectionMatrix().invertToRef(this._cameraInvProj);\r\n camera.getViewMatrix().invertToRef(this._cameraInvView);\r\n this._outputTexture.setMatrix(\"invProjMtx\", this._cameraInvProj);\r\n this._outputTexture.setMatrix(\"invViewMtx\", this._cameraInvView);\r\n this._outputTexture.setMatrix(\"wsNormalizationMtx\", this._invWorldScaleMatrix);\r\n\r\n this._frameId++;\r\n\r\n let rotation = 0.0;\r\n if (this._scene.environmentTexture) {\r\n rotation = (this._scene.environmentTexture as CubeTexture).rotationY ?? 0;\r\n }\r\n rotation = this._scene.useRightHandedSystem ? -(rotation + 0.5 * Math.PI) : rotation - 0.5 * Math.PI;\r\n rotation = rotation % (2.0 * Math.PI);\r\n this._shadowParameters.set(this._sampleDirections, this._frameId, 1.0, rotation);\r\n this._outputTexture.setVector4(\"shadowParameters\", this._shadowParameters);\r\n const voxelGrid = this._renderPipeline!._getVoxelGridTexture();\r\n const highestMip = Math.floor(Math.log2(voxelGrid!.getSize().width));\r\n this._voxelBiasParameters.set(this._voxelNormalBias, this._voxelDirectionBias, highestMip, 0.0);\r\n this._outputTexture.setVector4(\"voxelBiasParameters\", this._voxelBiasParameters);\r\n\r\n // SSS Options.\r\n this._sssParameters.set(this._sssSamples, this._sssStride, this._sssMaxDist, this._sssThickness);\r\n this._outputTexture.setVector4(\"sssParameters\", this._sssParameters);\r\n this._opacityParameters.set(this._voxelShadowOpacity, this._ssShadowOpacity, 0.0, 0.0);\r\n this._outputTexture.setVector4(\"shadowOpacity\", this._opacityParameters);\r\n this._outputTexture.setTexture(\"voxelGridSampler\", voxelGrid);\r\n this._outputTexture.setTexture(\"blueNoiseSampler\", this._renderPipeline!._getNoiseTexture());\r\n const cdfGenerator = this._scene.iblCdfGenerator;\r\n if (cdfGenerator) {\r\n this._outputTexture.setTexture(\"icdfSampler\", cdfGenerator.getIcdfTexture());\r\n }\r\n if (this._debugVoxelMarchEnabled) {\r\n this._outputTexture.defines += \"#define VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION 1u\\n\";\r\n }\r\n\r\n const geometryBufferRenderer = this._scene.geometryBufferRenderer;\r\n if (!geometryBufferRenderer) {\r\n return;\r\n }\r\n const depthIndex = geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.SCREENSPACE_DEPTH_TEXTURE_TYPE);\r\n this._outputTexture.setTexture(\"depthSampler\", geometryBufferRenderer.getGBuffer().textures[depthIndex]);\r\n const wnormalIndex = geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.NORMAL_TEXTURE_TYPE);\r\n this._outputTexture.setTexture(\"worldNormalSampler\", geometryBufferRenderer.getGBuffer().textures[wnormalIndex]);\r\n }\r\n\r\n /**\r\n * Called by render pipeline when canvas resized.\r\n * @param scaleFactor The factor by which to scale the canvas size.\r\n */\r\n public resize(scaleFactor: number = 1.0) {\r\n const newSize = {\r\n width: Math.max(1.0, Math.floor(this._engine.getRenderWidth() * scaleFactor)),\r\n height: Math.max(1.0, Math.floor(this._engine.getRenderHeight() * scaleFactor)),\r\n };\r\n this._outputTexture.resize(newSize, false);\r\n }\r\n\r\n /**\r\n * Checks if the pass is ready\r\n * @returns true if the pass is ready\r\n */\r\n public isReady() {\r\n return (\r\n this._outputTexture.isReady() &&\r\n !(this._debugPassPP && !this._debugPassPP.isReady()) &&\r\n this._scene.iblCdfGenerator &&\r\n this._scene.iblCdfGenerator.getIcdfTexture().isReady() &&\r\n this._renderPipeline!._getVoxelGridTexture().isReady()\r\n );\r\n }\r\n\r\n /**\r\n * Disposes the associated resources\r\n */\r\n public dispose() {\r\n this._outputTexture.dispose();\r\n if (this._debugPassPP) {\r\n this._debugPassPP.dispose();\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -10,31 +10,26 @@ export declare class IblCdfGenerator {
|
|
|
10
10
|
private _scene;
|
|
11
11
|
private _engine;
|
|
12
12
|
private _cdfyPT;
|
|
13
|
-
private _icdfyPT;
|
|
14
13
|
private _cdfxPT;
|
|
15
|
-
private
|
|
14
|
+
private _icdfPT;
|
|
15
|
+
private _scaledLuminancePT;
|
|
16
16
|
private _iblSource;
|
|
17
17
|
private _dummyTexture;
|
|
18
18
|
/**
|
|
19
|
-
* Gets the IBL source texture being used by the
|
|
19
|
+
* Gets the IBL source texture being used by the CDF renderer
|
|
20
20
|
*/
|
|
21
21
|
get iblSource(): BaseTexture;
|
|
22
22
|
/**
|
|
23
|
-
* Sets the IBL source texture to be used by the
|
|
24
|
-
* This will trigger recreation of the
|
|
23
|
+
* Sets the IBL source texture to be used by the CDF renderer.
|
|
24
|
+
* This will trigger recreation of the CDF assets.
|
|
25
25
|
*/
|
|
26
26
|
set iblSource(source: BaseTexture);
|
|
27
27
|
private _recreateAssetsFromNewIbl;
|
|
28
28
|
/**
|
|
29
|
-
* Return the cumulative distribution function (CDF)
|
|
30
|
-
* @returns Return the cumulative distribution function (CDF)
|
|
29
|
+
* Return the cumulative distribution function (CDF) texture
|
|
30
|
+
* @returns Return the cumulative distribution function (CDF) texture
|
|
31
31
|
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Return the cumulative distribution function (CDF) X texture
|
|
35
|
-
* @returns Return the cumulative distribution function (CDF) X texture
|
|
36
|
-
*/
|
|
37
|
-
getIcdfxTexture(): Texture;
|
|
32
|
+
getIcdfTexture(): Texture;
|
|
38
33
|
/** Enable the debug view for this pass */
|
|
39
34
|
debugEnabled: boolean;
|
|
40
35
|
private _debugPass;
|
|
@@ -62,25 +57,25 @@ export declare class IblCdfGenerator {
|
|
|
62
57
|
*/
|
|
63
58
|
static _SceneComponentInitialization: (scene: Scene) => void;
|
|
64
59
|
/**
|
|
65
|
-
* Instanciates the
|
|
60
|
+
* Instanciates the CDF renderer
|
|
66
61
|
* @param scene Scene to attach to
|
|
67
|
-
* @returns The
|
|
62
|
+
* @returns The CDF renderer
|
|
68
63
|
*/
|
|
69
64
|
constructor(scene: Scene);
|
|
70
65
|
/**
|
|
71
|
-
* Observable that triggers when the
|
|
66
|
+
* Observable that triggers when the CDF renderer is ready
|
|
72
67
|
*/
|
|
73
68
|
onGeneratedObservable: Observable<void>;
|
|
74
69
|
private _createTextures;
|
|
75
70
|
private _disposeTextures;
|
|
76
71
|
private _createDebugPass;
|
|
77
72
|
/**
|
|
78
|
-
* Checks if the
|
|
79
|
-
* @returns true if the
|
|
73
|
+
* Checks if the CDF renderer is ready
|
|
74
|
+
* @returns true if the CDF renderer is ready
|
|
80
75
|
*/
|
|
81
76
|
isReady(): boolean;
|
|
82
77
|
/**
|
|
83
|
-
* Disposes the
|
|
78
|
+
* Disposes the CDF renderer and associated resources
|
|
84
79
|
*/
|
|
85
80
|
dispose(): void;
|
|
86
81
|
}
|
|
@@ -12,14 +12,14 @@ import { _WarnImport } from "../Misc/devTools.js";
|
|
|
12
12
|
*/
|
|
13
13
|
export class IblCdfGenerator {
|
|
14
14
|
/**
|
|
15
|
-
* Gets the IBL source texture being used by the
|
|
15
|
+
* Gets the IBL source texture being used by the CDF renderer
|
|
16
16
|
*/
|
|
17
17
|
get iblSource() {
|
|
18
18
|
return this._iblSource;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Sets the IBL source texture to be used by the
|
|
22
|
-
* This will trigger recreation of the
|
|
21
|
+
* Sets the IBL source texture to be used by the CDF renderer.
|
|
22
|
+
* This will trigger recreation of the CDF assets.
|
|
23
23
|
*/
|
|
24
24
|
set iblSource(source) {
|
|
25
25
|
if (this._iblSource === source) {
|
|
@@ -29,7 +29,7 @@ export class IblCdfGenerator {
|
|
|
29
29
|
this._iblSource = source;
|
|
30
30
|
if (source.isCube) {
|
|
31
31
|
if (source.isReadyOrNotBlocking()) {
|
|
32
|
-
this._recreateAssetsFromNewIbl(
|
|
32
|
+
this._recreateAssetsFromNewIbl();
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
35
|
source.onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));
|
|
@@ -37,14 +37,14 @@ export class IblCdfGenerator {
|
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
39
|
if (source.isReadyOrNotBlocking()) {
|
|
40
|
-
this._recreateAssetsFromNewIbl(
|
|
40
|
+
this._recreateAssetsFromNewIbl();
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
43
|
source.onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
_recreateAssetsFromNewIbl(
|
|
47
|
+
_recreateAssetsFromNewIbl() {
|
|
48
48
|
if (this._debugPass) {
|
|
49
49
|
this._debugPass.dispose();
|
|
50
50
|
}
|
|
@@ -53,24 +53,13 @@ export class IblCdfGenerator {
|
|
|
53
53
|
// Recreate the debug pass because of the new textures
|
|
54
54
|
this._createDebugPass();
|
|
55
55
|
}
|
|
56
|
-
// Once the textures are generated, notify that they are ready to use.
|
|
57
|
-
this._icdfxPT.onGeneratedObservable.addOnce(() => {
|
|
58
|
-
this.onGeneratedObservable.notifyObservers();
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Return the cumulative distribution function (CDF) Y texture
|
|
63
|
-
* @returns Return the cumulative distribution function (CDF) Y texture
|
|
64
|
-
*/
|
|
65
|
-
getIcdfyTexture() {
|
|
66
|
-
return this._icdfyPT ? this._icdfyPT : this._dummyTexture;
|
|
67
56
|
}
|
|
68
57
|
/**
|
|
69
|
-
* Return the cumulative distribution function (CDF)
|
|
70
|
-
* @returns Return the cumulative distribution function (CDF)
|
|
58
|
+
* Return the cumulative distribution function (CDF) texture
|
|
59
|
+
* @returns Return the cumulative distribution function (CDF) texture
|
|
71
60
|
*/
|
|
72
|
-
|
|
73
|
-
return this.
|
|
61
|
+
getIcdfTexture() {
|
|
62
|
+
return this._icdfPT ? this._icdfPT : this._dummyTexture;
|
|
74
63
|
}
|
|
75
64
|
/**
|
|
76
65
|
* Sets params that control the position and scaling of the debug display on the screen.
|
|
@@ -99,27 +88,27 @@ export class IblCdfGenerator {
|
|
|
99
88
|
return this._debugPass;
|
|
100
89
|
}
|
|
101
90
|
/**
|
|
102
|
-
* Instanciates the
|
|
91
|
+
* Instanciates the CDF renderer
|
|
103
92
|
* @param scene Scene to attach to
|
|
104
|
-
* @returns The
|
|
93
|
+
* @returns The CDF renderer
|
|
105
94
|
*/
|
|
106
95
|
constructor(scene) {
|
|
107
96
|
/** Enable the debug view for this pass */
|
|
108
97
|
this.debugEnabled = false;
|
|
109
98
|
this._debugSizeParams = new Vector4(0.0, 0.0, 0.0, 0.0);
|
|
110
|
-
this._debugPassName = "
|
|
99
|
+
this._debugPassName = "CDF Debug";
|
|
111
100
|
/**
|
|
112
|
-
* Observable that triggers when the
|
|
101
|
+
* Observable that triggers when the CDF renderer is ready
|
|
113
102
|
*/
|
|
114
103
|
this.onGeneratedObservable = new Observable();
|
|
115
104
|
this._scene = scene;
|
|
116
105
|
this._engine = scene.getEngine();
|
|
117
|
-
const blackPixels = new
|
|
118
|
-
this._dummyTexture = new RawTexture(blackPixels, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false);
|
|
106
|
+
const blackPixels = new Uint16Array([0, 0, 0, 255]);
|
|
107
|
+
this._dummyTexture = new RawTexture(blackPixels, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, undefined, 2);
|
|
119
108
|
IblCdfGenerator._SceneComponentInitialization(this._scene);
|
|
120
109
|
}
|
|
121
110
|
_createTextures() {
|
|
122
|
-
const size = this._iblSource ? this._iblSource.getSize() : { width: 1, height: 1 };
|
|
111
|
+
const size = this._iblSource ? { width: this._iblSource.getSize().width, height: this._iblSource.getSize().height } : { width: 1, height: 1 };
|
|
123
112
|
if (!this._iblSource) {
|
|
124
113
|
this._iblSource = RawTexture.CreateRTexture(new Uint8Array([255]), 1, 1, this._scene, false, false, 1, 0);
|
|
125
114
|
this._iblSource.name = "Placeholder IBL Source";
|
|
@@ -139,26 +128,26 @@ export class IblCdfGenerator {
|
|
|
139
128
|
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
140
129
|
extraInitializationsAsync: async () => {
|
|
141
130
|
if (isWebGPU) {
|
|
142
|
-
await Promise.all([import("../ShadersWGSL/iblCdfx.fragment.js"), import("../ShadersWGSL/iblCdfy.fragment.js")]);
|
|
131
|
+
await Promise.all([import("../ShadersWGSL/iblCdfx.fragment.js"), import("../ShadersWGSL/iblCdfy.fragment.js"), import("../ShadersWGSL/iblScaledLuminance.fragment.js")]);
|
|
143
132
|
}
|
|
144
133
|
else {
|
|
145
|
-
await Promise.all([import("../Shaders/iblCdfx.fragment.js"), import("../Shaders/iblCdfy.fragment.js")]);
|
|
134
|
+
await Promise.all([import("../Shaders/iblCdfx.fragment.js"), import("../Shaders/iblCdfy.fragment.js"), import("../Shaders/iblScaledLuminance.fragment.js")]);
|
|
146
135
|
}
|
|
147
136
|
},
|
|
148
137
|
};
|
|
149
138
|
const icdfOptions = {
|
|
150
139
|
generateDepthBuffer: false,
|
|
151
140
|
generateMipMaps: false,
|
|
152
|
-
format:
|
|
141
|
+
format: 5,
|
|
153
142
|
type: 2,
|
|
154
143
|
samplingMode: 1,
|
|
155
144
|
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
156
145
|
extraInitializationsAsync: async () => {
|
|
157
146
|
if (isWebGPU) {
|
|
158
|
-
await Promise.all([import("../ShadersWGSL/
|
|
147
|
+
await Promise.all([import("../ShadersWGSL/iblIcdf.fragment.js")]);
|
|
159
148
|
}
|
|
160
149
|
else {
|
|
161
|
-
await Promise.all([import("../Shaders/
|
|
150
|
+
await Promise.all([import("../Shaders/iblIcdf.fragment.js")]);
|
|
162
151
|
}
|
|
163
152
|
},
|
|
164
153
|
};
|
|
@@ -166,28 +155,47 @@ export class IblCdfGenerator {
|
|
|
166
155
|
this._cdfyPT.autoClear = false;
|
|
167
156
|
this._cdfyPT.setTexture("iblSource", this._iblSource);
|
|
168
157
|
this._cdfyPT.setInt("iblHeight", size.height);
|
|
158
|
+
this._cdfyPT.wrapV = 0;
|
|
159
|
+
this._cdfyPT.refreshRate = 0;
|
|
169
160
|
if (this._iblSource.isCube) {
|
|
170
161
|
this._cdfyPT.defines = "#define IBL_USE_CUBE_MAP\n";
|
|
171
162
|
}
|
|
172
|
-
this._cdfyPT.refreshRate = 0;
|
|
173
|
-
this._icdfyPT = new ProceduralTexture("icdfyTexture", { width: size.width, height: size.height }, "iblIcdfy", this._scene, icdfOptions, false, false);
|
|
174
|
-
this._icdfyPT.autoClear = false;
|
|
175
|
-
this._icdfyPT.setTexture("cdfy", this._cdfyPT);
|
|
176
|
-
this._icdfyPT.refreshRate = 0;
|
|
177
163
|
this._cdfxPT = new ProceduralTexture("cdfxTexture", { width: size.width + 1, height: 1 }, "iblCdfx", this._scene, cdfOptions, false, false);
|
|
178
164
|
this._cdfxPT.autoClear = false;
|
|
179
165
|
this._cdfxPT.setTexture("cdfy", this._cdfyPT);
|
|
180
166
|
this._cdfxPT.refreshRate = 0;
|
|
181
|
-
this.
|
|
182
|
-
this.
|
|
183
|
-
this.
|
|
184
|
-
this.
|
|
167
|
+
this._cdfxPT.wrapU = 0;
|
|
168
|
+
this._scaledLuminancePT = new ProceduralTexture("iblScaledLuminance", { width: size.width, height: size.height }, "iblScaledLuminance", this._scene, { ...icdfOptions, samplingMode: 3, generateMipMaps: true }, true, false);
|
|
169
|
+
this._scaledLuminancePT.autoClear = false;
|
|
170
|
+
this._scaledLuminancePT.setTexture("iblSource", this._iblSource);
|
|
171
|
+
this._scaledLuminancePT.setInt("iblHeight", size.height);
|
|
172
|
+
this._scaledLuminancePT.setInt("iblWidth", size.width);
|
|
173
|
+
this._scaledLuminancePT.refreshRate = 0;
|
|
174
|
+
if (this._iblSource.isCube) {
|
|
175
|
+
this._scaledLuminancePT.defines = "#define IBL_USE_CUBE_MAP\n";
|
|
176
|
+
}
|
|
177
|
+
this._icdfPT = new ProceduralTexture("icdfTexture", { width: size.width, height: size.height }, "iblIcdf", this._scene, icdfOptions, false, false);
|
|
178
|
+
this._icdfPT.autoClear = false;
|
|
179
|
+
this._icdfPT.setTexture("cdfy", this._cdfyPT);
|
|
180
|
+
this._icdfPT.setTexture("cdfx", this._cdfxPT);
|
|
181
|
+
this._icdfPT.setTexture("iblSource", this._iblSource);
|
|
182
|
+
this._icdfPT.setTexture("scaledLuminanceSampler", this._scaledLuminancePT);
|
|
183
|
+
this._icdfPT.refreshRate = 0;
|
|
184
|
+
this._icdfPT.wrapV = 0;
|
|
185
|
+
this._icdfPT.wrapU = 0;
|
|
186
|
+
if (this._iblSource.isCube) {
|
|
187
|
+
this._icdfPT.defines = "#define IBL_USE_CUBE_MAP\n";
|
|
188
|
+
}
|
|
189
|
+
// Once the textures are generated, notify that they are ready to use.
|
|
190
|
+
this._icdfPT.onGeneratedObservable.addOnce(() => {
|
|
191
|
+
this.onGeneratedObservable.notifyObservers();
|
|
192
|
+
});
|
|
185
193
|
}
|
|
186
194
|
_disposeTextures() {
|
|
187
195
|
this._cdfyPT?.dispose();
|
|
188
|
-
this._icdfyPT?.dispose();
|
|
189
196
|
this._cdfxPT?.dispose();
|
|
190
|
-
this.
|
|
197
|
+
this._icdfPT?.dispose();
|
|
198
|
+
this._scaledLuminancePT?.dispose();
|
|
191
199
|
}
|
|
192
200
|
_createDebugPass() {
|
|
193
201
|
if (this._debugPass) {
|
|
@@ -201,19 +209,19 @@ export class IblCdfGenerator {
|
|
|
201
209
|
engine: this._engine,
|
|
202
210
|
textureType: 0,
|
|
203
211
|
uniforms: ["sizeParams"],
|
|
204
|
-
samplers: ["cdfy", "
|
|
212
|
+
samplers: ["cdfy", "icdf", "cdfx", "iblSource"],
|
|
205
213
|
defines: this._iblSource?.isCube ? "#define IBL_USE_CUBE_MAP\n" : "",
|
|
206
214
|
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
207
215
|
extraInitializations: (useWebGPU, list) => {
|
|
208
216
|
if (useWebGPU) {
|
|
209
|
-
list.push(import("../ShadersWGSL/
|
|
217
|
+
list.push(import("../ShadersWGSL/iblCdfDebug.fragment.js"));
|
|
210
218
|
}
|
|
211
219
|
else {
|
|
212
|
-
list.push(import("../Shaders/
|
|
220
|
+
list.push(import("../Shaders/iblCdfDebug.fragment.js"));
|
|
213
221
|
}
|
|
214
222
|
},
|
|
215
223
|
};
|
|
216
|
-
this._debugPass = new PostProcess(this._debugPassName, "
|
|
224
|
+
this._debugPass = new PostProcess(this._debugPassName, "iblCdfDebug", debugOptions);
|
|
217
225
|
const debugEffect = this._debugPass.getEffect();
|
|
218
226
|
if (debugEffect) {
|
|
219
227
|
debugEffect.defines = this._iblSource?.isCube ? "#define IBL_USE_CUBE_MAP\n" : "";
|
|
@@ -223,16 +231,15 @@ export class IblCdfGenerator {
|
|
|
223
231
|
}
|
|
224
232
|
this._debugPass.onApplyObservable.add((effect) => {
|
|
225
233
|
effect.setTexture("cdfy", this._cdfyPT);
|
|
226
|
-
effect.setTexture("
|
|
234
|
+
effect.setTexture("icdf", this._icdfPT);
|
|
227
235
|
effect.setTexture("cdfx", this._cdfxPT);
|
|
228
|
-
effect.setTexture("icdfx", this._icdfxPT);
|
|
229
236
|
effect.setTexture("iblSource", this._iblSource);
|
|
230
237
|
effect.setFloat4("sizeParams", this._debugSizeParams.x, this._debugSizeParams.y, this._debugSizeParams.z, this._debugSizeParams.w);
|
|
231
238
|
});
|
|
232
239
|
}
|
|
233
240
|
/**
|
|
234
|
-
* Checks if the
|
|
235
|
-
* @returns true if the
|
|
241
|
+
* Checks if the CDF renderer is ready
|
|
242
|
+
* @returns true if the CDF renderer is ready
|
|
236
243
|
*/
|
|
237
244
|
isReady() {
|
|
238
245
|
return (this._iblSource &&
|
|
@@ -240,15 +247,15 @@ export class IblCdfGenerator {
|
|
|
240
247
|
this._iblSource.isReady() &&
|
|
241
248
|
this._cdfyPT &&
|
|
242
249
|
this._cdfyPT.isReady() &&
|
|
243
|
-
this.
|
|
244
|
-
this.
|
|
250
|
+
this._icdfPT &&
|
|
251
|
+
this._icdfPT.isReady() &&
|
|
245
252
|
this._cdfxPT &&
|
|
246
253
|
this._cdfxPT.isReady() &&
|
|
247
|
-
this.
|
|
248
|
-
this.
|
|
254
|
+
this._scaledLuminancePT &&
|
|
255
|
+
this._scaledLuminancePT.isReady());
|
|
249
256
|
}
|
|
250
257
|
/**
|
|
251
|
-
* Disposes the
|
|
258
|
+
* Disposes the CDF renderer and associated resources
|
|
252
259
|
*/
|
|
253
260
|
dispose() {
|
|
254
261
|
this._disposeTextures();
|