@babylonjs/core 7.39.1 → 7.39.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/Engines/thinEngine.js +9 -3
- package/Engines/thinEngine.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,183 @@
|
|
|
1
|
+
import { CascadedShadowGenerator } from "../../../Lights/Shadows/cascadedShadowGenerator.js";
|
|
2
|
+
import { FrameGraphShadowGeneratorTask } from "./shadowGeneratorTask.js";
|
|
3
|
+
import { DirectionalLight } from "../../../Lights/directionalLight.js";
|
|
4
|
+
/**
|
|
5
|
+
* Task used to generate a cascaded shadow map from a list of objects.
|
|
6
|
+
*/
|
|
7
|
+
export class FrameGraphCascadedShadowGeneratorTask extends FrameGraphShadowGeneratorTask {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this._numCascades = CascadedShadowGenerator.DEFAULT_CASCADES_COUNT;
|
|
11
|
+
this._debug = false;
|
|
12
|
+
this._stabilizeCascades = false;
|
|
13
|
+
this._lambda = 0.5;
|
|
14
|
+
this._cascadeBlendPercentage = 0.1;
|
|
15
|
+
this._depthClamp = true;
|
|
16
|
+
this._autoCalcDepthBounds = false;
|
|
17
|
+
this._shadowMaxZ = 10000;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Checks if a shadow generator task is a cascaded shadow generator task.
|
|
21
|
+
* @param task The task to check.
|
|
22
|
+
* @returns True if the task is a cascaded shadow generator task, else false.
|
|
23
|
+
*/
|
|
24
|
+
static IsCascadedShadowGenerator(task) {
|
|
25
|
+
return task.numCascades !== undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The number of cascades.
|
|
29
|
+
*/
|
|
30
|
+
get numCascades() {
|
|
31
|
+
return this._numCascades;
|
|
32
|
+
}
|
|
33
|
+
set numCascades(value) {
|
|
34
|
+
if (value === this._numCascades) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this._numCascades = value;
|
|
38
|
+
this._setupShadowGenerator();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Gets or sets a value indicating whether the shadow generator should display the cascades.
|
|
42
|
+
*/
|
|
43
|
+
get debug() {
|
|
44
|
+
return this._debug;
|
|
45
|
+
}
|
|
46
|
+
set debug(value) {
|
|
47
|
+
if (value === this._debug) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this._debug = value;
|
|
51
|
+
if (this._shadowGenerator) {
|
|
52
|
+
this._shadowGenerator.debug = value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Gets or sets a value indicating whether the shadow generator should stabilize the cascades.
|
|
57
|
+
*/
|
|
58
|
+
get stabilizeCascades() {
|
|
59
|
+
return this._stabilizeCascades;
|
|
60
|
+
}
|
|
61
|
+
set stabilizeCascades(value) {
|
|
62
|
+
if (value === this._stabilizeCascades) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this._stabilizeCascades = value;
|
|
66
|
+
if (this._shadowGenerator) {
|
|
67
|
+
this._shadowGenerator.stabilizeCascades = value;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets or sets the lambda parameter of the shadow generator.
|
|
72
|
+
*/
|
|
73
|
+
get lambda() {
|
|
74
|
+
return this._lambda;
|
|
75
|
+
}
|
|
76
|
+
set lambda(value) {
|
|
77
|
+
if (value === this._lambda) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this._lambda = value;
|
|
81
|
+
if (this._shadowGenerator) {
|
|
82
|
+
this._shadowGenerator.lambda = value;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Gets or sets the cascade blend percentage.
|
|
87
|
+
*/
|
|
88
|
+
get cascadeBlendPercentage() {
|
|
89
|
+
return this._cascadeBlendPercentage;
|
|
90
|
+
}
|
|
91
|
+
set cascadeBlendPercentage(value) {
|
|
92
|
+
if (value === this._cascadeBlendPercentage) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this._cascadeBlendPercentage = value;
|
|
96
|
+
if (this._shadowGenerator) {
|
|
97
|
+
this._shadowGenerator.cascadeBlendPercentage = value;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Gets or sets a value indicating whether the shadow generator should use depth clamping.
|
|
102
|
+
*/
|
|
103
|
+
get depthClamp() {
|
|
104
|
+
return this._depthClamp;
|
|
105
|
+
}
|
|
106
|
+
set depthClamp(value) {
|
|
107
|
+
if (value === this._depthClamp) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this._depthClamp = value;
|
|
111
|
+
if (this._shadowGenerator) {
|
|
112
|
+
this._shadowGenerator.depthClamp = value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Gets or sets a value indicating whether the shadow generator should automatically calculate the depth bounds.
|
|
117
|
+
*/
|
|
118
|
+
get autoCalcDepthBounds() {
|
|
119
|
+
return this._autoCalcDepthBounds;
|
|
120
|
+
}
|
|
121
|
+
set autoCalcDepthBounds(value) {
|
|
122
|
+
if (value === this._autoCalcDepthBounds) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
this._autoCalcDepthBounds = value;
|
|
126
|
+
if (this._shadowGenerator) {
|
|
127
|
+
this._shadowGenerator.autoCalcDepthBounds = value;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Gets or sets the maximum shadow Z value.
|
|
132
|
+
*/
|
|
133
|
+
get shadowMaxZ() {
|
|
134
|
+
return this._shadowMaxZ;
|
|
135
|
+
}
|
|
136
|
+
set shadowMaxZ(value) {
|
|
137
|
+
if (value === this._shadowMaxZ) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this._shadowMaxZ = value;
|
|
141
|
+
if (this._shadowGenerator) {
|
|
142
|
+
this._shadowGenerator.shadowMaxZ = value;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Gets or sets the camera used to generate the shadow generator.
|
|
147
|
+
*/
|
|
148
|
+
get camera() {
|
|
149
|
+
return this._camera;
|
|
150
|
+
}
|
|
151
|
+
set camera(camera) {
|
|
152
|
+
this._camera = camera;
|
|
153
|
+
this._setupShadowGenerator();
|
|
154
|
+
}
|
|
155
|
+
record() {
|
|
156
|
+
if (this.camera === undefined) {
|
|
157
|
+
throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: camera is required`);
|
|
158
|
+
}
|
|
159
|
+
super.record();
|
|
160
|
+
}
|
|
161
|
+
_createShadowGenerator() {
|
|
162
|
+
if (!(this.light instanceof DirectionalLight)) {
|
|
163
|
+
throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: the CSM shadow generator only supports directional lights.`);
|
|
164
|
+
}
|
|
165
|
+
this._shadowGenerator = new CascadedShadowGenerator(this.mapSize, this.light, this.useFloat32TextureType, this._camera, this.useRedTextureFormat);
|
|
166
|
+
this._shadowGenerator.numCascades = this._numCascades;
|
|
167
|
+
}
|
|
168
|
+
_setupShadowGenerator() {
|
|
169
|
+
super._setupShadowGenerator();
|
|
170
|
+
const shadowGenerator = this._shadowGenerator;
|
|
171
|
+
if (shadowGenerator === undefined) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
shadowGenerator.debug = this._debug;
|
|
175
|
+
shadowGenerator.stabilizeCascades = this._stabilizeCascades;
|
|
176
|
+
shadowGenerator.lambda = this._lambda;
|
|
177
|
+
shadowGenerator.cascadeBlendPercentage = this._cascadeBlendPercentage;
|
|
178
|
+
shadowGenerator.depthClamp = this._depthClamp;
|
|
179
|
+
shadowGenerator.autoCalcDepthBounds = this._autoCalcDepthBounds;
|
|
180
|
+
shadowGenerator.shadowMaxZ = this._shadowMaxZ;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=csmShadowGeneratorTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csmShadowGeneratorTask.js","sourceRoot":"","s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esContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Camera } from \"core/index\";\r\nimport { CascadedShadowGenerator } from \"../../../Lights/Shadows/cascadedShadowGenerator\";\r\nimport { FrameGraphShadowGeneratorTask } from \"./shadowGeneratorTask\";\r\nimport { DirectionalLight } from \"../../../Lights/directionalLight\";\r\n\r\n/**\r\n * Task used to generate a cascaded shadow map from a list of objects.\r\n */\r\nexport class FrameGraphCascadedShadowGeneratorTask extends FrameGraphShadowGeneratorTask {\r\n protected override _shadowGenerator: CascadedShadowGenerator | undefined;\r\n\r\n /**\r\n * Checks if a shadow generator task is a cascaded shadow generator task.\r\n * @param task The task to check.\r\n * @returns True if the task is a cascaded shadow generator task, else false.\r\n */\r\n public static IsCascadedShadowGenerator(task: FrameGraphShadowGeneratorTask): task is FrameGraphCascadedShadowGeneratorTask {\r\n return (task as FrameGraphCascadedShadowGeneratorTask).numCascades !== undefined;\r\n }\r\n\r\n private _numCascades = CascadedShadowGenerator.DEFAULT_CASCADES_COUNT;\r\n /**\r\n * The number of cascades.\r\n */\r\n public get numCascades() {\r\n return this._numCascades;\r\n }\r\n\r\n public set numCascades(value: number) {\r\n if (value === this._numCascades) {\r\n return;\r\n }\r\n\r\n this._numCascades = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _debug = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should display the cascades.\r\n */\r\n public get debug() {\r\n return this._debug;\r\n }\r\n\r\n public set debug(value: boolean) {\r\n if (value === this._debug) {\r\n return;\r\n }\r\n\r\n this._debug = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.debug = value;\r\n }\r\n }\r\n\r\n private _stabilizeCascades = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should stabilize the cascades.\r\n */\r\n public get stabilizeCascades() {\r\n return this._stabilizeCascades;\r\n }\r\n\r\n public set stabilizeCascades(value: boolean) {\r\n if (value === this._stabilizeCascades) {\r\n return;\r\n }\r\n\r\n this._stabilizeCascades = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.stabilizeCascades = value;\r\n }\r\n }\r\n\r\n private _lambda = 0.5;\r\n /**\r\n * Gets or sets the lambda parameter of the shadow generator.\r\n */\r\n public get lambda() {\r\n return this._lambda;\r\n }\r\n\r\n public set lambda(value: number) {\r\n if (value === this._lambda) {\r\n return;\r\n }\r\n\r\n this._lambda = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.lambda = value;\r\n }\r\n }\r\n\r\n private _cascadeBlendPercentage = 0.1;\r\n /**\r\n * Gets or sets the cascade blend percentage.\r\n */\r\n public get cascadeBlendPercentage() {\r\n return this._cascadeBlendPercentage;\r\n }\r\n\r\n public set cascadeBlendPercentage(value: number) {\r\n if (value === this._cascadeBlendPercentage) {\r\n return;\r\n }\r\n\r\n this._cascadeBlendPercentage = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.cascadeBlendPercentage = value;\r\n }\r\n }\r\n\r\n private _depthClamp = true;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should use depth clamping.\r\n */\r\n public get depthClamp() {\r\n return this._depthClamp;\r\n }\r\n\r\n public set depthClamp(value: boolean) {\r\n if (value === this._depthClamp) {\r\n return;\r\n }\r\n\r\n this._depthClamp = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.depthClamp = value;\r\n }\r\n }\r\n\r\n private _autoCalcDepthBounds = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should automatically calculate the depth bounds.\r\n */\r\n public get autoCalcDepthBounds() {\r\n return this._autoCalcDepthBounds;\r\n }\r\n\r\n public set autoCalcDepthBounds(value: boolean) {\r\n if (value === this._autoCalcDepthBounds) {\r\n return;\r\n }\r\n\r\n this._autoCalcDepthBounds = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.autoCalcDepthBounds = value;\r\n }\r\n }\r\n\r\n private _shadowMaxZ = 10000;\r\n /**\r\n * Gets or sets the maximum shadow Z value.\r\n */\r\n public get shadowMaxZ() {\r\n return this._shadowMaxZ;\r\n }\r\n\r\n public set shadowMaxZ(value: number) {\r\n if (value === this._shadowMaxZ) {\r\n return;\r\n }\r\n\r\n this._shadowMaxZ = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.shadowMaxZ = value;\r\n }\r\n }\r\n\r\n private _camera: Camera;\r\n /**\r\n * Gets or sets the camera used to generate the shadow generator.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n public override record() {\r\n if (this.camera === undefined) {\r\n throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: camera is required`);\r\n }\r\n\r\n super.record();\r\n }\r\n\r\n protected override _createShadowGenerator() {\r\n if (!(this.light instanceof DirectionalLight)) {\r\n throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: the CSM shadow generator only supports directional lights.`);\r\n }\r\n this._shadowGenerator = new CascadedShadowGenerator(this.mapSize, this.light, this.useFloat32TextureType, this._camera, this.useRedTextureFormat);\r\n this._shadowGenerator.numCascades = this._numCascades;\r\n }\r\n\r\n protected override _setupShadowGenerator() {\r\n super._setupShadowGenerator();\r\n\r\n const shadowGenerator = this._shadowGenerator as CascadedShadowGenerator | undefined;\r\n if (shadowGenerator === undefined) {\r\n return;\r\n }\r\n\r\n shadowGenerator.debug = this._debug;\r\n shadowGenerator.stabilizeCascades = this._stabilizeCascades;\r\n shadowGenerator.lambda = this._lambda;\r\n shadowGenerator.cascadeBlendPercentage = this._cascadeBlendPercentage;\r\n shadowGenerator.depthClamp = this._depthClamp;\r\n shadowGenerator.autoCalcDepthBounds = this._autoCalcDepthBounds;\r\n shadowGenerator.shadowMaxZ = this._shadowMaxZ;\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext, ObjectRendererOptions } from "../../../index.js";
|
|
1
|
+
import type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext, ObjectRendererOptions, Nullable, Observer, FrameGraphShadowGeneratorTask } from "../../../index.js";
|
|
2
2
|
import { FrameGraphTask } from "../../frameGraphTask";
|
|
3
3
|
import { ObjectRenderer } from "../../../Rendering/objectRenderer";
|
|
4
4
|
/**
|
|
@@ -17,6 +17,10 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
17
17
|
* The dependencies of the task (optional).
|
|
18
18
|
*/
|
|
19
19
|
dependencies?: FrameGraphTextureHandle[];
|
|
20
|
+
/**
|
|
21
|
+
* The shadow generators used to render the objects (optional).
|
|
22
|
+
*/
|
|
23
|
+
shadowGenerators?: FrameGraphShadowGeneratorTask[];
|
|
20
24
|
private _camera;
|
|
21
25
|
/**
|
|
22
26
|
* Gets or sets the camera used to render the objects.
|
|
@@ -35,6 +39,10 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
35
39
|
* If depth writing should be enabled (default is true).
|
|
36
40
|
*/
|
|
37
41
|
depthWrite: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* If shadows should be disabled (default is false).
|
|
44
|
+
*/
|
|
45
|
+
disableShadows: boolean;
|
|
38
46
|
/**
|
|
39
47
|
* The output texture.
|
|
40
48
|
* This texture will point to the same texture than the destinationTexture property if it is set.
|
|
@@ -47,16 +55,18 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
47
55
|
* Note, however, that the handle itself will be different!
|
|
48
56
|
*/
|
|
49
57
|
readonly outputDepthTexture: FrameGraphTextureHandle;
|
|
50
|
-
protected readonly _scene: Scene;
|
|
51
|
-
protected readonly _renderer: ObjectRenderer;
|
|
52
|
-
protected _textureWidth: number;
|
|
53
|
-
protected _textureHeight: number;
|
|
54
58
|
/**
|
|
55
59
|
* The object renderer used to render the objects.
|
|
56
60
|
*/
|
|
57
61
|
get objectRenderer(): ObjectRenderer;
|
|
58
62
|
get name(): string;
|
|
59
63
|
set name(value: string);
|
|
64
|
+
protected readonly _scene: Scene;
|
|
65
|
+
protected readonly _renderer: ObjectRenderer;
|
|
66
|
+
protected _textureWidth: number;
|
|
67
|
+
protected _textureHeight: number;
|
|
68
|
+
protected _onBeforeRenderObservable: Nullable<Observer<number>>;
|
|
69
|
+
protected _onAfterRenderObservable: Nullable<Observer<number>>;
|
|
60
70
|
/**
|
|
61
71
|
* Constructs a new object renderer task.
|
|
62
72
|
* @param name The name of the task.
|
|
@@ -68,4 +78,5 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
68
78
|
isReady(): boolean;
|
|
69
79
|
record(skipCreationOfDisabledPasses?: boolean, additionalExecute?: (context: FrameGraphRenderContext) => void): void;
|
|
70
80
|
dispose(): void;
|
|
81
|
+
private _setLightsForShadow;
|
|
71
82
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from "../../frameGraphTypes.js";
|
|
2
2
|
import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
3
3
|
import { ObjectRenderer } from "../../../Rendering/objectRenderer.js";
|
|
4
|
+
import { FrameGraphCascadedShadowGeneratorTask } from "./csmShadowGeneratorTask.js";
|
|
4
5
|
/**
|
|
5
6
|
* Task used to render objects to a texture.
|
|
6
7
|
*/
|
|
@@ -43,6 +44,10 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
43
44
|
* The dependencies of the task (optional).
|
|
44
45
|
*/
|
|
45
46
|
this.dependencies = [];
|
|
47
|
+
/**
|
|
48
|
+
* The shadow generators used to render the objects (optional).
|
|
49
|
+
*/
|
|
50
|
+
this.shadowGenerators = [];
|
|
46
51
|
/**
|
|
47
52
|
* If depth testing should be enabled (default is true).
|
|
48
53
|
*/
|
|
@@ -51,6 +56,12 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
51
56
|
* If depth writing should be enabled (default is true).
|
|
52
57
|
*/
|
|
53
58
|
this.depthWrite = true;
|
|
59
|
+
/**
|
|
60
|
+
* If shadows should be disabled (default is false).
|
|
61
|
+
*/
|
|
62
|
+
this.disableShadows = false;
|
|
63
|
+
this._onBeforeRenderObservable = null;
|
|
64
|
+
this._onAfterRenderObservable = null;
|
|
54
65
|
this._scene = scene;
|
|
55
66
|
this._renderer = new ObjectRenderer(name, scene, options);
|
|
56
67
|
this.name = name;
|
|
@@ -90,6 +101,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
90
101
|
}
|
|
91
102
|
this._textureWidth = outputTextureDescription.size.width;
|
|
92
103
|
this._textureHeight = outputTextureDescription.size.height;
|
|
104
|
+
this._setLightsForShadow();
|
|
93
105
|
const pass = this._frameGraph.addRenderPass(this.name);
|
|
94
106
|
pass.setRenderTarget(this.destinationTexture);
|
|
95
107
|
pass.setRenderTargetDepth(this.depthTexture);
|
|
@@ -121,5 +133,39 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
121
133
|
this._renderer.dispose();
|
|
122
134
|
super.dispose();
|
|
123
135
|
}
|
|
136
|
+
_setLightsForShadow() {
|
|
137
|
+
const lightsForShadow = new Set();
|
|
138
|
+
const shadowEnabled = new Map();
|
|
139
|
+
if (this.shadowGenerators) {
|
|
140
|
+
for (const shadowGeneratorTask of this.shadowGenerators) {
|
|
141
|
+
const shadowGenerator = shadowGeneratorTask.shadowGenerator;
|
|
142
|
+
const light = shadowGenerator.getLight();
|
|
143
|
+
if (light.isEnabled() && light.shadowEnabled) {
|
|
144
|
+
lightsForShadow.add(light);
|
|
145
|
+
if (FrameGraphCascadedShadowGeneratorTask.IsCascadedShadowGenerator(shadowGeneratorTask)) {
|
|
146
|
+
light._shadowGenerators.set(shadowGeneratorTask.camera, shadowGenerator);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
light._shadowGenerators.set(null, shadowGenerator);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable);
|
|
155
|
+
this._onBeforeRenderObservable = this._renderer.onBeforeRenderObservable.add(() => {
|
|
156
|
+
for (let i = 0; i < this._scene.lights.length; i++) {
|
|
157
|
+
const light = this._scene.lights[i];
|
|
158
|
+
shadowEnabled.set(light, light.shadowEnabled);
|
|
159
|
+
light.shadowEnabled = !this.disableShadows && lightsForShadow.has(light);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable);
|
|
163
|
+
this._onAfterRenderObservable = this._renderer.onAfterRenderObservable.add(() => {
|
|
164
|
+
for (let i = 0; i < this._scene.lights.length; i++) {
|
|
165
|
+
const light = this._scene.lights[i];
|
|
166
|
+
light.shadowEnabled = shadowEnabled.get(light);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
124
170
|
}
|
|
125
171
|
//# sourceMappingURL=objectRendererTask.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,cAAc;IAkB5D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAc;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;IA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M,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACrC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;QAED,IAAI,CAAC,4BAA4B,EAAE,CAAC;YAChC,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;YAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACtD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACrD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;YAE9C,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;gBAClC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBACrC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACpC,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext, ObjectRendererOptions } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\n\r\n/**\r\n * Task used to render objects to a texture.\r\n */\r\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\r\n /**\r\n * The destination texture where the objects will be rendered.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture where the objects will be rendered (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The dependencies of the task (optional).\r\n */\r\n public dependencies?: FrameGraphTextureHandle[] = [];\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used to render the objects.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The list of objects to render.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * If depth writing should be enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * The output texture.\r\n * This texture will point to the same texture than the destinationTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n protected readonly _scene: Scene;\r\n protected readonly _renderer: ObjectRenderer;\r\n protected _textureWidth: number;\r\n protected _textureHeight: number;\r\n\r\n /**\r\n * The object renderer used to render the objects.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\r\n\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n /**\r\n * Constructs a new object renderer 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 the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this.name = name;\r\n\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\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 override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void) {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`\r\n );\r\n }\r\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`\r\n );\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\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 this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n additionalExecute?.(context);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n }\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n }\r\n\r\n public override dispose(): void {\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"objectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,qCAAqC,EAAE,MAAM,0BAA0B,CAAC;AAEjF;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,cAAc;IAuB5D;;OAEG;IACH,IAA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C,cAAc,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC7E,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAC7E,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,GAAG,CAAC,GAAG,EAAE;YAC5E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACpC,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC;YACpD,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphTextureHandle,\r\n Scene,\r\n Camera,\r\n FrameGraphObjectList,\r\n FrameGraphRenderContext,\r\n ObjectRendererOptions,\r\n Light,\r\n Nullable,\r\n Observer,\r\n FrameGraphShadowGeneratorTask,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\nimport { FrameGraphCascadedShadowGeneratorTask } from \"./csmShadowGeneratorTask\";\r\n\r\n/**\r\n * Task used to render objects to a texture.\r\n */\r\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\r\n /**\r\n * The destination texture where the objects will be rendered.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture where the objects will be rendered (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The dependencies of the task (optional).\r\n */\r\n public dependencies?: FrameGraphTextureHandle[] = [];\r\n\r\n /**\r\n * The shadow generators used to render the objects (optional).\r\n */\r\n public shadowGenerators?: FrameGraphShadowGeneratorTask[] = [];\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used to render the objects.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The list of objects to render.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * If depth writing should be enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * If shadows should be disabled (default is false).\r\n */\r\n public disableShadows = false;\r\n\r\n /**\r\n * The output texture.\r\n * This texture will point to the same texture than the destinationTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The object renderer used to render the objects.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\r\n\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n protected readonly _scene: Scene;\r\n protected readonly _renderer: ObjectRenderer;\r\n protected _textureWidth: number;\r\n protected _textureHeight: number;\r\n protected _onBeforeRenderObservable: Nullable<Observer<number>> = null;\r\n protected _onAfterRenderObservable: Nullable<Observer<number>> = null;\r\n\r\n /**\r\n * Constructs a new object renderer 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 the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this.name = name;\r\n\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\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 override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void) {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`\r\n );\r\n }\r\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`\r\n );\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n this._setLightsForShadow();\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 this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n additionalExecute?.(context);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n }\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n }\r\n\r\n public override dispose(): void {\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n\r\n private _setLightsForShadow() {\r\n const lightsForShadow: Set<Light> = new Set();\r\n const shadowEnabled: Map<Light, boolean> = new Map();\r\n\r\n if (this.shadowGenerators) {\r\n for (const shadowGeneratorTask of this.shadowGenerators) {\r\n const shadowGenerator = shadowGeneratorTask.shadowGenerator;\r\n const light = shadowGenerator.getLight();\r\n if (light.isEnabled() && light.shadowEnabled) {\r\n lightsForShadow.add(light);\r\n if (FrameGraphCascadedShadowGeneratorTask.IsCascadedShadowGenerator(shadowGeneratorTask)) {\r\n light._shadowGenerators!.set(shadowGeneratorTask.camera, shadowGenerator);\r\n } else {\r\n light._shadowGenerators!.set(null, shadowGenerator);\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable);\r\n this._onBeforeRenderObservable = this._renderer.onBeforeRenderObservable.add(() => {\r\n for (let i = 0; i < this._scene.lights.length; i++) {\r\n const light = this._scene.lights[i];\r\n shadowEnabled.set(light, light.shadowEnabled);\r\n light.shadowEnabled = !this.disableShadows && lightsForShadow.has(light);\r\n }\r\n });\r\n\r\n this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable);\r\n this._onAfterRenderObservable = this._renderer.onAfterRenderObservable.add(() => {\r\n for (let i = 0; i < this._scene.lights.length; i++) {\r\n const light = this._scene.lights[i];\r\n light.shadowEnabled = shadowEnabled.get(light)!;\r\n }\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -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
|
+
}
|