@babylonjs/core 7.33.0 → 7.34.0
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 +14 -0
- package/Cameras/arcRotateCamera.js +39 -19
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +2 -0
- package/Decorators/nodeDecorator.js +1 -0
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +63 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +150 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +3 -47
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +2 -129
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.d.ts +40 -0
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js +98 -0
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -3
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +3 -2
- package/FrameGraph/Node/Blocks/index.js +3 -2
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Passes/renderPass.js +1 -1
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.d.ts +21 -0
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +110 -0
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -0
- package/FrameGraph/frameGraph.d.ts +6 -0
- package/FrameGraph/frameGraph.js +15 -1
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +3 -2
- package/FrameGraph/frameGraphRenderContext.js +9 -4
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.js +5 -1
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +8 -0
- package/FrameGraph/frameGraphTextureManager.js +51 -7
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/FrameGraph/frameGraphTypes.d.ts +2 -0
- package/FrameGraph/frameGraphTypes.js.map +1 -1
- package/FrameGraph/index.d.ts +3 -2
- package/FrameGraph/index.js +3 -2
- package/FrameGraph/index.js.map +1 -1
- package/Layers/layer.d.ts +4 -0
- package/Layers/layer.js +13 -2
- package/Layers/layer.js.map +1 -1
- package/Loading/sceneLoader.d.ts +11 -8
- package/Loading/sceneLoader.js +64 -35
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +2 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +12 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js +6 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +9 -2
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/index.d.ts +2 -0
- package/Materials/Node/Blocks/GaussianSplatting/index.js +3 -0
- package/Materials/Node/Blocks/GaussianSplatting/index.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +10 -3
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +1 -1
- package/Materials/Node/nodeMaterial.js +1 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +2 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +7 -2
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/abstractMesh.hotSpot.js +2 -0
- package/Meshes/abstractMesh.hotSpot.js.map +1 -1
- package/Meshes/csg2.js +0 -3
- package/Meshes/csg2.js.map +1 -1
- package/Misc/webRequest.fetch.d.ts +16 -0
- package/Misc/webRequest.fetch.js +33 -0
- package/Misc/webRequest.fetch.js.map +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.d.ts +2 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js +2 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.d.ts +6 -8
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js +32 -49
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js.map +1 -1
- package/PostProcesses/thinTAAPostProcess.d.ts +72 -0
- package/PostProcesses/thinTAAPostProcess.js +149 -0
- package/PostProcesses/thinTAAPostProcess.js.map +1 -0
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.d.ts +3 -3
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +7 -7
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +70 -69
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +102 -112
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +8 -6
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Shaders/geometry.vertex.js +1 -1
- package/Shaders/geometry.vertex.js.map +1 -1
- package/Shaders/layer.fragment.js +3 -1
- package/Shaders/layer.fragment.js.map +1 -1
- package/Shaders/volumetricLightScattering.fragment.js +1 -1
- package/Shaders/volumetricLightScattering.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +47 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplattingFragmentDeclaration.d.ts +7 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplattingFragmentDeclaration.js +20 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplattingFragmentDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.d.ts +7 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js +13 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js +10 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -0
- package/ShadersWGSL/gaussianSplatting.fragment.d.ts +10 -0
- package/ShadersWGSL/gaussianSplatting.fragment.js +23 -0
- package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -0
- package/ShadersWGSL/gaussianSplatting.vertex.d.ts +14 -0
- package/ShadersWGSL/gaussianSplatting.vertex.js +31 -0
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -0
- package/ShadersWGSL/geometry.vertex.js +1 -1
- package/ShadersWGSL/geometry.vertex.js.map +1 -1
- package/ShadersWGSL/layer.fragment.js +4 -2
- package/ShadersWGSL/layer.fragment.js.map +1 -1
- package/ShadersWGSL/taa.fragment.d.ts +5 -0
- package/ShadersWGSL/taa.fragment.js +11 -0
- package/ShadersWGSL/taa.fragment.js.map +1 -0
- package/package.json +1 -1
|
@@ -25,7 +25,8 @@ import { Observable } from "../../Misc/observable.js";
|
|
|
25
25
|
*/
|
|
26
26
|
export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
27
27
|
/**
|
|
28
|
-
* Reset the shadow accumulation.
|
|
28
|
+
* Reset the shadow accumulation. This has a similar affect to lowering the remanence for a single frame.
|
|
29
|
+
* This is useful when making a sudden change to the IBL.
|
|
29
30
|
*/
|
|
30
31
|
resetAccumulation() {
|
|
31
32
|
this._accumulationPass.reset = true;
|
|
@@ -78,16 +79,17 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
78
79
|
/**
|
|
79
80
|
* The number of samples used in the screen space shadow pass.
|
|
80
81
|
*/
|
|
81
|
-
get
|
|
82
|
+
get ssShadowSampleCount() {
|
|
82
83
|
return this._voxelTracingPass?.sssSamples;
|
|
83
84
|
}
|
|
84
|
-
set
|
|
85
|
+
set ssShadowSampleCount(value) {
|
|
85
86
|
if (!this._voxelTracingPass)
|
|
86
87
|
return;
|
|
87
88
|
this._voxelTracingPass.sssSamples = value;
|
|
88
89
|
}
|
|
89
90
|
/**
|
|
90
|
-
* The stride of the screen-space shadow pass. This controls the distance between samples
|
|
91
|
+
* The stride of the screen-space shadow pass. This controls the distance between samples
|
|
92
|
+
* in pixels.
|
|
91
93
|
*/
|
|
92
94
|
get ssShadowStride() {
|
|
93
95
|
return this._voxelTracingPass?.sssStride;
|
|
@@ -98,8 +100,9 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
98
100
|
this._voxelTracingPass.sssStride = value;
|
|
99
101
|
}
|
|
100
102
|
/**
|
|
101
|
-
* A scale for the maximum distance a shadow can be cast in
|
|
102
|
-
* The
|
|
103
|
+
* A scale for the maximum distance a screen-space shadow can be cast in world-space.
|
|
104
|
+
* The maximum distance that screen-space shadows cast is derived from the voxel size
|
|
105
|
+
* and this value so shouldn't need to change if you scale your scene
|
|
103
106
|
*/
|
|
104
107
|
get ssShadowDistanceScale() {
|
|
105
108
|
return this._sssMaxDistScale;
|
|
@@ -109,7 +112,9 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
109
112
|
this._updateSSShadowParams();
|
|
110
113
|
}
|
|
111
114
|
/**
|
|
112
|
-
* Screen-space shadow thickness. This value controls the
|
|
115
|
+
* Screen-space shadow thickness scale. This value controls the assumed thickness of
|
|
116
|
+
* on-screen surfaces in world-space. It scales with the size of the shadow-casting
|
|
117
|
+
* region so shouldn't need to change if you scale your scene.
|
|
113
118
|
*/
|
|
114
119
|
get ssShadowThicknessScale() {
|
|
115
120
|
return this._sssThicknessScale;
|
|
@@ -213,14 +218,12 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
213
218
|
return this._dummyTexture2d;
|
|
214
219
|
}
|
|
215
220
|
/**
|
|
216
|
-
*
|
|
221
|
+
* Turn on or off the debug view of the G-Buffer. This will display only the targets
|
|
222
|
+
* of the g-buffer that are used by the shadow pipeline.
|
|
217
223
|
*/
|
|
218
224
|
get gbufferDebugEnabled() {
|
|
219
225
|
return this._gbufferDebugEnabled;
|
|
220
226
|
}
|
|
221
|
-
/**
|
|
222
|
-
* Turn on or off the debug view of the G-Buffer
|
|
223
|
-
*/
|
|
224
227
|
set gbufferDebugEnabled(enabled) {
|
|
225
228
|
if (enabled && !this.allowDebugPasses) {
|
|
226
229
|
Logger.Warn("Can't enable G-Buffer debug view without setting allowDebugPasses to true.");
|
|
@@ -261,14 +264,14 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
261
264
|
}
|
|
262
265
|
}
|
|
263
266
|
/**
|
|
264
|
-
*
|
|
267
|
+
* This displays the voxel grid in slices spread across the screen.
|
|
268
|
+
* It also displays what slices of the model are stored in each layer
|
|
269
|
+
* of the voxel grid. Each red stripe represents one layer while each gradient
|
|
270
|
+
* (from bright red to black) represents the layers rendered in a single draw call.
|
|
265
271
|
*/
|
|
266
272
|
get voxelDebugEnabled() {
|
|
267
273
|
return this._voxelRenderer?.voxelDebugEnabled;
|
|
268
274
|
}
|
|
269
|
-
/**
|
|
270
|
-
* Turn on or off the debug view of the voxel grid
|
|
271
|
-
*/
|
|
272
275
|
set voxelDebugEnabled(enabled) {
|
|
273
276
|
if (!this._voxelRenderer)
|
|
274
277
|
return;
|
|
@@ -285,23 +288,20 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
285
288
|
}
|
|
286
289
|
}
|
|
287
290
|
/**
|
|
288
|
-
*
|
|
289
|
-
*
|
|
291
|
+
* When using tri-planar voxelization (the default), this value can be used to
|
|
292
|
+
* display only the voxelization result for that axis. z-axis = 0, y-axis = 1, x-axis = 2
|
|
290
293
|
*/
|
|
291
294
|
get voxelDebugAxis() {
|
|
292
295
|
return this._voxelRenderer?.voxelDebugAxis;
|
|
293
296
|
}
|
|
294
|
-
/**
|
|
295
|
-
* Set the axis to display for the voxel grid debug view
|
|
296
|
-
* When using tri-axis voxelization, this will display the voxel grid for the specified axis
|
|
297
|
-
*/
|
|
298
297
|
set voxelDebugAxis(axisNum) {
|
|
299
298
|
if (!this._voxelRenderer)
|
|
300
299
|
return;
|
|
301
300
|
this._voxelRenderer.voxelDebugAxis = axisNum;
|
|
302
301
|
}
|
|
303
302
|
/**
|
|
304
|
-
*
|
|
303
|
+
* Displays a given mip of the voxel grid. `voxelDebugAxis` must be undefined in this
|
|
304
|
+
* case because we only generate mips for the combined voxel grid.
|
|
305
305
|
*/
|
|
306
306
|
set voxelDebugDisplayMip(mipNum) {
|
|
307
307
|
if (!this._voxelRenderer)
|
|
@@ -309,14 +309,11 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
309
309
|
this._voxelRenderer.setDebugMipNumber(mipNum);
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
312
|
-
* Display the debug view for the
|
|
312
|
+
* Display the debug view for just the shadow samples taken this frame.
|
|
313
313
|
*/
|
|
314
314
|
get voxelTracingDebugEnabled() {
|
|
315
315
|
return this._voxelTracingPass?.debugEnabled;
|
|
316
316
|
}
|
|
317
|
-
/**
|
|
318
|
-
* Display the debug view for the voxel tracing pass
|
|
319
|
-
*/
|
|
320
317
|
set voxelTracingDebugEnabled(enabled) {
|
|
321
318
|
if (!this._voxelTracingPass)
|
|
322
319
|
return;
|
|
@@ -340,9 +337,6 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
340
337
|
get spatialBlurPassDebugEnabled() {
|
|
341
338
|
return this._spatialBlurPass.debugEnabled;
|
|
342
339
|
}
|
|
343
|
-
/**
|
|
344
|
-
* Display the debug view for the spatial blur pass
|
|
345
|
-
*/
|
|
346
340
|
set spatialBlurPassDebugEnabled(enabled) {
|
|
347
341
|
if (!this._spatialBlurPass)
|
|
348
342
|
return;
|
|
@@ -361,14 +355,11 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
361
355
|
}
|
|
362
356
|
}
|
|
363
357
|
/**
|
|
364
|
-
* Display the debug view for the
|
|
358
|
+
* Display the debug view for the shadows accumulated over time.
|
|
365
359
|
*/
|
|
366
360
|
get accumulationPassDebugEnabled() {
|
|
367
361
|
return this._accumulationPass?.debugEnabled;
|
|
368
362
|
}
|
|
369
|
-
/**
|
|
370
|
-
* Display the debug view for the accumulation pass
|
|
371
|
-
*/
|
|
372
363
|
set accumulationPassDebugEnabled(enabled) {
|
|
373
364
|
if (!this._accumulationPass)
|
|
374
365
|
return;
|
|
@@ -387,7 +378,8 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
387
378
|
}
|
|
388
379
|
}
|
|
389
380
|
/**
|
|
390
|
-
* Add a mesh to be used for shadow
|
|
381
|
+
* Add a mesh to be used for shadow-casting in the IBL shadow pipeline.
|
|
382
|
+
* These meshes will be written to the voxel grid.
|
|
391
383
|
* @param mesh A mesh or list of meshes that you want to cast shadows
|
|
392
384
|
*/
|
|
393
385
|
addShadowCastingMesh(mesh) {
|
|
@@ -405,7 +397,8 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
405
397
|
}
|
|
406
398
|
}
|
|
407
399
|
/**
|
|
408
|
-
* Remove a mesh from the shadow-casting list.
|
|
400
|
+
* Remove a mesh from the shadow-casting list. The mesh will no longer be written
|
|
401
|
+
* to the voxel grid and will not cast shadows.
|
|
409
402
|
* @param mesh The mesh or list of meshes that you don't want to cast shadows.
|
|
410
403
|
*/
|
|
411
404
|
removeShadowCastingMesh(mesh) {
|
|
@@ -432,11 +425,6 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
432
425
|
get resolutionExp() {
|
|
433
426
|
return this._voxelRenderer.voxelResolutionExp;
|
|
434
427
|
}
|
|
435
|
-
/**
|
|
436
|
-
* The exponent of the resolution of the voxel shadow grid. Higher resolutions will result in sharper
|
|
437
|
-
* shadows but are more expensive to compute and require more memory.
|
|
438
|
-
* The resolution is calculated as 2 to the power of this number.
|
|
439
|
-
*/
|
|
440
428
|
set resolutionExp(newResolution) {
|
|
441
429
|
if (newResolution === this._voxelRenderer.voxelResolutionExp)
|
|
442
430
|
return;
|
|
@@ -444,7 +432,7 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
444
432
|
Logger.Warn("Can't change the resolution of the voxel grid while voxelization is in progress.");
|
|
445
433
|
return;
|
|
446
434
|
}
|
|
447
|
-
this._voxelRenderer.voxelResolutionExp = newResolution;
|
|
435
|
+
this._voxelRenderer.voxelResolutionExp = Math.max(1, Math.min(newResolution, 8));
|
|
448
436
|
this._accumulationPass.reset = true;
|
|
449
437
|
}
|
|
450
438
|
/**
|
|
@@ -464,25 +452,25 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
464
452
|
/**
|
|
465
453
|
* The decree to which the shadows persist between frames. 0.0 is no persistence, 1.0 is full persistence.
|
|
466
454
|
**/
|
|
467
|
-
get
|
|
468
|
-
return this._accumulationPass?.
|
|
455
|
+
get shadowRemanence() {
|
|
456
|
+
return this._accumulationPass?.remanence;
|
|
469
457
|
}
|
|
470
458
|
/**
|
|
471
459
|
* The decree to which the shadows persist between frames. 0.0 is no persistence, 1.0 is full persistence.
|
|
472
460
|
**/
|
|
473
|
-
set
|
|
461
|
+
set shadowRemanence(value) {
|
|
474
462
|
if (!this._accumulationPass)
|
|
475
463
|
return;
|
|
476
|
-
this._accumulationPass.
|
|
464
|
+
this._accumulationPass.remanence = value;
|
|
477
465
|
}
|
|
478
466
|
/**
|
|
479
|
-
* The global rotation of the IBL for shadows
|
|
467
|
+
* The global Y-axis rotation of the IBL for shadows. This should match the Y-rotation of the environment map applied to materials, skybox, etc.
|
|
480
468
|
*/
|
|
481
469
|
get envRotation() {
|
|
482
470
|
return this._voxelTracingPass?.envRotation;
|
|
483
471
|
}
|
|
484
472
|
/**
|
|
485
|
-
* The global rotation of the IBL for shadows
|
|
473
|
+
* The global Y-axis rotation of the IBL for shadows. This should match the Y-rotation of the environment map applied to materials, skybox, etc.
|
|
486
474
|
*/
|
|
487
475
|
set envRotation(value) {
|
|
488
476
|
if (!this._voxelTracingPass)
|
|
@@ -527,6 +515,65 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
527
515
|
}
|
|
528
516
|
return engine._features.supportIBLShadows;
|
|
529
517
|
}
|
|
518
|
+
/**
|
|
519
|
+
* Toggle the shadow tracing on or off
|
|
520
|
+
* @param enabled Toggle the shadow tracing on or off
|
|
521
|
+
*/
|
|
522
|
+
toggleShadow(enabled) {
|
|
523
|
+
this._enabled = enabled;
|
|
524
|
+
this._voxelTracingPass.enabled = enabled;
|
|
525
|
+
this._spatialBlurPass.enabled = enabled;
|
|
526
|
+
this._accumulationPass.enabled = enabled;
|
|
527
|
+
this._materialsWithRenderPlugin.forEach((mat) => {
|
|
528
|
+
if (mat.pluginManager) {
|
|
529
|
+
const plugin = mat.pluginManager.getPlugin(IBLShadowsPluginMaterial.Name);
|
|
530
|
+
plugin.isEnabled = enabled;
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
this._setPluginParameters();
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Trigger the scene to be re-voxelized. This should be run when any shadow-casters have been added, removed or moved.
|
|
537
|
+
*/
|
|
538
|
+
updateVoxelization() {
|
|
539
|
+
if (this._shadowCastingMeshes.length === 0) {
|
|
540
|
+
Logger.Warn("IBL Shadows: updateVoxelization called with no shadow-casting meshes to voxelize.");
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
this._voxelRenderer.updateVoxelGrid(this._shadowCastingMeshes);
|
|
544
|
+
this._updateSSShadowParams();
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Trigger the scene bounds of shadow-casters to be calculated. This is the world size that the voxel grid will cover and will always be a cube.
|
|
548
|
+
*/
|
|
549
|
+
updateSceneBounds() {
|
|
550
|
+
const bounds = {
|
|
551
|
+
min: new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE),
|
|
552
|
+
max: new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE),
|
|
553
|
+
};
|
|
554
|
+
this._shadowCastingMeshes.forEach((mesh) => {
|
|
555
|
+
const localBounds = mesh.getHierarchyBoundingVectors(true);
|
|
556
|
+
bounds.min = Vector3.Minimize(bounds.min, localBounds.min);
|
|
557
|
+
bounds.max = Vector3.Maximize(bounds.max, localBounds.max);
|
|
558
|
+
});
|
|
559
|
+
const size = bounds.max.subtract(bounds.min);
|
|
560
|
+
this.voxelGridSize = Math.max(size.x, size.y, size.z);
|
|
561
|
+
if (this._shadowCastingMeshes.length === 0 || !isFinite(this.voxelGridSize) || this.voxelGridSize === 0) {
|
|
562
|
+
Logger.Warn("IBL Shadows: Scene size is invalid. Can't update bounds.");
|
|
563
|
+
this.voxelGridSize = 1.0;
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
const halfSize = this.voxelGridSize / 2.0;
|
|
567
|
+
const centre = bounds.max.add(bounds.min).multiplyByFloats(-0.5, -0.5, -0.5);
|
|
568
|
+
const invWorldScaleMatrix = Matrix.Compose(new Vector3(1.0 / halfSize, 1.0 / halfSize, 1.0 / halfSize), new Quaternion(), new Vector3(0, 0, 0));
|
|
569
|
+
const invTranslationMatrix = Matrix.Compose(new Vector3(1.0, 1.0, 1.0), new Quaternion(), centre);
|
|
570
|
+
invTranslationMatrix.multiplyToRef(invWorldScaleMatrix, invWorldScaleMatrix);
|
|
571
|
+
this._voxelTracingPass.setWorldScaleMatrix(invWorldScaleMatrix);
|
|
572
|
+
this._voxelRenderer.setWorldScaleMatrix(invWorldScaleMatrix);
|
|
573
|
+
// Set world scale for spatial blur.
|
|
574
|
+
this._spatialBlurPass.setWorldScale(halfSize * 2.0);
|
|
575
|
+
this._updateSSShadowParams();
|
|
576
|
+
}
|
|
530
577
|
/**
|
|
531
578
|
* @param name The rendering pipeline name
|
|
532
579
|
* @param scene The scene linked to this pipeline
|
|
@@ -602,13 +649,14 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
602
649
|
});
|
|
603
650
|
this.sampleDirections = options.sampleDirections || 2;
|
|
604
651
|
this.voxelShadowOpacity = options.voxelShadowOpacity ?? 1.0;
|
|
652
|
+
this.envRotation = options.envRotation ?? 0.0;
|
|
605
653
|
this.shadowRenderSizeFactor = options.shadowRenderSizeFactor || 1.0;
|
|
606
654
|
this.ssShadowOpacity = options.ssShadowsEnabled === undefined || options.ssShadowsEnabled ? 1.0 : 0.0;
|
|
607
655
|
this.ssShadowDistanceScale = options.ssShadowDistanceScale || 1.25;
|
|
608
|
-
this.
|
|
656
|
+
this.ssShadowSampleCount = options.ssShadowSampleCount || 16;
|
|
609
657
|
this.ssShadowStride = options.ssShadowStride || 8;
|
|
610
658
|
this.ssShadowThicknessScale = options.ssShadowThicknessScale || 1.0;
|
|
611
|
-
this.
|
|
659
|
+
this.shadowRemanence = options.shadowRemanence ?? 0.75;
|
|
612
660
|
this._noiseTexture = new Texture("https://assets.babylonjs.com/textures/blue_noise/blue_noise_rgb.png", this.scene, false, true, 1);
|
|
613
661
|
if (this.scene.environmentTexture) {
|
|
614
662
|
this._importanceSamplingRenderer.iblSource = this.scene.environmentTexture;
|
|
@@ -624,23 +672,6 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
624
672
|
this.onNewIblReadyObservable.notifyObservers();
|
|
625
673
|
});
|
|
626
674
|
}
|
|
627
|
-
/**
|
|
628
|
-
* Toggle the shadow tracing on or off
|
|
629
|
-
* @param enabled Toggle the shadow tracing on or off
|
|
630
|
-
*/
|
|
631
|
-
toggleShadow(enabled) {
|
|
632
|
-
this._enabled = enabled;
|
|
633
|
-
this._voxelTracingPass.enabled = enabled;
|
|
634
|
-
this._spatialBlurPass.enabled = enabled;
|
|
635
|
-
this._accumulationPass.enabled = enabled;
|
|
636
|
-
this._materialsWithRenderPlugin.forEach((mat) => {
|
|
637
|
-
if (mat.pluginManager) {
|
|
638
|
-
const plugin = mat.pluginManager.getPlugin(IBLShadowsPluginMaterial.Name);
|
|
639
|
-
plugin.isEnabled = enabled;
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
this._setPluginParameters();
|
|
643
|
-
}
|
|
644
675
|
_handleResize() {
|
|
645
676
|
this._voxelRenderer.resize();
|
|
646
677
|
this._voxelTracingPass.resize(this.shadowRenderSizeFactor);
|
|
@@ -803,49 +834,6 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
803
834
|
}
|
|
804
835
|
}
|
|
805
836
|
}
|
|
806
|
-
/**
|
|
807
|
-
* Trigger the scene to be re-voxelized. This is useful when the scene has changed and the voxel grid needs to be updated.
|
|
808
|
-
*/
|
|
809
|
-
updateVoxelization() {
|
|
810
|
-
if (this._shadowCastingMeshes.length === 0) {
|
|
811
|
-
Logger.Warn("IBL Shadows: updateVoxelization called with no shadow-casting meshes to voxelize.");
|
|
812
|
-
return;
|
|
813
|
-
}
|
|
814
|
-
this._voxelRenderer.updateVoxelGrid(this._shadowCastingMeshes);
|
|
815
|
-
this._updateSSShadowParams();
|
|
816
|
-
}
|
|
817
|
-
/**
|
|
818
|
-
* Trigger the scene bounds of shadow-casters to be updated. This is useful when the scene has changed and the bounds need
|
|
819
|
-
* to be recalculated. This will also trigger a re-voxelization.
|
|
820
|
-
*/
|
|
821
|
-
updateSceneBounds() {
|
|
822
|
-
const bounds = {
|
|
823
|
-
min: new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE),
|
|
824
|
-
max: new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE),
|
|
825
|
-
};
|
|
826
|
-
this._shadowCastingMeshes.forEach((mesh) => {
|
|
827
|
-
const localBounds = mesh.getHierarchyBoundingVectors(true);
|
|
828
|
-
bounds.min = Vector3.Minimize(bounds.min, localBounds.min);
|
|
829
|
-
bounds.max = Vector3.Maximize(bounds.max, localBounds.max);
|
|
830
|
-
});
|
|
831
|
-
const size = bounds.max.subtract(bounds.min);
|
|
832
|
-
this.voxelGridSize = Math.max(size.x, size.y, size.z);
|
|
833
|
-
if (this._shadowCastingMeshes.length === 0 || !isFinite(this.voxelGridSize) || this.voxelGridSize === 0) {
|
|
834
|
-
Logger.Warn("IBL Shadows: Scene size is invalid. Can't update bounds.");
|
|
835
|
-
this.voxelGridSize = 1.0;
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
838
|
-
const halfSize = this.voxelGridSize / 2.0;
|
|
839
|
-
const centre = bounds.max.add(bounds.min).multiplyByFloats(-0.5, -0.5, -0.5);
|
|
840
|
-
const invWorldScaleMatrix = Matrix.Compose(new Vector3(1.0 / halfSize, 1.0 / halfSize, 1.0 / halfSize), new Quaternion(), new Vector3(0, 0, 0));
|
|
841
|
-
const invTranslationMatrix = Matrix.Compose(new Vector3(1.0, 1.0, 1.0), new Quaternion(), centre);
|
|
842
|
-
invTranslationMatrix.multiplyToRef(invWorldScaleMatrix, invWorldScaleMatrix);
|
|
843
|
-
this._voxelTracingPass.setWorldScaleMatrix(invWorldScaleMatrix);
|
|
844
|
-
this._voxelRenderer.setWorldScaleMatrix(invWorldScaleMatrix);
|
|
845
|
-
// Set world scale for spatial blur.
|
|
846
|
-
this._spatialBlurPass.setWorldScale(halfSize * 2.0);
|
|
847
|
-
this._updateSSShadowParams();
|
|
848
|
-
}
|
|
849
837
|
/**
|
|
850
838
|
* Update the SS shadow max distance and thickness based on the voxel grid size and resolution.
|
|
851
839
|
* The max distance should be just a little larger than the world size of a single voxel.
|
|
@@ -855,7 +843,8 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
855
843
|
this._voxelTracingPass.sssThickness = this._sssThicknessScale * 0.005 * this.voxelGridSize;
|
|
856
844
|
}
|
|
857
845
|
/**
|
|
858
|
-
* Apply the shadows to a material or array of materials.
|
|
846
|
+
* Apply the shadows to a material or array of materials. If no material is provided, all
|
|
847
|
+
* materials in the scene will be added.
|
|
859
848
|
* @param material Material that will be affected by the shadows. If not provided, all materials of the scene will be affected.
|
|
860
849
|
*/
|
|
861
850
|
addShadowReceivingMaterial(material) {
|
|
@@ -876,8 +865,9 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
876
865
|
}
|
|
877
866
|
}
|
|
878
867
|
/**
|
|
879
|
-
* Remove a material from
|
|
880
|
-
*
|
|
868
|
+
* Remove a material from the list of materials that receive shadows. If no material
|
|
869
|
+
* is provided, all materials in the scene will be removed.
|
|
870
|
+
* @param material The material or array of materials that will no longer receive shadows
|
|
881
871
|
*/
|
|
882
872
|
removeShadowReceivingMaterial(material) {
|
|
883
873
|
if (Array.isArray(material)) {
|