@onerjs/core 8.30.3 → 8.30.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Audio/audioSceneComponent.d.ts +9 -5
- package/Audio/audioSceneComponent.js +1 -0
- package/Audio/audioSceneComponent.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +8 -0
- package/AudioV2/abstractAudio/audioEngineV2.js +19 -0
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +5 -0
- package/AudioV2/webAudio/webAudioEngine.js +8 -0
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +2 -2
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js +5 -2
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Cameras/camera.d.ts +4 -0
- package/Cameras/camera.js +18 -9
- package/Cameras/camera.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +8 -0
- package/Engines/WebGPU/webgpuDrawContext.js +8 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/computeShaderBlock.d.ts +42 -0
- package/FrameGraph/Node/Blocks/computeShaderBlock.js +74 -0
- package/FrameGraph/Node/Blocks/computeShaderBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/executeBlock.d.ts +11 -1
- package/FrameGraph/Node/Blocks/executeBlock.js +18 -0
- package/FrameGraph/Node/Blocks/executeBlock.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/Blocks/inputBlock.js +2 -0
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/outputBlock.js +1 -0
- package/FrameGraph/Node/Blocks/outputBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.d.ts +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +7 -3
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +7 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/pass.d.ts +11 -1
- package/FrameGraph/Passes/pass.js +11 -1
- package/FrameGraph/Passes/pass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/computeShaderTask.d.ts +115 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js +174 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js.map +1 -0
- package/FrameGraph/Tasks/Misc/executeTask.d.ts +5 -0
- package/FrameGraph/Tasks/Misc/executeTask.js +3 -0
- package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js +7 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +1 -1
- package/FrameGraph/frameGraph.js +3 -6
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +3 -2
- package/FrameGraph/frameGraphTask.js +5 -2
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.js +2 -2
- 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/Lights/directionalLight.js +1 -4
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/pointLight.js +2 -5
- package/Lights/pointLight.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +9 -5
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.d.ts +14 -0
- package/Materials/PBR/openpbrMaterial.js +16 -0
- package/Materials/PBR/openpbrMaterial.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +8 -0
- package/Materials/materialHelper.functions.js +31 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/shaderMaterial.js +20 -0
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +26 -13
- package/Maths/math.vector.functions.js +29 -8
- package/Maths/math.vector.functions.js.map +1 -1
- package/Meshes/mesh.js +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Misc/decorators.d.ts +1 -1
- package/Misc/decorators.js.map +1 -1
- package/Misc/dumpTools.d.ts +20 -0
- package/Misc/dumpTools.js +60 -49
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/index.d.ts +1 -2
- package/Misc/index.js +1 -2
- package/Misc/index.js.map +1 -1
- package/Misc/sceneSerializer.js +4 -1
- package/Misc/sceneSerializer.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +57 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +163 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/index.d.ts +5 -4
- package/Particles/Node/Blocks/Emitters/index.js +5 -4
- package/Particles/Node/Blocks/Emitters/index.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +2 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +4 -0
- package/Particles/Node/Blocks/systemBlock.js +8 -0
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +5 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +4 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.js +5 -0
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +4 -3
- package/Particles/Node/nodeParticleSystemSet.helper.js +182 -115
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Physics/physicsRaycastResult.d.ts +3 -0
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.js +1 -1
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +9 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +4 -0
- package/PostProcesses/postProcess.js +4 -0
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/thinSSAO2PostProcess.d.ts +1 -0
- package/PostProcesses/thinSSAO2PostProcess.js +18 -6
- package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +1 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrCoatLayerData.js +4 -0
- package/Shaders/ShadersInclude/openpbrCoatLayerData.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrDirectLighting.js +5 -2
- package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +2 -2
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrFuzzLayerData.js +1 -1
- package/Shaders/ShadersInclude/openpbrFuzzLayerData.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/Shaders/particles.vertex.js +1 -1
- package/Shaders/particles.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +2 -2
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.js +4 -0
- package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +5 -2
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +2 -2
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrFuzzLayerData.js +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrFuzzLayerData.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.js +77 -3
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
- package/ShadersWGSL/particles.vertex.js +1 -1
- package/ShadersWGSL/particles.vertex.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +2 -0
- package/scene.js +9 -1
- package/scene.js.map +1 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { BaseTexture, DataBuffer, ExternalTexture, FrameGraph, FrameGraphContext, FrameGraphPass, IComputeShaderOptions, IComputeShaderPath, InternalTexture, StorageBuffer, TextureSampler, VideoTexture } from "../../../index.js";
|
|
2
|
+
import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
3
|
+
import { ComputeShader } from "../../../Compute/computeShader.js";
|
|
4
|
+
import { Vector3 } from "../../../Maths/math.vector.js";
|
|
5
|
+
import { UniformBuffer } from "../../../Materials/uniformBuffer.js";
|
|
6
|
+
/**
|
|
7
|
+
* Task used to execute a compute shader (WebGPU only)
|
|
8
|
+
*/
|
|
9
|
+
export declare class FrameGraphComputeShaderTask extends FrameGraphTask {
|
|
10
|
+
private readonly _notSupported;
|
|
11
|
+
private readonly _cs;
|
|
12
|
+
private readonly _ubo;
|
|
13
|
+
/**
|
|
14
|
+
* Defines the dispatch size for the compute shader
|
|
15
|
+
*/
|
|
16
|
+
dispatchSize: Vector3;
|
|
17
|
+
/**
|
|
18
|
+
* Defines an indirect dispatch buffer and offset.
|
|
19
|
+
* If set, this will be used instead of the dispatchSize property and an indirect dispatch will be performed.
|
|
20
|
+
* "offset" is the offset in the buffer where the workgroup counts are stored (default: 0)
|
|
21
|
+
*/
|
|
22
|
+
indirectDispatch?: {
|
|
23
|
+
buffer: StorageBuffer | DataBuffer;
|
|
24
|
+
offset?: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* An optional execute function that will be called at the beginning of the task execution
|
|
28
|
+
*/
|
|
29
|
+
execute?: (context: FrameGraphContext) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the compute shader used by the task
|
|
32
|
+
*/
|
|
33
|
+
get computeShader(): ComputeShader;
|
|
34
|
+
/**
|
|
35
|
+
* Gets a uniform buffer created by a call to createUniformBuffer()
|
|
36
|
+
* @param name Name of the uniform buffer
|
|
37
|
+
* @returns The uniform buffer
|
|
38
|
+
*/
|
|
39
|
+
getUniformBuffer(name: string): UniformBuffer;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new compute shader task.
|
|
42
|
+
* @param name The name of the task.
|
|
43
|
+
* @param frameGraph The frame graph the task belongs to.
|
|
44
|
+
* @param shaderPath Defines the route to the shader code in one of three ways:
|
|
45
|
+
* * object: \{ compute: "custom" \}, used with ShaderStore.ShadersStoreWGSL["customComputeShader"]
|
|
46
|
+
* * object: \{ computeElement: "HTMLElementId" \}, used with shader code in script tags
|
|
47
|
+
* * object: \{ computeSource: "compute shader code string" \}, where the string contains the shader code
|
|
48
|
+
* * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + "ComputeShader"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.
|
|
49
|
+
* @param options Define the options used to create the shader
|
|
50
|
+
*/
|
|
51
|
+
constructor(name: string, frameGraph: FrameGraph, shaderPath: IComputeShaderPath | string, options?: Partial<IComputeShaderOptions>);
|
|
52
|
+
isReady(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a uniform buffer and binds it to the shader
|
|
55
|
+
* @param name Name of the uniform buffer
|
|
56
|
+
* @param description Description of the uniform buffer: names and sizes (in floats) of the uniforms
|
|
57
|
+
* @param autoUpdate If the UBO must be updated automatically before each dispatch (default: true)
|
|
58
|
+
* @returns The created uniform buffer
|
|
59
|
+
*/
|
|
60
|
+
createUniformBuffer(name: string, description: {
|
|
61
|
+
[name: string]: number;
|
|
62
|
+
}, autoUpdate?: boolean): UniformBuffer;
|
|
63
|
+
/**
|
|
64
|
+
* Binds a texture to the shader
|
|
65
|
+
* @param name Binding name of the texture
|
|
66
|
+
* @param texture Texture to bind
|
|
67
|
+
* @param bindSampler Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture
|
|
68
|
+
*/
|
|
69
|
+
setTexture(name: string, texture: BaseTexture, bindSampler?: boolean): void;
|
|
70
|
+
/**
|
|
71
|
+
* Binds an internal texture to the shader
|
|
72
|
+
* @param name Binding name of the texture
|
|
73
|
+
* @param texture Texture to bind
|
|
74
|
+
*/
|
|
75
|
+
setInternalTexture(name: string, texture: InternalTexture): void;
|
|
76
|
+
/**
|
|
77
|
+
* Binds a storage texture to the shader
|
|
78
|
+
* @param name Binding name of the texture
|
|
79
|
+
* @param texture Texture to bind
|
|
80
|
+
*/
|
|
81
|
+
setStorageTexture(name: string, texture: BaseTexture): void;
|
|
82
|
+
/**
|
|
83
|
+
* Binds an external texture to the shader
|
|
84
|
+
* @param name Binding name of the texture
|
|
85
|
+
* @param texture Texture to bind
|
|
86
|
+
*/
|
|
87
|
+
setExternalTexture(name: string, texture: ExternalTexture): void;
|
|
88
|
+
/**
|
|
89
|
+
* Binds a video texture to the shader (by binding the external texture attached to this video)
|
|
90
|
+
* @param name Binding name of the texture
|
|
91
|
+
* @param texture Texture to bind
|
|
92
|
+
* @returns true if the video texture was successfully bound, else false. false will be returned if the current engine does not support external textures
|
|
93
|
+
*/
|
|
94
|
+
setVideoTexture(name: string, texture: VideoTexture): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Binds a uniform buffer to the shader
|
|
97
|
+
* @param name Binding name of the buffer
|
|
98
|
+
* @param buffer Buffer to bind
|
|
99
|
+
*/
|
|
100
|
+
setUniformBuffer(name: string, buffer: UniformBuffer | DataBuffer): void;
|
|
101
|
+
/**
|
|
102
|
+
* Binds a storage buffer to the shader
|
|
103
|
+
* @param name Binding name of the buffer
|
|
104
|
+
* @param buffer Buffer to bind
|
|
105
|
+
*/
|
|
106
|
+
setStorageBuffer(name: string, buffer: StorageBuffer | DataBuffer): void;
|
|
107
|
+
/**
|
|
108
|
+
* Binds a texture sampler to the shader
|
|
109
|
+
* @param name Binding name of the sampler
|
|
110
|
+
* @param sampler Sampler to bind
|
|
111
|
+
*/
|
|
112
|
+
setTextureSampler(name: string, sampler: TextureSampler): void;
|
|
113
|
+
record(skipCreationOfDisabledPasses?: boolean): FrameGraphPass<FrameGraphContext>;
|
|
114
|
+
dispose(): void;
|
|
115
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
2
|
+
import { ComputeShader } from "../../../Compute/computeShader.js";
|
|
3
|
+
import { Vector3 } from "../../../Maths/math.vector.js";
|
|
4
|
+
import { UniformBuffer } from "../../../Materials/uniformBuffer.js";
|
|
5
|
+
import { Logger } from "../../../Misc/logger.js";
|
|
6
|
+
/**
|
|
7
|
+
* Task used to execute a compute shader (WebGPU only)
|
|
8
|
+
*/
|
|
9
|
+
export class FrameGraphComputeShaderTask extends FrameGraphTask {
|
|
10
|
+
/**
|
|
11
|
+
* Gets the compute shader used by the task
|
|
12
|
+
*/
|
|
13
|
+
get computeShader() {
|
|
14
|
+
return this._cs;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Gets a uniform buffer created by a call to createUniformBuffer()
|
|
18
|
+
* @param name Name of the uniform buffer
|
|
19
|
+
* @returns The uniform buffer
|
|
20
|
+
*/
|
|
21
|
+
getUniformBuffer(name) {
|
|
22
|
+
return this._ubo[name]?.ubo;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new compute shader task.
|
|
26
|
+
* @param name The name of the task.
|
|
27
|
+
* @param frameGraph The frame graph the task belongs to.
|
|
28
|
+
* @param shaderPath Defines the route to the shader code in one of three ways:
|
|
29
|
+
* * object: \{ compute: "custom" \}, used with ShaderStore.ShadersStoreWGSL["customComputeShader"]
|
|
30
|
+
* * object: \{ computeElement: "HTMLElementId" \}, used with shader code in script tags
|
|
31
|
+
* * object: \{ computeSource: "compute shader code string" \}, where the string contains the shader code
|
|
32
|
+
* * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + "ComputeShader"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.
|
|
33
|
+
* @param options Define the options used to create the shader
|
|
34
|
+
*/
|
|
35
|
+
constructor(name, frameGraph, shaderPath, options = {}) {
|
|
36
|
+
super(name, frameGraph);
|
|
37
|
+
/**
|
|
38
|
+
* Defines the dispatch size for the compute shader
|
|
39
|
+
*/
|
|
40
|
+
this.dispatchSize = new Vector3(1, 1, 1);
|
|
41
|
+
if (!frameGraph.engine.getCaps().supportComputeShaders) {
|
|
42
|
+
this._notSupported = true;
|
|
43
|
+
Logger.Error("This engine does not support compute shaders!");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this._notSupported = false;
|
|
47
|
+
this._cs = new ComputeShader(name + "_cs", frameGraph.engine, shaderPath, options);
|
|
48
|
+
this._ubo = {};
|
|
49
|
+
}
|
|
50
|
+
isReady() {
|
|
51
|
+
return this._notSupported ? true : this._cs.isReady();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates a uniform buffer and binds it to the shader
|
|
55
|
+
* @param name Name of the uniform buffer
|
|
56
|
+
* @param description Description of the uniform buffer: names and sizes (in floats) of the uniforms
|
|
57
|
+
* @param autoUpdate If the UBO must be updated automatically before each dispatch (default: true)
|
|
58
|
+
* @returns The created uniform buffer
|
|
59
|
+
*/
|
|
60
|
+
createUniformBuffer(name, description, autoUpdate = true) {
|
|
61
|
+
const uBuffer = new UniformBuffer(this._frameGraph.engine);
|
|
62
|
+
this._ubo[name] = { ubo: uBuffer, autoUpdate };
|
|
63
|
+
for (const key in description) {
|
|
64
|
+
uBuffer.addUniform(key, description[key]);
|
|
65
|
+
}
|
|
66
|
+
this._cs.setUniformBuffer(name, uBuffer);
|
|
67
|
+
return uBuffer;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Binds a texture to the shader
|
|
71
|
+
* @param name Binding name of the texture
|
|
72
|
+
* @param texture Texture to bind
|
|
73
|
+
* @param bindSampler Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture
|
|
74
|
+
*/
|
|
75
|
+
setTexture(name, texture, bindSampler = true) {
|
|
76
|
+
this._cs.setTexture(name, texture, bindSampler);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Binds an internal texture to the shader
|
|
80
|
+
* @param name Binding name of the texture
|
|
81
|
+
* @param texture Texture to bind
|
|
82
|
+
*/
|
|
83
|
+
setInternalTexture(name, texture) {
|
|
84
|
+
this._cs.setInternalTexture(name, texture);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Binds a storage texture to the shader
|
|
88
|
+
* @param name Binding name of the texture
|
|
89
|
+
* @param texture Texture to bind
|
|
90
|
+
*/
|
|
91
|
+
setStorageTexture(name, texture) {
|
|
92
|
+
this._cs.setStorageTexture(name, texture);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Binds an external texture to the shader
|
|
96
|
+
* @param name Binding name of the texture
|
|
97
|
+
* @param texture Texture to bind
|
|
98
|
+
*/
|
|
99
|
+
setExternalTexture(name, texture) {
|
|
100
|
+
this._cs.setExternalTexture(name, texture);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Binds a video texture to the shader (by binding the external texture attached to this video)
|
|
104
|
+
* @param name Binding name of the texture
|
|
105
|
+
* @param texture Texture to bind
|
|
106
|
+
* @returns true if the video texture was successfully bound, else false. false will be returned if the current engine does not support external textures
|
|
107
|
+
*/
|
|
108
|
+
setVideoTexture(name, texture) {
|
|
109
|
+
return this._cs.setVideoTexture(name, texture);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Binds a uniform buffer to the shader
|
|
113
|
+
* @param name Binding name of the buffer
|
|
114
|
+
* @param buffer Buffer to bind
|
|
115
|
+
*/
|
|
116
|
+
setUniformBuffer(name, buffer) {
|
|
117
|
+
this._cs.setUniformBuffer(name, buffer);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Binds a storage buffer to the shader
|
|
121
|
+
* @param name Binding name of the buffer
|
|
122
|
+
* @param buffer Buffer to bind
|
|
123
|
+
*/
|
|
124
|
+
setStorageBuffer(name, buffer) {
|
|
125
|
+
this._cs.setStorageBuffer(name, buffer);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Binds a texture sampler to the shader
|
|
129
|
+
* @param name Binding name of the sampler
|
|
130
|
+
* @param sampler Sampler to bind
|
|
131
|
+
*/
|
|
132
|
+
setTextureSampler(name, sampler) {
|
|
133
|
+
this._cs.setTextureSampler(name, sampler);
|
|
134
|
+
}
|
|
135
|
+
record(skipCreationOfDisabledPasses) {
|
|
136
|
+
const pass = this._frameGraph.addPass(this.name);
|
|
137
|
+
if (this._notSupported) {
|
|
138
|
+
pass.setExecuteFunc(() => { });
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
pass.setExecuteFunc((context) => {
|
|
142
|
+
this.execute?.(context);
|
|
143
|
+
for (const key in this._ubo) {
|
|
144
|
+
const uboEntry = this._ubo[key];
|
|
145
|
+
if (uboEntry.autoUpdate) {
|
|
146
|
+
uboEntry.ubo.update();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (this.indirectDispatch) {
|
|
150
|
+
context.pushDebugGroup(`Indirect dispatch compute shader (${this.name})`);
|
|
151
|
+
this._cs.dispatchIndirect(this.indirectDispatch.buffer, this.indirectDispatch.offset);
|
|
152
|
+
context.popDebugGroup();
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
context.pushDebugGroup(`Dispatch compute shader (${this.name})`);
|
|
156
|
+
this._cs.dispatch(this.dispatchSize.x, this.dispatchSize.y, this.dispatchSize.z);
|
|
157
|
+
context.popDebugGroup();
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (!skipCreationOfDisabledPasses) {
|
|
162
|
+
const passDisabled = this._frameGraph.addPass(this.name + "_disabled", true);
|
|
163
|
+
passDisabled.setExecuteFunc(() => { });
|
|
164
|
+
}
|
|
165
|
+
return pass;
|
|
166
|
+
}
|
|
167
|
+
dispose() {
|
|
168
|
+
for (const key in this._ubo) {
|
|
169
|
+
this._ubo[key].ubo.dispose();
|
|
170
|
+
}
|
|
171
|
+
super.dispose();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=computeShaderTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeShaderT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,qCAAqC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;oBAC1E,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;oBACtF,OAAO,CAAC,aAAa,EAAE,CAAC;gBAC5B,CAAC;qBAAM,CAAC;oBACJ,OAAO,CAAC,cAAc,CAAC,4BAA4B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;oBACjE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;oBACjF,OAAO,CAAC,aAAa,EAAE,CAAC;gBAC5B,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QAED,IAAI,CAAC,4BAA4B,EAAE,CAAC;YAChC,MAAM,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;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACjC,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n BaseTexture,\r\n DataBuffer,\r\n ExternalTexture,\r\n FrameGraph,\r\n FrameGraphContext,\r\n FrameGraphPass,\r\n IComputeShaderOptions,\r\n IComputeShaderPath,\r\n InternalTexture,\r\n StorageBuffer,\r\n TextureSampler,\r\n VideoTexture,\r\n} from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ComputeShader } from \"core/Compute/computeShader\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { UniformBuffer } from \"core/Materials/uniformBuffer\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Task used to execute a compute shader (WebGPU only)\r\n */\r\nexport class FrameGraphComputeShaderTask extends FrameGraphTask {\r\n private readonly _notSupported: boolean;\r\n private readonly _cs: ComputeShader;\r\n private readonly _ubo: { [name: string]: { ubo: UniformBuffer; autoUpdate: boolean } };\r\n\r\n /**\r\n * Defines the dispatch size for the compute shader\r\n */\r\n public dispatchSize = new Vector3(1, 1, 1);\r\n\r\n /**\r\n * Defines an indirect dispatch buffer and offset.\r\n * If set, this will be used instead of the dispatchSize property and an indirect dispatch will be performed.\r\n * \"offset\" is the offset in the buffer where the workgroup counts are stored (default: 0)\r\n */\r\n public indirectDispatch?: { buffer: StorageBuffer | DataBuffer; offset?: number };\r\n\r\n /**\r\n * An optional execute function that will be called at the beginning of the task execution\r\n */\r\n public execute?: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * Gets the compute shader used by the task\r\n */\r\n public get computeShader(): ComputeShader {\r\n return this._cs;\r\n }\r\n\r\n /**\r\n * Gets a uniform buffer created by a call to createUniformBuffer()\r\n * @param name Name of the uniform buffer\r\n * @returns The uniform buffer\r\n */\r\n public getUniformBuffer(name: string): UniformBuffer {\r\n return this._ubo[name]?.ubo;\r\n }\r\n\r\n /**\r\n * Creates a new compute shader task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param shaderPath Defines the route to the shader code in one of three ways:\r\n * * object: \\{ compute: \"custom\" \\}, used with ShaderStore.ShadersStoreWGSL[\"customComputeShader\"]\r\n * * object: \\{ computeElement: \"HTMLElementId\" \\}, used with shader code in script tags\r\n * * object: \\{ computeSource: \"compute shader code string\" \\}, where the string contains the shader code\r\n * * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + \"ComputeShader\"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.\r\n * @param options Define the options used to create the shader\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, shaderPath: IComputeShaderPath | string, options: Partial<IComputeShaderOptions> = {}) {\r\n super(name, frameGraph);\r\n\r\n if (!frameGraph.engine.getCaps().supportComputeShaders) {\r\n this._notSupported = true;\r\n Logger.Error(\"This engine does not support compute shaders!\");\r\n return;\r\n }\r\n\r\n this._notSupported = false;\r\n this._cs = new ComputeShader(name + \"_cs\", frameGraph.engine, shaderPath, options);\r\n this._ubo = {};\r\n }\r\n\r\n public override isReady(): boolean {\r\n return this._notSupported ? true : this._cs.isReady();\r\n }\r\n\r\n /**\r\n * Creates a uniform buffer and binds it to the shader\r\n * @param name Name of the uniform buffer\r\n * @param description Description of the uniform buffer: names and sizes (in floats) of the uniforms\r\n * @param autoUpdate If the UBO must be updated automatically before each dispatch (default: true)\r\n * @returns The created uniform buffer\r\n */\r\n public createUniformBuffer(name: string, description: { [name: string]: number }, autoUpdate = true): UniformBuffer {\r\n const uBuffer = new UniformBuffer(this._frameGraph.engine);\r\n\r\n this._ubo[name] = { ubo: uBuffer, autoUpdate };\r\n\r\n for (const key in description) {\r\n uBuffer.addUniform(key, description[key]);\r\n }\r\n\r\n this._cs.setUniformBuffer(name, uBuffer);\r\n\r\n return uBuffer;\r\n }\r\n\r\n /**\r\n * Binds a texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n * @param bindSampler Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture\r\n */\r\n public setTexture(name: string, texture: BaseTexture, bindSampler = true): void {\r\n this._cs.setTexture(name, texture, bindSampler);\r\n }\r\n\r\n /**\r\n * Binds an internal texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n */\r\n public setInternalTexture(name: string, texture: InternalTexture): void {\r\n this._cs.setInternalTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds a storage texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n */\r\n public setStorageTexture(name: string, texture: BaseTexture): void {\r\n this._cs.setStorageTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds an external texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n */\r\n public setExternalTexture(name: string, texture: ExternalTexture): void {\r\n this._cs.setExternalTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds a video texture to the shader (by binding the external texture attached to this video)\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n * @returns true if the video texture was successfully bound, else false. false will be returned if the current engine does not support external textures\r\n */\r\n public setVideoTexture(name: string, texture: VideoTexture) {\r\n return this._cs.setVideoTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds a uniform buffer to the shader\r\n * @param name Binding name of the buffer\r\n * @param buffer Buffer to bind\r\n */\r\n public setUniformBuffer(name: string, buffer: UniformBuffer | DataBuffer): void {\r\n this._cs.setUniformBuffer(name, buffer);\r\n }\r\n\r\n /**\r\n * Binds a storage buffer to the shader\r\n * @param name Binding name of the buffer\r\n * @param buffer Buffer to bind\r\n */\r\n public setStorageBuffer(name: string, buffer: StorageBuffer | DataBuffer): void {\r\n this._cs.setStorageBuffer(name, buffer);\r\n }\r\n\r\n /**\r\n * Binds a texture sampler to the shader\r\n * @param name Binding name of the sampler\r\n * @param sampler Sampler to bind\r\n */\r\n public setTextureSampler(name: string, sampler: TextureSampler): void {\r\n this._cs.setTextureSampler(name, sampler);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses?: boolean): FrameGraphPass<FrameGraphContext> {\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n if (this._notSupported) {\r\n pass.setExecuteFunc(() => {});\r\n } else {\r\n pass.setExecuteFunc((context) => {\r\n this.execute?.(context);\r\n\r\n for (const key in this._ubo) {\r\n const uboEntry = this._ubo[key];\r\n if (uboEntry.autoUpdate) {\r\n uboEntry.ubo.update();\r\n }\r\n }\r\n\r\n if (this.indirectDispatch) {\r\n context.pushDebugGroup(`Indirect dispatch compute shader (${this.name})`);\r\n this._cs.dispatchIndirect(this.indirectDispatch.buffer, this.indirectDispatch.offset);\r\n context.popDebugGroup();\r\n } else {\r\n context.pushDebugGroup(`Dispatch compute shader (${this.name})`);\r\n this._cs.dispatch(this.dispatchSize.x, this.dispatchSize.y, this.dispatchSize.z);\r\n context.popDebugGroup();\r\n }\r\n });\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc(() => {});\r\n }\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose(): void {\r\n for (const key in this._ubo) {\r\n this._ubo[key].ubo.dispose();\r\n }\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -12,6 +12,11 @@ export declare class FrameGraphExecuteTask extends FrameGraphTask {
|
|
|
12
12
|
* The function to execute when the task is disabled (optional).
|
|
13
13
|
*/
|
|
14
14
|
funcDisabled?: (context: FrameGraphContext) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Custom readiness check (optional).
|
|
17
|
+
*/
|
|
18
|
+
customIsReady?: () => boolean;
|
|
19
|
+
isReady(): boolean;
|
|
15
20
|
/**
|
|
16
21
|
* Creates a new execute task.
|
|
17
22
|
* @param name The name of the task.
|
|
@@ -3,6 +3,9 @@ import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
|
3
3
|
* Task used to execute a custom function.
|
|
4
4
|
*/
|
|
5
5
|
export class FrameGraphExecuteTask extends FrameGraphTask {
|
|
6
|
+
isReady() {
|
|
7
|
+
return !this.customIsReady || this.customIsReady();
|
|
8
|
+
}
|
|
6
9
|
/**
|
|
7
10
|
* Creates a new execute task.
|
|
8
11
|
* @param name The name of the task.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Misc/executeTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,cAAc;
|
|
1
|
+
{"version":3,"file":"executeTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Misc/executeTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,cAAc;IAgBrC,OAAO;QACnB,OAAO,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5B,CAAC;IAEM,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QACjF,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAE7E,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphContext, FrameGraphPass } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to execute a custom function.\r\n */\r\nexport class FrameGraphExecuteTask extends FrameGraphTask {\r\n /**\r\n * The function to execute.\r\n */\r\n public func: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * The function to execute when the task is disabled (optional).\r\n */\r\n public funcDisabled?: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * Custom readiness check (optional).\r\n */\r\n public customIsReady?: () => boolean;\r\n\r\n public override isReady(): boolean {\r\n return !this.customIsReady || this.customIsReady();\r\n }\r\n\r\n /**\r\n * Creates a new execute task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n }\r\n\r\n public record(): FrameGraphPass<FrameGraphContext> {\r\n if (!this.func) {\r\n throw new Error(\"FrameGraphExecuteTask: Execute task must have a function.\");\r\n }\r\n\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n pass.setExecuteFunc((context) => {\r\n this.func(context);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc((context) => {\r\n this.funcDisabled?.(context);\r\n });\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
|
|
@@ -51,7 +51,7 @@ export declare class FrameGraphBloomTask extends FrameGraphTask {
|
|
|
51
51
|
* @param hdr Whether the bloom effect is HDR.
|
|
52
52
|
* @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.
|
|
53
53
|
*/
|
|
54
|
-
constructor(name: string, frameGraph: FrameGraph, weight
|
|
54
|
+
constructor(name: string, frameGraph: FrameGraph, weight?: number, kernel?: number, threshold?: number, hdr?: boolean, bloomScale?: number);
|
|
55
55
|
isReady(): boolean;
|
|
56
56
|
record(): void;
|
|
57
57
|
dispose(): void;
|
|
@@ -39,7 +39,7 @@ export class FrameGraphBloomTask extends FrameGraphTask {
|
|
|
39
39
|
* @param hdr Whether the bloom effect is HDR.
|
|
40
40
|
* @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.
|
|
41
41
|
*/
|
|
42
|
-
constructor(name, frameGraph, weight, kernel, threshold, hdr = false, bloomScale = 0.5) {
|
|
42
|
+
constructor(name, frameGraph, weight = 0.25, kernel = 64, threshold = 0.2, hdr = false, bloomScale = 0.5) {
|
|
43
43
|
super(name, frameGraph);
|
|
44
44
|
/**
|
|
45
45
|
* The sampling mode to use for the source texture.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bloomTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/bloomTask.ts"],"names":[],"mappings":"AACA,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,IAA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AI,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":["import 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 target 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 targetTexture?: 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.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) || 1,\r\n height: Math.floor(sourceTextureDescription.size.height * this.bloom.scale) || 1,\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.targetTexture = 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.targetTexture = 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.targetTexture = 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.targetTexture, 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.targetTexture = 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":"AACA,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,I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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":["import 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 target 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 targetTexture?: 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 = 0.25, kernel = 64, threshold = 0.2, 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.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) || 1,\r\n height: Math.floor(sourceTextureDescription.size.height * this.bloom.scale) || 1,\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.targetTexture = 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.targetTexture = 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.targetTexture = 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.targetTexture, 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.targetTexture = 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"]}
|
|
@@ -9,6 +9,7 @@ export declare class FrameGraphSSAO2Task extends FrameGraphPostProcessTask {
|
|
|
9
9
|
normalTexture: FrameGraphTextureHandle;
|
|
10
10
|
camera: Camera;
|
|
11
11
|
readonly postProcess: ThinSSAO2PostProcess;
|
|
12
|
+
private _currentCameraMode;
|
|
12
13
|
constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinSSAO2PostProcess);
|
|
13
14
|
record(skipCreationOfDisabledPasses?: boolean): FrameGraphRenderPass;
|
|
14
15
|
}
|
|
@@ -7,13 +7,20 @@ import { ThinSSAO2PostProcess } from "../../../PostProcesses/thinSSAO2PostProces
|
|
|
7
7
|
export class FrameGraphSSAO2Task extends FrameGraphPostProcessTask {
|
|
8
8
|
constructor(name, frameGraph, thinPostProcess) {
|
|
9
9
|
super(name, frameGraph, thinPostProcess || new ThinSSAO2PostProcess(name, frameGraph.scene));
|
|
10
|
+
this._currentCameraMode = -1;
|
|
10
11
|
}
|
|
11
12
|
record(skipCreationOfDisabledPasses = false) {
|
|
12
13
|
if (this.sourceTexture === undefined || this.depthTexture === undefined || this.normalTexture === undefined || this.camera === undefined) {
|
|
13
14
|
throw new Error(`FrameGraphSSAO2Task "${this.name}": sourceTexture, depthTexture, normalTexture and camera are required`);
|
|
14
15
|
}
|
|
16
|
+
this._currentCameraMode = this.camera.mode;
|
|
17
|
+
this.postProcess.updateEffect();
|
|
15
18
|
const pass = super.record(skipCreationOfDisabledPasses, (context) => {
|
|
16
19
|
this.postProcess.camera = this.camera;
|
|
20
|
+
if (this._currentCameraMode !== this.camera.mode) {
|
|
21
|
+
this._currentCameraMode = this.camera.mode;
|
|
22
|
+
this.postProcess.updateEffect();
|
|
23
|
+
}
|
|
17
24
|
context.setTextureSamplingMode(this.depthTexture, 2);
|
|
18
25
|
context.setTextureSamplingMode(this.normalTexture, 2);
|
|
19
26
|
}, (context) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssao2Task.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/ssao2Task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE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AAI,EAAE,CAAC;gBAC/C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBAC3C,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;YACpC,CAAC;YAED,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,6BAA6B,CAAC,CAAC;YAC3F,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,6BAA6B,CAAC,CAAC;QAChG,CAAC,EACD,CAAC,OAAO,EAAE,EAAE;YACR,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACnG,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,eAAe,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACzG,CAAC,CACJ,CAAC;QAEF,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QAE1C,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":["import type { FrameGraph, FrameGraphRenderPass, Camera, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphPostProcessTask } from \"./postProcessTask\";\r\nimport { ThinSSAO2PostProcess } from \"core/PostProcesses/thinSSAO2PostProcess\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class FrameGraphSSAO2Task extends FrameGraphPostProcessTask {\r\n public depthTexture: FrameGraphTextureHandle;\r\n\r\n public normalTexture: FrameGraphTextureHandle;\r\n\r\n public camera: Camera;\r\n\r\n public override readonly postProcess: ThinSSAO2PostProcess;\r\n\r\n private _currentCameraMode = -1;\r\n\r\n constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinSSAO2PostProcess) {\r\n super(name, frameGraph, thinPostProcess || new ThinSSAO2PostProcess(name, frameGraph.scene));\r\n }\r\n\r\n public override record(skipCreationOfDisabledPasses = false): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined || this.depthTexture === undefined || this.normalTexture === undefined || this.camera === undefined) {\r\n throw new Error(`FrameGraphSSAO2Task \"${this.name}\": sourceTexture, depthTexture, normalTexture and camera are required`);\r\n }\r\n\r\n this._currentCameraMode = this.camera.mode;\r\n this.postProcess.updateEffect();\r\n\r\n const pass = super.record(\r\n skipCreationOfDisabledPasses,\r\n (context) => {\r\n this.postProcess.camera = this.camera;\r\n\r\n if (this._currentCameraMode !== this.camera.mode) {\r\n this._currentCameraMode = this.camera.mode;\r\n this.postProcess.updateEffect();\r\n }\r\n\r\n context.setTextureSamplingMode(this.depthTexture, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n context.setTextureSamplingMode(this.normalTexture, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n },\r\n (context) => {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"depthSampler\", this.depthTexture);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"normalSampler\", this.normalTexture);\r\n }\r\n );\r\n\r\n pass.addDependencies([this.depthTexture]);\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"]}
|
|
@@ -121,7 +121,7 @@ export declare class FrameGraph implements IDisposable {
|
|
|
121
121
|
* Returns a promise that resolves when the frame graph is ready to be executed
|
|
122
122
|
* This method must be called after the graph has been built (FrameGraph.build called)!
|
|
123
123
|
* @param timeStep Time step in ms between retries (default is 16)
|
|
124
|
-
* @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is
|
|
124
|
+
* @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 5000)
|
|
125
125
|
* @returns The promise that resolves when the graph is ready
|
|
126
126
|
*/
|
|
127
127
|
whenReadyAsync(timeStep?: number, maxTimeout?: number): Promise<void>;
|
package/FrameGraph/frameGraph.js
CHANGED
|
@@ -198,10 +198,10 @@ export class FrameGraph {
|
|
|
198
198
|
* Returns a promise that resolves when the frame graph is ready to be executed
|
|
199
199
|
* This method must be called after the graph has been built (FrameGraph.build called)!
|
|
200
200
|
* @param timeStep Time step in ms between retries (default is 16)
|
|
201
|
-
* @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is
|
|
201
|
+
* @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 5000)
|
|
202
202
|
* @returns The promise that resolves when the graph is ready
|
|
203
203
|
*/
|
|
204
|
-
async whenReadyAsync(timeStep = 16, maxTimeout =
|
|
204
|
+
async whenReadyAsync(timeStep = 16, maxTimeout = 5000) {
|
|
205
205
|
let firstNotReadyTask = null;
|
|
206
206
|
return await new Promise((resolve) => {
|
|
207
207
|
this._whenReadyAsyncCancel = _RetryWithInterval(() => {
|
|
@@ -247,10 +247,7 @@ export class FrameGraph {
|
|
|
247
247
|
this._renderContext.bindRenderTarget();
|
|
248
248
|
this.textureManager._updateHistoryTextures();
|
|
249
249
|
for (const task of this._tasks) {
|
|
250
|
-
|
|
251
|
-
for (const pass of passes) {
|
|
252
|
-
pass._execute();
|
|
253
|
-
}
|
|
250
|
+
task._execute();
|
|
254
251
|
}
|
|
255
252
|
this._renderContext.bindRenderTarget(undefined, undefined, true); // restore default framebuffer
|
|
256
253
|
}
|