@onerjs/core 8.36.3 → 8.36.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/Behaviors/Cameras/geospatialClippingBehavior.d.ts +40 -0
  2. package/Behaviors/Cameras/geospatialClippingBehavior.js +80 -0
  3. package/Behaviors/Cameras/geospatialClippingBehavior.js.map +1 -0
  4. package/Behaviors/Cameras/index.d.ts +2 -0
  5. package/Behaviors/Cameras/index.js +2 -0
  6. package/Behaviors/Cameras/index.js.map +1 -1
  7. package/Cameras/Inputs/geospatialCameraPointersInput.js +4 -2
  8. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  9. package/Cameras/Limits/geospatialLimits.d.ts +9 -1
  10. package/Cameras/Limits/geospatialLimits.js +23 -3
  11. package/Cameras/Limits/geospatialLimits.js.map +1 -1
  12. package/Cameras/geospatialCamera.d.ts +23 -0
  13. package/Cameras/geospatialCamera.js +109 -34
  14. package/Cameras/geospatialCamera.js.map +1 -1
  15. package/Cameras/geospatialCameraMovement.js +1 -0
  16. package/Cameras/geospatialCameraMovement.js.map +1 -1
  17. package/Debug/debugLayer.js +11 -3
  18. package/Debug/debugLayer.js.map +1 -1
  19. package/IAssetContainer.d.ts +5 -0
  20. package/IAssetContainer.js.map +1 -1
  21. package/Layers/highlightLayer.d.ts +16 -0
  22. package/Layers/highlightLayer.js +16 -0
  23. package/Layers/highlightLayer.js.map +1 -1
  24. package/Lights/Clustered/clusteredLightContainer.js +1 -1
  25. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  26. package/Loading/Plugins/babylonFileLoader.js +2 -0
  27. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  28. package/Materials/effectRenderer.d.ts +2 -1
  29. package/Materials/effectRenderer.js +2 -12
  30. package/Materials/effectRenderer.js.map +1 -1
  31. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +6 -1
  32. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +21 -17
  33. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  34. package/Particles/solidParticleSystem.d.ts +3 -0
  35. package/Particles/solidParticleSystem.js +7 -4
  36. package/Particles/solidParticleSystem.js.map +1 -1
  37. package/Sprites/spriteManager.d.ts +3 -0
  38. package/Sprites/spriteManager.js +9 -0
  39. package/Sprites/spriteManager.js.map +1 -1
  40. package/assetContainer.d.ts +5 -0
  41. package/assetContainer.js +32 -0
  42. package/assetContainer.js.map +1 -1
  43. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"effectRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effectRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,sCAAsC;AACtC,OAAO,+BAA+B,CAAC;AAgBvC,sCAAsC;AACtC,MAAM,cAAc,GAAG;IACnB,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,cAAc;IAgBvB;;;;OAIG;IACH,YAAY,MAAsB,EAAE,UAAkC,cAAc;QAX5E,wBAAmB,GAAG,IAAI,QAAQ,CAAC,CAAC,EAAE,CAAC,EA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,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC7E,CAAC;IAED;;;OAGG;IACI,IAAI,CAAC,iBAAiB,GAAG,KAAK;QACjC,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACtD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACjD,IAAI,CAAC,WAAW,CAAC,MAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC;QAED,aAAa,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,MAAO,CAAC,CAAC;IAClH,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,WAAoB,KAAK;QACpC,IAAI,IAAI,CAAC,0BAA0B,EAAE,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,2BAA2B,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YAC5F,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC;QAC3C,CAAC;QACD,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;;AAlWD;;;GAGG;AACW,uBAAS,GAAG,KAAK,AAAR,CAAS;AAEjB,yCAA2B,GAA6E,EAAE,AAA/E,CAAgF","sourcesContent":["import type { NonNullableFields, Nullable } from \"../types\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Viewport } from \"../Maths/math.viewport\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { IShaderPath } from \"./effect\";\r\nimport { Effect } from \"./effect\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { DrawWrapper } from \"./drawWrapper\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\n\r\n// Prevents ES6 issue if not imported.\r\nimport \"../Shaders/postprocess.vertex\";\r\n\r\n/**\r\n * Effect Render Options\r\n */\r\nexport interface IEffectRendererOptions {\r\n /**\r\n * Defines the vertices positions.\r\n */\r\n positions?: number[];\r\n /**\r\n * Defines the indices.\r\n */\r\n indices?: number[];\r\n}\r\n\r\n// Fullscreen quad buffers by default.\r\nconst DefaultOptions = {\r\n positions: [1, 1, -1, 1, -1, -1, 1, -1],\r\n indices: [0, 1, 2, 0, 2, 3],\r\n};\r\n\r\n/**\r\n * Helper class to render one or more effects.\r\n * You can access the previous rendering in your shader by declaring a sampler named textureSampler\r\n */\r\nexport class EffectRenderer {\r\n /**\r\n * The engine the effect renderer has been created for.\r\n */\r\n public readonly engine: AbstractEngine;\r\n\r\n private _vertexBuffers: { [key: string]: VertexBuffer };\r\n private _indexBuffer: DataBuffer;\r\n private _indexBufferLength: number;\r\n\r\n private _fullscreenViewport = new Viewport(0, 0, 1, 1);\r\n private _onContextRestoredObserver: Nullable<Observer<AbstractEngine>>;\r\n\r\n private _savedStateDepthTest: boolean;\r\n private _savedStateStencilTest: boolean;\r\n\r\n /**\r\n * Creates an effect renderer\r\n * @param engine the engine to use for rendering\r\n * @param options defines the options of the effect renderer\r\n */\r\n constructor(engine: AbstractEngine, options: IEffectRendererOptions = DefaultOptions) {\r\n const positions = options.positions ?? DefaultOptions.positions;\r\n const indices = options.indices ?? DefaultOptions.indices;\r\n\r\n this.engine = engine;\r\n this._vertexBuffers = {\r\n // Note, always assumes stride of 2.\r\n [VertexBuffer.PositionKind]: new VertexBuffer(engine, positions, VertexBuffer.PositionKind, false, false, 2),\r\n };\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n this._indexBufferLength = indices.length;\r\n\r\n this._onContextRestoredObserver = engine.onContextRestoredObservable.add(() => {\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n\r\n for (const key in this._vertexBuffers) {\r\n const vertexBuffer = this._vertexBuffers[key];\r\n vertexBuffer._rebuild();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Sets the current viewport in normalized coordinates 0-1\r\n * @param viewport Defines the viewport to set (defaults to 0 0 1 1)\r\n */\r\n public setViewport(viewport = this._fullscreenViewport): void {\r\n this.engine.setViewport(viewport);\r\n }\r\n\r\n /**\r\n * Binds the embedded attributes buffer to the effect.\r\n * @param effect Defines the effect to bind the attributes for\r\n */\r\n public bindBuffers(effect: Effect): void {\r\n this.engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);\r\n }\r\n\r\n /**\r\n * Sets the current effect wrapper to use during draw.\r\n * The effect needs to be ready before calling this api.\r\n * This also sets the default full screen position attribute.\r\n * @param effectWrapper Defines the effect to draw with\r\n * @param depthTest Whether to enable depth testing (default: false)\r\n * @param stencilTest Whether to enable stencil testing (default: false)\r\n */\r\n public applyEffectWrapper(effectWrapper: EffectWrapper, depthTest = false, stencilTest = false): void {\r\n this.engine.setState(true);\r\n this.engine.depthCullingState.depthTest = depthTest;\r\n this.engine.stencilState.stencilTest = stencilTest;\r\n this.engine.enableEffect(effectWrapper.drawWrapper);\r\n this.bindBuffers(effectWrapper.effect);\r\n effectWrapper.onApplyObservable.notifyObservers({});\r\n }\r\n\r\n /**\r\n * Saves engine states\r\n */\r\n public saveStates(): void {\r\n this._savedStateDepthTest = this.engine.depthCullingState.depthTest;\r\n this._savedStateStencilTest = this.engine.stencilState.stencilTest;\r\n }\r\n\r\n /**\r\n * Restores engine states\r\n */\r\n public restoreStates(): void {\r\n this.engine.depthCullingState.depthTest = this._savedStateDepthTest;\r\n this.engine.stencilState.stencilTest = this._savedStateStencilTest;\r\n }\r\n\r\n /**\r\n * Draws a full screen quad.\r\n */\r\n public draw(): void {\r\n this.engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, this._indexBufferLength);\r\n }\r\n\r\n private _isRenderTargetTexture(texture: RenderTargetWrapper | IRenderTargetTexture): texture is IRenderTargetTexture {\r\n return (texture as IRenderTargetTexture).renderTarget !== undefined;\r\n }\r\n\r\n /**\r\n * renders one or more effects to a specified texture\r\n * @param effectWrapper the effect to renderer\r\n * @param outputTexture texture to draw to, if null it will render to the currently bound frame buffer\r\n */\r\n public render(effectWrapper: EffectWrapper, outputTexture: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null) {\r\n // Ensure effect is ready\r\n if (!effectWrapper.effect.isReady()) {\r\n return;\r\n }\r\n\r\n this.saveStates();\r\n\r\n // Reset state\r\n this.setViewport();\r\n\r\n const out = outputTexture === null ? null : this._isRenderTargetTexture(outputTexture) ? outputTexture.renderTarget! : outputTexture;\r\n\r\n if (out) {\r\n this.engine.bindFramebuffer(out);\r\n }\r\n\r\n this.applyEffectWrapper(effectWrapper);\r\n\r\n this.draw();\r\n\r\n if (out) {\r\n this.engine.unBindFramebuffer(out);\r\n }\r\n\r\n this.restoreStates();\r\n }\r\n\r\n /**\r\n * Disposes of the effect renderer\r\n */\r\n dispose() {\r\n const vertexBuffer = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (vertexBuffer) {\r\n vertexBuffer.dispose();\r\n delete this._vertexBuffers[VertexBuffer.PositionKind];\r\n }\r\n\r\n if (this._indexBuffer) {\r\n this.engine._releaseBuffer(this._indexBuffer);\r\n }\r\n\r\n if (this._onContextRestoredObserver) {\r\n this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Allows for custom processing of the shader code used by an effect wrapper\r\n */\r\nexport type EffectWrapperCustomShaderCodeProcessing = {\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated after the #include have been processed\r\n */\r\n processCodeAfterIncludes?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU\r\n */\r\n processFinalCode?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called before creating the effect to collect additional custom bindings (defines, uniforms, samplers)\r\n */\r\n defineCustomBindings?: (postProcessName: string, defines: Nullable<string>, uniforms: string[], samplers: string[]) => Nullable<string>;\r\n /**\r\n * If provided, will be called when binding inputs to the shader code to allow the user to add custom bindings\r\n */\r\n bindCustomBindings?: (postProcessName: string, effect: Effect) => void;\r\n};\r\n\r\n/**\r\n * Options to create an EffectWrapper\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface EffectWrapperCreationOptions {\r\n /**\r\n * Engine to use to create the effect\r\n */\r\n engine?: AbstractEngine;\r\n /**\r\n * Fragment shader for the effect\r\n */\r\n fragmentShader?: string;\r\n /**\r\n * Use the shader store instead of direct source code\r\n */\r\n useShaderStore?: boolean;\r\n /**\r\n * Vertex shader for the effect (default: \"postprocess\")\r\n */\r\n vertexShader?: string;\r\n /**\r\n * Alias for vertexShader\r\n */\r\n vertexUrl?: string;\r\n /**\r\n * Attributes to use in the shader (default: [\"position\"])\r\n */\r\n attributeNames?: Array<string>;\r\n /**\r\n * Uniforms to use in the shader\r\n */\r\n uniformNames?: Array<string>;\r\n /**\r\n * Alias for uniformNames. Note that if it is provided, it takes precedence over uniformNames.\r\n */\r\n uniforms?: Nullable<string[]>;\r\n /**\r\n * Texture sampler names to use in the shader\r\n */\r\n samplerNames?: Array<string>;\r\n /**\r\n * Alias for samplerNames. Note that if it is provided, it takes precedence over samplerNames.\r\n */\r\n samplers?: Nullable<string[]>;\r\n /**\r\n * The list of uniform buffers used in the shader (if any)\r\n */\r\n uniformBuffers?: Nullable<string[]>;\r\n /**\r\n * Defines to use in the shader\r\n */\r\n defines?: Nullable<string | Array<string>>;\r\n /**\r\n * The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined)\r\n * See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n */\r\n indexParameters?: any;\r\n /**\r\n * If the shader should not be compiled immediately. (default: false)\r\n */\r\n blockCompilation?: boolean;\r\n /**\r\n * Callback when effect is compiled\r\n */\r\n onCompiled?: Nullable<(effect: Effect) => void>;\r\n /**\r\n * The friendly name of the effect (default: \"effectWrapper\")\r\n */\r\n name?: string;\r\n /**\r\n * The language the shader is written in (default: GLSL)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n /**\r\n * Defines additional code to call to prepare the shader code\r\n */\r\n extraInitializations?: (useWebGPU: boolean, list: Promise<any>[]) => void;\r\n /**\r\n * Additional async code to run before preparing the effect\r\n */\r\n extraInitializationsAsync?: () => Promise<void>;\r\n /**\r\n * If the effect should be used as a post process (default: false). If true, the effect will be created with a \"scale\" uniform and a \"textureSampler\" sampler\r\n */\r\n useAsPostProcess?: boolean;\r\n /**\r\n * Sets this property to true if the fragment shader doesn't use a textureSampler texture (default: false).\r\n */\r\n allowEmptySourceTexture?: boolean;\r\n}\r\n\r\n/**\r\n * Wraps an effect to be used for rendering\r\n */\r\nexport class EffectWrapper {\r\n /**\r\n * Force code to compile to glsl even on WebGPU engines.\r\n * False by default. This is mostly meant for backward compatibility.\r\n */\r\n public static ForceGLSL = false;\r\n\r\n private static _CustomShaderCodeProcessing: { [effectWrapperName: string]: EffectWrapperCustomShaderCodeProcessing } = {};\r\n\r\n /**\r\n * Registers a shader code processing with an effect wrapper name.\r\n * @param effectWrapperName name of the effect wrapper. Use null for the fallback shader code processing. This is the shader code processing that will be used in case no specific shader code processing has been associated to an effect wrapper name\r\n * @param customShaderCodeProcessing shader code processing to associate to the effect wrapper name\r\n */\r\n public static RegisterShaderCodeProcessing(effectWrapperName: Nullable<string>, customShaderCodeProcessing?: EffectWrapperCustomShaderCodeProcessing) {\r\n if (!customShaderCodeProcessing) {\r\n delete EffectWrapper._CustomShaderCodeProcessing[effectWrapperName ?? \"\"];\r\n return;\r\n }\r\n\r\n EffectWrapper._CustomShaderCodeProcessing[effectWrapperName ?? \"\"] = customShaderCodeProcessing;\r\n }\r\n\r\n private static _GetShaderCodeProcessing(effectWrapperName: string) {\r\n return EffectWrapper._CustomShaderCodeProcessing[effectWrapperName] ?? EffectWrapper._CustomShaderCodeProcessing[\"\"];\r\n }\r\n\r\n /**\r\n * Gets or sets the name of the effect wrapper\r\n */\r\n public get name() {\r\n return this.options.name;\r\n }\r\n\r\n public set name(value: string) {\r\n this.options.name = value;\r\n }\r\n\r\n /**\r\n * Type of alpha mode to use when applying the effect (default: Engine.ALPHA_DISABLE). Used only if useAsPostProcess is true.\r\n */\r\n public alphaMode = Constants.ALPHA_DISABLE;\r\n\r\n /**\r\n * Executed when the effect is created\r\n * @returns effect that was created for this effect wrapper\r\n */\r\n public onEffectCreatedObservable = new Observable<Effect>(undefined, true);\r\n\r\n /**\r\n * Options used to create the effect wrapper\r\n */\r\n public readonly options: Required<NonNullableFields<EffectWrapperCreationOptions>>;\r\n\r\n /**\r\n * Get a value indicating if the effect is ready to be used\r\n * @returns true if the post-process is ready (shader is compiled)\r\n */\r\n public isReady() {\r\n return this._drawWrapper.effect?.isReady() ?? false;\r\n }\r\n\r\n /**\r\n * Get the draw wrapper associated with the effect wrapper\r\n * @returns the draw wrapper associated with the effect wrapper\r\n */\r\n public get drawWrapper() {\r\n return this._drawWrapper;\r\n }\r\n\r\n /**\r\n * Event that is fired (only when the EffectWrapper is used with an EffectRenderer) right before the effect is drawn (should be used to update uniforms)\r\n */\r\n public onApplyObservable = new Observable<{}>();\r\n\r\n /**\r\n * The underlying effect\r\n */\r\n public get effect(): Effect {\r\n return this._drawWrapper.effect!;\r\n }\r\n\r\n public set effect(effect: Effect) {\r\n this._drawWrapper.effect = effect;\r\n }\r\n\r\n protected readonly _drawWrapper: DrawWrapper;\r\n protected _shadersLoaded = false;\r\n protected readonly _shaderPath: IShaderPath;\r\n /** @internal */\r\n public _webGPUReady = false;\r\n\r\n private _onContextRestoredObserver: Nullable<Observer<AbstractEngine>>;\r\n\r\n /**\r\n * Creates an effect to be rendered\r\n * @param creationOptions options to create the effect\r\n */\r\n constructor(creationOptions: EffectWrapperCreationOptions) {\r\n this.options = {\r\n ...creationOptions,\r\n name: creationOptions.name || \"effectWrapper\",\r\n engine: creationOptions.engine!,\r\n uniforms: creationOptions.uniforms || creationOptions.uniformNames || [],\r\n uniformNames: undefined as any,\r\n samplers: creationOptions.samplers || creationOptions.samplerNames || [],\r\n samplerNames: undefined as any,\r\n attributeNames: creationOptions.attributeNames || [\"position\"],\r\n uniformBuffers: creationOptions.uniformBuffers || [],\r\n defines: creationOptions.defines || \"\",\r\n useShaderStore: creationOptions.useShaderStore || false,\r\n vertexUrl: creationOptions.vertexUrl || creationOptions.vertexShader || \"postprocess\",\r\n vertexShader: undefined as any,\r\n fragmentShader: creationOptions.fragmentShader || \"pass\",\r\n indexParameters: creationOptions.indexParameters,\r\n blockCompilation: creationOptions.blockCompilation || false,\r\n shaderLanguage: creationOptions.shaderLanguage || ShaderLanguage.GLSL,\r\n onCompiled: creationOptions.onCompiled || (undefined as any),\r\n extraInitializations: creationOptions.extraInitializations || (undefined as any),\r\n extraInitializationsAsync: creationOptions.extraInitializationsAsync || (undefined as any),\r\n useAsPostProcess: creationOptions.useAsPostProcess ?? false,\r\n allowEmptySourceTexture: creationOptions.allowEmptySourceTexture ?? false,\r\n };\r\n\r\n this.options.uniformNames = this.options.uniforms;\r\n this.options.samplerNames = this.options.samplers;\r\n this.options.vertexShader = this.options.vertexUrl;\r\n\r\n if (this.options.useAsPostProcess) {\r\n if (!this.options.allowEmptySourceTexture && this.options.samplers.indexOf(\"textureSampler\") === -1) {\r\n this.options.samplers.push(\"textureSampler\");\r\n }\r\n if (this.options.uniforms.indexOf(\"scale\") === -1) {\r\n this.options.uniforms.push(\"scale\");\r\n }\r\n }\r\n\r\n if (creationOptions.vertexUrl || creationOptions.vertexShader) {\r\n this._shaderPath = {\r\n vertexSource: this.options.vertexShader,\r\n };\r\n } else {\r\n if (!this.options.useAsPostProcess) {\r\n this.options.uniforms.push(\"scale\");\r\n\r\n this.onApplyObservable.add(() => {\r\n this.effect.setFloat2(\"scale\", 1, 1);\r\n });\r\n }\r\n\r\n this._shaderPath = {\r\n vertex: this.options.vertexShader,\r\n };\r\n }\r\n\r\n this._shaderPath.fragmentSource = this.options.fragmentShader;\r\n this._shaderPath.spectorName = this.options.name;\r\n\r\n if (this.options.useShaderStore) {\r\n this._shaderPath.fragment = this._shaderPath.fragmentSource;\r\n if (!this._shaderPath.vertex) {\r\n this._shaderPath.vertex = this._shaderPath.vertexSource;\r\n }\r\n\r\n delete this._shaderPath.fragmentSource;\r\n delete this._shaderPath.vertexSource;\r\n }\r\n\r\n this.onApplyObservable.add(() => {\r\n this.bind();\r\n });\r\n\r\n if (!this.options.useShaderStore) {\r\n this._onContextRestoredObserver = this.options.engine.onContextRestoredObservable.add(() => {\r\n this.effect._pipelineContext = null; // because _prepareEffect will try to dispose this pipeline before recreating it and that would lead to webgl errors\r\n this.effect._prepareEffect();\r\n });\r\n }\r\n\r\n this._drawWrapper = new DrawWrapper(this.options.engine);\r\n this._webGPUReady = this.options.shaderLanguage === ShaderLanguage.WGSL;\r\n\r\n const defines = Array.isArray(this.options.defines) ? this.options.defines.join(\"\\n\") : this.options.defines;\r\n\r\n this._postConstructor(this.options.blockCompilation, defines, this.options.extraInitializations);\r\n }\r\n\r\n protected _gatherImports(useWebGPU = false, list: Promise<any>[]) {\r\n if (!this.options.useAsPostProcess) {\r\n return;\r\n }\r\n\r\n // this._webGPUReady is used to detect when an effect wrapper is intended to be used with WebGPU\r\n if (useWebGPU && this._webGPUReady) {\r\n list.push(Promise.all([import(\"../ShadersWGSL/postprocess.vertex\")]));\r\n } else {\r\n list.push(Promise.all([import(\"../Shaders/postprocess.vertex\")]));\r\n }\r\n }\r\n\r\n private _importPromises: Array<Promise<any>> = [];\r\n\r\n /** @internal */\r\n public _postConstructor(\r\n blockCompilation: boolean,\r\n defines: Nullable<string> = null,\r\n extraInitializations?: (useWebGPU: boolean, list: Promise<any>[]) => void,\r\n importPromises?: Array<Promise<any>>\r\n ) {\r\n this._importPromises.length = 0;\r\n\r\n if (importPromises) {\r\n this._importPromises.push(...importPromises);\r\n }\r\n\r\n const useWebGPU = this.options.engine.isWebGPU && !EffectWrapper.ForceGLSL;\r\n\r\n this._gatherImports(useWebGPU, this._importPromises);\r\n if (extraInitializations !== undefined) {\r\n extraInitializations(useWebGPU, this._importPromises);\r\n }\r\n\r\n if (useWebGPU && this._webGPUReady) {\r\n this.options.shaderLanguage = ShaderLanguage.WGSL;\r\n }\r\n\r\n if (!blockCompilation) {\r\n this.updateEffect(defines);\r\n }\r\n }\r\n\r\n /**\r\n * Updates the effect with the current effect wrapper compile time values and recompiles the shader.\r\n * @param defines Define statements that should be added at the beginning of the shader. (default: null)\r\n * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)\r\n * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)\r\n * @param indexParameters The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n * @param onCompiled Called when the shader has been compiled.\r\n * @param onError Called if there is an error when compiling a shader.\r\n * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)\r\n * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)\r\n */\r\n public updateEffect(\r\n defines: Nullable<string> = null,\r\n uniforms: Nullable<string[]> = null,\r\n samplers: Nullable<string[]> = null,\r\n indexParameters?: any,\r\n onCompiled?: (effect: Effect) => void,\r\n onError?: (effect: Effect, errors: string) => void,\r\n vertexUrl?: string,\r\n fragmentUrl?: string\r\n ) {\r\n const customShaderCodeProcessing = EffectWrapper._GetShaderCodeProcessing(this.name);\r\n if (customShaderCodeProcessing?.defineCustomBindings) {\r\n const newUniforms = uniforms?.slice() ?? [];\r\n newUniforms.push(...this.options.uniforms);\r\n\r\n const newSamplers = samplers?.slice() ?? [];\r\n newSamplers.push(...this.options.samplers);\r\n\r\n defines = customShaderCodeProcessing.defineCustomBindings(this.name, defines, newUniforms, newSamplers);\r\n uniforms = newUniforms;\r\n samplers = newSamplers;\r\n }\r\n\r\n this.options.defines = defines || \"\";\r\n\r\n const waitImportsLoaded =\r\n this._shadersLoaded || this._importPromises.length === 0\r\n ? undefined\r\n : async () => {\r\n await Promise.all(this._importPromises);\r\n this._shadersLoaded = true;\r\n };\r\n\r\n let extraInitializationsAsync: (() => Promise<void>) | undefined;\r\n if (this.options.extraInitializationsAsync) {\r\n extraInitializationsAsync = async () => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n waitImportsLoaded?.();\r\n await this.options.extraInitializationsAsync();\r\n };\r\n } else {\r\n extraInitializationsAsync = waitImportsLoaded;\r\n }\r\n\r\n if (this.options.useShaderStore) {\r\n this._drawWrapper.effect = this.options.engine.createEffect(\r\n { vertex: vertexUrl ?? this._shaderPath.vertex, fragment: fragmentUrl ?? this._shaderPath.fragment },\r\n {\r\n attributes: this.options.attributeNames,\r\n uniformsNames: uniforms || this.options.uniforms,\r\n uniformBuffersNames: this.options.uniformBuffers,\r\n samplers: samplers || this.options.samplers,\r\n defines: defines !== null ? defines : \"\",\r\n fallbacks: null,\r\n onCompiled: onCompiled ?? this.options.onCompiled,\r\n onError: onError ?? null,\r\n indexParameters: indexParameters || this.options.indexParameters,\r\n processCodeAfterIncludes: customShaderCodeProcessing?.processCodeAfterIncludes\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing.processCodeAfterIncludes!(this.name, shaderType, code)\r\n : null,\r\n processFinalCode: customShaderCodeProcessing?.processFinalCode\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing.processFinalCode!(this.name, shaderType, code)\r\n : null,\r\n shaderLanguage: this.options.shaderLanguage,\r\n extraInitializationsAsync,\r\n },\r\n this.options.engine\r\n );\r\n } else {\r\n this._drawWrapper.effect = new Effect(\r\n this._shaderPath,\r\n this.options.attributeNames,\r\n uniforms || this.options.uniforms,\r\n samplers || this.options.samplerNames,\r\n this.options.engine,\r\n defines,\r\n undefined,\r\n onCompiled || this.options.onCompiled,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this.options.shaderLanguage,\r\n extraInitializationsAsync\r\n );\r\n }\r\n\r\n this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect);\r\n }\r\n\r\n /**\r\n * Binds the data to the effect.\r\n * @param noDefaultBindings if true, the default bindings (scale and alpha mode) will not be set.\r\n */\r\n public bind(noDefaultBindings = false) {\r\n if (this.options.useAsPostProcess && !noDefaultBindings) {\r\n this.options.engine.setAlphaMode(this.alphaMode);\r\n this.drawWrapper.effect!.setFloat2(\"scale\", 1, 1);\r\n }\r\n\r\n EffectWrapper._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name, this._drawWrapper.effect!);\r\n }\r\n\r\n /**\r\n * Disposes of the effect wrapper\r\n * @param _ignored kept for backward compatibility\r\n */\r\n public dispose(_ignored: boolean = false) {\r\n if (this._onContextRestoredObserver) {\r\n this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n this.onEffectCreatedObservable.clear();\r\n this._drawWrapper.dispose(true);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"effectRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effectRenderer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,O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AAU,EACrC,SAAS,EACT,SAAS,EACT,SAAS,EACT,IAAI,CAAC,OAAO,CAAC,cAAc,EAC3B,yBAAyB,CAC5B,CAAC;QACN,CAAC;QAED,IAAI,CAAC,yBAAyB,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC7E,CAAC;IAED;;;OAGG;IACI,IAAI,CAAC,iBAAiB,GAAG,KAAK;QACjC,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACtD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACjD,IAAI,CAAC,WAAW,CAAC,MAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC;QAED,aAAa,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,kBAAkB,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,MAAO,CAAC,CAAC;IAClH,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,WAAoB,KAAK;QACpC,IAAI,IAAI,CAAC,0BAA0B,EAAE,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,2BAA2B,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YAC5F,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC;QAC3C,CAAC;QACD,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;;AAvVD;;;GAGG;AACW,uBAAS,GAAG,KAAK,AAAR,CAAS;AAEjB,yCAA2B,GAA6E,EAAE,AAA/E,CAAgF","sourcesContent":["import type { NonNullableFields, Nullable } from \"../types\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Viewport } from \"../Maths/math.viewport\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { IShaderPath } from \"./effect\";\r\nimport { Effect } from \"./effect\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { DrawWrapper } from \"./drawWrapper\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\n\r\n// Prevents ES6 issue if not imported.\r\nimport \"../Shaders/postprocess.vertex\";\r\nimport \"../ShadersWGSL/postprocess.vertex\";\r\n\r\n/**\r\n * Effect Render Options\r\n */\r\nexport interface IEffectRendererOptions {\r\n /**\r\n * Defines the vertices positions.\r\n */\r\n positions?: number[];\r\n /**\r\n * Defines the indices.\r\n */\r\n indices?: number[];\r\n}\r\n\r\n// Fullscreen quad buffers by default.\r\nconst DefaultOptions = {\r\n positions: [1, 1, -1, 1, -1, -1, 1, -1],\r\n indices: [0, 1, 2, 0, 2, 3],\r\n};\r\n\r\n/**\r\n * Helper class to render one or more effects.\r\n * You can access the previous rendering in your shader by declaring a sampler named textureSampler\r\n */\r\nexport class EffectRenderer {\r\n /**\r\n * The engine the effect renderer has been created for.\r\n */\r\n public readonly engine: AbstractEngine;\r\n\r\n private _vertexBuffers: { [key: string]: VertexBuffer };\r\n private _indexBuffer: DataBuffer;\r\n private _indexBufferLength: number;\r\n\r\n private _fullscreenViewport = new Viewport(0, 0, 1, 1);\r\n private _onContextRestoredObserver: Nullable<Observer<AbstractEngine>>;\r\n\r\n private _savedStateDepthTest: boolean;\r\n private _savedStateStencilTest: boolean;\r\n\r\n /**\r\n * Creates an effect renderer\r\n * @param engine the engine to use for rendering\r\n * @param options defines the options of the effect renderer\r\n */\r\n constructor(engine: AbstractEngine, options: IEffectRendererOptions = DefaultOptions) {\r\n const positions = options.positions ?? DefaultOptions.positions;\r\n const indices = options.indices ?? DefaultOptions.indices;\r\n\r\n this.engine = engine;\r\n this._vertexBuffers = {\r\n // Note, always assumes stride of 2.\r\n [VertexBuffer.PositionKind]: new VertexBuffer(engine, positions, VertexBuffer.PositionKind, false, false, 2),\r\n };\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n this._indexBufferLength = indices.length;\r\n\r\n this._onContextRestoredObserver = engine.onContextRestoredObservable.add(() => {\r\n this._indexBuffer = engine.createIndexBuffer(indices);\r\n\r\n for (const key in this._vertexBuffers) {\r\n const vertexBuffer = this._vertexBuffers[key];\r\n vertexBuffer._rebuild();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Sets the current viewport in normalized coordinates 0-1\r\n * @param viewport Defines the viewport to set (defaults to 0 0 1 1)\r\n */\r\n public setViewport(viewport = this._fullscreenViewport): void {\r\n this.engine.setViewport(viewport);\r\n }\r\n\r\n /**\r\n * Binds the embedded attributes buffer to the effect.\r\n * @param effect Defines the effect to bind the attributes for\r\n */\r\n public bindBuffers(effect: Effect): void {\r\n this.engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);\r\n }\r\n\r\n /**\r\n * Sets the current effect wrapper to use during draw.\r\n * The effect needs to be ready before calling this api.\r\n * This also sets the default full screen position attribute.\r\n * @param effectWrapper Defines the effect to draw with\r\n * @param depthTest Whether to enable depth testing (default: false)\r\n * @param stencilTest Whether to enable stencil testing (default: false)\r\n */\r\n public applyEffectWrapper(effectWrapper: EffectWrapper, depthTest = false, stencilTest = false): void {\r\n this.engine.setState(true);\r\n this.engine.depthCullingState.depthTest = depthTest;\r\n this.engine.stencilState.stencilTest = stencilTest;\r\n this.engine.enableEffect(effectWrapper.drawWrapper);\r\n this.bindBuffers(effectWrapper.effect);\r\n effectWrapper.onApplyObservable.notifyObservers({});\r\n }\r\n\r\n /**\r\n * Saves engine states\r\n */\r\n public saveStates(): void {\r\n this._savedStateDepthTest = this.engine.depthCullingState.depthTest;\r\n this._savedStateStencilTest = this.engine.stencilState.stencilTest;\r\n }\r\n\r\n /**\r\n * Restores engine states\r\n */\r\n public restoreStates(): void {\r\n this.engine.depthCullingState.depthTest = this._savedStateDepthTest;\r\n this.engine.stencilState.stencilTest = this._savedStateStencilTest;\r\n }\r\n\r\n /**\r\n * Draws a full screen quad.\r\n */\r\n public draw(): void {\r\n this.engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, this._indexBufferLength);\r\n }\r\n\r\n private _isRenderTargetTexture(texture: RenderTargetWrapper | IRenderTargetTexture): texture is IRenderTargetTexture {\r\n return (texture as IRenderTargetTexture).renderTarget !== undefined;\r\n }\r\n\r\n /**\r\n * renders one or more effects to a specified texture\r\n * @param effectWrapper the effect to renderer\r\n * @param outputTexture texture to draw to, if null it will render to the currently bound frame buffer\r\n */\r\n public render(effectWrapper: EffectWrapper, outputTexture: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null) {\r\n // Ensure effect is ready\r\n if (!effectWrapper.effect.isReady()) {\r\n return;\r\n }\r\n\r\n this.saveStates();\r\n\r\n // Reset state\r\n this.setViewport();\r\n\r\n const out = outputTexture === null ? null : this._isRenderTargetTexture(outputTexture) ? outputTexture.renderTarget! : outputTexture;\r\n\r\n if (out) {\r\n this.engine.bindFramebuffer(out);\r\n }\r\n\r\n this.applyEffectWrapper(effectWrapper);\r\n\r\n this.draw();\r\n\r\n if (out) {\r\n this.engine.unBindFramebuffer(out);\r\n }\r\n\r\n this.restoreStates();\r\n }\r\n\r\n /**\r\n * Disposes of the effect renderer\r\n */\r\n dispose() {\r\n const vertexBuffer = this._vertexBuffers[VertexBuffer.PositionKind];\r\n if (vertexBuffer) {\r\n vertexBuffer.dispose();\r\n delete this._vertexBuffers[VertexBuffer.PositionKind];\r\n }\r\n\r\n if (this._indexBuffer) {\r\n this.engine._releaseBuffer(this._indexBuffer);\r\n }\r\n\r\n if (this._onContextRestoredObserver) {\r\n this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Allows for custom processing of the shader code used by an effect wrapper\r\n */\r\nexport type EffectWrapperCustomShaderCodeProcessing = {\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated after the #include have been processed\r\n */\r\n processCodeAfterIncludes?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU\r\n */\r\n processFinalCode?: (postProcessName: string, shaderType: string, code: string) => string;\r\n /**\r\n * If provided, will be called before creating the effect to collect additional custom bindings (defines, uniforms, samplers)\r\n */\r\n defineCustomBindings?: (postProcessName: string, defines: Nullable<string>, uniforms: string[], samplers: string[]) => Nullable<string>;\r\n /**\r\n * If provided, will be called when binding inputs to the shader code to allow the user to add custom bindings\r\n */\r\n bindCustomBindings?: (postProcessName: string, effect: Effect) => void;\r\n};\r\n\r\n/**\r\n * Options to create an EffectWrapper\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface EffectWrapperCreationOptions {\r\n /**\r\n * Engine to use to create the effect\r\n */\r\n engine?: AbstractEngine;\r\n /**\r\n * Fragment shader for the effect\r\n */\r\n fragmentShader?: string;\r\n /**\r\n * Use the shader store instead of direct source code\r\n */\r\n useShaderStore?: boolean;\r\n /**\r\n * Vertex shader for the effect (default: \"postprocess\")\r\n */\r\n vertexShader?: string;\r\n /**\r\n * Alias for vertexShader\r\n */\r\n vertexUrl?: string;\r\n /**\r\n * Attributes to use in the shader (default: [\"position\"])\r\n */\r\n attributeNames?: Array<string>;\r\n /**\r\n * Uniforms to use in the shader\r\n */\r\n uniformNames?: Array<string>;\r\n /**\r\n * Alias for uniformNames. Note that if it is provided, it takes precedence over uniformNames.\r\n */\r\n uniforms?: Nullable<string[]>;\r\n /**\r\n * Texture sampler names to use in the shader\r\n */\r\n samplerNames?: Array<string>;\r\n /**\r\n * Alias for samplerNames. Note that if it is provided, it takes precedence over samplerNames.\r\n */\r\n samplers?: Nullable<string[]>;\r\n /**\r\n * The list of uniform buffers used in the shader (if any)\r\n */\r\n uniformBuffers?: Nullable<string[]>;\r\n /**\r\n * Defines to use in the shader\r\n */\r\n defines?: Nullable<string | Array<string>>;\r\n /**\r\n * The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined)\r\n * See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n */\r\n indexParameters?: any;\r\n /**\r\n * If the shader should not be compiled immediately. (default: false)\r\n */\r\n blockCompilation?: boolean;\r\n /**\r\n * Callback when effect is compiled\r\n */\r\n onCompiled?: Nullable<(effect: Effect) => void>;\r\n /**\r\n * The friendly name of the effect (default: \"effectWrapper\")\r\n */\r\n name?: string;\r\n /**\r\n * The language the shader is written in (default: GLSL)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n /**\r\n * Defines additional code to call to prepare the shader code\r\n */\r\n extraInitializations?: (useWebGPU: boolean, list: Promise<any>[]) => void;\r\n /**\r\n * Additional async code to run before preparing the effect\r\n */\r\n extraInitializationsAsync?: () => Promise<void>;\r\n /**\r\n * If the effect should be used as a post process (default: false). If true, the effect will be created with a \"scale\" uniform and a \"textureSampler\" sampler\r\n */\r\n useAsPostProcess?: boolean;\r\n /**\r\n * Sets this property to true if the fragment shader doesn't use a textureSampler texture (default: false).\r\n */\r\n allowEmptySourceTexture?: boolean;\r\n}\r\n\r\n/**\r\n * Wraps an effect to be used for rendering\r\n */\r\nexport class EffectWrapper {\r\n /**\r\n * Force code to compile to glsl even on WebGPU engines.\r\n * False by default. This is mostly meant for backward compatibility.\r\n */\r\n public static ForceGLSL = false;\r\n\r\n private static _CustomShaderCodeProcessing: { [effectWrapperName: string]: EffectWrapperCustomShaderCodeProcessing } = {};\r\n\r\n /**\r\n * Registers a shader code processing with an effect wrapper name.\r\n * @param effectWrapperName name of the effect wrapper. Use null for the fallback shader code processing. This is the shader code processing that will be used in case no specific shader code processing has been associated to an effect wrapper name\r\n * @param customShaderCodeProcessing shader code processing to associate to the effect wrapper name\r\n */\r\n public static RegisterShaderCodeProcessing(effectWrapperName: Nullable<string>, customShaderCodeProcessing?: EffectWrapperCustomShaderCodeProcessing) {\r\n if (!customShaderCodeProcessing) {\r\n delete EffectWrapper._CustomShaderCodeProcessing[effectWrapperName ?? \"\"];\r\n return;\r\n }\r\n\r\n EffectWrapper._CustomShaderCodeProcessing[effectWrapperName ?? \"\"] = customShaderCodeProcessing;\r\n }\r\n\r\n private static _GetShaderCodeProcessing(effectWrapperName: string) {\r\n return EffectWrapper._CustomShaderCodeProcessing[effectWrapperName] ?? EffectWrapper._CustomShaderCodeProcessing[\"\"];\r\n }\r\n\r\n /**\r\n * Gets or sets the name of the effect wrapper\r\n */\r\n public get name() {\r\n return this.options.name;\r\n }\r\n\r\n public set name(value: string) {\r\n this.options.name = value;\r\n }\r\n\r\n /**\r\n * Type of alpha mode to use when applying the effect (default: Engine.ALPHA_DISABLE). Used only if useAsPostProcess is true.\r\n */\r\n public alphaMode = Constants.ALPHA_DISABLE;\r\n\r\n /**\r\n * Executed when the effect is created\r\n * @returns effect that was created for this effect wrapper\r\n */\r\n public onEffectCreatedObservable = new Observable<Effect>(undefined, true);\r\n\r\n /**\r\n * Options used to create the effect wrapper\r\n */\r\n public readonly options: Required<NonNullableFields<EffectWrapperCreationOptions>>;\r\n\r\n /**\r\n * Get a value indicating if the effect is ready to be used\r\n * @returns true if the post-process is ready (shader is compiled)\r\n */\r\n public isReady() {\r\n return this._drawWrapper.effect?.isReady() ?? false;\r\n }\r\n\r\n /**\r\n * Get the draw wrapper associated with the effect wrapper\r\n * @returns the draw wrapper associated with the effect wrapper\r\n */\r\n public get drawWrapper() {\r\n return this._drawWrapper;\r\n }\r\n\r\n /**\r\n * Event that is fired (only when the EffectWrapper is used with an EffectRenderer) right before the effect is drawn (should be used to update uniforms)\r\n */\r\n public onApplyObservable = new Observable<{}>();\r\n\r\n /**\r\n * The underlying effect\r\n */\r\n public get effect(): Effect {\r\n return this._drawWrapper.effect!;\r\n }\r\n\r\n public set effect(effect: Effect) {\r\n this._drawWrapper.effect = effect;\r\n }\r\n\r\n protected readonly _drawWrapper: DrawWrapper;\r\n protected _shadersLoaded = false;\r\n protected readonly _shaderPath: IShaderPath;\r\n /** @internal */\r\n public _webGPUReady = false;\r\n\r\n private _onContextRestoredObserver: Nullable<Observer<AbstractEngine>>;\r\n\r\n /**\r\n * Creates an effect to be rendered\r\n * @param creationOptions options to create the effect\r\n */\r\n constructor(creationOptions: EffectWrapperCreationOptions) {\r\n this.options = {\r\n ...creationOptions,\r\n name: creationOptions.name || \"effectWrapper\",\r\n engine: creationOptions.engine!,\r\n uniforms: creationOptions.uniforms || creationOptions.uniformNames || [],\r\n uniformNames: undefined as any,\r\n samplers: creationOptions.samplers || creationOptions.samplerNames || [],\r\n samplerNames: undefined as any,\r\n attributeNames: creationOptions.attributeNames || [\"position\"],\r\n uniformBuffers: creationOptions.uniformBuffers || [],\r\n defines: creationOptions.defines || \"\",\r\n useShaderStore: creationOptions.useShaderStore || false,\r\n vertexUrl: creationOptions.vertexUrl || creationOptions.vertexShader || \"postprocess\",\r\n vertexShader: undefined as any,\r\n fragmentShader: creationOptions.fragmentShader || \"pass\",\r\n indexParameters: creationOptions.indexParameters,\r\n blockCompilation: creationOptions.blockCompilation || false,\r\n shaderLanguage: creationOptions.shaderLanguage || ShaderLanguage.GLSL,\r\n onCompiled: creationOptions.onCompiled || (undefined as any),\r\n extraInitializations: creationOptions.extraInitializations || (undefined as any),\r\n extraInitializationsAsync: creationOptions.extraInitializationsAsync || (undefined as any),\r\n useAsPostProcess: creationOptions.useAsPostProcess ?? false,\r\n allowEmptySourceTexture: creationOptions.allowEmptySourceTexture ?? false,\r\n };\r\n\r\n this.options.uniformNames = this.options.uniforms;\r\n this.options.samplerNames = this.options.samplers;\r\n this.options.vertexShader = this.options.vertexUrl;\r\n\r\n if (this.options.useAsPostProcess) {\r\n if (!this.options.allowEmptySourceTexture && this.options.samplers.indexOf(\"textureSampler\") === -1) {\r\n this.options.samplers.push(\"textureSampler\");\r\n }\r\n if (this.options.uniforms.indexOf(\"scale\") === -1) {\r\n this.options.uniforms.push(\"scale\");\r\n }\r\n }\r\n\r\n if (creationOptions.vertexUrl || creationOptions.vertexShader) {\r\n this._shaderPath = {\r\n vertexSource: this.options.vertexShader,\r\n };\r\n } else {\r\n if (!this.options.useAsPostProcess) {\r\n this.options.uniforms.push(\"scale\");\r\n\r\n this.onApplyObservable.add(() => {\r\n this.effect.setFloat2(\"scale\", 1, 1);\r\n });\r\n }\r\n\r\n this._shaderPath = {\r\n vertex: this.options.vertexShader,\r\n };\r\n }\r\n\r\n this._shaderPath.fragmentSource = this.options.fragmentShader;\r\n this._shaderPath.spectorName = this.options.name;\r\n\r\n if (this.options.useShaderStore) {\r\n this._shaderPath.fragment = this._shaderPath.fragmentSource;\r\n if (!this._shaderPath.vertex) {\r\n this._shaderPath.vertex = this._shaderPath.vertexSource;\r\n }\r\n\r\n delete this._shaderPath.fragmentSource;\r\n delete this._shaderPath.vertexSource;\r\n }\r\n\r\n this.onApplyObservable.add(() => {\r\n this.bind();\r\n });\r\n\r\n if (!this.options.useShaderStore) {\r\n this._onContextRestoredObserver = this.options.engine.onContextRestoredObservable.add(() => {\r\n this.effect._pipelineContext = null; // because _prepareEffect will try to dispose this pipeline before recreating it and that would lead to webgl errors\r\n this.effect._prepareEffect();\r\n });\r\n }\r\n\r\n this._drawWrapper = new DrawWrapper(this.options.engine);\r\n this._webGPUReady = this.options.shaderLanguage === ShaderLanguage.WGSL;\r\n\r\n const defines = Array.isArray(this.options.defines) ? this.options.defines.join(\"\\n\") : this.options.defines;\r\n\r\n this._postConstructor(this.options.blockCompilation, defines, this.options.extraInitializations);\r\n }\r\n\r\n protected _gatherImports(_useWebGPU = false, _list: Promise<any>[]) {}\r\n\r\n private _importPromises: Array<Promise<any>> = [];\r\n\r\n /** @internal */\r\n public _postConstructor(\r\n blockCompilation: boolean,\r\n defines: Nullable<string> = null,\r\n extraInitializations?: (useWebGPU: boolean, list: Promise<any>[]) => void,\r\n importPromises?: Array<Promise<any>>\r\n ) {\r\n this._importPromises.length = 0;\r\n\r\n if (importPromises) {\r\n this._importPromises.push(...importPromises);\r\n }\r\n\r\n const useWebGPU = this.options.engine.isWebGPU && !EffectWrapper.ForceGLSL;\r\n\r\n this._gatherImports(useWebGPU, this._importPromises);\r\n if (extraInitializations !== undefined) {\r\n extraInitializations(useWebGPU, this._importPromises);\r\n }\r\n\r\n if (useWebGPU && this._webGPUReady) {\r\n this.options.shaderLanguage = ShaderLanguage.WGSL;\r\n }\r\n\r\n if (!blockCompilation) {\r\n this.updateEffect(defines);\r\n }\r\n }\r\n\r\n /**\r\n * Updates the effect with the current effect wrapper compile time values and recompiles the shader.\r\n * @param defines Define statements that should be added at the beginning of the shader. (default: null)\r\n * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)\r\n * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)\r\n * @param indexParameters The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n * @param onCompiled Called when the shader has been compiled.\r\n * @param onError Called if there is an error when compiling a shader.\r\n * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)\r\n * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)\r\n */\r\n public updateEffect(\r\n defines: Nullable<string> = null,\r\n uniforms: Nullable<string[]> = null,\r\n samplers: Nullable<string[]> = null,\r\n indexParameters?: any,\r\n onCompiled?: (effect: Effect) => void,\r\n onError?: (effect: Effect, errors: string) => void,\r\n vertexUrl?: string,\r\n fragmentUrl?: string\r\n ) {\r\n const customShaderCodeProcessing = EffectWrapper._GetShaderCodeProcessing(this.name);\r\n if (customShaderCodeProcessing?.defineCustomBindings) {\r\n const newUniforms = uniforms?.slice() ?? [];\r\n newUniforms.push(...this.options.uniforms);\r\n\r\n const newSamplers = samplers?.slice() ?? [];\r\n newSamplers.push(...this.options.samplers);\r\n\r\n defines = customShaderCodeProcessing.defineCustomBindings(this.name, defines, newUniforms, newSamplers);\r\n uniforms = newUniforms;\r\n samplers = newSamplers;\r\n }\r\n\r\n this.options.defines = defines || \"\";\r\n\r\n const waitImportsLoaded =\r\n this._shadersLoaded || this._importPromises.length === 0\r\n ? undefined\r\n : async () => {\r\n await Promise.all(this._importPromises);\r\n this._shadersLoaded = true;\r\n };\r\n\r\n let extraInitializationsAsync: (() => Promise<void>) | undefined;\r\n if (this.options.extraInitializationsAsync) {\r\n extraInitializationsAsync = async () => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n waitImportsLoaded?.();\r\n await this.options.extraInitializationsAsync();\r\n };\r\n } else {\r\n extraInitializationsAsync = waitImportsLoaded;\r\n }\r\n\r\n if (this.options.useShaderStore) {\r\n this._drawWrapper.effect = this.options.engine.createEffect(\r\n { vertex: vertexUrl ?? this._shaderPath.vertex, fragment: fragmentUrl ?? this._shaderPath.fragment },\r\n {\r\n attributes: this.options.attributeNames,\r\n uniformsNames: uniforms || this.options.uniforms,\r\n uniformBuffersNames: this.options.uniformBuffers,\r\n samplers: samplers || this.options.samplers,\r\n defines: defines !== null ? defines : \"\",\r\n fallbacks: null,\r\n onCompiled: onCompiled ?? this.options.onCompiled,\r\n onError: onError ?? null,\r\n indexParameters: indexParameters || this.options.indexParameters,\r\n processCodeAfterIncludes: customShaderCodeProcessing?.processCodeAfterIncludes\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing.processCodeAfterIncludes!(this.name, shaderType, code)\r\n : null,\r\n processFinalCode: customShaderCodeProcessing?.processFinalCode\r\n ? (shaderType: string, code: string) => customShaderCodeProcessing.processFinalCode!(this.name, shaderType, code)\r\n : null,\r\n shaderLanguage: this.options.shaderLanguage,\r\n extraInitializationsAsync,\r\n },\r\n this.options.engine\r\n );\r\n } else {\r\n this._drawWrapper.effect = new Effect(\r\n this._shaderPath,\r\n this.options.attributeNames,\r\n uniforms || this.options.uniforms,\r\n samplers || this.options.samplerNames,\r\n this.options.engine,\r\n defines,\r\n undefined,\r\n onCompiled || this.options.onCompiled,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this.options.shaderLanguage,\r\n extraInitializationsAsync\r\n );\r\n }\r\n\r\n this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect);\r\n }\r\n\r\n /**\r\n * Binds the data to the effect.\r\n * @param noDefaultBindings if true, the default bindings (scale and alpha mode) will not be set.\r\n */\r\n public bind(noDefaultBindings = false) {\r\n if (this.options.useAsPostProcess && !noDefaultBindings) {\r\n this.options.engine.setAlphaMode(this.alphaMode);\r\n this.drawWrapper.effect!.setFloat2(\"scale\", 1, 1);\r\n }\r\n\r\n EffectWrapper._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name, this._drawWrapper.effect!);\r\n }\r\n\r\n /**\r\n * Disposes of the effect wrapper\r\n * @param _ignored kept for backward compatibility\r\n */\r\n public dispose(_ignored: boolean = false) {\r\n if (this._onContextRestoredObserver) {\r\n this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n this.onEffectCreatedObservable.clear();\r\n this._drawWrapper.dispose(true);\r\n }\r\n}\r\n"]}
@@ -185,7 +185,7 @@ export interface PLYHeader {
185
185
  export declare class GaussianSplattingMesh extends Mesh {
186
186
  private _vertexCount;
187
187
  private _worker;
188
- private _modelViewMatrix;
188
+ private _modelViewProjectionMatrix;
189
189
  private _depthMix;
190
190
  private _canPostToWorker;
191
191
  private _readyToDisplay;
@@ -210,6 +210,11 @@ export declare class GaussianSplattingMesh extends Mesh {
210
210
  private _shDegree;
211
211
  private static readonly _BatchSize;
212
212
  private _cameraViewInfos;
213
+ private static readonly _DefaultViewUpdateThreshold;
214
+ /**
215
+ * Cosine value of the angle threshold to update view dependent splat sorting. Default is 0.0001.
216
+ */
217
+ viewUpdateThreshold: number;
213
218
  protected _disableDepthSort: boolean;
214
219
  /**
215
220
  * If true, disables depth sorting of the splats (default: false)
@@ -296,7 +296,7 @@ export class GaussianSplattingMesh extends Mesh {
296
296
  super(name, scene);
297
297
  this._vertexCount = 0;
298
298
  this._worker = null;
299
- this._modelViewMatrix = Matrix.Identity();
299
+ this._modelViewProjectionMatrix = Matrix.Identity();
300
300
  this._canPostToWorker = true;
301
301
  this._readyToDisplay = false;
302
302
  this._covariancesATexture = null;
@@ -315,6 +315,10 @@ export class GaussianSplattingMesh extends Mesh {
315
315
  this._sortIsDirty = false;
316
316
  this._shDegree = 0;
317
317
  this._cameraViewInfos = new Map();
318
+ /**
319
+ * Cosine value of the angle threshold to update view dependent splat sorting. Default is 0.0001.
320
+ */
321
+ this.viewUpdateThreshold = GaussianSplattingMesh._DefaultViewUpdateThreshold;
318
322
  this._disableDepthSort = false;
319
323
  this._loadingPromise = null;
320
324
  this.subMeshes = [];
@@ -378,11 +382,14 @@ export class GaussianSplattingMesh extends Mesh {
378
382
  return true;
379
383
  }
380
384
  _getCameraDirection(camera) {
381
- const cameraMatrix = camera.getViewMatrix();
382
- this.getWorldMatrix().multiplyToRef(cameraMatrix, this._modelViewMatrix);
385
+ const cameraViewMatrix = camera.getViewMatrix();
386
+ const cameraProjectionMatrix = camera.getProjectionMatrix();
387
+ const cameraViewProjectionMatrix = TmpVectors.Matrix[0];
388
+ cameraViewMatrix.multiplyToRef(cameraProjectionMatrix, cameraViewProjectionMatrix);
389
+ this.getWorldMatrix().multiplyToRef(cameraViewProjectionMatrix, this._modelViewProjectionMatrix);
383
390
  // return vector used to compute distance to camera
384
391
  const localDirection = TmpVectors.Vector3[1];
385
- localDirection.set(this._modelViewMatrix.m[2], this._modelViewMatrix.m[6], this._modelViewMatrix.m[10]);
392
+ localDirection.set(this._modelViewProjectionMatrix.m[8], this._modelViewProjectionMatrix.m[9], this._modelViewProjectionMatrix.m[10]);
386
393
  localDirection.normalize();
387
394
  return localDirection;
388
395
  }
@@ -439,20 +446,19 @@ export class GaussianSplattingMesh extends Mesh {
439
446
  const cameraDirection = this._getCameraDirection(camera);
440
447
  const previousCameraDirection = cameraViewInfos.cameraDirection;
441
448
  const dot = Vector3.Dot(cameraDirection, previousCameraDirection);
442
- if ((forced || Math.abs(dot - 1) >= 0.01) && this._canPostToWorker) {
449
+ if ((forced || Math.abs(dot - 1) >= this.viewUpdateThreshold) && this._canPostToWorker) {
443
450
  cameraViewInfos.cameraDirection.copyFrom(cameraDirection);
444
451
  cameraViewInfos.frameIdLastUpdate = frameId;
445
452
  this._canPostToWorker = false;
446
453
  if (this._worker) {
447
454
  this._worker.postMessage({
448
- view: this._modelViewMatrix.m,
455
+ modelViewProjection: this._modelViewProjectionMatrix.m,
449
456
  depthMix: this._depthMix,
450
- useRightHandedSystem: this._scene.useRightHandedSystem,
451
457
  cameraId: camera.uniqueId,
452
458
  }, [this._depthMix.buffer]);
453
459
  }
454
460
  else if (_native && _native.sortSplats) {
455
- _native.sortSplats(this._modelViewMatrix, this._splatPositions, this._splatIndex, this._scene.useRightHandedSystem);
461
+ _native.sortSplats(this._modelViewProjectionMatrix, this._splatPositions, this._splatIndex, this._scene.useRightHandedSystem);
456
462
  if (cameraViewInfos.splatIndexBufferSet) {
457
463
  cameraViewInfos.mesh.thinInstanceBufferUpdated("splatIndex");
458
464
  }
@@ -1220,7 +1226,7 @@ export class GaussianSplattingMesh extends Mesh {
1220
1226
  newGS.makeGeometryUnique();
1221
1227
  newGS._vertexCount = this._vertexCount;
1222
1228
  newGS._copyTextures(this);
1223
- newGS._modelViewMatrix = Matrix.Identity();
1229
+ newGS._modelViewProjectionMatrix = Matrix.Identity();
1224
1230
  newGS._splatPositions = this._splatPositions;
1225
1231
  newGS._readyToDisplay = false;
1226
1232
  newGS._disableDepthSort = this._disableDepthSort;
@@ -1555,6 +1561,7 @@ GaussianSplattingMesh._SplatBatchSize = 327680;
1555
1561
  // batch size between 2 yield calls during the PLY to splat conversion.
1556
1562
  GaussianSplattingMesh._PlyConversionBatchSize = 32768;
1557
1563
  GaussianSplattingMesh._BatchSize = 16; // 16 splats per instance
1564
+ GaussianSplattingMesh._DefaultViewUpdateThreshold = 1e-4;
1558
1565
  /**
1559
1566
  * Set the number of batch (a batch is 16384 splats) after which a display update is performed
1560
1567
  * A value of 0 (default) means display update will not happens before splat is ready.
@@ -1573,11 +1580,11 @@ GaussianSplattingMesh._CreateWorker = function (self) {
1573
1580
  // udpate on view changed
1574
1581
  else {
1575
1582
  const cameraId = e.data.cameraId;
1576
- const viewProj = e.data.view;
1583
+ const modelViewProjection = e.data.modelViewProjection;
1577
1584
  const vertexCountPadded = (positions.length / 4 + 15) & ~0xf;
1578
- if (!positions || !viewProj) {
1585
+ if (!positions || !modelViewProjection) {
1579
1586
  // Sanity check, it shouldn't happen!
1580
- throw new Error("positions or view is not defined!");
1587
+ throw new Error("positions or modelViewProjection matrix is not defined!");
1581
1588
  }
1582
1589
  depthMix = e.data.depthMix;
1583
1590
  indices = new Uint32Array(depthMix.buffer);
@@ -1586,12 +1593,9 @@ GaussianSplattingMesh._CreateWorker = function (self) {
1586
1593
  for (let j = 0; j < vertexCountPadded; j++) {
1587
1594
  indices[2 * j] = j;
1588
1595
  }
1589
- let depthFactor = -1;
1590
- if (e.data.useRightHandedSystem) {
1591
- depthFactor = 1;
1592
- }
1593
1596
  for (let j = 0; j < vertexCountPadded; j++) {
1594
- floatMix[2 * j + 1] = 10000 + (viewProj[2] * positions[4 * j + 0] + viewProj[6] * positions[4 * j + 1] + viewProj[10] * positions[4 * j + 2]) * depthFactor;
1597
+ floatMix[2 * j + 1] =
1598
+ 10000 - (modelViewProjection[2] * positions[4 * j + 0] + modelViewProjection[6] * positions[4 * j + 1] + modelViewProjection[10] * positions[4 * j + 2]);
1595
1599
  }
1596
1600
  depthMix.sort();
1597
1601
  self.postMessage({ depthMix, cameraId }, [depthMix.buffer]);