@babylonjs/core 7.39.1 → 7.39.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cameras/arcRotateCamera.d.ts +1 -1
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Debug/directionalLightFrustumViewer.d.ts +2 -1
- package/Debug/directionalLightFrustumViewer.js +4 -3
- package/Debug/directionalLightFrustumViewer.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +1 -0
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +8 -0
- package/Engines/constants.js +8 -0
- package/Engines/constants.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +3 -9
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +3 -9
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +3 -9
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +5 -17
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +5 -17
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +3 -9
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +6 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +40 -20
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.d.ts +77 -0
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +250 -0
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.d.ts +57 -0
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +169 -0
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Rendering/cullObjectsBlock.js +3 -9
- package/FrameGraph/Node/Blocks/Rendering/cullObjectsBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +4 -13
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +27 -0
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.d.ts +19 -0
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +28 -0
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -9
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +3 -9
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +2 -5
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/executeBlock.d.ts +29 -0
- package/FrameGraph/Node/Blocks/executeBlock.js +43 -0
- package/FrameGraph/Node/Blocks/executeBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/index.d.ts +4 -0
- package/FrameGraph/Node/Blocks/index.js +4 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.d.ts +7 -2
- package/FrameGraph/Node/Blocks/inputBlock.js +13 -0
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/resourceContainerBlock.d.ts +55 -0
- package/FrameGraph/Node/Blocks/resourceContainerBlock.js +97 -0
- package/FrameGraph/Node/Blocks/resourceContainerBlock.js.map +1 -0
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +13 -10
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js +11 -4
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +32 -4
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.d.ts +1 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js +11 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.d.ts +18 -0
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +24 -0
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -1
- package/FrameGraph/Passes/cullPass.d.ts +1 -1
- package/FrameGraph/Passes/cullPass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/executeTask.d.ts +22 -0
- package/FrameGraph/Tasks/Misc/executeTask.js +28 -0
- package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +72 -0
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +183 -0
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +16 -5
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +46 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +107 -0
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +264 -0
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -0
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +7 -0
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +9 -0
- package/FrameGraph/frameGraph.js +12 -3
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.js +4 -1
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/FrameGraph/index.d.ts +5 -0
- package/FrameGraph/index.js +5 -0
- package/FrameGraph/index.js.map +1 -1
- package/Inputs/scene.inputManager.d.ts +1 -1
- package/Inputs/scene.inputManager.js +8 -1
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +1 -1
- package/Lights/Shadows/shadowGenerator.js +2 -7
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/directionalLight.d.ts +5 -4
- package/Lights/directionalLight.js +7 -9
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/shadowLight.d.ts +4 -4
- package/Lights/shadowLight.js +3 -2
- package/Lights/shadowLight.js.map +1 -1
- package/Lights/spotLight.d.ts +2 -2
- package/Lights/spotLight.js +3 -2
- package/Lights/spotLight.js.map +1 -1
- package/Loading/sceneLoader.d.ts +1 -1
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterial.js +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js +18 -6
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
- package/Materials/PBR/pbrSpecularGlossinessMaterial.js +18 -6
- package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +2 -0
- package/Materials/Textures/renderTargetTexture.js +18 -8
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/material.js +3 -1
- package/Materials/material.js.map +1 -1
- package/Materials/materialPluginBase.d.ts +4 -0
- package/Materials/materialPluginBase.js +4 -0
- package/Materials/materialPluginBase.js.map +1 -1
- package/Maths/math.color.js.map +1 -1
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/lattice.material.d.ts +3 -8
- package/Meshes/lattice.material.js.map +1 -1
- package/Misc/copyTextureToTexture.js +1 -1
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Misc/filesInput.d.ts +3 -1
- package/Misc/filesInput.js +8 -4
- package/Misc/filesInput.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +2 -2
- package/PostProcesses/postProcess.js +4 -4
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/postProcessManager.js +1 -1
- package/PostProcesses/postProcessManager.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/Shaders/default.fragment.js +2 -1
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/default.vertex.js +2 -1
- package/Shaders/default.vertex.js.map +1 -1
- package/Shaders/pbr.fragment.js +2 -1
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +2 -1
- package/Shaders/pbr.vertex.js.map +1 -1
- package/XR/webXRCamera.js +3 -0
- package/XR/webXRCamera.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +7 -0
- package/scene.js +10 -1
- package/scene.js.map +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Scene, FrameGraph, FrameGraphObjectList, IShadowLight, FrameGraphTextureHandle } from "../../../index.js";
|
|
2
|
+
import { FrameGraphTask } from "../../frameGraphTask";
|
|
3
|
+
import { ShadowGenerator } from "../../../Lights/Shadows/shadowGenerator";
|
|
4
|
+
/**
|
|
5
|
+
* Task used to generate shadows from a list of objects.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FrameGraphShadowGeneratorTask extends FrameGraphTask {
|
|
8
|
+
/**
|
|
9
|
+
* The object list that generates shadows.
|
|
10
|
+
*/
|
|
11
|
+
objectList: FrameGraphObjectList;
|
|
12
|
+
private _light;
|
|
13
|
+
/**
|
|
14
|
+
* The light to generate shadows from.
|
|
15
|
+
*/
|
|
16
|
+
get light(): IShadowLight;
|
|
17
|
+
set light(value: IShadowLight);
|
|
18
|
+
private _mapSize;
|
|
19
|
+
/**
|
|
20
|
+
* The size of the shadow map.
|
|
21
|
+
*/
|
|
22
|
+
get mapSize(): number;
|
|
23
|
+
set mapSize(value: number);
|
|
24
|
+
private _useFloat32TextureType;
|
|
25
|
+
/**
|
|
26
|
+
* If true, the shadow map will use a 32 bits float texture type (else, 16 bits float is used if supported).
|
|
27
|
+
*/
|
|
28
|
+
get useFloat32TextureType(): boolean;
|
|
29
|
+
set useFloat32TextureType(value: boolean);
|
|
30
|
+
private _useRedTextureFormat;
|
|
31
|
+
/**
|
|
32
|
+
* If true, the shadow map will use a red texture format (else, a RGBA format is used).
|
|
33
|
+
*/
|
|
34
|
+
get useRedTextureFormat(): boolean;
|
|
35
|
+
set useRedTextureFormat(value: boolean);
|
|
36
|
+
private _bias;
|
|
37
|
+
/**
|
|
38
|
+
* The bias to apply to the shadow map.
|
|
39
|
+
*/
|
|
40
|
+
get bias(): number;
|
|
41
|
+
set bias(value: number);
|
|
42
|
+
private _normalBias;
|
|
43
|
+
/**
|
|
44
|
+
* The normal bias to apply to the shadow map.
|
|
45
|
+
*/
|
|
46
|
+
get normalBias(): number;
|
|
47
|
+
set normalBias(value: number);
|
|
48
|
+
private _darkness;
|
|
49
|
+
/**
|
|
50
|
+
* The darkness of the shadows.
|
|
51
|
+
*/
|
|
52
|
+
get darkness(): number;
|
|
53
|
+
set darkness(value: number);
|
|
54
|
+
private _transparencyShadow;
|
|
55
|
+
/**
|
|
56
|
+
* Gets or sets the ability to have transparent shadow
|
|
57
|
+
*/
|
|
58
|
+
get transparencyShadow(): boolean;
|
|
59
|
+
set transparencyShadow(value: boolean);
|
|
60
|
+
private _enableSoftTransparentShadow;
|
|
61
|
+
/**
|
|
62
|
+
* Enables or disables shadows with varying strength based on the transparency
|
|
63
|
+
*/
|
|
64
|
+
get enableSoftTransparentShadow(): boolean;
|
|
65
|
+
set enableSoftTransparentShadow(value: boolean);
|
|
66
|
+
private _useOpacityTextureForTransparentShadow;
|
|
67
|
+
/**
|
|
68
|
+
* If this is true, use the opacity texture's alpha channel for transparent shadows instead of the diffuse one
|
|
69
|
+
*/
|
|
70
|
+
get useOpacityTextureForTransparentShadow(): boolean;
|
|
71
|
+
set useOpacityTextureForTransparentShadow(value: boolean);
|
|
72
|
+
private _filter;
|
|
73
|
+
/**
|
|
74
|
+
* The filter to apply to the shadow map.
|
|
75
|
+
*/
|
|
76
|
+
get filter(): number;
|
|
77
|
+
set filter(value: number);
|
|
78
|
+
private _filteringQuality;
|
|
79
|
+
/**
|
|
80
|
+
* The filtering quality to apply to the filter.
|
|
81
|
+
*/
|
|
82
|
+
get filteringQuality(): number;
|
|
83
|
+
set filteringQuality(value: number);
|
|
84
|
+
/**
|
|
85
|
+
* The shadow generator.
|
|
86
|
+
*/
|
|
87
|
+
readonly shadowGenerator: ShadowGenerator;
|
|
88
|
+
/**
|
|
89
|
+
* The shadow map texture.
|
|
90
|
+
*/
|
|
91
|
+
readonly outputTexture: FrameGraphTextureHandle;
|
|
92
|
+
protected _shadowGenerator: ShadowGenerator | undefined;
|
|
93
|
+
protected _createShadowGenerator(): void;
|
|
94
|
+
protected _setupShadowGenerator(): void;
|
|
95
|
+
isReady(): boolean;
|
|
96
|
+
private _engine;
|
|
97
|
+
private _scene;
|
|
98
|
+
/**
|
|
99
|
+
* Creates a new shadow generator task.
|
|
100
|
+
* @param name The name of the task.
|
|
101
|
+
* @param frameGraph The frame graph the task belongs to.
|
|
102
|
+
* @param scene The scene to create the shadow generator for.
|
|
103
|
+
*/
|
|
104
|
+
constructor(name: string, frameGraph: FrameGraph, scene: Scene);
|
|
105
|
+
record(): void;
|
|
106
|
+
dispose(): void;
|
|
107
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
2
|
+
import { ShadowGenerator } from "../../../Lights/Shadows/shadowGenerator.js";
|
|
3
|
+
/**
|
|
4
|
+
* Task used to generate shadows from a list of objects.
|
|
5
|
+
*/
|
|
6
|
+
export class FrameGraphShadowGeneratorTask extends FrameGraphTask {
|
|
7
|
+
/**
|
|
8
|
+
* The light to generate shadows from.
|
|
9
|
+
*/
|
|
10
|
+
get light() {
|
|
11
|
+
return this._light;
|
|
12
|
+
}
|
|
13
|
+
set light(value) {
|
|
14
|
+
if (value === this._light) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
this._light = value;
|
|
18
|
+
this._setupShadowGenerator();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The size of the shadow map.
|
|
22
|
+
*/
|
|
23
|
+
get mapSize() {
|
|
24
|
+
return this._mapSize;
|
|
25
|
+
}
|
|
26
|
+
set mapSize(value) {
|
|
27
|
+
if (value === this._mapSize) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this._mapSize = value;
|
|
31
|
+
this._setupShadowGenerator();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* If true, the shadow map will use a 32 bits float texture type (else, 16 bits float is used if supported).
|
|
35
|
+
*/
|
|
36
|
+
get useFloat32TextureType() {
|
|
37
|
+
return this._useFloat32TextureType;
|
|
38
|
+
}
|
|
39
|
+
set useFloat32TextureType(value) {
|
|
40
|
+
if (value === this._useFloat32TextureType) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this._useFloat32TextureType = value;
|
|
44
|
+
this._setupShadowGenerator();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* If true, the shadow map will use a red texture format (else, a RGBA format is used).
|
|
48
|
+
*/
|
|
49
|
+
get useRedTextureFormat() {
|
|
50
|
+
return this._useRedTextureFormat;
|
|
51
|
+
}
|
|
52
|
+
set useRedTextureFormat(value) {
|
|
53
|
+
if (value === this._useRedTextureFormat) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this._useRedTextureFormat = value;
|
|
57
|
+
this._setupShadowGenerator();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The bias to apply to the shadow map.
|
|
61
|
+
*/
|
|
62
|
+
get bias() {
|
|
63
|
+
return this._bias;
|
|
64
|
+
}
|
|
65
|
+
set bias(value) {
|
|
66
|
+
if (value === this._bias) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this._bias = value;
|
|
70
|
+
if (this._shadowGenerator) {
|
|
71
|
+
this._shadowGenerator.bias = value;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The normal bias to apply to the shadow map.
|
|
76
|
+
*/
|
|
77
|
+
get normalBias() {
|
|
78
|
+
return this._normalBias;
|
|
79
|
+
}
|
|
80
|
+
set normalBias(value) {
|
|
81
|
+
if (value === this._normalBias) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this._normalBias = value;
|
|
85
|
+
if (this._shadowGenerator) {
|
|
86
|
+
this._shadowGenerator.normalBias = value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The darkness of the shadows.
|
|
91
|
+
*/
|
|
92
|
+
get darkness() {
|
|
93
|
+
return this._darkness;
|
|
94
|
+
}
|
|
95
|
+
set darkness(value) {
|
|
96
|
+
if (value === this._darkness) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this._darkness = value;
|
|
100
|
+
if (this._shadowGenerator) {
|
|
101
|
+
this._shadowGenerator.darkness = value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Gets or sets the ability to have transparent shadow
|
|
106
|
+
*/
|
|
107
|
+
get transparencyShadow() {
|
|
108
|
+
return this._transparencyShadow;
|
|
109
|
+
}
|
|
110
|
+
set transparencyShadow(value) {
|
|
111
|
+
if (value === this._transparencyShadow) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this._transparencyShadow = value;
|
|
115
|
+
if (this._shadowGenerator) {
|
|
116
|
+
this._shadowGenerator.transparencyShadow = value;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Enables or disables shadows with varying strength based on the transparency
|
|
121
|
+
*/
|
|
122
|
+
get enableSoftTransparentShadow() {
|
|
123
|
+
return this._enableSoftTransparentShadow;
|
|
124
|
+
}
|
|
125
|
+
set enableSoftTransparentShadow(value) {
|
|
126
|
+
if (value === this._enableSoftTransparentShadow) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
this._enableSoftTransparentShadow = value;
|
|
130
|
+
if (this._shadowGenerator) {
|
|
131
|
+
this._shadowGenerator.enableSoftTransparentShadow = value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* If this is true, use the opacity texture's alpha channel for transparent shadows instead of the diffuse one
|
|
136
|
+
*/
|
|
137
|
+
get useOpacityTextureForTransparentShadow() {
|
|
138
|
+
return this._useOpacityTextureForTransparentShadow;
|
|
139
|
+
}
|
|
140
|
+
set useOpacityTextureForTransparentShadow(value) {
|
|
141
|
+
if (value === this._useOpacityTextureForTransparentShadow) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
this._useOpacityTextureForTransparentShadow = value;
|
|
145
|
+
if (this._shadowGenerator) {
|
|
146
|
+
this._shadowGenerator.useOpacityTextureForTransparentShadow = value;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The filter to apply to the shadow map.
|
|
151
|
+
*/
|
|
152
|
+
get filter() {
|
|
153
|
+
return this._filter;
|
|
154
|
+
}
|
|
155
|
+
set filter(value) {
|
|
156
|
+
if (value === this._filter) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
this._filter = value;
|
|
160
|
+
if (this._shadowGenerator) {
|
|
161
|
+
this._shadowGenerator.filter = value;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The filtering quality to apply to the filter.
|
|
166
|
+
*/
|
|
167
|
+
get filteringQuality() {
|
|
168
|
+
return this._filteringQuality;
|
|
169
|
+
}
|
|
170
|
+
set filteringQuality(value) {
|
|
171
|
+
if (value === this._filteringQuality) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
this._filteringQuality = value;
|
|
175
|
+
if (this._shadowGenerator) {
|
|
176
|
+
this._shadowGenerator.filteringQuality = value;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
_createShadowGenerator() {
|
|
180
|
+
this._shadowGenerator = new ShadowGenerator(this._mapSize, this._light, this._useFloat32TextureType, undefined, this._useRedTextureFormat);
|
|
181
|
+
}
|
|
182
|
+
_setupShadowGenerator() {
|
|
183
|
+
this._shadowGenerator?.dispose();
|
|
184
|
+
this._shadowGenerator = undefined;
|
|
185
|
+
if (this._light !== undefined) {
|
|
186
|
+
this._createShadowGenerator();
|
|
187
|
+
const shadowGenerator = this._shadowGenerator;
|
|
188
|
+
if (shadowGenerator === undefined) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
shadowGenerator.bias = this._bias;
|
|
192
|
+
shadowGenerator.normalBias = this._normalBias;
|
|
193
|
+
shadowGenerator.darkness = this._darkness;
|
|
194
|
+
shadowGenerator.transparencyShadow = this._transparencyShadow;
|
|
195
|
+
shadowGenerator.enableSoftTransparentShadow = this._enableSoftTransparentShadow;
|
|
196
|
+
shadowGenerator.useOpacityTextureForTransparentShadow = this._useOpacityTextureForTransparentShadow;
|
|
197
|
+
shadowGenerator.filter = this._filter;
|
|
198
|
+
shadowGenerator.filteringQuality = this._filteringQuality;
|
|
199
|
+
shadowGenerator.getShadowMap()._disableEngineStages = true;
|
|
200
|
+
this.shadowGenerator = shadowGenerator;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
isReady() {
|
|
204
|
+
return !!this._shadowGenerator && !!this._shadowGenerator.getShadowMap()?.isReadyForRendering();
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Creates a new shadow generator task.
|
|
208
|
+
* @param name The name of the task.
|
|
209
|
+
* @param frameGraph The frame graph the task belongs to.
|
|
210
|
+
* @param scene The scene to create the shadow generator for.
|
|
211
|
+
*/
|
|
212
|
+
constructor(name, frameGraph, scene) {
|
|
213
|
+
super(name, frameGraph);
|
|
214
|
+
this._mapSize = 1024;
|
|
215
|
+
this._useFloat32TextureType = false;
|
|
216
|
+
this._useRedTextureFormat = true;
|
|
217
|
+
this._bias = 0.01;
|
|
218
|
+
this._normalBias = 0;
|
|
219
|
+
this._darkness = 0;
|
|
220
|
+
this._transparencyShadow = false;
|
|
221
|
+
this._enableSoftTransparentShadow = false;
|
|
222
|
+
this._useOpacityTextureForTransparentShadow = false;
|
|
223
|
+
this._filter = ShadowGenerator.FILTER_PCF;
|
|
224
|
+
this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
|
|
225
|
+
this._engine = scene.getEngine();
|
|
226
|
+
this._scene = scene;
|
|
227
|
+
this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
|
|
228
|
+
}
|
|
229
|
+
record() {
|
|
230
|
+
if (this.light === undefined || this.objectList === undefined) {
|
|
231
|
+
throw new Error(`FrameGraphShadowGeneratorTask ${this.name}: light and objectList are required`);
|
|
232
|
+
}
|
|
233
|
+
const shadowMap = this._frameGraph.textureManager.importTexture(`${this.name} shadowmap`, this._shadowGenerator.getShadowMap().getInternalTexture());
|
|
234
|
+
this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, shadowMap);
|
|
235
|
+
const pass = this._frameGraph.addPass(this.name);
|
|
236
|
+
pass.setExecuteFunc((_context) => {
|
|
237
|
+
if (!this.light.isEnabled() || !this.light.shadowEnabled) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const shadowMap = this._shadowGenerator.getShadowMap();
|
|
241
|
+
shadowMap.renderList = this.objectList.meshes;
|
|
242
|
+
shadowMap.particleSystemList = this.objectList.particleSystems;
|
|
243
|
+
const currentRenderTarget = this._engine._currentRenderTarget;
|
|
244
|
+
this._scene.incrementRenderId();
|
|
245
|
+
this._scene.resetCachedMaterial();
|
|
246
|
+
shadowMap.render();
|
|
247
|
+
if (this._engine._currentRenderTarget !== currentRenderTarget) {
|
|
248
|
+
if (!currentRenderTarget) {
|
|
249
|
+
this._engine.restoreDefaultFramebuffer();
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
this._engine.bindFramebuffer(currentRenderTarget);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
const passDisabled = this._frameGraph.addPass(this.name + "_disabled", true);
|
|
257
|
+
passDisabled.setExecuteFunc((_context) => { });
|
|
258
|
+
}
|
|
259
|
+
dispose() {
|
|
260
|
+
this._shadowGenerator?.dispose();
|
|
261
|
+
this._shadowGenerator = undefined;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=shadowGeneratorTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadowGeneratorTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/shadowGeneratorTask.ts"],"names":[],"mappings":"AAEA,OAAO,E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B,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC;gBAC7C,CAAC;qBAAM,CAAC;oBACJ,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;gBACtD,CAAC;YACL,CAAC;QACL,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,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,gBAAgB,EAAE,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;IACtC,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Scene, FrameGraph, FrameGraphObjectList, IShadowLight, WritableObject, AbstractEngine, FrameGraphTextureHandle } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ShadowGenerator } from \"../../../Lights/Shadows/shadowGenerator\";\r\n\r\n/**\r\n * Task used to generate shadows from a list of objects.\r\n */\r\nexport class FrameGraphShadowGeneratorTask extends FrameGraphTask {\r\n /**\r\n * The object list that generates shadows.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n private _light: IShadowLight;\r\n /**\r\n * The light to generate shadows from.\r\n */\r\n public get light(): IShadowLight {\r\n return this._light;\r\n }\r\n\r\n public set light(value: IShadowLight) {\r\n if (value === this._light) {\r\n return;\r\n }\r\n\r\n this._light = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _mapSize = 1024;\r\n /**\r\n * The size of the shadow map.\r\n */\r\n public get mapSize() {\r\n return this._mapSize;\r\n }\r\n\r\n public set mapSize(value: number) {\r\n if (value === this._mapSize) {\r\n return;\r\n }\r\n\r\n this._mapSize = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _useFloat32TextureType = false;\r\n /**\r\n * If true, the shadow map will use a 32 bits float texture type (else, 16 bits float is used if supported).\r\n */\r\n public get useFloat32TextureType() {\r\n return this._useFloat32TextureType;\r\n }\r\n\r\n public set useFloat32TextureType(value: boolean) {\r\n if (value === this._useFloat32TextureType) {\r\n return;\r\n }\r\n\r\n this._useFloat32TextureType = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _useRedTextureFormat = true;\r\n /**\r\n * If true, the shadow map will use a red texture format (else, a RGBA format is used).\r\n */\r\n public get useRedTextureFormat() {\r\n return this._useRedTextureFormat;\r\n }\r\n\r\n public set useRedTextureFormat(value: boolean) {\r\n if (value === this._useRedTextureFormat) {\r\n return;\r\n }\r\n\r\n this._useRedTextureFormat = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _bias = 0.01;\r\n /**\r\n * The bias to apply to the shadow map.\r\n */\r\n public get bias() {\r\n return this._bias;\r\n }\r\n\r\n public set bias(value: number) {\r\n if (value === this._bias) {\r\n return;\r\n }\r\n\r\n this._bias = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.bias = value;\r\n }\r\n }\r\n\r\n private _normalBias = 0;\r\n /**\r\n * The normal bias to apply to the shadow map.\r\n */\r\n public get normalBias() {\r\n return this._normalBias;\r\n }\r\n\r\n public set normalBias(value: number) {\r\n if (value === this._normalBias) {\r\n return;\r\n }\r\n\r\n this._normalBias = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.normalBias = value;\r\n }\r\n }\r\n\r\n private _darkness = 0;\r\n /**\r\n * The darkness of the shadows.\r\n */\r\n public get darkness() {\r\n return this._darkness;\r\n }\r\n\r\n public set darkness(value: number) {\r\n if (value === this._darkness) {\r\n return;\r\n }\r\n\r\n this._darkness = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.darkness = value;\r\n }\r\n }\r\n\r\n private _transparencyShadow = false;\r\n /**\r\n * Gets or sets the ability to have transparent shadow\r\n */\r\n public get transparencyShadow() {\r\n return this._transparencyShadow;\r\n }\r\n\r\n public set transparencyShadow(value: boolean) {\r\n if (value === this._transparencyShadow) {\r\n return;\r\n }\r\n\r\n this._transparencyShadow = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.transparencyShadow = value;\r\n }\r\n }\r\n\r\n private _enableSoftTransparentShadow = false;\r\n /**\r\n * Enables or disables shadows with varying strength based on the transparency\r\n */\r\n public get enableSoftTransparentShadow() {\r\n return this._enableSoftTransparentShadow;\r\n }\r\n\r\n public set enableSoftTransparentShadow(value: boolean) {\r\n if (value === this._enableSoftTransparentShadow) {\r\n return;\r\n }\r\n\r\n this._enableSoftTransparentShadow = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.enableSoftTransparentShadow = value;\r\n }\r\n }\r\n\r\n private _useOpacityTextureForTransparentShadow = false;\r\n /**\r\n * If this is true, use the opacity texture's alpha channel for transparent shadows instead of the diffuse one\r\n */\r\n public get useOpacityTextureForTransparentShadow() {\r\n return this._useOpacityTextureForTransparentShadow;\r\n }\r\n\r\n public set useOpacityTextureForTransparentShadow(value: boolean) {\r\n if (value === this._useOpacityTextureForTransparentShadow) {\r\n return;\r\n }\r\n\r\n this._useOpacityTextureForTransparentShadow = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.useOpacityTextureForTransparentShadow = value;\r\n }\r\n }\r\n\r\n private _filter = ShadowGenerator.FILTER_PCF;\r\n /**\r\n * The filter to apply to the shadow map.\r\n */\r\n public get filter() {\r\n return this._filter;\r\n }\r\n\r\n public set filter(value: number) {\r\n if (value === this._filter) {\r\n return;\r\n }\r\n\r\n this._filter = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.filter = value;\r\n }\r\n }\r\n\r\n private _filteringQuality = ShadowGenerator.QUALITY_HIGH;\r\n /**\r\n * The filtering quality to apply to the filter.\r\n */\r\n public get filteringQuality() {\r\n return this._filteringQuality;\r\n }\r\n\r\n public set filteringQuality(value: number) {\r\n if (value === this._filteringQuality) {\r\n return;\r\n }\r\n\r\n this._filteringQuality = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.filteringQuality = value;\r\n }\r\n }\r\n\r\n /**\r\n * The shadow generator.\r\n */\r\n public readonly shadowGenerator: ShadowGenerator;\r\n\r\n /**\r\n * The shadow map texture.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n protected _shadowGenerator: ShadowGenerator | undefined;\r\n\r\n protected _createShadowGenerator() {\r\n this._shadowGenerator = new ShadowGenerator(this._mapSize, this._light, this._useFloat32TextureType, undefined, this._useRedTextureFormat);\r\n }\r\n\r\n protected _setupShadowGenerator() {\r\n this._shadowGenerator?.dispose();\r\n this._shadowGenerator = undefined;\r\n if (this._light !== undefined) {\r\n this._createShadowGenerator();\r\n const shadowGenerator = this._shadowGenerator as ShadowGenerator | undefined;\r\n if (shadowGenerator === undefined) {\r\n return;\r\n }\r\n shadowGenerator.bias = this._bias;\r\n shadowGenerator.normalBias = this._normalBias;\r\n shadowGenerator.darkness = this._darkness;\r\n shadowGenerator.transparencyShadow = this._transparencyShadow;\r\n shadowGenerator.enableSoftTransparentShadow = this._enableSoftTransparentShadow;\r\n shadowGenerator.useOpacityTextureForTransparentShadow = this._useOpacityTextureForTransparentShadow;\r\n shadowGenerator.filter = this._filter;\r\n shadowGenerator.filteringQuality = this._filteringQuality;\r\n shadowGenerator.getShadowMap()!._disableEngineStages = true;\r\n (this.shadowGenerator as WritableObject<ShadowGenerator | undefined>) = shadowGenerator;\r\n }\r\n }\r\n\r\n public override isReady(): boolean {\r\n return !!this._shadowGenerator && !!this._shadowGenerator.getShadowMap()?.isReadyForRendering();\r\n }\r\n\r\n private _engine: AbstractEngine;\r\n private _scene: Scene;\r\n\r\n /**\r\n * Creates a new shadow generator task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene to create the shadow generator for.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene) {\r\n super(name, frameGraph);\r\n\r\n this._engine = scene.getEngine();\r\n this._scene = scene;\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.light === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphShadowGeneratorTask ${this.name}: light and objectList are required`);\r\n }\r\n\r\n const shadowMap = this._frameGraph.textureManager.importTexture(`${this.name} shadowmap`, this._shadowGenerator!.getShadowMap()!.getInternalTexture()!);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, shadowMap);\r\n\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n pass.setExecuteFunc((_context) => {\r\n if (!this.light.isEnabled() || !this.light.shadowEnabled) {\r\n return;\r\n }\r\n\r\n const shadowMap = this._shadowGenerator!.getShadowMap()!;\r\n\r\n shadowMap.renderList = this.objectList.meshes;\r\n shadowMap.particleSystemList = this.objectList.particleSystems;\r\n\r\n const currentRenderTarget = this._engine._currentRenderTarget;\r\n\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n shadowMap.render();\r\n\r\n if (this._engine._currentRenderTarget !== currentRenderTarget) {\r\n if (!currentRenderTarget) {\r\n this._engine.restoreDefaultFramebuffer();\r\n } else {\r\n this._engine.bindFramebuffer(currentRenderTarget);\r\n }\r\n }\r\n });\r\n\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n\r\n public override dispose() {\r\n this._shadowGenerator?.dispose();\r\n this._shadowGenerator = undefined;\r\n }\r\n}\r\n"]}
|
|
@@ -34,12 +34,19 @@ export class FrameGraphClearTextureTask extends FrameGraphTask {
|
|
|
34
34
|
if (this.destinationTexture === undefined && this.depthTexture === undefined) {
|
|
35
35
|
throw new Error(`FrameGraphClearTextureTask ${this.name}: destinationTexture and depthTexture can't both be undefined.`);
|
|
36
36
|
}
|
|
37
|
+
let textureSamples = 0;
|
|
38
|
+
let depthSamples = 0;
|
|
37
39
|
if (this.destinationTexture !== undefined) {
|
|
40
|
+
textureSamples = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture).options.samples || 1;
|
|
38
41
|
this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
|
|
39
42
|
}
|
|
40
43
|
if (this.depthTexture !== undefined) {
|
|
44
|
+
depthSamples = this._frameGraph.textureManager.getTextureDescription(this.depthTexture).options.samples || 1;
|
|
41
45
|
this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
|
|
42
46
|
}
|
|
47
|
+
if (textureSamples !== depthSamples && textureSamples !== 0 && depthSamples !== 0) {
|
|
48
|
+
throw new Error(`FrameGraphClearTextureTask ${this.name}: the depth texture and the output texture must have the same number of samples.`);
|
|
49
|
+
}
|
|
43
50
|
const pass = this._frameGraph.addRenderPass(this.name);
|
|
44
51
|
pass.setRenderTarget(this.destinationTexture);
|
|
45
52
|
pass.setRenderTargetDepth(this.depthTexture);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clearTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,cAAc;IAyC1D;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QA9C5B;;WAEG;QACI,UAAK,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAE5C;;WAEG;QACI,eAAU,GAAG,IAAI,CAAC;QAEzB;;WAEG;QACI,eAAU,GAAG,KAAK,CAAC;QAE1B;;WAEG;QAC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CAAC;QAEH,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,kBAAkB,CAAC,CAAC;QACtD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACrD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Color4 } from \"../../../Maths/math.color\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to clear a texture.\r\n */\r\nexport class FrameGraphClearTextureTask extends FrameGraphTask {\r\n /**\r\n * The color to clear the texture with.\r\n */\r\n public color = new Color4(0.2, 0.2, 0.3, 1);\r\n\r\n /**\r\n * If the color should be cleared.\r\n */\r\n public clearColor = true;\r\n\r\n /**\r\n * If the depth should be cleared.\r\n */\r\n public clearDepth = false;\r\n\r\n /**\r\n * If the stencil should be cleared.\r\n */\r\n public clearStencil = false;\r\n\r\n /**\r\n * The texture to clear.\r\n */\r\n public destinationTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture to clear.\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as destinationTexture, but the handle will be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth texture (same as depthTexture, but the handle will be different).\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new clear 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 this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.destinationTexture === undefined && this.depthTexture === undefined) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: destinationTexture and depthTexture can't both be undefined.`);\r\n }\r\n\r\n if (this.destinationTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n }\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n context.clear(this.color, !!this.clearColor, !!this.clearDepth, !!this.clearStencil);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"clearTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,cAAc;IAyC1D;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QA9C5B;;WAEG;QACI,UAAK,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAE5C;;WAEG;QACI,eA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I,cAAc,KAAK,CAAC,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;YAChF,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAAC,IAAI,kFAAkF,CAAC,CAAC;QAC/I,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEvD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC9C,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7C,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;QAEH,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,kBAAkB,CAAC,CAAC;QACtD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACrD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Color4 } from \"../../../Maths/math.color\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to clear a texture.\r\n */\r\nexport class FrameGraphClearTextureTask extends FrameGraphTask {\r\n /**\r\n * The color to clear the texture with.\r\n */\r\n public color = new Color4(0.2, 0.2, 0.3, 1);\r\n\r\n /**\r\n * If the color should be cleared.\r\n */\r\n public clearColor = true;\r\n\r\n /**\r\n * If the depth should be cleared.\r\n */\r\n public clearDepth = false;\r\n\r\n /**\r\n * If the stencil should be cleared.\r\n */\r\n public clearStencil = false;\r\n\r\n /**\r\n * The texture to clear.\r\n */\r\n public destinationTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture to clear.\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as destinationTexture, but the handle will be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth texture (same as depthTexture, but the handle will be different).\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new clear 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 this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record() {\r\n if (this.destinationTexture === undefined && this.depthTexture === undefined) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: destinationTexture and depthTexture can't both be undefined.`);\r\n }\r\n\r\n let textureSamples = 0;\r\n let depthSamples = 0;\r\n\r\n if (this.destinationTexture !== undefined) {\r\n textureSamples = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture).options.samples || 1;\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n }\r\n if (this.depthTexture !== undefined) {\r\n depthSamples = this._frameGraph.textureManager.getTextureDescription(this.depthTexture).options.samples || 1;\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n if (textureSamples !== depthSamples && textureSamples !== 0 && depthSamples !== 0) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: the depth texture and the output texture must have the same number of samples.`);\r\n }\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n context.clear(this.color, !!this.clearColor, !!this.clearDepth, !!this.clearStencil);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Scene, AbstractEngine, FrameGraphTask } from "../index.js";
|
|
2
|
+
import { FrameGraphPass } from "./Passes/pass";
|
|
2
3
|
import { FrameGraphRenderPass } from "./Passes/renderPass";
|
|
3
4
|
import { FrameGraphCullPass } from "./Passes/cullPass";
|
|
5
|
+
import { FrameGraphContext } from "./frameGraphContext";
|
|
4
6
|
import { FrameGraphTextureManager } from "./frameGraphTextureManager";
|
|
5
7
|
import { Observable } from "../Misc/observable.js";
|
|
6
8
|
/**
|
|
@@ -43,6 +45,13 @@ export declare class FrameGraph {
|
|
|
43
45
|
* @param task Task to add
|
|
44
46
|
*/
|
|
45
47
|
addTask(task: FrameGraphTask): void;
|
|
48
|
+
/**
|
|
49
|
+
* Adds a pass to a task. This method can only be called during a Task.record execution.
|
|
50
|
+
* @param name The name of the pass
|
|
51
|
+
* @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)
|
|
52
|
+
* @returns The render pass created
|
|
53
|
+
*/
|
|
54
|
+
addPass(name: string, whenTaskDisabled?: boolean): FrameGraphPass<FrameGraphContext>;
|
|
46
55
|
/**
|
|
47
56
|
* Adds a render pass to a task. This method can only be called during a Task.record execution.
|
|
48
57
|
* @param name The name of the pass
|
package/FrameGraph/frameGraph.js
CHANGED
|
@@ -7,9 +7,9 @@ import { FrameGraphTextureManager } from "./frameGraphTextureManager.js";
|
|
|
7
7
|
import { Observable } from "../Misc/observable.js";
|
|
8
8
|
var FrameGraphPassType;
|
|
9
9
|
(function (FrameGraphPassType) {
|
|
10
|
-
FrameGraphPassType[FrameGraphPassType["
|
|
11
|
-
FrameGraphPassType[FrameGraphPassType["
|
|
12
|
-
FrameGraphPassType[FrameGraphPassType["
|
|
10
|
+
FrameGraphPassType[FrameGraphPassType["Normal"] = 0] = "Normal";
|
|
11
|
+
FrameGraphPassType[FrameGraphPassType["Render"] = 1] = "Render";
|
|
12
|
+
FrameGraphPassType[FrameGraphPassType["Cull"] = 2] = "Cull";
|
|
13
13
|
})(FrameGraphPassType || (FrameGraphPassType = {}));
|
|
14
14
|
/**
|
|
15
15
|
* Class used to implement a frame graph
|
|
@@ -58,6 +58,15 @@ export class FrameGraph {
|
|
|
58
58
|
}
|
|
59
59
|
this._tasks.push(task);
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Adds a pass to a task. This method can only be called during a Task.record execution.
|
|
63
|
+
* @param name The name of the pass
|
|
64
|
+
* @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)
|
|
65
|
+
* @returns The render pass created
|
|
66
|
+
*/
|
|
67
|
+
addPass(name, whenTaskDisabled = false) {
|
|
68
|
+
return this._addPass(name, FrameGraphPassType.Normal, whenTaskDisabled);
|
|
69
|
+
}
|
|
61
70
|
/**
|
|
62
71
|
* Adds a render pass to a task. This method can only be called during a Task.record execution.
|
|
63
72
|
* @param name The name of the pass
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBA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AE,CAAC;oBACR,OAAO,EAAE,CAAC;gBACd,CAAC;qBAAM,CAAC;oBACJ,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;gBACpC,CAAC;YACL,CAAC,CAAC;YAEF,UAAU,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QAEvC,IAAI,CAAC,cAAc,CAAC,sBAAsB,EAAE,CAAC;QAE7C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAEjC,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;gBACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpB,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,KAAK;QACR,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QACvC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;CACJ","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nimport type { Scene, AbstractEngine, FrameGraphTask } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphCullPass } from \"./Passes/cullPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\n\r\nenum FrameGraphPassType {\r\n Render = 0,\r\n Cull = 1,\r\n Compute = 2,\r\n}\r\n\r\n/**\r\n * Class used to implement a frame graph\r\n * @experimental\r\n */\r\nexport class FrameGraph {\r\n /**\r\n * Gets the texture manager used by the frame graph\r\n */\r\n public readonly textureManager: FrameGraphTextureManager;\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _tasks: FrameGraphTask[] = [];\r\n private readonly _passContext: FrameGraphContext;\r\n private readonly _renderContext: FrameGraphRenderContext;\r\n private _currentProcessedTask: FrameGraphTask | null = null;\r\n\r\n /**\r\n * Observable raised when the node render graph is built\r\n */\r\n public onBuildObservable = new Observable<FrameGraph>();\r\n\r\n /**\r\n * Gets the engine used by the frame graph\r\n */\r\n public get engine() {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Constructs the frame graph\r\n * @param engine defines the hosting engine\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector\r\n * @param scene defines the scene the frame graph is associated with\r\n */\r\n constructor(engine: AbstractEngine, debugTextures = false, scene: Scene) {\r\n this._engine = engine;\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext();\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n }\r\n\r\n /**\r\n * Adds a render pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The render pass created\r\n */\r\n public addRenderPass(name: string, whenTaskDisabled = false): FrameGraphRenderPass {\r\n return this._addPass(name, FrameGraphPassType.Render, whenTaskDisabled) as FrameGraphRenderPass;\r\n }\r\n\r\n /**\r\n * Adds a cull pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The cull pass created\r\n */\r\n public addCullPass(name: string, whenTaskDisabled = false): FrameGraphCullPass {\r\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled) as FrameGraphCullPass;\r\n }\r\n\r\n private _addPass(name: string, passType: FrameGraphPassType, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass {\r\n if (!this._currentProcessedTask) {\r\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\r\n }\r\n\r\n let pass: FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass;\r\n\r\n switch (passType) {\r\n case FrameGraphPassType.Render:\r\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\r\n break;\r\n case FrameGraphPassType.Cull:\r\n pass = new FrameGraphCullPass(name, this._currentProcessedTask, this._passContext, this._engine);\r\n break;\r\n default:\r\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\r\n break;\r\n }\r\n\r\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\r\n\r\n return pass;\r\n }\r\n\r\n /**\r\n * Builds the frame graph.\r\n * This method should be called after all tasks have been added to the frame graph (FrameGraph.addTask) and before the graph is executed (FrameGraph.execute).\r\n */\r\n public build(): void {\r\n this.textureManager._releaseTextures(false);\r\n\r\n for (const task of this._tasks) {\r\n task._reset();\r\n\r\n this._currentProcessedTask = task;\r\n this.textureManager._isRecordingTask = true;\r\n\r\n task.record();\r\n\r\n this.textureManager._isRecordingTask = false;\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n this.textureManager._allocateTextures();\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed\r\n * This method must be called after the graph has been built (FrameGraph.build called)!\r\n * @param timeout Timeout in ms between retries (default is 16)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public whenReadyAsync(timeout = 16): Promise<void> {\r\n return new Promise((resolve) => {\r\n const checkReady = () => {\r\n let ready = this._renderContext._isReady();\r\n for (const task of this._tasks) {\r\n ready = task.isReady() && ready;\r\n }\r\n if (ready) {\r\n resolve();\r\n } else {\r\n setTimeout(checkReady, timeout);\r\n }\r\n };\r\n\r\n checkReady();\r\n });\r\n }\r\n\r\n /**\r\n * Executes the frame graph.\r\n */\r\n public execute(): void {\r\n this._renderContext.bindRenderTarget();\r\n\r\n this.textureManager._updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n const passes = task._getPasses();\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clears the frame graph (remove the tasks and release the textures).\r\n * The frame graph can be built again after this method is called.\r\n */\r\n public clear(): void {\r\n for (const task of this._tasks) {\r\n task._reset();\r\n }\r\n\r\n this._tasks.length = 0;\r\n this.textureManager._releaseTextures();\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n /**\r\n * Disposes the frame graph\r\n */\r\n public dispose(): void {\r\n this.clear();\r\n this.textureManager._dispose();\r\n this._renderContext._dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"frameGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FrameGraph/frameGraph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KAAK,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;CACJ","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nimport type { Scene, AbstractEngine, FrameGraphTask } from \"core/index\";\r\nimport { FrameGraphPass } from \"./Passes/pass\";\r\nimport { FrameGraphRenderPass } from \"./Passes/renderPass\";\r\nimport { FrameGraphCullPass } from \"./Passes/cullPass\";\r\nimport { FrameGraphRenderContext } from \"./frameGraphRenderContext\";\r\nimport { FrameGraphContext } from \"./frameGraphContext\";\r\nimport { FrameGraphTextureManager } from \"./frameGraphTextureManager\";\r\nimport { Observable } from \"core/Misc/observable\";\r\n\r\nenum FrameGraphPassType {\r\n Normal = 0,\r\n Render = 1,\r\n Cull = 2,\r\n}\r\n\r\n/**\r\n * Class used to implement a frame graph\r\n * @experimental\r\n */\r\nexport class FrameGraph {\r\n /**\r\n * Gets the texture manager used by the frame graph\r\n */\r\n public readonly textureManager: FrameGraphTextureManager;\r\n\r\n private readonly _engine: AbstractEngine;\r\n private readonly _tasks: FrameGraphTask[] = [];\r\n private readonly _passContext: FrameGraphContext;\r\n private readonly _renderContext: FrameGraphRenderContext;\r\n private _currentProcessedTask: FrameGraphTask | null = null;\r\n\r\n /**\r\n * Observable raised when the node render graph is built\r\n */\r\n public onBuildObservable = new Observable<FrameGraph>();\r\n\r\n /**\r\n * Gets the engine used by the frame graph\r\n */\r\n public get engine() {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Constructs the frame graph\r\n * @param engine defines the hosting engine\r\n * @param debugTextures defines a boolean indicating that textures created by the frame graph should be visible in the inspector\r\n * @param scene defines the scene the frame graph is associated with\r\n */\r\n constructor(engine: AbstractEngine, debugTextures = false, scene: Scene) {\r\n this._engine = engine;\r\n this.textureManager = new FrameGraphTextureManager(this._engine, debugTextures, scene);\r\n this._passContext = new FrameGraphContext();\r\n this._renderContext = new FrameGraphRenderContext(this._engine, this.textureManager, scene);\r\n }\r\n\r\n /**\r\n * Gets a task by name\r\n * @param name Name of the task to get\r\n * @returns The task or undefined if not found\r\n */\r\n public getTaskByName<T extends FrameGraphTask>(name: string): T | undefined {\r\n return this._tasks.find((t) => t.name === name) as T;\r\n }\r\n\r\n /**\r\n * Adds a task to the frame graph\r\n * @param task Task to add\r\n */\r\n public addTask(task: FrameGraphTask): void {\r\n if (this._currentProcessedTask !== null) {\r\n throw new Error(`FrameGraph.addTask: Can't add the task \"${task.name}\" while another task is currently building (task: ${this._currentProcessedTask.name}).`);\r\n }\r\n\r\n this._tasks.push(task);\r\n }\r\n\r\n /**\r\n * Adds a pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The render pass created\r\n */\r\n public addPass(name: string, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> {\r\n return this._addPass(name, FrameGraphPassType.Normal, whenTaskDisabled) as FrameGraphPass<FrameGraphContext>;\r\n }\r\n\r\n /**\r\n * Adds a render pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The render pass created\r\n */\r\n public addRenderPass(name: string, whenTaskDisabled = false): FrameGraphRenderPass {\r\n return this._addPass(name, FrameGraphPassType.Render, whenTaskDisabled) as FrameGraphRenderPass;\r\n }\r\n\r\n /**\r\n * Adds a cull pass to a task. This method can only be called during a Task.record execution.\r\n * @param name The name of the pass\r\n * @param whenTaskDisabled If true, the pass will be added to the list of passes to execute when the task is disabled (default is false)\r\n * @returns The cull pass created\r\n */\r\n public addCullPass(name: string, whenTaskDisabled = false): FrameGraphCullPass {\r\n return this._addPass(name, FrameGraphPassType.Cull, whenTaskDisabled) as FrameGraphCullPass;\r\n }\r\n\r\n private _addPass(name: string, passType: FrameGraphPassType, whenTaskDisabled = false): FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass {\r\n if (!this._currentProcessedTask) {\r\n throw new Error(\"FrameGraph: A pass must be created during a Task.record execution only.\");\r\n }\r\n\r\n let pass: FrameGraphPass<FrameGraphContext> | FrameGraphRenderPass;\r\n\r\n switch (passType) {\r\n case FrameGraphPassType.Render:\r\n pass = new FrameGraphRenderPass(name, this._currentProcessedTask, this._renderContext, this._engine);\r\n break;\r\n case FrameGraphPassType.Cull:\r\n pass = new FrameGraphCullPass(name, this._currentProcessedTask, this._passContext, this._engine);\r\n break;\r\n default:\r\n pass = new FrameGraphPass(name, this._currentProcessedTask, this._passContext);\r\n break;\r\n }\r\n\r\n this._currentProcessedTask._addPass(pass, whenTaskDisabled);\r\n\r\n return pass;\r\n }\r\n\r\n /**\r\n * Builds the frame graph.\r\n * This method should be called after all tasks have been added to the frame graph (FrameGraph.addTask) and before the graph is executed (FrameGraph.execute).\r\n */\r\n public build(): void {\r\n this.textureManager._releaseTextures(false);\r\n\r\n for (const task of this._tasks) {\r\n task._reset();\r\n\r\n this._currentProcessedTask = task;\r\n this.textureManager._isRecordingTask = true;\r\n\r\n task.record();\r\n\r\n this.textureManager._isRecordingTask = false;\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n this.textureManager._allocateTextures();\r\n\r\n for (const task of this._tasks) {\r\n task._checkTask();\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when the frame graph is ready to be executed\r\n * This method must be called after the graph has been built (FrameGraph.build called)!\r\n * @param timeout Timeout in ms between retries (default is 16)\r\n * @returns The promise that resolves when the graph is ready\r\n */\r\n public whenReadyAsync(timeout = 16): Promise<void> {\r\n return new Promise((resolve) => {\r\n const checkReady = () => {\r\n let ready = this._renderContext._isReady();\r\n for (const task of this._tasks) {\r\n ready = task.isReady() && ready;\r\n }\r\n if (ready) {\r\n resolve();\r\n } else {\r\n setTimeout(checkReady, timeout);\r\n }\r\n };\r\n\r\n checkReady();\r\n });\r\n }\r\n\r\n /**\r\n * Executes the frame graph.\r\n */\r\n public execute(): void {\r\n this._renderContext.bindRenderTarget();\r\n\r\n this.textureManager._updateHistoryTextures();\r\n\r\n for (const task of this._tasks) {\r\n const passes = task._getPasses();\r\n\r\n for (const pass of passes) {\r\n pass._execute();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clears the frame graph (remove the tasks and release the textures).\r\n * The frame graph can be built again after this method is called.\r\n */\r\n public clear(): void {\r\n for (const task of this._tasks) {\r\n task._reset();\r\n }\r\n\r\n this._tasks.length = 0;\r\n this.textureManager._releaseTextures();\r\n this._currentProcessedTask = null;\r\n }\r\n\r\n /**\r\n * Disposes the frame graph\r\n */\r\n public dispose(): void {\r\n this.clear();\r\n this.textureManager._dispose();\r\n this._renderContext._dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -435,7 +435,10 @@ export class FrameGraphTextureManager {
|
|
|
435
435
|
handle = handle ?? FrameGraphTextureManager._Counter++;
|
|
436
436
|
textureIndex = textureIndex || 0;
|
|
437
437
|
const textureName = creationOptions.isHistoryTexture ? `${name} ping` : name;
|
|
438
|
-
|
|
438
|
+
let label = creationOptions.options.labels?.[textureIndex] ?? "";
|
|
439
|
+
if (label === textureName) {
|
|
440
|
+
label = "";
|
|
441
|
+
}
|
|
439
442
|
const textureEntry = {
|
|
440
443
|
texture,
|
|
441
444
|
name: `${textureName}${label ? " " + label : ""}`,
|