@babylonjs/core 8.39.0 → 8.39.2
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/Interfaces/ISoundOptions.d.ts +1 -1
- package/Audio/Interfaces/ISoundOptions.js.map +1 -1
- package/Audio/audioEngine.d.ts +3 -4
- package/Audio/audioEngine.js +9 -6
- package/Audio/audioEngine.js.map +1 -1
- package/Audio/sound.d.ts +33 -54
- package/Audio/sound.js +450 -718
- package/Audio/sound.js.map +1 -1
- package/AudioV2/abstractAudio/abstractAudioOutNode.d.ts +1 -1
- package/AudioV2/abstractAudio/abstractAudioOutNode.js +1 -1
- package/AudioV2/abstractAudio/abstractAudioOutNode.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.d.ts +1 -1
- package/AudioV2/abstractAudio/abstractSound.js +2 -2
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSoundSource.d.ts +11 -3
- package/AudioV2/abstractAudio/abstractSoundSource.js +37 -1
- package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -1
- package/AudioV2/abstractAudio/audioBus.d.ts +8 -3
- package/AudioV2/abstractAudio/audioBus.js +24 -1
- package/AudioV2/abstractAudio/audioBus.js.map +1 -1
- package/AudioV2/abstractAudio/staticSound.d.ts +1 -1
- package/AudioV2/abstractAudio/staticSound.js +2 -2
- package/AudioV2/abstractAudio/staticSound.js.map +1 -1
- package/AudioV2/abstractAudio/streamingSound.d.ts +1 -1
- package/AudioV2/abstractAudio/streamingSound.js +2 -2
- package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.d.ts +1 -1
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js +3 -0
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +1 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +1 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +12 -2
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +2 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +6 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js +25 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
- package/AudioV2/webAudio/components/webAudioParameterComponent.js +2 -2
- package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +3 -0
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +14 -17
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js +1 -0
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js +1 -0
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js.map +1 -1
- package/AudioV2/webAudio/webAudioBus.d.ts +2 -7
- package/AudioV2/webAudio/webAudioBus.js +4 -24
- package/AudioV2/webAudio/webAudioBus.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.js +1 -0
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioSoundSource.d.ts +2 -7
- package/AudioV2/webAudio/webAudioSoundSource.js +3 -24
- package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +3 -7
- package/AudioV2/webAudio/webAudioStaticSound.js +13 -26
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -7
- package/AudioV2/webAudio/webAudioStreamingSound.js +6 -23
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Cameras/arcRotateCamera.js +4 -5
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +2 -2
- package/Cameras/geospatialCamera.js +13 -12
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -2
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +8 -9
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.d.ts +74 -0
- package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.js +179 -0
- package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/index.d.ts +2 -0
- package/FrameGraph/Node/Blocks/index.js +2 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Blocks/lightingVolumeBlock.d.ts +43 -0
- package/FrameGraph/Node/Blocks/lightingVolumeBlock.js +93 -0
- package/FrameGraph/Node/Blocks/lightingVolumeBlock.js.map +1 -0
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.d.ts +31 -0
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.js +56 -0
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +2 -2
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.d.ts +30 -0
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js +57 -0
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.d.ts +91 -0
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js +177 -0
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +2 -2
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.js +2 -2
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/index.d.ts +2 -0
- package/FrameGraph/index.js +2 -0
- package/FrameGraph/index.js.map +1 -1
- package/Lights/lightingVolume.d.ts +3 -6
- package/Lights/lightingVolume.js +41 -30
- package/Lights/lightingVolume.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +7 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +19 -5
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +1 -0
- package/Materials/uniformBuffer.js +8 -1
- package/Materials/uniformBuffer.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +5 -2
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +138 -45
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Physics/v2/characterController.d.ts +42 -2
- package/Physics/v2/characterController.js +140 -46
- package/Physics/v2/characterController.js.map +1 -1
- package/Shaders/volumetricLightingBlendVolume.fragment.d.ts +5 -0
- package/Shaders/volumetricLightingBlendVolume.fragment.js +21 -0
- package/Shaders/volumetricLightingBlendVolume.fragment.js.map +1 -0
- package/Shaders/volumetricLightingRenderVolume.fragment.d.ts +7 -0
- package/Shaders/volumetricLightingRenderVolume.fragment.js +25 -0
- package/Shaders/volumetricLightingRenderVolume.fragment.js.map +1 -0
- package/Shaders/volumetricLightingRenderVolume.vertex.d.ts +9 -0
- package/Shaders/volumetricLightingRenderVolume.vertex.js +18 -0
- package/Shaders/volumetricLightingRenderVolume.vertex.js.map +1 -0
- package/ShadersWGSL/gaussianSplattingDepth.fragment.d.ts +0 -1
- package/ShadersWGSL/gaussianSplattingDepth.fragment.js +0 -2
- package/ShadersWGSL/gaussianSplattingDepth.fragment.js.map +1 -1
- package/ShadersWGSL/volumetricLightingBlendVolume.fragment.d.ts +5 -0
- package/ShadersWGSL/volumetricLightingBlendVolume.fragment.js +22 -0
- package/ShadersWGSL/volumetricLightingBlendVolume.fragment.js.map +1 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.fragment.d.ts +7 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.fragment.js +27 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.fragment.js.map +1 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.vertex.d.ts +7 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.vertex.js +17 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.vertex.js.map +1 -0
- package/States/IStencilState.d.ts +48 -2
- package/States/IStencilState.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postProcessTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/postProcessTask.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAAc;IAsFzD;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACxC,CAAC;IAQD;;;;;OAKG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,WAA0B;QACxE,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAlG5B;;WAE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C,CAAC;YACjD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC/D,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;gBACpC,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;oBACnC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;wBAChB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBACvC,CAAC;oBACD,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;gBACpF,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphTextureHandle,\r\n DrawWrapper,\r\n FrameGraphRenderPass,\r\n FrameGraphRenderContext,\r\n EffectWrapper,\r\n IStencilState,\r\n IViewportLike,\r\n Nullable,\r\n} from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task which applies a post process.\r\n */\r\nexport class FrameGraphPostProcessTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the post process on.\r\n * It's allowed to be undefined if the post process does not require a source texture.\r\n * In that case, targetTexture must be provided.\r\n */\r\n public sourceTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the source texture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The target texture to render the post process to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The stencil state to use for the post process (optional).\r\n */\r\n public stencilState?: IStencilState;\r\n\r\n /**\r\n * The depth attachment texture to use for the post process (optional).\r\n * Note that a post-process task never writes to the depth buffer: attaching a depth texture is only useful if you want to test against the depth/stencil aspect or write to the stencil buffer.\r\n */\r\n public depthAttachmentTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * If true, the depth attachment will be read-only.\r\n * This means that the post process will not write to the depth buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * If true, the stencil attachment will be read-only.\r\n * This means that the post process will not write to the stencil buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /**\r\n * If true, color write will be disabled when applying the post process.\r\n * This means that the post process will not write to the color buffer.\r\n */\r\n public disableColorWrite = false;\r\n\r\n /**\r\n * If true, the post process will be generated by a back face full-screen quad (CW order).\r\n */\r\n public drawBackFace = false;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * The viewport to use when applying the post process.\r\n * If set to null, the currently active viewport is used.\r\n * If undefined (default), the viewport is reset to a full screen viewport before applying the post process.\r\n */\r\n public viewport?: Nullable<IViewportLike>;\r\n\r\n /**\r\n * The output texture of the post process.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthAttachmentTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthAttachmentTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The post process to apply.\r\n */\r\n public readonly postProcess: EffectWrapper;\r\n\r\n /**\r\n * The draw wrapper used by the post process\r\n */\r\n public get drawWrapper() {\r\n return this._postProcessDrawWrapper;\r\n }\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n protected _sourceWidth: number;\r\n protected _sourceHeight: number;\r\n protected _outputWidth: number;\r\n protected _outputHeight: number;\r\n\r\n /**\r\n * Constructs a new post process task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param postProcess The post process to apply.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, postProcess: EffectWrapper) {\r\n super(name, frameGraph);\r\n\r\n this.postProcess = postProcess;\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthAttachmentTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.postProcess.isReady();\r\n }\r\n\r\n public record(\r\n skipCreationOfDisabledPasses = false,\r\n additionalExecute?: (context: FrameGraphRenderContext) => void,\r\n additionalBindings?: (context: FrameGraphRenderContext) => void\r\n ): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined && this.targetTexture === undefined) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture or targetTexture is required`);\r\n }\r\n\r\n const sourceTextureCreationOptions = this.sourceTexture !== undefined ? this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture) : undefined;\r\n if (sourceTextureCreationOptions) {\r\n sourceTextureCreationOptions.options.samples = 1;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this.name, sourceTextureCreationOptions);\r\n if (this.depthAttachmentTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthAttachmentTexture, this.depthAttachmentTexture);\r\n }\r\n\r\n if (sourceTextureCreationOptions) {\r\n const sourceSize = this._frameGraph.textureManager.getTextureAbsoluteDimensions(sourceTextureCreationOptions);\r\n\r\n this._sourceWidth = sourceSize.width;\r\n this._sourceHeight = sourceSize.height;\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.outputTexture);\r\n\r\n this._outputWidth = outputTextureDescription.size.width;\r\n this._outputHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.depthReadOnly = this.depthReadOnly;\r\n pass.stencilReadOnly = this.stencilReadOnly;\r\n\r\n pass.addDependencies(this.sourceTexture);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setRenderTargetDepth(this.depthAttachmentTexture);\r\n pass.setExecuteFunc((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n }\r\n additionalExecute?.(context);\r\n if (this.viewport) {\r\n context.setViewport(this.viewport);\r\n }\r\n context.applyFullScreenEffect(\r\n this._postProcessDrawWrapper,\r\n () => {\r\n if (this.sourceTexture !== undefined) {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture);\r\n }\r\n additionalBindings?.(context);\r\n this.postProcess.bind();\r\n },\r\n this.stencilState,\r\n this.disableColorWrite,\r\n this.drawBackFace,\r\n this.depthTest,\r\n this.viewport !== undefined\r\n );\r\n });\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.depthReadOnly = this.depthReadOnly;\r\n passDisabled.stencilReadOnly = this.stencilReadOnly;\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setRenderTargetDepth(this.depthAttachmentTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n if (this.viewport) {\r\n context.setViewport(this.viewport);\r\n }\r\n context.copyTexture(this.sourceTexture, undefined, this.viewport !== undefined);\r\n }\r\n });\r\n }\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose(): void {\r\n this.postProcess.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"postProcessTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/postProcessTask.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAAc;IAsFzD;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACxC,CAAC;IAQD;;;;;OAKG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,WAA0B;QACxE,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAlG5B;;WAEG;QACI,uBAAkB,GAAG,SAAS,CAAC,6BAA6B,CAAC;QAmBpE;;;;;WAKG;QACI,kBAAa,GAAG,KAAK,CAAC;QAE7B;;;;;WAKG;QACI,oBAAe,GAAG,KAAK,CAAC;QAE/B;;;WAGG;QACI,sBAAiB,GAAG,KAAK,CAAC;QAEjC;;WAEG;QACI,iBAAY,GAAG,KAAK,CAAC;QAE5B;;WAEG;QACI,cAAS,GAAG,IAAI,CAAC;QAgDpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC;QAE5D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;QAC5E,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;IAC/F,CAAC;IAEe,OAAO;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IAC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andle,\r\n DrawWrapper,\r\n FrameGraphRenderPass,\r\n FrameGraphRenderContext,\r\n EffectWrapper,\r\n IViewportLike,\r\n Nullable,\r\n IStencilStateProperties,\r\n} from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task which applies a post process.\r\n */\r\nexport class FrameGraphPostProcessTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the post process on.\r\n * It's allowed to be undefined if the post process does not require a source texture.\r\n * In that case, targetTexture must be provided.\r\n */\r\n public sourceTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the source texture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The target texture to render the post process to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The stencil state to use for the post process (optional).\r\n */\r\n public stencilState?: IStencilStateProperties;\r\n\r\n /**\r\n * The depth attachment texture to use for the post process (optional).\r\n * Note that a post-process task never writes to the depth buffer: attaching a depth texture is only useful if you want to test against the depth/stencil aspect or write to the stencil buffer.\r\n */\r\n public depthAttachmentTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * If true, the depth attachment will be read-only.\r\n * This means that the post process will not write to the depth buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * If true, the stencil attachment will be read-only.\r\n * This means that the post process will not write to the stencil buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /**\r\n * If true, color write will be disabled when applying the post process.\r\n * This means that the post process will not write to the color buffer.\r\n */\r\n public disableColorWrite = false;\r\n\r\n /**\r\n * If true, the post process will be generated by a back face full-screen quad (CW order).\r\n */\r\n public drawBackFace = false;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * The viewport to use when applying the post process.\r\n * If set to null, the currently active viewport is used.\r\n * If undefined (default), the viewport is reset to a full screen viewport before applying the post process.\r\n */\r\n public viewport?: Nullable<IViewportLike>;\r\n\r\n /**\r\n * The output texture of the post process.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthAttachmentTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthAttachmentTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The post process to apply.\r\n */\r\n public readonly postProcess: EffectWrapper;\r\n\r\n /**\r\n * The draw wrapper used by the post process\r\n */\r\n public get drawWrapper() {\r\n return this._postProcessDrawWrapper;\r\n }\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n protected _sourceWidth: number;\r\n protected _sourceHeight: number;\r\n protected _outputWidth: number;\r\n protected _outputHeight: number;\r\n\r\n /**\r\n * Constructs a new post process task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param postProcess The post process to apply.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, postProcess: EffectWrapper) {\r\n super(name, frameGraph);\r\n\r\n this.postProcess = postProcess;\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthAttachmentTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.postProcess.isReady();\r\n }\r\n\r\n public record(\r\n skipCreationOfDisabledPasses = false,\r\n additionalExecute?: (context: FrameGraphRenderContext) => void,\r\n additionalBindings?: (context: FrameGraphRenderContext) => void\r\n ): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined && this.targetTexture === undefined) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture or targetTexture is required`);\r\n }\r\n\r\n const sourceTextureCreationOptions = this.sourceTexture !== undefined ? this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture) : undefined;\r\n if (sourceTextureCreationOptions) {\r\n sourceTextureCreationOptions.options.samples = 1;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this.name, sourceTextureCreationOptions);\r\n if (this.depthAttachmentTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthAttachmentTexture, this.depthAttachmentTexture);\r\n }\r\n\r\n if (sourceTextureCreationOptions) {\r\n const sourceSize = this._frameGraph.textureManager.getTextureAbsoluteDimensions(sourceTextureCreationOptions);\r\n\r\n this._sourceWidth = sourceSize.width;\r\n this._sourceHeight = sourceSize.height;\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.outputTexture);\r\n\r\n this._outputWidth = outputTextureDescription.size.width;\r\n this._outputHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.depthReadOnly = this.depthReadOnly;\r\n pass.stencilReadOnly = this.stencilReadOnly;\r\n\r\n pass.addDependencies(this.sourceTexture);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setRenderTargetDepth(this.depthAttachmentTexture);\r\n pass.setExecuteFunc((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n }\r\n additionalExecute?.(context);\r\n if (this.viewport) {\r\n context.setViewport(this.viewport);\r\n }\r\n context.applyFullScreenEffect(\r\n this._postProcessDrawWrapper,\r\n () => {\r\n if (this.sourceTexture !== undefined) {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture);\r\n }\r\n additionalBindings?.(context);\r\n this.postProcess.bind();\r\n },\r\n this.stencilState,\r\n this.disableColorWrite,\r\n this.drawBackFace,\r\n this.depthTest,\r\n this.viewport !== undefined\r\n );\r\n });\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.depthReadOnly = this.depthReadOnly;\r\n passDisabled.stencilReadOnly = this.stencilReadOnly;\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setRenderTargetDepth(this.depthAttachmentTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n if (this.viewport) {\r\n context.setViewport(this.viewport);\r\n }\r\n context.copyTexture(this.sourceTexture, undefined, this.viewport !== undefined);\r\n }\r\n });\r\n }\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose(): void {\r\n this.postProcess.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AbstractEngine, Camera, EffectWrapperCreationOptions, FrameGraph, FrameGraphRenderPass, FrameGraphTextureHandle, Nullable } from "../../../index.js";
|
|
2
|
+
import { Vector3 } from "../../../Maths/math.vector.js";
|
|
3
|
+
import { ThinPassPostProcess } from "../../../PostProcesses/thinPassPostProcess.js";
|
|
4
|
+
import { FrameGraphPostProcessTask } from "./postProcessTask.js";
|
|
5
|
+
import "../../../Shaders/volumetricLightingBlendVolume.fragment.js";
|
|
6
|
+
import "../../../ShadersWGSL/volumetricLightingBlendVolume.fragment.js";
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
declare class VolumetricLightingBlendVolumeThinPostProcess extends ThinPassPostProcess {
|
|
11
|
+
camera: Camera;
|
|
12
|
+
outputTextureWidth: number;
|
|
13
|
+
outputTextureHeight: number;
|
|
14
|
+
extinction: Vector3;
|
|
15
|
+
enableExtinction: boolean;
|
|
16
|
+
private _invProjection;
|
|
17
|
+
constructor(name: string, engine?: Nullable<AbstractEngine>, enableExtinction?: boolean, options?: EffectWrapperCreationOptions);
|
|
18
|
+
bind(noDefaultBindings?: boolean): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare class FrameGraphVolumetricLightingBlendVolumeTask extends FrameGraphPostProcessTask {
|
|
24
|
+
readonly postProcess: VolumetricLightingBlendVolumeThinPostProcess;
|
|
25
|
+
depthTexture: FrameGraphTextureHandle;
|
|
26
|
+
camera: Camera;
|
|
27
|
+
constructor(name: string, frameGraph: FrameGraph, enableExtinction?: boolean);
|
|
28
|
+
record(skipCreationOfDisabledPasses?: boolean): FrameGraphRenderPass;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Vector3, Matrix } from "../../../Maths/math.vector.js";
|
|
2
|
+
|
|
3
|
+
import { ThinPassPostProcess } from "../../../PostProcesses/thinPassPostProcess.js";
|
|
4
|
+
import { FrameGraphPostProcessTask } from "./postProcessTask.js";
|
|
5
|
+
import "../../../Shaders/volumetricLightingBlendVolume.fragment.js";
|
|
6
|
+
import "../../../ShadersWGSL/volumetricLightingBlendVolume.fragment.js";
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
class VolumetricLightingBlendVolumeThinPostProcess extends ThinPassPostProcess {
|
|
11
|
+
constructor(name, engine = null, enableExtinction = false, options) {
|
|
12
|
+
super(name, engine, {
|
|
13
|
+
...options,
|
|
14
|
+
fragmentShader: "volumetricLightingBlendVolume",
|
|
15
|
+
samplers: ["depthSampler"],
|
|
16
|
+
uniforms: ["invProjection", "outputTextureSize", "extinction"],
|
|
17
|
+
defines: enableExtinction ? ["#define DUAL_SOURCE_BLENDING", "#define USE_EXTINCTION"] : undefined,
|
|
18
|
+
});
|
|
19
|
+
this.outputTextureWidth = 0;
|
|
20
|
+
this.outputTextureHeight = 0;
|
|
21
|
+
this.extinction = new Vector3(0, 0, 0);
|
|
22
|
+
this.enableExtinction = false;
|
|
23
|
+
this._invProjection = new Matrix();
|
|
24
|
+
this.alphaMode = enableExtinction ? 20 : 1;
|
|
25
|
+
}
|
|
26
|
+
bind(noDefaultBindings = false) {
|
|
27
|
+
super.bind(noDefaultBindings);
|
|
28
|
+
const effect = this.drawWrapper.effect;
|
|
29
|
+
this._invProjection.copyFrom(this.camera.getProjectionMatrix());
|
|
30
|
+
this._invProjection.invert();
|
|
31
|
+
effect.setMatrix("invProjection", this._invProjection);
|
|
32
|
+
effect.setFloat2("outputTextureSize", this.outputTextureWidth, this.outputTextureHeight);
|
|
33
|
+
effect.setVector3("extinction", this.extinction);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export class FrameGraphVolumetricLightingBlendVolumeTask extends FrameGraphPostProcessTask {
|
|
40
|
+
constructor(name, frameGraph, enableExtinction = false) {
|
|
41
|
+
super(name, frameGraph, new VolumetricLightingBlendVolumeThinPostProcess(name, frameGraph.engine, enableExtinction));
|
|
42
|
+
}
|
|
43
|
+
record(skipCreationOfDisabledPasses = false) {
|
|
44
|
+
if (this.sourceTexture === undefined || this.depthTexture === undefined || this.camera === undefined) {
|
|
45
|
+
throw new Error(`FrameGraphVolumetricLightingBlendVolumeTask "${this.name}": sourceTexture, depthTexture and camera are required`);
|
|
46
|
+
}
|
|
47
|
+
const pass = super.record(skipCreationOfDisabledPasses, undefined, (context) => {
|
|
48
|
+
this.postProcess.camera = this.camera;
|
|
49
|
+
context.bindTextureHandle(this._postProcessDrawWrapper.effect, "depthSampler", this.depthTexture);
|
|
50
|
+
});
|
|
51
|
+
pass.addDependencies(this.depthTexture);
|
|
52
|
+
this.postProcess.outputTextureWidth = this._outputWidth;
|
|
53
|
+
this.postProcess.outputTextureHeight = this._outputHeight;
|
|
54
|
+
return pass;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=volumetricLightingBlendVolumeTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volumetricLightingBlendVolumeTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,sCAA+B;AACzD,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,mBAAmB,EAAE,sDAA+C;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,oEAA6D;AAC7D,wEAAiE;AAEjE;;GAEG;AACH,MAAM,4CAA6C,SAAQ,mBAAmB;IAa1E,YAAY,IAAY,EAAE,SAAmC,IAAI,EAAE,gBAAgB,GAAG,KAAK,EAAE,OAAsC;QAC/H,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE;YAChB,GAAG,OAAO;YACV,cAAc,EAAE,+BAA+B;YAC/C,QAAQ,EAAE,CAAC,cAAc,CAAC;YAC1B,QAAQ,EAAE,CAAC,eAAe,EAAE,mBAAmB,EAAE,YAAY,CAAC;YAC9D,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,8BAA8B,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC,SAAS;SACrG,CAAC,CAAC;QAjBA,uBAAkB,GAAG,CAAC,CAAC;QAEvB,wBAAmB,GAAG,CAAC,CAAC;QAExB,eAAU,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAElC,qBAAgB,GAAG,KAAK,CAAC;QAa5B,IAAI,CAAC,cAAc,GAAG,IAAI,MAAM,EAAE,CAAC;QACnC,IAAI,CAAC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,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;YAC3E,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YACtC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACvG,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAExC,IAAI,CAAC,WAAW,CAAC,kBAAkB,GAAG,IAAI,CAAC,YAAY,CAAC;QACxD,IAAI,CAAC,WAAW,CAAC,mBAAmB,GAAG,IAAI,CAAC,aAAa,CAAC;QAE1D,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { AbstractEngine, Camera, EffectWrapperCreationOptions, FrameGraph, FrameGraphRenderPass, FrameGraphTextureHandle, Nullable } from \"core/index\";\r\nimport { Vector3, Matrix } from \"core/Maths/math.vector\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { ThinPassPostProcess } from \"core/PostProcesses/thinPassPostProcess\";\r\nimport { FrameGraphPostProcessTask } from \"./postProcessTask\";\r\n\r\nimport \"core/Shaders/volumetricLightingBlendVolume.fragment\";\r\nimport \"core/ShadersWGSL/volumetricLightingBlendVolume.fragment\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass VolumetricLightingBlendVolumeThinPostProcess extends ThinPassPostProcess {\r\n public camera: Camera;\r\n\r\n public outputTextureWidth = 0;\r\n\r\n public outputTextureHeight = 0;\r\n\r\n public extinction = new Vector3(0, 0, 0);\r\n\r\n public enableExtinction = false;\r\n\r\n private _invProjection: Matrix;\r\n\r\n constructor(name: string, engine: Nullable<AbstractEngine> = null, enableExtinction = false, options?: EffectWrapperCreationOptions) {\r\n super(name, engine, {\r\n ...options,\r\n fragmentShader: \"volumetricLightingBlendVolume\",\r\n samplers: [\"depthSampler\"],\r\n uniforms: [\"invProjection\", \"outputTextureSize\", \"extinction\"],\r\n defines: enableExtinction ? [\"#define DUAL_SOURCE_BLENDING\", \"#define USE_EXTINCTION\"] : undefined,\r\n });\r\n\r\n this._invProjection = new Matrix();\r\n this.alphaMode = enableExtinction ? Constants.ALPHA_DUAL_SRC0_ADD_SRC1xDST : Constants.ALPHA_ADD;\r\n }\r\n\r\n public override bind(noDefaultBindings = false) {\r\n super.bind(noDefaultBindings);\r\n\r\n const effect = this.drawWrapper.effect!;\r\n\r\n this._invProjection.copyFrom(this.camera.getProjectionMatrix());\r\n this._invProjection.invert();\r\n\r\n effect.setMatrix(\"invProjection\", this._invProjection);\r\n effect.setFloat2(\"outputTextureSize\", this.outputTextureWidth, this.outputTextureHeight);\r\n effect.setVector3(\"extinction\", this.extinction);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class FrameGraphVolumetricLightingBlendVolumeTask extends FrameGraphPostProcessTask {\r\n public override readonly postProcess: VolumetricLightingBlendVolumeThinPostProcess;\r\n\r\n public depthTexture: FrameGraphTextureHandle;\r\n\r\n public camera: Camera;\r\n\r\n constructor(name: string, frameGraph: FrameGraph, enableExtinction = false) {\r\n super(name, frameGraph, new VolumetricLightingBlendVolumeThinPostProcess(name, frameGraph.engine, enableExtinction));\r\n }\r\n\r\n public override record(skipCreationOfDisabledPasses = false): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined || this.depthTexture === undefined || this.camera === undefined) {\r\n throw new Error(`FrameGraphVolumetricLightingBlendVolumeTask \"${this.name}\": sourceTexture, depthTexture and camera are required`);\r\n }\r\n\r\n const pass = super.record(skipCreationOfDisabledPasses, undefined, (context) => {\r\n this.postProcess.camera = this.camera;\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"depthSampler\", this.depthTexture);\r\n });\r\n\r\n pass.addDependencies(this.depthTexture);\r\n\r\n this.postProcess.outputTextureWidth = this._outputWidth;\r\n this.postProcess.outputTextureHeight = this._outputHeight;\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Camera, DirectionalLight, FrameGraph, FrameGraphObjectList, FrameGraphTextureHandle } from "../../../index.js";
|
|
2
|
+
import { Vector3 } from "../../../Maths/math.vector.js";
|
|
3
|
+
import { Color3 } from "../../../Maths/math.color.js";
|
|
4
|
+
import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
5
|
+
import "../../../Shaders/volumetricLightingRenderVolume.vertex.js";
|
|
6
|
+
import "../../../Shaders/volumetricLightingRenderVolume.fragment.js";
|
|
7
|
+
import "../../../ShadersWGSL/volumetricLightingRenderVolume.vertex.js";
|
|
8
|
+
import "../../../ShadersWGSL/volumetricLightingRenderVolume.fragment.js";
|
|
9
|
+
/**
|
|
10
|
+
* A frame graph task that performs volumetric lighting.
|
|
11
|
+
*/
|
|
12
|
+
export declare class FrameGraphVolumetricLightingTask extends FrameGraphTask {
|
|
13
|
+
/**
|
|
14
|
+
* The target texture to which the volumetric lighting will be applied.
|
|
15
|
+
*/
|
|
16
|
+
targetTexture: FrameGraphTextureHandle;
|
|
17
|
+
/**
|
|
18
|
+
* The sampling mode to use when blending the volumetric lighting texture with targetTexture.
|
|
19
|
+
*/
|
|
20
|
+
sourceSamplingMode: number;
|
|
21
|
+
/**
|
|
22
|
+
* The depth texture used for volumetric lighting calculations.
|
|
23
|
+
* It must be the depth texture used to generate targetTexture.
|
|
24
|
+
*/
|
|
25
|
+
depthTexture: FrameGraphTextureHandle;
|
|
26
|
+
/**
|
|
27
|
+
* The camera used for volumetric lighting calculations.
|
|
28
|
+
*/
|
|
29
|
+
camera: Camera;
|
|
30
|
+
/**
|
|
31
|
+
* The mesh representing the lighting volume.
|
|
32
|
+
* This is the mesh that will be rendered to create the volumetric lighting effect.
|
|
33
|
+
*/
|
|
34
|
+
lightingVolumeMesh: FrameGraphObjectList;
|
|
35
|
+
/**
|
|
36
|
+
* The directional light used for volumetric lighting.
|
|
37
|
+
*/
|
|
38
|
+
light: DirectionalLight;
|
|
39
|
+
/**
|
|
40
|
+
* The lighting volume texture (optional).
|
|
41
|
+
* If not provided, a new texture will be created, which the same size, format and type as targetTexture.
|
|
42
|
+
* This is the texture that will store the volumetric lighting information, before being blended to targetTexture.
|
|
43
|
+
*/
|
|
44
|
+
lightingVolumeTexture?: FrameGraphTextureHandle;
|
|
45
|
+
private _extinctionPhaseG;
|
|
46
|
+
/**
|
|
47
|
+
* The phase G parameter for the volumetric lighting effect (default: 0).
|
|
48
|
+
* This parameter controls the anisotropy of the scattering.
|
|
49
|
+
* A value of 0 means isotropic scattering, while a value of 1 means forward scattering and -1 means backward scattering.
|
|
50
|
+
*/
|
|
51
|
+
get phaseG(): number;
|
|
52
|
+
set phaseG(value: number);
|
|
53
|
+
/**
|
|
54
|
+
* Whether to enable extinction in the volumetric lighting effect (default: false).
|
|
55
|
+
* Read-only property set in the constructor.
|
|
56
|
+
*/
|
|
57
|
+
readonly enableExtinction: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The extinction coefficient for the volumetric lighting effect (default: (0, 0, 0) - no extinction).
|
|
60
|
+
* This parameter controls how much light is absorbed and scattered as it travels through the medium.
|
|
61
|
+
*/
|
|
62
|
+
get extinction(): Vector3;
|
|
63
|
+
set extinction(value: Vector3);
|
|
64
|
+
private _lightPower;
|
|
65
|
+
/**
|
|
66
|
+
* The light power/color for the volumetric lighting effect (default: (1, 1, 1)).
|
|
67
|
+
* This parameter controls the intensity and color of the light used for volumetric lighting.
|
|
68
|
+
*/
|
|
69
|
+
get lightPower(): Color3;
|
|
70
|
+
set lightPower(value: Color3);
|
|
71
|
+
get name(): string;
|
|
72
|
+
set name(name: string);
|
|
73
|
+
/**
|
|
74
|
+
* The output texture of the task.
|
|
75
|
+
*/
|
|
76
|
+
readonly outputTexture: FrameGraphTextureHandle;
|
|
77
|
+
private readonly _clearLightingVolumeTextureTask;
|
|
78
|
+
private readonly _renderLightingVolumeTask;
|
|
79
|
+
private readonly _blendLightingVolumeTask;
|
|
80
|
+
private _renderLightingVolumeMaterial;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new FrameGraphVolumetricLightingTask.
|
|
83
|
+
* @param name The name of the task.
|
|
84
|
+
* @param frameGraph The frame graph to which the task belongs.
|
|
85
|
+
* @param enableExtinction Whether to enable extinction in the volumetric lighting effect (default: false). If you don't plan to set extinction to something different than (0, 0, 0), you can disable this to save some performance.
|
|
86
|
+
*/
|
|
87
|
+
constructor(name: string, frameGraph: FrameGraph, enableExtinction?: boolean);
|
|
88
|
+
isReady(): boolean;
|
|
89
|
+
record(skipCreationOfDisabledPasses?: boolean): void;
|
|
90
|
+
dispose(): void;
|
|
91
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { FrameGraphVolumetricLightingBlendVolumeTask } from "./volumetricLightingBlendVolumeTask.js";
|
|
2
|
+
import { Matrix, TmpVectors, Vector2, Vector3, Vector4 } from "../../../Maths/math.vector.js";
|
|
3
|
+
import { Color3, Color4 } from "../../../Maths/math.color.js";
|
|
4
|
+
import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
5
|
+
|
|
6
|
+
import { FrameGraphClearTextureTask } from "../Texture/clearTextureTask.js";
|
|
7
|
+
import { FrameGraphObjectRendererTask } from "../Rendering/objectRendererTask.js";
|
|
8
|
+
import { ShaderMaterial } from "../../../Materials/shaderMaterial.js";
|
|
9
|
+
import "../../../Shaders/volumetricLightingRenderVolume.vertex.js";
|
|
10
|
+
import "../../../Shaders/volumetricLightingRenderVolume.fragment.js";
|
|
11
|
+
import "../../../ShadersWGSL/volumetricLightingRenderVolume.vertex.js";
|
|
12
|
+
import "../../../ShadersWGSL/volumetricLightingRenderVolume.fragment.js";
|
|
13
|
+
const InvViewProjectionMatrix = new Matrix();
|
|
14
|
+
/**
|
|
15
|
+
* A frame graph task that performs volumetric lighting.
|
|
16
|
+
*/
|
|
17
|
+
export class FrameGraphVolumetricLightingTask extends FrameGraphTask {
|
|
18
|
+
/**
|
|
19
|
+
* The phase G parameter for the volumetric lighting effect (default: 0).
|
|
20
|
+
* This parameter controls the anisotropy of the scattering.
|
|
21
|
+
* A value of 0 means isotropic scattering, while a value of 1 means forward scattering and -1 means backward scattering.
|
|
22
|
+
*/
|
|
23
|
+
get phaseG() {
|
|
24
|
+
return this._extinctionPhaseG.w;
|
|
25
|
+
}
|
|
26
|
+
set phaseG(value) {
|
|
27
|
+
this._extinctionPhaseG.w = value;
|
|
28
|
+
this._renderLightingVolumeMaterial.setVector4("extinctionPhaseG", this._extinctionPhaseG);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The extinction coefficient for the volumetric lighting effect (default: (0, 0, 0) - no extinction).
|
|
32
|
+
* This parameter controls how much light is absorbed and scattered as it travels through the medium.
|
|
33
|
+
*/
|
|
34
|
+
get extinction() {
|
|
35
|
+
return this._blendLightingVolumeTask.postProcess.extinction;
|
|
36
|
+
}
|
|
37
|
+
set extinction(value) {
|
|
38
|
+
this._extinctionPhaseG.x = Math.max(value.x, 1e-6);
|
|
39
|
+
this._extinctionPhaseG.y = Math.max(value.y, 1e-6);
|
|
40
|
+
this._extinctionPhaseG.z = Math.max(value.z, 1e-6);
|
|
41
|
+
this._renderLightingVolumeMaterial.setVector4("extinctionPhaseG", this._extinctionPhaseG);
|
|
42
|
+
this._blendLightingVolumeTask.postProcess.extinction.copyFromFloats(this._extinctionPhaseG.x, this._extinctionPhaseG.y, this._extinctionPhaseG.z);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The light power/color for the volumetric lighting effect (default: (1, 1, 1)).
|
|
46
|
+
* This parameter controls the intensity and color of the light used for volumetric lighting.
|
|
47
|
+
*/
|
|
48
|
+
get lightPower() {
|
|
49
|
+
return this._lightPower;
|
|
50
|
+
}
|
|
51
|
+
set lightPower(value) {
|
|
52
|
+
this._lightPower.copyFrom(value);
|
|
53
|
+
this._renderLightingVolumeMaterial.setColor3("lightPower", this._lightPower);
|
|
54
|
+
}
|
|
55
|
+
get name() {
|
|
56
|
+
return this._name;
|
|
57
|
+
}
|
|
58
|
+
set name(name) {
|
|
59
|
+
this._name = name;
|
|
60
|
+
if (this._renderLightingVolumeMaterial) {
|
|
61
|
+
this._renderLightingVolumeMaterial.name = `${name} - render lighting volume`;
|
|
62
|
+
}
|
|
63
|
+
if (this._clearLightingVolumeTextureTask) {
|
|
64
|
+
this._clearLightingVolumeTextureTask.name = `${name} - clear lighting volume texture`;
|
|
65
|
+
}
|
|
66
|
+
if (this._renderLightingVolumeTask) {
|
|
67
|
+
this._renderLightingVolumeTask.name = `${name} - render lighting volume`;
|
|
68
|
+
}
|
|
69
|
+
if (this._blendLightingVolumeTask) {
|
|
70
|
+
this._blendLightingVolumeTask.name = `${name} - blend lighting volume`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Creates a new FrameGraphVolumetricLightingTask.
|
|
75
|
+
* @param name The name of the task.
|
|
76
|
+
* @param frameGraph The frame graph to which the task belongs.
|
|
77
|
+
* @param enableExtinction Whether to enable extinction in the volumetric lighting effect (default: false). If you don't plan to set extinction to something different than (0, 0, 0), you can disable this to save some performance.
|
|
78
|
+
*/
|
|
79
|
+
constructor(name, frameGraph, enableExtinction = false) {
|
|
80
|
+
super(name, frameGraph);
|
|
81
|
+
/**
|
|
82
|
+
* The sampling mode to use when blending the volumetric lighting texture with targetTexture.
|
|
83
|
+
*/
|
|
84
|
+
this.sourceSamplingMode = 2;
|
|
85
|
+
this._extinctionPhaseG = new Vector4(0, 0, 0, 0);
|
|
86
|
+
this._lightPower = new Color3(1, 1, 1);
|
|
87
|
+
this.enableExtinction = enableExtinction;
|
|
88
|
+
const isWebGPU = this._frameGraph.engine.isWebGPU;
|
|
89
|
+
this._renderLightingVolumeMaterial = new ShaderMaterial(`${name} - render lighting volume`, this._frameGraph.scene, "volumetricLightingRenderVolume", {
|
|
90
|
+
attributes: ["position"],
|
|
91
|
+
uniformBuffers: ["Scene", "Mesh"],
|
|
92
|
+
uniforms: ["world", "viewProjection", "vEyePosition", "lightDir", "invViewProjection", "outputTextureSize", "extinctionPhaseG", "lightPower"],
|
|
93
|
+
samplers: ["depthTexture"],
|
|
94
|
+
defines: enableExtinction ? ["USE_EXTINCTION"] : [],
|
|
95
|
+
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
96
|
+
needAlphaBlending: true,
|
|
97
|
+
});
|
|
98
|
+
this._renderLightingVolumeMaterial.backFaceCulling = false;
|
|
99
|
+
this._renderLightingVolumeMaterial.alphaMode = 1;
|
|
100
|
+
this._renderLightingVolumeMaterial.onBindObservable.add(() => {
|
|
101
|
+
this._renderLightingVolumeMaterial.bindEyePosition(this._renderLightingVolumeMaterial.getEffect());
|
|
102
|
+
});
|
|
103
|
+
this._clearLightingVolumeTextureTask = new FrameGraphClearTextureTask(`${name} - clear lighting volume texture`, frameGraph);
|
|
104
|
+
this._renderLightingVolumeTask = new FrameGraphObjectRendererTask(`${name} - render lighting volume`, frameGraph, frameGraph.scene);
|
|
105
|
+
this._blendLightingVolumeTask = new FrameGraphVolumetricLightingBlendVolumeTask(`${name} - blend lighting volume`, frameGraph, enableExtinction);
|
|
106
|
+
this.onTexturesAllocatedObservable.add(() => {
|
|
107
|
+
this._renderLightingVolumeMaterial.setInternalTexture("depthTexture", frameGraph.textureManager.getTextureFromHandle(this.depthTexture));
|
|
108
|
+
});
|
|
109
|
+
this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
|
|
110
|
+
// Triggers the setters to set the uniforms
|
|
111
|
+
this.phaseG = this._extinctionPhaseG.w;
|
|
112
|
+
this.extinction = new Vector3(this.extinction.x, this.extinction.y, this.extinction.z);
|
|
113
|
+
this.lightPower = this._lightPower;
|
|
114
|
+
}
|
|
115
|
+
isReady() {
|
|
116
|
+
return (this._renderLightingVolumeMaterial.isReady() &&
|
|
117
|
+
this._clearLightingVolumeTextureTask.isReady() &&
|
|
118
|
+
this._renderLightingVolumeMaterial.isReady() &&
|
|
119
|
+
this._blendLightingVolumeTask.isReady());
|
|
120
|
+
}
|
|
121
|
+
record(skipCreationOfDisabledPasses = false) {
|
|
122
|
+
if (this.targetTexture === undefined || this.depthTexture === undefined || this.camera === undefined || this.lightingVolumeMesh === undefined || this.light === undefined) {
|
|
123
|
+
throw new Error(`FrameGraphVolumetricLightingTask "${this.name}": targetTexture, depthTexture, camera, lightingVolumeMesh and light are required`);
|
|
124
|
+
}
|
|
125
|
+
if (!this.lightingVolumeMesh.meshes || this.lightingVolumeMesh.meshes.length === 0) {
|
|
126
|
+
throw new Error(`FrameGraphVolumetricLightingTask "${this.name}": lightingVolumeMesh is empty`);
|
|
127
|
+
}
|
|
128
|
+
this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture);
|
|
129
|
+
const textureManager = this._frameGraph.textureManager;
|
|
130
|
+
let lightingVolumeTexture = this.lightingVolumeTexture;
|
|
131
|
+
if (!lightingVolumeTexture) {
|
|
132
|
+
const targetTextureCreationOptions = textureManager.getTextureCreationOptions(this.targetTexture);
|
|
133
|
+
targetTextureCreationOptions.options.labels = ["InScattering"];
|
|
134
|
+
targetTextureCreationOptions.options.samples = 1;
|
|
135
|
+
lightingVolumeTexture = textureManager.createRenderTargetTexture(`${this.name} - lighting volume texture`, targetTextureCreationOptions);
|
|
136
|
+
}
|
|
137
|
+
this.lightingVolumeMesh.meshes[0].material = this._renderLightingVolumeMaterial;
|
|
138
|
+
const volumeTextureSize = textureManager.getTextureAbsoluteDimensions(lightingVolumeTexture);
|
|
139
|
+
this._renderLightingVolumeMaterial.setVector2("outputTextureSize", new Vector2(volumeTextureSize.width, volumeTextureSize.height));
|
|
140
|
+
const pass = this._frameGraph.addPass(this.name);
|
|
141
|
+
pass.setExecuteFunc(() => {
|
|
142
|
+
this.camera.getTransformationMatrix().invertToRef(InvViewProjectionMatrix);
|
|
143
|
+
this._renderLightingVolumeMaterial.setMatrix("invViewProjection", InvViewProjectionMatrix);
|
|
144
|
+
this._renderLightingVolumeMaterial.setVector3("lightDir", this.light.direction.normalizeToRef(TmpVectors.Vector3[0]));
|
|
145
|
+
});
|
|
146
|
+
this._clearLightingVolumeTextureTask.clearColor = true;
|
|
147
|
+
this._clearLightingVolumeTextureTask.clearStencil = this.enableExtinction;
|
|
148
|
+
this._clearLightingVolumeTextureTask.color = new Color4(0, 0, 0, 1);
|
|
149
|
+
this._clearLightingVolumeTextureTask.stencilValue = 0;
|
|
150
|
+
this._clearLightingVolumeTextureTask.targetTexture = lightingVolumeTexture;
|
|
151
|
+
this._clearLightingVolumeTextureTask.record(true);
|
|
152
|
+
this._renderLightingVolumeTask.targetTexture = this._clearLightingVolumeTextureTask.outputTexture;
|
|
153
|
+
this._renderLightingVolumeTask.objectList = this.lightingVolumeMesh;
|
|
154
|
+
this._renderLightingVolumeTask.camera = this.camera;
|
|
155
|
+
this._renderLightingVolumeTask.disableImageProcessing = true;
|
|
156
|
+
this._renderLightingVolumeTask.depthTest = false;
|
|
157
|
+
this._renderLightingVolumeTask.record(true);
|
|
158
|
+
this._blendLightingVolumeTask.sourceTexture = this._renderLightingVolumeTask.outputTexture;
|
|
159
|
+
this._blendLightingVolumeTask.sourceSamplingMode = this.sourceSamplingMode;
|
|
160
|
+
this._blendLightingVolumeTask.targetTexture = this.targetTexture;
|
|
161
|
+
this._blendLightingVolumeTask.depthTexture = this.depthTexture;
|
|
162
|
+
this._blendLightingVolumeTask.camera = this.camera;
|
|
163
|
+
this._blendLightingVolumeTask.record(true);
|
|
164
|
+
if (!skipCreationOfDisabledPasses) {
|
|
165
|
+
const disabledPass = this._frameGraph.addPass(this.name + "_disabled", true);
|
|
166
|
+
disabledPass.setExecuteFunc(() => { });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
dispose() {
|
|
170
|
+
this._renderLightingVolumeMaterial?.dispose();
|
|
171
|
+
this._clearLightingVolumeTextureTask.dispose();
|
|
172
|
+
this._renderLightingVolumeTask.dispose();
|
|
173
|
+
this._blendLightingVolumeTask.dispose();
|
|
174
|
+
super.dispose();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=volumetricLightingTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volumetricLightingTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2CAA2C,EAAE,MAAM,qCAAqC,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,sCAA+B;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,qCAA8B;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,6CAAsC;AAG/D,mEAA4D;AAC5D,qEAA8D;AAC9D,uEAAgE;AAChE,yEAAkE;AAElE,MAAM,uBAAuB,GAAG,IAAI,MAAM,EAAE,CAAC;AAE7C;;GAEG;AACH,MAAM,OAAO,gCAAiC,SAAQ,cAAc;IA0ChE;;;;OAIG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,IAAW,MAAM,CAAC,KAAa;QAC3B,IAAI,CAAC,iBAAiB,CAAC,CAAC,GAAG,KAAK,CAAC;QACjC,IAAI,CAAC,6BAA6B,CAAC,UAAU,CAAC,kBAAkB,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC9F,CAAC;IAQD;;;OAGG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,wBAAwB,CAAC,WAAW,CAAC,UAAU,CAAC;IAChE,CAA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YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;YAE7E,YAAY,CAAC,cAAc,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,6BAA6B,EAAE,OAAO,EAAE,CAAC;QAC9C,IAAI,CAAC,+BAA+B,CAAC,OAAO,EAAE,CAAC;QAC/C,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,CAAC;QACzC,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,CAAC;QACxC,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type { Camera, DirectionalLight, FrameGraph, FrameGraphObjectList, FrameGraphTextureHandle } from \"core/index\";\r\nimport { FrameGraphVolumetricLightingBlendVolumeTask } from \"./volumetricLightingBlendVolumeTask\";\r\nimport { Matrix, TmpVectors, Vector2, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphClearTextureTask } from \"../Texture/clearTextureTask\";\r\nimport { FrameGraphObjectRendererTask } from \"../Rendering/objectRendererTask\";\r\nimport { ShaderMaterial } from \"core/Materials/shaderMaterial\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\nimport \"core/Shaders/volumetricLightingRenderVolume.vertex\";\r\nimport \"core/Shaders/volumetricLightingRenderVolume.fragment\";\r\nimport \"core/ShadersWGSL/volumetricLightingRenderVolume.vertex\";\r\nimport \"core/ShadersWGSL/volumetricLightingRenderVolume.fragment\";\r\n\r\nconst InvViewProjectionMatrix = new Matrix();\r\n\r\n/**\r\n * A frame graph task that performs volumetric lighting.\r\n */\r\nexport class FrameGraphVolumetricLightingTask extends FrameGraphTask {\r\n /**\r\n * The target texture to which the volumetric lighting will be applied.\r\n */\r\n public targetTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use when blending the volumetric lighting texture with targetTexture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The depth texture used for volumetric lighting calculations.\r\n * It must be the depth texture used to generate targetTexture.\r\n */\r\n public depthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The camera used for volumetric lighting calculations.\r\n */\r\n public camera: Camera;\r\n\r\n /**\r\n * The mesh representing the lighting volume.\r\n * This is the mesh that will be rendered to create the volumetric lighting effect.\r\n */\r\n public lightingVolumeMesh: FrameGraphObjectList;\r\n\r\n /**\r\n * The directional light used for volumetric lighting.\r\n */\r\n public light: DirectionalLight;\r\n\r\n /**\r\n * The lighting volume texture (optional).\r\n * If not provided, a new texture will be created, which the same size, format and type as targetTexture.\r\n * This is the texture that will store the volumetric lighting information, before being blended to targetTexture.\r\n */\r\n public lightingVolumeTexture?: FrameGraphTextureHandle;\r\n\r\n private _extinctionPhaseG = new Vector4(0, 0, 0, 0);\r\n\r\n /**\r\n * The phase G parameter for the volumetric lighting effect (default: 0).\r\n * This parameter controls the anisotropy of the scattering.\r\n * A value of 0 means isotropic scattering, while a value of 1 means forward scattering and -1 means backward scattering.\r\n */\r\n public get phaseG() {\r\n return this._extinctionPhaseG.w;\r\n }\r\n\r\n public set phaseG(value: number) {\r\n this._extinctionPhaseG.w = value;\r\n this._renderLightingVolumeMaterial.setVector4(\"extinctionPhaseG\", this._extinctionPhaseG);\r\n }\r\n\r\n /**\r\n * Whether to enable extinction in the volumetric lighting effect (default: false).\r\n * Read-only property set in the constructor.\r\n */\r\n public readonly enableExtinction: boolean;\r\n\r\n /**\r\n * The extinction coefficient for the volumetric lighting effect (default: (0, 0, 0) - no extinction).\r\n * This parameter controls how much light is absorbed and scattered as it travels through the medium.\r\n */\r\n public get extinction() {\r\n return this._blendLightingVolumeTask.postProcess.extinction;\r\n }\r\n\r\n public set extinction(value: Vector3) {\r\n this._extinctionPhaseG.x = Math.max(value.x, 1e-6);\r\n this._extinctionPhaseG.y = Math.max(value.y, 1e-6);\r\n this._extinctionPhaseG.z = Math.max(value.z, 1e-6);\r\n this._renderLightingVolumeMaterial.setVector4(\"extinctionPhaseG\", this._extinctionPhaseG);\r\n this._blendLightingVolumeTask.postProcess.extinction.copyFromFloats(this._extinctionPhaseG.x, this._extinctionPhaseG.y, this._extinctionPhaseG.z);\r\n }\r\n\r\n private _lightPower = new Color3(1, 1, 1);\r\n\r\n /**\r\n * The light power/color for the volumetric lighting effect (default: (1, 1, 1)).\r\n * This parameter controls the intensity and color of the light used for volumetric lighting.\r\n */\r\n public get lightPower() {\r\n return this._lightPower;\r\n }\r\n\r\n public set lightPower(value: Color3) {\r\n this._lightPower.copyFrom(value);\r\n this._renderLightingVolumeMaterial.setColor3(\"lightPower\", this._lightPower);\r\n }\r\n\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(name: string) {\r\n this._name = name;\r\n if (this._renderLightingVolumeMaterial) {\r\n this._renderLightingVolumeMaterial.name = `${name} - render lighting volume`;\r\n }\r\n if (this._clearLightingVolumeTextureTask) {\r\n this._clearLightingVolumeTextureTask.name = `${name} - clear lighting volume texture`;\r\n }\r\n if (this._renderLightingVolumeTask) {\r\n this._renderLightingVolumeTask.name = `${name} - render lighting volume`;\r\n }\r\n if (this._blendLightingVolumeTask) {\r\n this._blendLightingVolumeTask.name = `${name} - blend lighting volume`;\r\n }\r\n }\r\n\r\n /**\r\n * The output texture of the task.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n private readonly _clearLightingVolumeTextureTask: FrameGraphClearTextureTask;\r\n private readonly _renderLightingVolumeTask: FrameGraphObjectRendererTask;\r\n private readonly _blendLightingVolumeTask: FrameGraphVolumetricLightingBlendVolumeTask;\r\n private _renderLightingVolumeMaterial: ShaderMaterial;\r\n\r\n /**\r\n * Creates a new FrameGraphVolumetricLightingTask.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph to which the task belongs.\r\n * @param enableExtinction Whether to enable extinction in the volumetric lighting effect (default: false). If you don't plan to set extinction to something different than (0, 0, 0), you can disable this to save some performance.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, enableExtinction = false) {\r\n super(name, frameGraph);\r\n\r\n this.enableExtinction = enableExtinction;\r\n\r\n const isWebGPU = this._frameGraph.engine.isWebGPU;\r\n\r\n this._renderLightingVolumeMaterial = new ShaderMaterial(`${name} - render lighting volume`, this._frameGraph.scene, \"volumetricLightingRenderVolume\", {\r\n attributes: [\"position\"],\r\n uniformBuffers: [\"Scene\", \"Mesh\"],\r\n uniforms: [\"world\", \"viewProjection\", \"vEyePosition\", \"lightDir\", \"invViewProjection\", \"outputTextureSize\", \"extinctionPhaseG\", \"lightPower\"],\r\n samplers: [\"depthTexture\"],\r\n defines: enableExtinction ? [\"USE_EXTINCTION\"] : [],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n needAlphaBlending: true,\r\n });\r\n this._renderLightingVolumeMaterial.backFaceCulling = false;\r\n this._renderLightingVolumeMaterial.alphaMode = Constants.ALPHA_ADD;\r\n this._renderLightingVolumeMaterial.onBindObservable.add(() => {\r\n this._renderLightingVolumeMaterial.bindEyePosition(this._renderLightingVolumeMaterial.getEffect());\r\n });\r\n\r\n this._clearLightingVolumeTextureTask = new FrameGraphClearTextureTask(`${name} - clear lighting volume texture`, frameGraph);\r\n this._renderLightingVolumeTask = new FrameGraphObjectRendererTask(`${name} - render lighting volume`, frameGraph, frameGraph.scene);\r\n this._blendLightingVolumeTask = new FrameGraphVolumetricLightingBlendVolumeTask(`${name} - blend lighting volume`, frameGraph, enableExtinction);\r\n\r\n this.onTexturesAllocatedObservable.add(() => {\r\n this._renderLightingVolumeMaterial.setInternalTexture(\"depthTexture\", frameGraph.textureManager.getTextureFromHandle(this.depthTexture)!);\r\n });\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n\r\n // Triggers the setters to set the uniforms\r\n this.phaseG = this._extinctionPhaseG.w;\r\n this.extinction = new Vector3(this.extinction.x, this.extinction.y, this.extinction.z);\r\n this.lightPower = this._lightPower;\r\n }\r\n\r\n public override isReady() {\r\n return (\r\n this._renderLightingVolumeMaterial.isReady() &&\r\n this._clearLightingVolumeTextureTask.isReady() &&\r\n this._renderLightingVolumeMaterial.isReady() &&\r\n this._blendLightingVolumeTask.isReady()\r\n );\r\n }\r\n\r\n public override record(skipCreationOfDisabledPasses = false) {\r\n if (this.targetTexture === undefined || this.depthTexture === undefined || this.camera === undefined || this.lightingVolumeMesh === undefined || this.light === undefined) {\r\n throw new Error(`FrameGraphVolumetricLightingTask \"${this.name}\": targetTexture, depthTexture, camera, lightingVolumeMesh and light are required`);\r\n }\r\n if (!this.lightingVolumeMesh.meshes || this.lightingVolumeMesh.meshes.length === 0) {\r\n throw new Error(`FrameGraphVolumetricLightingTask \"${this.name}\": lightingVolumeMesh is empty`);\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture);\r\n\r\n const textureManager = this._frameGraph.textureManager;\r\n\r\n let lightingVolumeTexture = this.lightingVolumeTexture;\r\n if (!lightingVolumeTexture) {\r\n const targetTextureCreationOptions = textureManager.getTextureCreationOptions(this.targetTexture);\r\n\r\n targetTextureCreationOptions.options.labels = [\"InScattering\"];\r\n targetTextureCreationOptions.options.samples = 1;\r\n\r\n lightingVolumeTexture = textureManager.createRenderTargetTexture(`${this.name} - lighting volume texture`, targetTextureCreationOptions);\r\n }\r\n\r\n this.lightingVolumeMesh.meshes[0].material = this._renderLightingVolumeMaterial;\r\n\r\n const volumeTextureSize = textureManager.getTextureAbsoluteDimensions(lightingVolumeTexture);\r\n\r\n this._renderLightingVolumeMaterial.setVector2(\"outputTextureSize\", new Vector2(volumeTextureSize.width, volumeTextureSize.height));\r\n\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n pass.setExecuteFunc(() => {\r\n this.camera.getTransformationMatrix().invertToRef(InvViewProjectionMatrix);\r\n\r\n this._renderLightingVolumeMaterial.setMatrix(\"invViewProjection\", InvViewProjectionMatrix);\r\n this._renderLightingVolumeMaterial.setVector3(\"lightDir\", this.light.direction.normalizeToRef(TmpVectors.Vector3[0]));\r\n });\r\n\r\n this._clearLightingVolumeTextureTask.clearColor = true;\r\n this._clearLightingVolumeTextureTask.clearStencil = this.enableExtinction;\r\n this._clearLightingVolumeTextureTask.color = new Color4(0, 0, 0, 1);\r\n this._clearLightingVolumeTextureTask.stencilValue = 0;\r\n this._clearLightingVolumeTextureTask.targetTexture = lightingVolumeTexture;\r\n this._clearLightingVolumeTextureTask.record(true);\r\n\r\n this._renderLightingVolumeTask.targetTexture = this._clearLightingVolumeTextureTask.outputTexture;\r\n this._renderLightingVolumeTask.objectList = this.lightingVolumeMesh;\r\n this._renderLightingVolumeTask.camera = this.camera;\r\n this._renderLightingVolumeTask.disableImageProcessing = true;\r\n this._renderLightingVolumeTask.depthTest = false;\r\n this._renderLightingVolumeTask.record(true);\r\n\r\n this._blendLightingVolumeTask.sourceTexture = this._renderLightingVolumeTask.outputTexture;\r\n this._blendLightingVolumeTask.sourceSamplingMode = this.sourceSamplingMode;\r\n this._blendLightingVolumeTask.targetTexture = this.targetTexture;\r\n this._blendLightingVolumeTask.depthTexture = this.depthTexture;\r\n this._blendLightingVolumeTask.camera = this.camera;\r\n this._blendLightingVolumeTask.record(true);\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const disabledPass = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n disabledPass.setExecuteFunc(() => {});\r\n }\r\n }\r\n\r\n public override dispose() {\r\n this._renderLightingVolumeMaterial?.dispose();\r\n this._clearLightingVolumeTextureTask.dispose();\r\n this._renderLightingVolumeTask.dispose();\r\n this._blendLightingVolumeTask.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -203,7 +203,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
203
203
|
}
|
|
204
204
|
const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);
|
|
205
205
|
if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {
|
|
206
|
-
throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);
|
|
206
|
+
throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture "${depthTextureDescription.options.labels?.[0] ?? "noname"}" (${depthTextureDescription.options.samples} samples) and the output texture "${outputTextureDescription.options.labels?.[0] ?? "noname"}" (${outputTextureDescription.options.samples} samples) must have the same number of samples`);
|
|
207
207
|
}
|
|
208
208
|
depthEnabled = true;
|
|
209
209
|
}
|