@babylonjs/core 7.52.1 → 7.52.3
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/AudioV2/abstractAudio/abstractAudioBus.d.ts +11 -0
- package/AudioV2/abstractAudio/abstractAudioBus.js +10 -0
- package/AudioV2/abstractAudio/abstractAudioBus.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.d.ts +11 -5
- package/AudioV2/abstractAudio/abstractSound.js +11 -5
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/audioBus.d.ts +5 -6
- package/AudioV2/abstractAudio/audioBus.js +1 -5
- package/AudioV2/abstractAudio/audioBus.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +1 -2
- package/AudioV2/abstractAudio/audioEngineV2.js +1 -5
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.d.ts +43 -0
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +71 -0
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -0
- package/AudioV2/abstractAudio/mainAudioBus.d.ts +2 -2
- package/AudioV2/abstractAudio/mainAudioBus.js.map +1 -1
- package/AudioV2/abstractAudio/staticSound.d.ts +6 -6
- package/AudioV2/abstractAudio/staticSound.js +5 -5
- package/AudioV2/abstractAudio/staticSound.js.map +1 -1
- package/AudioV2/abstractAudio/streamingSound.d.ts +2 -2
- package/AudioV2/abstractAudio/streamingSound.js +3 -3
- package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.d.ts +30 -6
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js +44 -21
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.d.ts +24 -0
- package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.js +30 -0
- package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.js.map +1 -0
- package/AudioV2/abstractAudio/subNodes/audioSubNode.d.ts +1 -0
- package/AudioV2/abstractAudio/subNodes/audioSubNode.js +1 -0
- package/AudioV2/abstractAudio/subNodes/audioSubNode.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +15 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +38 -3
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/stereoAudioSubNode.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.d.ts +86 -0
- package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.js +29 -0
- package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.js.map +1 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +29 -8
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +1 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +28 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js +5 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/audioAnalyzer.d.ts +35 -0
- package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js +96 -0
- package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js.map +1 -0
- package/AudioV2/abstractAudio/subProperties/index.d.ts +1 -0
- package/AudioV2/abstractAudio/subProperties/index.js +1 -0
- package/AudioV2/abstractAudio/subProperties/index.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +16 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js +48 -14
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +21 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +39 -4
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -1
- package/AudioV2/index.d.ts +1 -0
- package/AudioV2/index.js +1 -0
- package/AudioV2/index.js.map +1 -1
- package/AudioV2/spatialAudioAttachmentType.d.ts +5 -0
- package/AudioV2/spatialAudioAttachmentType.js +7 -0
- package/AudioV2/spatialAudioAttachmentType.js.map +1 -0
- package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.d.ts +13 -0
- package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.js +38 -0
- package/AudioV2/webAudio/components/spatialWebAudioUpdaterComponent.js.map +1 -0
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +13 -14
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +39 -39
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.d.ts +37 -0
- package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js +85 -0
- package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js.map +1 -0
- package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.d.ts +5 -3
- package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js +25 -2
- package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js.map +1 -1
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.d.ts +2 -1
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js +32 -17
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudio.d.ts +6 -2
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js +13 -15
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.d.ts +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js +41 -56
- package/AudioV2/webAudio/subProperties/spatialWebAudioListener.js.map +1 -1
- package/AudioV2/webAudio/webAudioBus.d.ts +3 -0
- package/AudioV2/webAudio/webAudioBus.js +23 -2
- package/AudioV2/webAudio/webAudioBus.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +3 -1
- package/AudioV2/webAudio/webAudioEngine.js +11 -3
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +3 -0
- package/AudioV2/webAudio/webAudioStaticSound.js +23 -2
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -0
- package/AudioV2/webAudio/webAudioStreamingSound.js +23 -2
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +0 -1
- package/Engines/WebGPU/webgpuTextureManager.js +2 -57
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.d.ts +6 -0
- package/Engines/abstractEngine.js +3 -3
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.common.js +4 -0
- package/Engines/engine.common.js.map +1 -1
- package/Engines/nativeEngine.d.ts +1 -0
- package/Engines/nativeEngine.js +3 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.d.ts +1 -0
- package/Engines/nullEngine.js +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +1 -0
- package/Engines/thinEngine.js +7 -4
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +2 -1
- package/Engines/webgpuEngine.js +12 -9
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.d.ts +48 -0
- package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js +54 -0
- package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/index.d.ts +1 -0
- package/FlowGraph/Blocks/Data/index.js +1 -0
- package/FlowGraph/Blocks/Data/index.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +19 -13
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +3 -5
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js +2 -4
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +1 -2
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.js +2 -0
- package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +2 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
- package/FlowGraph/CustomTypes/flowGraphInteger.d.ts +1 -0
- package/FlowGraph/CustomTypes/flowGraphInteger.js +3 -0
- package/FlowGraph/CustomTypes/flowGraphInteger.js.map +1 -1
- package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +2 -0
- package/FlowGraph/CustomTypes/flowGraphMatrix.js +6 -0
- package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
- package/FlowGraph/flowGraphExecutionBlock.d.ts +1 -0
- package/FlowGraph/flowGraphExecutionBlock.js +4 -0
- package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
- package/FlowGraph/utils.d.ts +2 -1
- package/FlowGraph/utils.js +7 -2
- package/FlowGraph/utils.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.d.ts +126 -0
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +497 -0
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +30 -4
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +2 -3
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +3 -4
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/blurTask.js +2 -2
- package/FrameGraph/Tasks/PostProcesses/blurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +2 -3
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +4 -5
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +6 -0
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +14 -0
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.d.ts +11 -0
- package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js +18 -0
- package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.d.ts +76 -0
- package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js +170 -0
- package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssrTask.d.ts +16 -0
- package/FrameGraph/Tasks/PostProcesses/ssrTask.js +45 -0
- package/FrameGraph/Tasks/PostProcesses/ssrTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +10 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +29 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +7 -3
- package/FrameGraph/frameGraph.js +10 -4
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +2 -1
- package/FrameGraph/frameGraphTextureManager.js +4 -3
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/effectRenderer.js +1 -1
- package/Materials/effectRenderer.js.map +1 -1
- package/Materials/material.js +5 -3
- package/Materials/material.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.d.ts +7 -5
- package/Materials/materialHelper.geometryrendering.js +8 -3
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Materials/standardMaterial.js +1 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/geometry.js +18 -7
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +1 -1
- package/Meshes/mesh.vertexData.js +2 -1
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Particles/particleSystemComponent.d.ts +2 -1
- package/Particles/particleSystemComponent.js +2 -2
- package/Particles/particleSystemComponent.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.d.ts +23 -30
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +226 -411
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.d.ts +222 -0
- package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js +373 -0
- package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js.map +1 -0
- package/PostProcesses/thinDepthOfFieldEffect.d.ts +4 -4
- package/PostProcesses/thinDepthOfFieldEffect.js.map +1 -1
- package/PostProcesses/thinSSRBlurCombinerPostProcess.d.ts +41 -0
- package/PostProcesses/thinSSRBlurCombinerPostProcess.js +185 -0
- package/PostProcesses/thinSSRBlurCombinerPostProcess.js.map +1 -0
- package/PostProcesses/thinSSRBlurPostProcess.d.ts +18 -0
- package/PostProcesses/thinSSRBlurPostProcess.js +47 -0
- package/PostProcesses/thinSSRBlurPostProcess.js.map +1 -0
- package/PostProcesses/thinSSRPostProcess.d.ts +94 -0
- package/PostProcesses/thinSSRPostProcess.js +416 -0
- package/PostProcesses/thinSSRPostProcess.js.map +1 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +2 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -0
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/iblCdfGenerator.js +1 -1
- package/Rendering/iblCdfGenerator.js.map +1 -1
- package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js +13 -2
- package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
- package/ShadersWGSL/geometry.fragment.js +1 -1
- package/ShadersWGSL/geometry.fragment.js.map +1 -1
- package/ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js +13 -2
- package/ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
- package/package.json +1 -1
|
@@ -33,14 +33,13 @@ export class FrameGraphBloomTask extends FrameGraphTask {
|
|
|
33
33
|
* Constructs a new bloom task.
|
|
34
34
|
* @param name Name of the task.
|
|
35
35
|
* @param frameGraph The frame graph this task is associated with.
|
|
36
|
-
* @param engine The engine to use for the bloom effect.
|
|
37
36
|
* @param weight Weight of the bloom effect.
|
|
38
37
|
* @param kernel Kernel size of the bloom effect.
|
|
39
38
|
* @param threshold Threshold of the bloom effect.
|
|
40
39
|
* @param hdr Whether the bloom effect is HDR.
|
|
41
40
|
* @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.
|
|
42
41
|
*/
|
|
43
|
-
constructor(name, frameGraph,
|
|
42
|
+
constructor(name, frameGraph, weight, kernel, threshold, hdr = false, bloomScale = 0.5) {
|
|
44
43
|
super(name, frameGraph);
|
|
45
44
|
/**
|
|
46
45
|
* The sampling mode to use for the source texture.
|
|
@@ -49,7 +48,7 @@ export class FrameGraphBloomTask extends FrameGraphTask {
|
|
|
49
48
|
this.hdr = hdr;
|
|
50
49
|
this._defaultPipelineTextureType = 0;
|
|
51
50
|
if (hdr) {
|
|
52
|
-
const caps = engine.getCaps();
|
|
51
|
+
const caps = frameGraph.engine.getCaps();
|
|
53
52
|
if (caps.textureHalfFloatRender) {
|
|
54
53
|
this._defaultPipelineTextureType = 2;
|
|
55
54
|
}
|
|
@@ -57,7 +56,7 @@ export class FrameGraphBloomTask extends FrameGraphTask {
|
|
|
57
56
|
this._defaultPipelineTextureType = 1;
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
this.bloom = new ThinBloomEffect(name, engine, bloomScale);
|
|
59
|
+
this.bloom = new ThinBloomEffect(name, frameGraph.engine, bloomScale);
|
|
61
60
|
this.bloom.threshold = threshold;
|
|
62
61
|
this.bloom.kernel = kernel;
|
|
63
62
|
this.bloom.weight = weight;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bloomTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/bloomTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,kDAA2C;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IAiCnD;;OAEG;IACH,IAAoB,IAAI;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAoB,IAAI,CAAC,IAAY;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,GAAG,IAAI,YAAY,CAAC;QAC/C,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,M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,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEzB,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEjD,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureCreationOptions, FrameGraphTextureHandle, AbstractEngine } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphBloomMergeTask } from \"./bloomMergeTask\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ThinBloomEffect } from \"core/PostProcesses/thinBloomEffect\";\r\nimport { FrameGraphExtractHighlightsTask } from \"./extractHighlightsTask\";\r\nimport { FrameGraphBlurTask } from \"./blurTask\";\r\n\r\n/**\r\n * Task which applies a bloom render effect.\r\n */\r\nexport class FrameGraphBloomTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the bloom effect on.\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 destination texture to render the bloom effect to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public destinationTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture of the bloom effect.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The bloom effect to apply.\r\n */\r\n public readonly bloom: ThinBloomEffect;\r\n\r\n /**\r\n * Whether the bloom effect is HDR.\r\n * When true, the bloom effect will use a higher precision texture format (half float or float). Else, it will use unsigned byte.\r\n */\r\n public readonly hdr: boolean;\r\n\r\n /**\r\n * The name of the task.\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._downscale) {\r\n this._downscale.name = `${name} Downscale`;\r\n }\r\n\r\n if (this._blurX) {\r\n this._blurX.name = `${name} Blur X`;\r\n }\r\n\r\n if (this._blurY) {\r\n this._blurY.name = `${name} Blur Y`;\r\n }\r\n\r\n if (this._merge) {\r\n this._merge.name = `${name} Merge`;\r\n }\r\n }\r\n\r\n private readonly _downscale: FrameGraphExtractHighlightsTask;\r\n private readonly _blurX: FrameGraphBlurTask;\r\n private readonly _blurY: FrameGraphBlurTask;\r\n private readonly _merge: FrameGraphBloomMergeTask;\r\n private readonly _defaultPipelineTextureType: number;\r\n\r\n /**\r\n * Constructs a new bloom task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param engine The engine to use for the bloom effect.\r\n * @param weight Weight of the bloom effect.\r\n * @param kernel Kernel size of the bloom effect.\r\n * @param threshold Threshold of the bloom effect.\r\n * @param hdr Whether the bloom effect is HDR.\r\n * @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, engine: AbstractEngine, weight: number, kernel: number, threshold: number, hdr = false, bloomScale = 0.5) {\r\n super(name, frameGraph);\r\n\r\n this.hdr = hdr;\r\n\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (hdr) {\r\n const caps = engine.getCaps();\r\n if (caps.textureHalfFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n } else if (caps.textureFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n }\r\n\r\n this.bloom = new ThinBloomEffect(name, engine, bloomScale);\r\n this.bloom.threshold = threshold;\r\n this.bloom.kernel = kernel;\r\n this.bloom.weight = weight;\r\n\r\n this._downscale = new FrameGraphExtractHighlightsTask(`${name} Downscale`, this._frameGraph, this.bloom._downscale);\r\n this._blurX = new FrameGraphBlurTask(`${name} Blur X`, this._frameGraph, this.bloom._blurX);\r\n this._blurY = new FrameGraphBlurTask(`${name} Blur Y`, this._frameGraph, this.bloom._blurY);\r\n this._merge = new FrameGraphBloomMergeTask(`${name} Merge`, this._frameGraph, this.bloom._merge);\r\n\r\n this.onTexturesAllocatedObservable.add((context) => {\r\n this._downscale.onTexturesAllocatedObservable.notifyObservers(context);\r\n this._blurX.onTexturesAllocatedObservable.notifyObservers(context);\r\n this._blurY.onTexturesAllocatedObservable.notifyObservers(context);\r\n this._merge.onTexturesAllocatedObservable.notifyObservers(context);\r\n });\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.bloom.isReady();\r\n }\r\n\r\n public record(): void {\r\n if (this.sourceTexture === undefined) {\r\n throw new Error(\"FrameGraphBloomTask: sourceTexture is required\");\r\n }\r\n\r\n const sourceTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.sourceTexture);\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: {\r\n width: Math.floor(sourceTextureDescription.size.width * this.bloom.scale),\r\n height: Math.floor(sourceTextureDescription.size.height * this.bloom.scale),\r\n },\r\n options: {\r\n createMipMaps: false,\r\n types: [this._defaultPipelineTextureType],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n };\r\n\r\n const downscaleTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._downscale.name, textureCreationOptions);\r\n\r\n this._downscale.sourceTexture = this.sourceTexture;\r\n this._downscale.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._downscale.destinationTexture = downscaleTextureHandle;\r\n this._downscale.record(true);\r\n\r\n const blurXTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurX.name, textureCreationOptions);\r\n\r\n this._blurX.sourceTexture = downscaleTextureHandle;\r\n this._blurX.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurX.destinationTexture = blurXTextureHandle;\r\n this._blurX.record(true);\r\n\r\n const blurYTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurY.name, textureCreationOptions);\r\n\r\n this._blurY.sourceTexture = blurXTextureHandle;\r\n this._blurY.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurY.destinationTexture = blurYTextureHandle;\r\n this._blurY.record(true);\r\n\r\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture, this._merge.name, sourceTextureCreationOptions);\r\n\r\n this._merge.sourceTexture = this.sourceTexture;\r\n this._merge.sourceSamplingMode = this.sourceSamplingMode;\r\n this._merge.blurTexture = blurYTextureHandle;\r\n this._merge.destinationTexture = this.outputTexture;\r\n this._merge.record(true);\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n this._downscale.dispose();\r\n this._blurX.dispose();\r\n this._blurY.dispose();\r\n this._merge.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"bloomTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/bloomTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,kDAA2C;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IAiCnD;;OAEG;IACH,IAAoB,IAAI;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAoB,IAAI,CAAC,IAAY;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,GAAG,IAAI,YAAY,CAAC;QAC/C,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,GAAG,IAAI,SAAS,CAAC;QACxC,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,GAAG,IAAI,SAAS,CAAC;QACxC,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,GAAG,IAAI,QAA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,CAAC;QACjD,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureCreationOptions, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphBloomMergeTask } from \"./bloomMergeTask\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ThinBloomEffect } from \"core/PostProcesses/thinBloomEffect\";\r\nimport { FrameGraphExtractHighlightsTask } from \"./extractHighlightsTask\";\r\nimport { FrameGraphBlurTask } from \"./blurTask\";\r\n\r\n/**\r\n * Task which applies a bloom render effect.\r\n */\r\nexport class FrameGraphBloomTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the bloom effect on.\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 destination texture to render the bloom effect to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public destinationTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture of the bloom effect.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The bloom effect to apply.\r\n */\r\n public readonly bloom: ThinBloomEffect;\r\n\r\n /**\r\n * Whether the bloom effect is HDR.\r\n * When true, the bloom effect will use a higher precision texture format (half float or float). Else, it will use unsigned byte.\r\n */\r\n public readonly hdr: boolean;\r\n\r\n /**\r\n * The name of the task.\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._downscale) {\r\n this._downscale.name = `${name} Downscale`;\r\n }\r\n\r\n if (this._blurX) {\r\n this._blurX.name = `${name} Blur X`;\r\n }\r\n\r\n if (this._blurY) {\r\n this._blurY.name = `${name} Blur Y`;\r\n }\r\n\r\n if (this._merge) {\r\n this._merge.name = `${name} Merge`;\r\n }\r\n }\r\n\r\n private readonly _downscale: FrameGraphExtractHighlightsTask;\r\n private readonly _blurX: FrameGraphBlurTask;\r\n private readonly _blurY: FrameGraphBlurTask;\r\n private readonly _merge: FrameGraphBloomMergeTask;\r\n private readonly _defaultPipelineTextureType: number;\r\n\r\n /**\r\n * Constructs a new bloom task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param weight Weight of the bloom effect.\r\n * @param kernel Kernel size of the bloom effect.\r\n * @param threshold Threshold of the bloom effect.\r\n * @param hdr Whether the bloom effect is HDR.\r\n * @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, weight: number, kernel: number, threshold: number, hdr = false, bloomScale = 0.5) {\r\n super(name, frameGraph);\r\n\r\n this.hdr = hdr;\r\n\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (hdr) {\r\n const caps = frameGraph.engine.getCaps();\r\n if (caps.textureHalfFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n } else if (caps.textureFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n }\r\n\r\n this.bloom = new ThinBloomEffect(name, frameGraph.engine, bloomScale);\r\n this.bloom.threshold = threshold;\r\n this.bloom.kernel = kernel;\r\n this.bloom.weight = weight;\r\n\r\n this._downscale = new FrameGraphExtractHighlightsTask(`${name} Downscale`, this._frameGraph, this.bloom._downscale);\r\n this._blurX = new FrameGraphBlurTask(`${name} Blur X`, this._frameGraph, this.bloom._blurX);\r\n this._blurY = new FrameGraphBlurTask(`${name} Blur Y`, this._frameGraph, this.bloom._blurY);\r\n this._merge = new FrameGraphBloomMergeTask(`${name} Merge`, this._frameGraph, this.bloom._merge);\r\n\r\n this.onTexturesAllocatedObservable.add((context) => {\r\n this._downscale.onTexturesAllocatedObservable.notifyObservers(context);\r\n this._blurX.onTexturesAllocatedObservable.notifyObservers(context);\r\n this._blurY.onTexturesAllocatedObservable.notifyObservers(context);\r\n this._merge.onTexturesAllocatedObservable.notifyObservers(context);\r\n });\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.bloom.isReady();\r\n }\r\n\r\n public record(): void {\r\n if (this.sourceTexture === undefined) {\r\n throw new Error(\"FrameGraphBloomTask: sourceTexture is required\");\r\n }\r\n\r\n const sourceTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.sourceTexture);\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: {\r\n width: Math.floor(sourceTextureDescription.size.width * this.bloom.scale),\r\n height: Math.floor(sourceTextureDescription.size.height * this.bloom.scale),\r\n },\r\n options: {\r\n createMipMaps: false,\r\n types: [this._defaultPipelineTextureType],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n };\r\n\r\n const downscaleTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._downscale.name, textureCreationOptions);\r\n\r\n this._downscale.sourceTexture = this.sourceTexture;\r\n this._downscale.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._downscale.destinationTexture = downscaleTextureHandle;\r\n this._downscale.record(true);\r\n\r\n const blurXTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurX.name, textureCreationOptions);\r\n\r\n this._blurX.sourceTexture = downscaleTextureHandle;\r\n this._blurX.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurX.destinationTexture = blurXTextureHandle;\r\n this._blurX.record(true);\r\n\r\n const blurYTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurY.name, textureCreationOptions);\r\n\r\n this._blurY.sourceTexture = blurXTextureHandle;\r\n this._blurY.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurY.destinationTexture = blurYTextureHandle;\r\n this._blurY.record(true);\r\n\r\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture, this._merge.name, sourceTextureCreationOptions);\r\n\r\n this._merge.sourceTexture = this.sourceTexture;\r\n this._merge.sourceSamplingMode = this.sourceSamplingMode;\r\n this._merge.blurTexture = blurYTextureHandle;\r\n this._merge.destinationTexture = this.outputTexture;\r\n this._merge.record(true);\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n this._downscale.dispose();\r\n this._blurX.dispose();\r\n this._blurY.dispose();\r\n this._merge.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -16,8 +16,8 @@ export class FrameGraphBlurTask extends FrameGraphPostProcessTask {
|
|
|
16
16
|
}
|
|
17
17
|
record(skipCreationOfDisabledPasses = false, additionalExecute, additionalBindings) {
|
|
18
18
|
const pass = super.record(skipCreationOfDisabledPasses, additionalExecute, additionalBindings);
|
|
19
|
-
this.postProcess.textureWidth = this._outputWidth;
|
|
20
|
-
this.postProcess.textureHeight = this._outputHeight;
|
|
19
|
+
this.postProcess.textureWidth = this._outputWidth; // should be _sourceWidth, but to avoid a breaking change, we use _outputWidth (BlurPostProcess uses _outputTexture to get width/height)
|
|
20
|
+
this.postProcess.textureHeight = this._outputHeight; // same as above for height
|
|
21
21
|
return pass;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blurTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/blurTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,sDAA+C;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,sCAA+B;AAEjD;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,yBAAyB;IAG7D;;;;;OAKG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,eAAqC;QACnF,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,IAAI,IAAI,mBAAmB,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACxH,CAAC;IAEe,MAAM,CAClB,4BAA4B,GAAG,KAAK,EACpC,iBAA8D,EAC9D,kBAA+D;QAE/D,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,4BAA4B,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;QAE/F,IAAI,CAAC,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"blurTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/blurTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,sDAA+C;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,sCAA+B;AAEjD;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,yBAAyB;IAG7D;;;;;OAKG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,eAAqC;QACnF,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,IAAI,IAAI,mBAAmB,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACxH,CAAC;IAEe,MAAM,CAClB,4BAA4B,GAAG,KAAK,EACpC,iBAA8D,EAC9D,kBAA+D;QAE/D,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,4BAA4B,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;QAE/F,IAAI,CAAC,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,wIAAwI;QAC3L,IAAI,CAAC,WAAW,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,2BAA2B;QAEhF,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphRenderContext, FrameGraphRenderPass } from \"core/index\";\r\nimport { ThinBlurPostProcess } from \"core/PostProcesses/thinBlurPostProcess\";\r\nimport { FrameGraphPostProcessTask } from \"./postProcessTask\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * Task which applies a blur post process.\r\n */\r\nexport class FrameGraphBlurTask extends FrameGraphPostProcessTask {\r\n public override readonly postProcess: ThinBlurPostProcess;\r\n\r\n /**\r\n * Constructs a new blur task.\r\n * @param name Name of the task.\r\n * @param frameGraph Frame graph this task is associated with.\r\n * @param thinPostProcess The thin post process to use for the blur effect.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinBlurPostProcess) {\r\n super(name, frameGraph, thinPostProcess || new ThinBlurPostProcess(name, frameGraph.engine, new Vector2(1, 0), 10));\r\n }\r\n\r\n public override record(\r\n skipCreationOfDisabledPasses = false,\r\n additionalExecute?: (context: FrameGraphRenderContext) => void,\r\n additionalBindings?: (context: FrameGraphRenderContext) => void\r\n ): FrameGraphRenderPass {\r\n const pass = super.record(skipCreationOfDisabledPasses, additionalExecute, additionalBindings);\r\n\r\n this.postProcess.textureWidth = this._outputWidth; // should be _sourceWidth, but to avoid a breaking change, we use _outputWidth (BlurPostProcess uses _outputTexture to get width/height)\r\n this.postProcess.textureHeight = this._outputHeight; // same as above for height\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FrameGraph, FrameGraphTextureHandle,
|
|
1
|
+
import type { FrameGraph, FrameGraphTextureHandle, Camera } from "../../../index.js";
|
|
2
2
|
import { FrameGraphTask } from "../../frameGraphTask";
|
|
3
3
|
import { ThinDepthOfFieldEffectBlurLevel } from "../../../PostProcesses/thinDepthOfFieldEffect.js";
|
|
4
4
|
import { ThinDepthOfFieldEffect } from "../../../PostProcesses/thinDepthOfFieldEffect.js";
|
|
@@ -59,11 +59,10 @@ export declare class FrameGraphDepthOfFieldTask extends FrameGraphTask {
|
|
|
59
59
|
* Constructs a depth of field task.
|
|
60
60
|
* @param name The name of the task.
|
|
61
61
|
* @param frameGraph The frame graph this task belongs to.
|
|
62
|
-
* @param engine The engine to use for the depth of field effect.
|
|
63
62
|
* @param blurLevel The blur level of the depth of field effect (default: ThinDepthOfFieldEffectBlurLevel.Low).
|
|
64
63
|
* @param hdr Whether the depth of field effect is HDR.
|
|
65
64
|
*/
|
|
66
|
-
constructor(name: string, frameGraph: FrameGraph,
|
|
65
|
+
constructor(name: string, frameGraph: FrameGraph, blurLevel?: ThinDepthOfFieldEffectBlurLevel, hdr?: boolean);
|
|
67
66
|
isReady(): boolean;
|
|
68
67
|
record(): void;
|
|
69
68
|
dispose(): void;
|
|
@@ -33,11 +33,10 @@ export class FrameGraphDepthOfFieldTask extends FrameGraphTask {
|
|
|
33
33
|
* Constructs a depth of field task.
|
|
34
34
|
* @param name The name of the task.
|
|
35
35
|
* @param frameGraph The frame graph this task belongs to.
|
|
36
|
-
* @param engine The engine to use for the depth of field effect.
|
|
37
36
|
* @param blurLevel The blur level of the depth of field effect (default: ThinDepthOfFieldEffectBlurLevel.Low).
|
|
38
37
|
* @param hdr Whether the depth of field effect is HDR.
|
|
39
38
|
*/
|
|
40
|
-
constructor(name, frameGraph,
|
|
39
|
+
constructor(name, frameGraph, blurLevel = 0 /* ThinDepthOfFieldEffectBlurLevel.Low */, hdr = false) {
|
|
41
40
|
super(name, frameGraph);
|
|
42
41
|
/**
|
|
43
42
|
* The sampling mode to use for the source texture.
|
|
@@ -49,11 +48,11 @@ export class FrameGraphDepthOfFieldTask extends FrameGraphTask {
|
|
|
49
48
|
this.depthSamplingMode = 2;
|
|
50
49
|
this._blurX = [];
|
|
51
50
|
this._blurY = [];
|
|
52
|
-
this._engine = engine;
|
|
51
|
+
this._engine = frameGraph.engine;
|
|
53
52
|
this.hdr = hdr;
|
|
54
53
|
this._defaultPipelineTextureType = 0;
|
|
55
54
|
if (hdr) {
|
|
56
|
-
const caps = engine.getCaps();
|
|
55
|
+
const caps = frameGraph.engine.getCaps();
|
|
57
56
|
if (caps.textureHalfFloatRender) {
|
|
58
57
|
this._defaultPipelineTextureType = 2;
|
|
59
58
|
}
|
|
@@ -61,7 +60,7 @@ export class FrameGraphDepthOfFieldTask extends FrameGraphTask {
|
|
|
61
60
|
this._defaultPipelineTextureType = 1;
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
|
-
this.depthOfField = new ThinDepthOfFieldEffect(name, engine, blurLevel, true);
|
|
63
|
+
this.depthOfField = new ThinDepthOfFieldEffect(name, frameGraph.engine, blurLevel, true);
|
|
65
64
|
this._circleOfConfusion = new FrameGraphCircleOfConfusionTask(`${name} Circle of Confusion`, this._frameGraph, this.depthOfField._circleOfConfusion);
|
|
66
65
|
const blurCount = this.depthOfField._depthOfFieldBlurX.length;
|
|
67
66
|
for (let i = 0; i < blurCount; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depthOfFieldTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,yDAAkD;AAEnF;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,cAAc;IAgD1D;;OAEG;IACH,IAAoB,IAAI;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAoB,IAAI,CAAC,IAAY;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,kBAAkB,CAAC,IAAI,GAAG,GAAG,IAAI,sBAAsB,CAAC;QACjE,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC1C,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,IAAI,UAAU,CAAC,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AAO,EAAE,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureCreationOptions, FrameGraphTextureHandle, AbstractEngine, Camera } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ThinDepthOfFieldEffectBlurLevel } from \"core/PostProcesses/thinDepthOfFieldEffect\";\r\nimport { FrameGraphDepthOfFieldMergeTask } from \"./depthOfFieldMergeTask\";\r\nimport { FrameGraphCircleOfConfusionTask } from \"./circleOfConfusionTask\";\r\nimport { FrameGraphDepthOfFieldBlurTask } from \"./depthOfFieldBlurTask\";\r\nimport { ThinDepthOfFieldEffect } from \"core/PostProcesses/thinDepthOfFieldEffect\";\r\n\r\n/**\r\n * Task which applies a depth of field effect.\r\n */\r\nexport class FrameGraphDepthOfFieldTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the depth of field effect on.\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 depth texture to use for the depth of field effect.\r\n * Should store camera space depth (Z coordinate).\r\n */\r\n public depthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the depth texture.\r\n */\r\n public depthSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The camera used to render the scene.\r\n */\r\n public camera: Camera;\r\n\r\n /**\r\n * The destination texture to render the depth of field effect to.\r\n */\r\n public destinationTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture of the depth of field effect.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth of field effect.\r\n */\r\n public readonly depthOfField: ThinDepthOfFieldEffect;\r\n\r\n /**\r\n * Whether the depth of field effect is applied on HDR textures.\r\n * When true, the depth of field effect will use a higher precision texture format (half float or float). Else, it will use unsigned byte.\r\n */\r\n public readonly hdr: boolean;\r\n\r\n /**\r\n * The name of the task.\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._circleOfConfusion) {\r\n this._circleOfConfusion.name = `${name} Circle of Confusion`;\r\n }\r\n\r\n if (this._blurX) {\r\n for (let i = 0; i < this._blurX.length; i++) {\r\n this._blurX[i].name = `${name} Blur X${i}`;\r\n this._blurY[i].name = `${name} Blur Y${i}`;\r\n }\r\n }\r\n\r\n if (this._merge) {\r\n this._merge.name = `${name} Merge`;\r\n }\r\n }\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _circleOfConfusion: FrameGraphCircleOfConfusionTask;\r\n private readonly _blurX: FrameGraphDepthOfFieldBlurTask[] = [];\r\n private readonly _blurY: FrameGraphDepthOfFieldBlurTask[] = [];\r\n private readonly _merge: FrameGraphDepthOfFieldMergeTask;\r\n private readonly _defaultPipelineTextureType: number;\r\n\r\n /**\r\n * Constructs a depth of field task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph this task belongs to.\r\n * @param engine The engine to use for the depth of field effect.\r\n * @param blurLevel The blur level of the depth of field effect (default: ThinDepthOfFieldEffectBlurLevel.Low).\r\n * @param hdr Whether the depth of field effect is HDR.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, engine: AbstractEngine, blurLevel: ThinDepthOfFieldEffectBlurLevel = ThinDepthOfFieldEffectBlurLevel.Low, hdr = false) {\r\n super(name, frameGraph);\r\n\r\n this._engine = engine;\r\n this.hdr = hdr;\r\n\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (hdr) {\r\n const caps = engine.getCaps();\r\n if (caps.textureHalfFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n } else if (caps.textureFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n }\r\n\r\n this.depthOfField = new ThinDepthOfFieldEffect(name, engine, blurLevel, true);\r\n\r\n this._circleOfConfusion = new FrameGraphCircleOfConfusionTask(`${name} Circle of Confusion`, this._frameGraph, this.depthOfField._circleOfConfusion);\r\n\r\n const blurCount = this.depthOfField._depthOfFieldBlurX.length;\r\n\r\n for (let i = 0; i < blurCount; i++) {\r\n this._blurX.push(new FrameGraphDepthOfFieldBlurTask(`${name} Blur X${i}`, this._frameGraph, this.depthOfField._depthOfFieldBlurX[i][0]));\r\n this._blurY.push(new FrameGraphDepthOfFieldBlurTask(`${name} Blur Y${i}`, this._frameGraph, this.depthOfField._depthOfFieldBlurY[i][0]));\r\n }\r\n\r\n this._merge = new FrameGraphDepthOfFieldMergeTask(`${name} Merge`, this._frameGraph, this.depthOfField._dofMerge);\r\n\r\n this.onTexturesAllocatedObservable.add((context) => {\r\n this._circleOfConfusion.onTexturesAllocatedObservable.notifyObservers(context);\r\n for (let i = 0; i < blurCount; i++) {\r\n this._blurX[i].onTexturesAllocatedObservable.notifyObservers(context);\r\n this._blurY[i].onTexturesAllocatedObservable.notifyObservers(context);\r\n }\r\n this._merge.onTexturesAllocatedObservable.notifyObservers(context);\r\n });\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.depthOfField.isReady();\r\n }\r\n\r\n public record(): void {\r\n if (this.sourceTexture === undefined || this.depthTexture === undefined || this.camera === undefined) {\r\n throw new Error(\"FrameGraphDepthOfFieldTask: sourceTexture, depthTexture and camera are required\");\r\n }\r\n\r\n const sourceTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.sourceTexture);\r\n\r\n const textureSize = {\r\n width: sourceTextureDescription.size.width,\r\n height: sourceTextureDescription.size.height,\r\n };\r\n const circleOfConfusionTextureFormat = this._engine.isWebGPU || this._engine.version > 1 ? Constants.TEXTUREFORMAT_RED : Constants.TEXTUREFORMAT_RGBA;\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: textureSize,\r\n options: {\r\n createMipMaps: false,\r\n types: [this._defaultPipelineTextureType],\r\n formats: [circleOfConfusionTextureFormat],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n };\r\n\r\n const circleOfConfusionTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._circleOfConfusion.name, textureCreationOptions);\r\n\r\n this._circleOfConfusion.sourceTexture = this.sourceTexture; // texture not used by the CoC shader\r\n this._circleOfConfusion.depthTexture = this.depthTexture;\r\n this._circleOfConfusion.depthSamplingMode = this.depthSamplingMode;\r\n this._circleOfConfusion.camera = this.camera;\r\n this._circleOfConfusion.destinationTexture = circleOfConfusionTextureHandle;\r\n this._circleOfConfusion.record(true);\r\n\r\n textureCreationOptions.options.formats = [Constants.TEXTUREFORMAT_RGBA];\r\n\r\n const blurSteps: FrameGraphTextureHandle[] = [];\r\n\r\n for (let i = 0; i < this._blurX.length; i++) {\r\n const ratio = this.depthOfField._depthOfFieldBlurX[i][1];\r\n\r\n textureSize.width = Math.floor(sourceTextureDescription.size.width * ratio);\r\n textureSize.height = Math.floor(sourceTextureDescription.size.height * ratio);\r\n\r\n textureCreationOptions.options.labels![0] = \"step \" + (i + 1);\r\n\r\n const blurYTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurY[i].name, textureCreationOptions);\r\n\r\n this._blurY[i].sourceTexture = i === 0 ? this.sourceTexture : this._blurX[i - 1].outputTexture;\r\n this._blurY[i].sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurY[i].circleOfConfusionTexture = circleOfConfusionTextureHandle;\r\n this._blurY[i].destinationTexture = blurYTextureHandle;\r\n this._blurY[i].record(true);\r\n\r\n const blurXTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurX[i].name, textureCreationOptions);\r\n\r\n this._blurX[i].sourceTexture = this._blurY[i].outputTexture;\r\n this._blurX[i].sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurX[i].circleOfConfusionTexture = circleOfConfusionTextureHandle;\r\n this._blurX[i].destinationTexture = blurXTextureHandle;\r\n this._blurX[i].record(true);\r\n\r\n blurSteps.push(blurXTextureHandle);\r\n }\r\n\r\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture, this._merge.name, sourceTextureCreationOptions);\r\n\r\n this._merge.sourceTexture = this.sourceTexture;\r\n this._merge.sourceSamplingMode = this.sourceSamplingMode;\r\n this._merge.circleOfConfusionTexture = circleOfConfusionTextureHandle;\r\n this._merge.blurSteps = blurSteps;\r\n this._merge.destinationTexture = this.outputTexture;\r\n this._merge.record(true);\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n this._circleOfConfusion.dispose();\r\n for (let i = 0; i < this._blurX.length; i++) {\r\n this._blurX[i].dispose();\r\n this._blurY[i].dispose();\r\n }\r\n this._merge.dispose();\r\n super.dispose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C;YACzB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureCreationOptions, FrameGraphTextureHandle, AbstractEngine, Camera } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ThinDepthOfFieldEffectBlurLevel } from \"core/PostProcesses/thinDepthOfFieldEffect\";\r\nimport { FrameGraphDepthOfFieldMergeTask } from \"./depthOfFieldMergeTask\";\r\nimport { FrameGraphCircleOfConfusionTask } from \"./circleOfConfusionTask\";\r\nimport { FrameGraphDepthOfFieldBlurTask } from \"./depthOfFieldBlurTask\";\r\nimport { ThinDepthOfFieldEffect } from \"core/PostProcesses/thinDepthOfFieldEffect\";\r\n\r\n/**\r\n * Task which applies a depth of field effect.\r\n */\r\nexport class FrameGraphDepthOfFieldTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the depth of field effect on.\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 depth texture to use for the depth of field effect.\r\n * Should store camera space depth (Z coordinate).\r\n */\r\n public depthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the depth texture.\r\n */\r\n public depthSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The camera used to render the scene.\r\n */\r\n public camera: Camera;\r\n\r\n /**\r\n * The destination texture to render the depth of field effect to.\r\n */\r\n public destinationTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture of the depth of field effect.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth of field effect.\r\n */\r\n public readonly depthOfField: ThinDepthOfFieldEffect;\r\n\r\n /**\r\n * Whether the depth of field effect is applied on HDR textures.\r\n * When true, the depth of field effect will use a higher precision texture format (half float or float). Else, it will use unsigned byte.\r\n */\r\n public readonly hdr: boolean;\r\n\r\n /**\r\n * The name of the task.\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._circleOfConfusion) {\r\n this._circleOfConfusion.name = `${name} Circle of Confusion`;\r\n }\r\n\r\n if (this._blurX) {\r\n for (let i = 0; i < this._blurX.length; i++) {\r\n this._blurX[i].name = `${name} Blur X${i}`;\r\n this._blurY[i].name = `${name} Blur Y${i}`;\r\n }\r\n }\r\n\r\n if (this._merge) {\r\n this._merge.name = `${name} Merge`;\r\n }\r\n }\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _circleOfConfusion: FrameGraphCircleOfConfusionTask;\r\n private readonly _blurX: FrameGraphDepthOfFieldBlurTask[] = [];\r\n private readonly _blurY: FrameGraphDepthOfFieldBlurTask[] = [];\r\n private readonly _merge: FrameGraphDepthOfFieldMergeTask;\r\n private readonly _defaultPipelineTextureType: number;\r\n\r\n /**\r\n * Constructs a depth of field task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph this task belongs to.\r\n * @param blurLevel The blur level of the depth of field effect (default: ThinDepthOfFieldEffectBlurLevel.Low).\r\n * @param hdr Whether the depth of field effect is HDR.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, blurLevel: ThinDepthOfFieldEffectBlurLevel = ThinDepthOfFieldEffectBlurLevel.Low, hdr = false) {\r\n super(name, frameGraph);\r\n\r\n this._engine = frameGraph.engine;\r\n this.hdr = hdr;\r\n\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (hdr) {\r\n const caps = frameGraph.engine.getCaps();\r\n if (caps.textureHalfFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n } else if (caps.textureFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n }\r\n\r\n this.depthOfField = new ThinDepthOfFieldEffect(name, frameGraph.engine, blurLevel, true);\r\n\r\n this._circleOfConfusion = new FrameGraphCircleOfConfusionTask(`${name} Circle of Confusion`, this._frameGraph, this.depthOfField._circleOfConfusion);\r\n\r\n const blurCount = this.depthOfField._depthOfFieldBlurX.length;\r\n\r\n for (let i = 0; i < blurCount; i++) {\r\n this._blurX.push(new FrameGraphDepthOfFieldBlurTask(`${name} Blur X${i}`, this._frameGraph, this.depthOfField._depthOfFieldBlurX[i][0]));\r\n this._blurY.push(new FrameGraphDepthOfFieldBlurTask(`${name} Blur Y${i}`, this._frameGraph, this.depthOfField._depthOfFieldBlurY[i][0]));\r\n }\r\n\r\n this._merge = new FrameGraphDepthOfFieldMergeTask(`${name} Merge`, this._frameGraph, this.depthOfField._dofMerge);\r\n\r\n this.onTexturesAllocatedObservable.add((context) => {\r\n this._circleOfConfusion.onTexturesAllocatedObservable.notifyObservers(context);\r\n for (let i = 0; i < blurCount; i++) {\r\n this._blurX[i].onTexturesAllocatedObservable.notifyObservers(context);\r\n this._blurY[i].onTexturesAllocatedObservable.notifyObservers(context);\r\n }\r\n this._merge.onTexturesAllocatedObservable.notifyObservers(context);\r\n });\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.depthOfField.isReady();\r\n }\r\n\r\n public record(): void {\r\n if (this.sourceTexture === undefined || this.depthTexture === undefined || this.camera === undefined) {\r\n throw new Error(\"FrameGraphDepthOfFieldTask: sourceTexture, depthTexture and camera are required\");\r\n }\r\n\r\n const sourceTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.sourceTexture);\r\n\r\n const textureSize = {\r\n width: sourceTextureDescription.size.width,\r\n height: sourceTextureDescription.size.height,\r\n };\r\n const circleOfConfusionTextureFormat = this._engine.isWebGPU || this._engine.version > 1 ? Constants.TEXTUREFORMAT_RED : Constants.TEXTUREFORMAT_RGBA;\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: textureSize,\r\n options: {\r\n createMipMaps: false,\r\n types: [this._defaultPipelineTextureType],\r\n formats: [circleOfConfusionTextureFormat],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n };\r\n\r\n const circleOfConfusionTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._circleOfConfusion.name, textureCreationOptions);\r\n\r\n this._circleOfConfusion.sourceTexture = this.sourceTexture; // texture not used by the CoC shader\r\n this._circleOfConfusion.depthTexture = this.depthTexture;\r\n this._circleOfConfusion.depthSamplingMode = this.depthSamplingMode;\r\n this._circleOfConfusion.camera = this.camera;\r\n this._circleOfConfusion.destinationTexture = circleOfConfusionTextureHandle;\r\n this._circleOfConfusion.record(true);\r\n\r\n textureCreationOptions.options.formats = [Constants.TEXTUREFORMAT_RGBA];\r\n\r\n const blurSteps: FrameGraphTextureHandle[] = [];\r\n\r\n for (let i = 0; i < this._blurX.length; i++) {\r\n const ratio = this.depthOfField._depthOfFieldBlurX[i][1];\r\n\r\n textureSize.width = Math.floor(sourceTextureDescription.size.width * ratio);\r\n textureSize.height = Math.floor(sourceTextureDescription.size.height * ratio);\r\n\r\n textureCreationOptions.options.labels![0] = \"step \" + (i + 1);\r\n\r\n const blurYTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurY[i].name, textureCreationOptions);\r\n\r\n this._blurY[i].sourceTexture = i === 0 ? this.sourceTexture : this._blurX[i - 1].outputTexture;\r\n this._blurY[i].sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurY[i].circleOfConfusionTexture = circleOfConfusionTextureHandle;\r\n this._blurY[i].destinationTexture = blurYTextureHandle;\r\n this._blurY[i].record(true);\r\n\r\n const blurXTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurX[i].name, textureCreationOptions);\r\n\r\n this._blurX[i].sourceTexture = this._blurY[i].outputTexture;\r\n this._blurX[i].sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurX[i].circleOfConfusionTexture = circleOfConfusionTextureHandle;\r\n this._blurX[i].destinationTexture = blurXTextureHandle;\r\n this._blurX[i].record(true);\r\n\r\n blurSteps.push(blurXTextureHandle);\r\n }\r\n\r\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture, this._merge.name, sourceTextureCreationOptions);\r\n\r\n this._merge.sourceTexture = this.sourceTexture;\r\n this._merge.sourceSamplingMode = this.sourceSamplingMode;\r\n this._merge.circleOfConfusionTexture = circleOfConfusionTextureHandle;\r\n this._merge.blurSteps = blurSteps;\r\n this._merge.destinationTexture = this.outputTexture;\r\n this._merge.record(true);\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n this._circleOfConfusion.dispose();\r\n for (let i = 0; i < this._blurX.length; i++) {\r\n this._blurX[i].dispose();\r\n this._blurY[i].dispose();\r\n }\r\n this._merge.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -25,7 +25,13 @@ export declare class FrameGraphPostProcessTask extends FrameGraphTask {
|
|
|
25
25
|
* The post process to apply.
|
|
26
26
|
*/
|
|
27
27
|
readonly postProcess: EffectWrapper;
|
|
28
|
+
/**
|
|
29
|
+
* The draw wrapper used by the post process
|
|
30
|
+
*/
|
|
31
|
+
get drawWrapper(): DrawWrapper;
|
|
28
32
|
protected readonly _postProcessDrawWrapper: DrawWrapper;
|
|
33
|
+
protected _sourceWidth: number;
|
|
34
|
+
protected _sourceHeight: number;
|
|
29
35
|
protected _outputWidth: number;
|
|
30
36
|
protected _outputHeight: number;
|
|
31
37
|
/**
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
3
|
+
import { textureSizeIsObject } from "../../../Materials/Textures/textureCreationOptions.js";
|
|
3
4
|
/**
|
|
4
5
|
* Task which applies a post process.
|
|
5
6
|
*/
|
|
6
7
|
export class FrameGraphPostProcessTask extends FrameGraphTask {
|
|
8
|
+
/**
|
|
9
|
+
* The draw wrapper used by the post process
|
|
10
|
+
*/
|
|
11
|
+
get drawWrapper() {
|
|
12
|
+
return this._postProcessDrawWrapper;
|
|
13
|
+
}
|
|
7
14
|
/**
|
|
8
15
|
* Constructs a new post process task.
|
|
9
16
|
* @param name Name of the task.
|
|
@@ -33,6 +40,13 @@ export class FrameGraphPostProcessTask extends FrameGraphTask {
|
|
|
33
40
|
const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);
|
|
34
41
|
sourceTextureCreationOptions.options.samples = 1;
|
|
35
42
|
this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture, this.name, sourceTextureCreationOptions);
|
|
43
|
+
const sourceSize = !sourceTextureCreationOptions.sizeIsPercentage
|
|
44
|
+
? textureSizeIsObject(sourceTextureCreationOptions.size)
|
|
45
|
+
? sourceTextureCreationOptions.size
|
|
46
|
+
: { width: sourceTextureCreationOptions.size, height: sourceTextureCreationOptions.size }
|
|
47
|
+
: this._frameGraph.textureManager.getAbsoluteDimensions(sourceTextureCreationOptions.size);
|
|
48
|
+
this._sourceWidth = sourceSize.width;
|
|
49
|
+
this._sourceHeight = sourceSize.height;
|
|
36
50
|
const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.outputTexture);
|
|
37
51
|
this._outputWidth = outputTextureDescription.size.width;
|
|
38
52
|
this._outputHeight = outputTextureDescription.size.height;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postProcessTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/postProcessTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"postProcessTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/postProcessTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAC;AAEzF;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAAc;IA2BzD;;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;QAzC5B;;WAEG;QACI,uBAAkB,GAAG,SAAS,CAAC,6BAA6B,CAAC;QAwChE,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;QAE5E,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YAC/C,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,C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AO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle, DrawWrapper, FrameGraphRenderPass, FrameGraphRenderContext, EffectWrapper } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { textureSizeIsObject } from \"../../../Materials/Textures/textureCreationOptions\";\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 */\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 destination 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 destinationTexture?: FrameGraphTextureHandle;\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 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\r\n this.onTexturesAllocatedObservable.add((context) => {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n });\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) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture is required`);\r\n }\r\n\r\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\r\n sourceTextureCreationOptions.options.samples = 1;\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture, this.name, sourceTextureCreationOptions);\r\n\r\n const sourceSize = !sourceTextureCreationOptions.sizeIsPercentage\r\n ? textureSizeIsObject(sourceTextureCreationOptions.size)\r\n ? sourceTextureCreationOptions.size\r\n : { width: sourceTextureCreationOptions.size, height: sourceTextureCreationOptions.size }\r\n : this._frameGraph.textureManager.getAbsoluteDimensions(sourceTextureCreationOptions.size);\r\n\r\n this._sourceWidth = sourceSize.width;\r\n this._sourceHeight = sourceSize.height;\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.addDependencies(this.sourceTexture);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setExecuteFunc((context) => {\r\n additionalExecute?.(context);\r\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture);\r\n additionalBindings?.(context);\r\n this.postProcess.bind();\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.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\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,11 @@
|
|
|
1
|
+
import type { FrameGraph, FrameGraphRenderPass, FrameGraphRenderContext } from "../../../index.js";
|
|
2
|
+
import { FrameGraphPostProcessTask } from "./postProcessTask";
|
|
3
|
+
import { ThinSSRBlurPostProcess } from "../../../PostProcesses/thinSSRBlurPostProcess.js";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class FrameGraphSSRBlurTask extends FrameGraphPostProcessTask {
|
|
8
|
+
readonly postProcess: ThinSSRBlurPostProcess;
|
|
9
|
+
constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinSSRBlurPostProcess);
|
|
10
|
+
record(skipCreationOfDisabledPasses?: boolean, additionalExecute?: (context: FrameGraphRenderContext) => void, additionalBindings?: (context: FrameGraphRenderContext) => void): FrameGraphRenderPass;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FrameGraphPostProcessTask } from "./postProcessTask.js";
|
|
2
|
+
import { ThinSSRBlurPostProcess } from "../../../PostProcesses/thinSSRBlurPostProcess.js";
|
|
3
|
+
import { Vector2 } from "../../../Maths/math.vector.js";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export class FrameGraphSSRBlurTask extends FrameGraphPostProcessTask {
|
|
8
|
+
constructor(name, frameGraph, thinPostProcess) {
|
|
9
|
+
super(name, frameGraph, thinPostProcess || new ThinSSRBlurPostProcess(name, frameGraph.engine, new Vector2(1, 0), 0.03));
|
|
10
|
+
}
|
|
11
|
+
record(skipCreationOfDisabledPasses = false, additionalExecute, additionalBindings) {
|
|
12
|
+
const pass = super.record(skipCreationOfDisabledPasses, additionalExecute, additionalBindings);
|
|
13
|
+
this.postProcess.textureWidth = this._sourceWidth;
|
|
14
|
+
this.postProcess.textureHeight = this._sourceHeight;
|
|
15
|
+
return pass;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ssrBlurTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssrBlurTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/ssrBlurTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,yDAAkD;AACnF,OAAO,EAAE,OAAO,EAAE,sCAA+B;AAEjD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,yBAAyB;IAGhE,YAAY,IAAY,EAAE,UAAsB,EAAE,eAAwC;QACtF,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,IAAI,IAAI,sBAAsB,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IAC7H,CAAC;IAEe,MAAM,CAClB,4BAA4B,GAAG,KAAK,EACpC,iBAA8D,EAC9D,kBAA+D;QAE/D,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,4BAA4B,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;QAE/F,IAAI,CAAC,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QAClD,IAAI,CAAC,WAAW,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QAEpD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphRenderPass, FrameGraphRenderContext } from \"core/index\";\r\nimport { FrameGraphPostProcessTask } from \"./postProcessTask\";\r\nimport { ThinSSRBlurPostProcess } from \"core/PostProcesses/thinSSRBlurPostProcess\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class FrameGraphSSRBlurTask extends FrameGraphPostProcessTask {\r\n public override readonly postProcess: ThinSSRBlurPostProcess;\r\n\r\n constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinSSRBlurPostProcess) {\r\n super(name, frameGraph, thinPostProcess || new ThinSSRBlurPostProcess(name, frameGraph.engine, new Vector2(1, 0), 0.03));\r\n }\r\n\r\n public override record(\r\n skipCreationOfDisabledPasses = false,\r\n additionalExecute?: (context: FrameGraphRenderContext) => void,\r\n additionalBindings?: (context: FrameGraphRenderContext) => void\r\n ): FrameGraphRenderPass {\r\n const pass = super.record(skipCreationOfDisabledPasses, additionalExecute, additionalBindings);\r\n\r\n this.postProcess.textureWidth = this._sourceWidth;\r\n this.postProcess.textureHeight = this._sourceHeight;\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { FrameGraph, FrameGraphTextureHandle, Camera } from "../../../index.js";
|
|
2
|
+
import { FrameGraphTask } from "../../frameGraphTask";
|
|
3
|
+
import { ThinSSRRenderingPipeline } from "../../../PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js";
|
|
4
|
+
/**
|
|
5
|
+
* Task which applies a SSR post process.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FrameGraphSSRRenderingPipelineTask extends FrameGraphTask {
|
|
8
|
+
/**
|
|
9
|
+
* The source texture to apply the SSR effect on.
|
|
10
|
+
*/
|
|
11
|
+
sourceTexture: FrameGraphTextureHandle;
|
|
12
|
+
/**
|
|
13
|
+
* The sampling mode to use for the source texture.
|
|
14
|
+
*/
|
|
15
|
+
sourceSamplingMode: number;
|
|
16
|
+
/**
|
|
17
|
+
* The normal texture used by the SSR effect.
|
|
18
|
+
*/
|
|
19
|
+
normalTexture: FrameGraphTextureHandle;
|
|
20
|
+
/**
|
|
21
|
+
* The depth texture used by the SSR effect.
|
|
22
|
+
*/
|
|
23
|
+
depthTexture: FrameGraphTextureHandle;
|
|
24
|
+
/**
|
|
25
|
+
* The back depth texture used by the SSR effect (optional).
|
|
26
|
+
* This is used when automatic thickness computation is enabled.
|
|
27
|
+
* The back depth texture is the depth texture of the scene rendered for the back side of the objects (that is, front faces are culled).
|
|
28
|
+
*/
|
|
29
|
+
backDepthTexture?: FrameGraphTextureHandle;
|
|
30
|
+
/**
|
|
31
|
+
* The reflectivity texture used by the SSR effect
|
|
32
|
+
*/
|
|
33
|
+
reflectivityTexture: FrameGraphTextureHandle;
|
|
34
|
+
private _camera;
|
|
35
|
+
/**
|
|
36
|
+
* The camera used to render the scene.
|
|
37
|
+
*/
|
|
38
|
+
get camera(): Camera;
|
|
39
|
+
set camera(camera: Camera);
|
|
40
|
+
/**
|
|
41
|
+
* The destination texture to render the SSR effect to.
|
|
42
|
+
*/
|
|
43
|
+
destinationTexture?: FrameGraphTextureHandle;
|
|
44
|
+
/**
|
|
45
|
+
* The output texture of the SSR effect.
|
|
46
|
+
*/
|
|
47
|
+
readonly outputTexture: FrameGraphTextureHandle;
|
|
48
|
+
/**
|
|
49
|
+
* The SSR Rendering pipeline.
|
|
50
|
+
*/
|
|
51
|
+
readonly ssr: ThinSSRRenderingPipeline;
|
|
52
|
+
/**
|
|
53
|
+
* The name of the task.
|
|
54
|
+
*/
|
|
55
|
+
get name(): string;
|
|
56
|
+
set name(name: string);
|
|
57
|
+
/**
|
|
58
|
+
* The texture type used by the different post processes created by SSR.
|
|
59
|
+
* It's a read-only property. If you want to change it, you must recreate the task and pass the appropriate texture type to the constructor.
|
|
60
|
+
*/
|
|
61
|
+
readonly textureType: number;
|
|
62
|
+
private readonly _ssr;
|
|
63
|
+
private readonly _ssrBlurX;
|
|
64
|
+
private readonly _ssrBlurY;
|
|
65
|
+
private readonly _ssrBlurCombiner;
|
|
66
|
+
/**
|
|
67
|
+
* Constructs a SSR rendering pipeline task.
|
|
68
|
+
* @param name The name of the task.
|
|
69
|
+
* @param frameGraph The frame graph this task belongs to.
|
|
70
|
+
* @param textureType The texture type used by the different post processes created by SSR (default: Constants.TEXTURETYPE_UNSIGNED_BYTE)
|
|
71
|
+
*/
|
|
72
|
+
constructor(name: string, frameGraph: FrameGraph, textureType?: number);
|
|
73
|
+
isReady(): boolean;
|
|
74
|
+
record(): void;
|
|
75
|
+
dispose(): void;
|
|
76
|
+
}
|