@onerjs/core 8.29.1 → 8.29.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/Engines/abstractEngine.d.ts +13 -1
- package/Engines/abstractEngine.js +6 -3
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +15 -1
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.d.ts +3 -1
- package/FrameGraph/Node/nodeRenderGraph.js +3 -0
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.d.ts +7 -1
- package/Materials/floatingOriginMatrixOverrides.js +21 -9
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Misc/sceneSerializer.js +3 -2
- package/Misc/sceneSerializer.js.map +1 -1
- package/Particles/IParticleSystem.d.ts +4 -6
- package/Particles/IParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +4 -4
- package/Particles/gpuParticleSystem.js +4 -4
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.d.ts +4 -0
- package/Particles/particleSystem.js +7 -1
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/particleSystemSet.js +3 -1
- package/Particles/particleSystemSet.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +4 -2
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +64 -37
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Rendering/utilityLayerRenderer.js +1 -1
- package/Rendering/utilityLayerRenderer.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.fragment.js +6 -7
- package/ShadersWGSL/iblVoxelGrid.fragment.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.d.ts +0 -8
- package/ShadersWGSL/iblVoxelGrid.vertex.js +33 -22
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.js +1 -2
- package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +15 -12
- package/scene.js +27 -16
- package/scene.js.map +1 -1
|
@@ -23,8 +23,11 @@ export class _IblShadowsVoxelRenderer {
|
|
|
23
23
|
* @returns The voxel grid texture.
|
|
24
24
|
*/
|
|
25
25
|
getVoxelGrid() {
|
|
26
|
-
if (this.
|
|
27
|
-
return this.
|
|
26
|
+
if (this._engine.isWebGPU) {
|
|
27
|
+
return this._voxelGrid;
|
|
28
|
+
}
|
|
29
|
+
else if (this._triPlanarVoxelization) {
|
|
30
|
+
return this._combinedVoxelGridPT;
|
|
28
31
|
}
|
|
29
32
|
else {
|
|
30
33
|
return this._voxelGridZaxis;
|
|
@@ -50,6 +53,11 @@ export class _IblShadowsVoxelRenderer {
|
|
|
50
53
|
* Whether to use tri-planar voxelization. More expensive, but can help with artifacts.
|
|
51
54
|
*/
|
|
52
55
|
set triPlanarVoxelization(enabled) {
|
|
56
|
+
if (this._engine.isWebGPU) {
|
|
57
|
+
// WebGPU only supports tri-planar voxelization.
|
|
58
|
+
this._triPlanarVoxelization = true;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
53
61
|
if (this._triPlanarVoxelization === enabled) {
|
|
54
62
|
return;
|
|
55
63
|
}
|
|
@@ -175,24 +183,15 @@ export class _IblShadowsVoxelRenderer {
|
|
|
175
183
|
reusable: false,
|
|
176
184
|
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
177
185
|
extraInitializations: (useWebGPU, list) => {
|
|
178
|
-
if (this._isVoxelGrid3D) {
|
|
179
|
-
if (useWebGPU) {
|
|
180
|
-
list.push(import("../../ShadersWGSL/iblVoxelGrid3dDebug.fragment.js"));
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
list.push(import("../../Shaders/iblVoxelGrid3dDebug.fragment.js"));
|
|
184
|
-
}
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
186
|
if (useWebGPU) {
|
|
188
|
-
list.push(import("../../ShadersWGSL/
|
|
187
|
+
list.push(import("../../ShadersWGSL/iblVoxelGrid3dDebug.fragment.js"));
|
|
189
188
|
}
|
|
190
189
|
else {
|
|
191
|
-
list.push(import("../../Shaders/
|
|
190
|
+
list.push(import("../../Shaders/iblVoxelGrid3dDebug.fragment.js"));
|
|
192
191
|
}
|
|
193
192
|
},
|
|
194
193
|
};
|
|
195
|
-
this._voxelDebugPass = new PostProcess(this.debugPassName,
|
|
194
|
+
this._voxelDebugPass = new PostProcess(this.debugPassName, "iblVoxelGrid3dDebug", debugOptions);
|
|
196
195
|
this._voxelDebugPass.onApplyObservable.add((effect) => {
|
|
197
196
|
if (this._voxelDebugAxis === 0) {
|
|
198
197
|
effect.setTexture("voxelTexture", this._voxelGridXaxis);
|
|
@@ -217,14 +216,14 @@ export class _IblShadowsVoxelRenderer {
|
|
|
217
216
|
* @param scene Scene to attach to
|
|
218
217
|
* @param iblShadowsRenderPipeline The render pipeline this pass is associated with
|
|
219
218
|
* @param resolutionExp Resolution of the voxel grid. The final resolution will be 2^resolutionExp.
|
|
220
|
-
* @param triPlanarVoxelization Whether to use tri-planar voxelization.
|
|
219
|
+
* @param triPlanarVoxelization Whether to use tri-planar voxelization. Only applies to WebGL. Voxelization will take longer but will reduce missing geometry.
|
|
221
220
|
* @returns The voxel renderer
|
|
222
221
|
*/
|
|
223
222
|
constructor(scene, iblShadowsRenderPipeline, resolutionExp = 6, triPlanarVoxelization = true) {
|
|
224
223
|
this._voxelMrtsXaxis = [];
|
|
225
224
|
this._voxelMrtsYaxis = [];
|
|
226
225
|
this._voxelMrtsZaxis = [];
|
|
227
|
-
this.
|
|
226
|
+
this._voxelClearColor = new Color4(0, 0, 0, 1);
|
|
228
227
|
/**
|
|
229
228
|
* Observable that triggers when the voxelization is complete
|
|
230
229
|
*/
|
|
@@ -244,7 +243,7 @@ export class _IblShadowsVoxelRenderer {
|
|
|
244
243
|
this._debugPassName = "Voxelization Debug Pass";
|
|
245
244
|
this._scene = scene;
|
|
246
245
|
this._engine = scene.getEngine();
|
|
247
|
-
this._triPlanarVoxelization = triPlanarVoxelization;
|
|
246
|
+
this._triPlanarVoxelization = this._engine.isWebGPU || triPlanarVoxelization;
|
|
248
247
|
if (!this._engine.getCaps().drawBuffersExtension) {
|
|
249
248
|
Logger.Error("Can't do voxel rendering without the draw buffers extension.");
|
|
250
249
|
}
|
|
@@ -328,14 +327,13 @@ export class _IblShadowsVoxelRenderer {
|
|
|
328
327
|
const size = {
|
|
329
328
|
width: this._voxelResolution,
|
|
330
329
|
height: this._voxelResolution,
|
|
331
|
-
|
|
332
|
-
depth: this._isVoxelGrid3D ? this._voxelResolution : undefined,
|
|
330
|
+
depth: this._voxelResolution,
|
|
333
331
|
};
|
|
334
332
|
const voxelAxisOptions = {
|
|
335
333
|
generateDepthBuffer: false,
|
|
336
334
|
generateMipMaps: false,
|
|
337
335
|
type: 0,
|
|
338
|
-
format:
|
|
336
|
+
format: 5,
|
|
339
337
|
samplingMode: 1,
|
|
340
338
|
};
|
|
341
339
|
// We can render up to maxDrawBuffers voxel slices of the grid per render.
|
|
@@ -357,23 +355,31 @@ export class _IblShadowsVoxelRenderer {
|
|
|
357
355
|
}
|
|
358
356
|
},
|
|
359
357
|
};
|
|
360
|
-
if (this.
|
|
358
|
+
if (this._engine.isWebGPU) {
|
|
359
|
+
this._voxelGrid = new RenderTargetTexture("voxelGrid", size, this._scene, {
|
|
360
|
+
...voxelCombinedOptions,
|
|
361
|
+
format: 5,
|
|
362
|
+
creationFlags: 1,
|
|
363
|
+
});
|
|
364
|
+
this._voxelGridRT = new RenderTargetTexture("voxelGridRT", { width: Math.min(size.width * 2.0, 2048), height: Math.min(size.height * 2.0, 2048) }, this._scene, voxelAxisOptions);
|
|
365
|
+
}
|
|
366
|
+
else if (this._triPlanarVoxelization) {
|
|
361
367
|
this._voxelGridXaxis = new RenderTargetTexture("voxelGridXaxis", size, this._scene, voxelAxisOptions);
|
|
362
368
|
this._voxelGridYaxis = new RenderTargetTexture("voxelGridYaxis", size, this._scene, voxelAxisOptions);
|
|
363
369
|
this._voxelGridZaxis = new RenderTargetTexture("voxelGridZaxis", size, this._scene, voxelAxisOptions);
|
|
364
370
|
this._voxelMrtsXaxis = this._createVoxelMRTs("x_axis_", this._voxelGridXaxis, numSlabs);
|
|
365
371
|
this._voxelMrtsYaxis = this._createVoxelMRTs("y_axis_", this._voxelGridYaxis, numSlabs);
|
|
366
372
|
this._voxelMrtsZaxis = this._createVoxelMRTs("z_axis_", this._voxelGridZaxis, numSlabs);
|
|
367
|
-
this.
|
|
368
|
-
this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this.
|
|
369
|
-
this.
|
|
370
|
-
this.
|
|
371
|
-
this.
|
|
372
|
-
this.
|
|
373
|
+
this._combinedVoxelGridPT = new ProceduralTexture("combinedVoxelGrid", size, "iblCombineVoxelGrids", this._scene, voxelCombinedOptions, false);
|
|
374
|
+
this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._combinedVoxelGridPT), 1);
|
|
375
|
+
this._combinedVoxelGridPT.setFloat("layer", 0.0);
|
|
376
|
+
this._combinedVoxelGridPT.setTexture("voxelXaxisSampler", this._voxelGridXaxis);
|
|
377
|
+
this._combinedVoxelGridPT.setTexture("voxelYaxisSampler", this._voxelGridYaxis);
|
|
378
|
+
this._combinedVoxelGridPT.setTexture("voxelZaxisSampler", this._voxelGridZaxis);
|
|
373
379
|
// We will render this only after voxelization is completed for the 3 axes.
|
|
374
|
-
this.
|
|
375
|
-
this.
|
|
376
|
-
this.
|
|
380
|
+
this._combinedVoxelGridPT.autoClear = false;
|
|
381
|
+
this._combinedVoxelGridPT.wrapU = Texture.CLAMP_ADDRESSMODE;
|
|
382
|
+
this._combinedVoxelGridPT.wrapV = Texture.CLAMP_ADDRESSMODE;
|
|
377
383
|
}
|
|
378
384
|
else {
|
|
379
385
|
this._voxelGridZaxis = new RenderTargetTexture("voxelGridZaxis", size, this._scene, voxelCombinedOptions);
|
|
@@ -415,13 +421,13 @@ export class _IblShadowsVoxelRenderer {
|
|
|
415
421
|
voxelRT.wrapV = Texture.CLAMP_ADDRESSMODE;
|
|
416
422
|
voxelRT.noPrePassRenderer = true;
|
|
417
423
|
const mrtArray = [];
|
|
418
|
-
const targetTypes = new Array(this._maxDrawBuffers).fill(
|
|
424
|
+
const targetTypes = new Array(this._maxDrawBuffers).fill(32879);
|
|
419
425
|
for (let mrtIndex = 0; mrtIndex < numSlabs; mrtIndex++) {
|
|
420
426
|
let layerIndices = new Array(this._maxDrawBuffers).fill(0);
|
|
421
427
|
layerIndices = layerIndices.map((value, index) => mrtIndex * this._maxDrawBuffers + index);
|
|
422
428
|
let textureNames = new Array(this._maxDrawBuffers).fill("");
|
|
423
429
|
textureNames = textureNames.map((value, index) => "voxel_grid_" + name + (mrtIndex * this._maxDrawBuffers + index));
|
|
424
|
-
const mrt = new MultiRenderTarget("mrt_" + name + mrtIndex, { width: this._voxelResolution, height: this._voxelResolution, depth: this.
|
|
430
|
+
const mrt = new MultiRenderTarget("mrt_" + name + mrtIndex, { width: this._voxelResolution, height: this._voxelResolution, depth: this._voxelResolution }, this._maxDrawBuffers, // number of draw buffers
|
|
425
431
|
this._scene, {
|
|
426
432
|
types: new Array(this._maxDrawBuffers).fill(0),
|
|
427
433
|
samplingModes: new Array(this._maxDrawBuffers).fill(3),
|
|
@@ -455,7 +461,7 @@ export class _IblShadowsVoxelRenderer {
|
|
|
455
461
|
if (this._triPlanarVoxelization) {
|
|
456
462
|
this._voxelGridXaxis?.dispose();
|
|
457
463
|
this._voxelGridYaxis?.dispose();
|
|
458
|
-
this.
|
|
464
|
+
this._combinedVoxelGridPT?.dispose();
|
|
459
465
|
}
|
|
460
466
|
this._voxelGridZaxis?.dispose();
|
|
461
467
|
for (const mip of this._mipArray) {
|
|
@@ -471,7 +477,7 @@ export class _IblShadowsVoxelRenderer {
|
|
|
471
477
|
_createVoxelMaterials() {
|
|
472
478
|
const isWebGPU = this._engine.isWebGPU;
|
|
473
479
|
this._voxelMaterial = new ShaderMaterial("voxelization", this._scene, "iblVoxelGrid", {
|
|
474
|
-
uniforms: ["world", "viewMatrix", "invWorldScale", "nearPlane", "farPlane", "stepSize"],
|
|
480
|
+
uniforms: ["world", "viewMatrix", "invTransWorld", "invWorldScale", "nearPlane", "farPlane", "stepSize"],
|
|
475
481
|
defines: ["MAX_DRAW_BUFFERS " + this._maxDrawBuffers],
|
|
476
482
|
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
477
483
|
extraInitializationsAsync: async () => {
|
|
@@ -528,6 +534,7 @@ export class _IblShadowsVoxelRenderer {
|
|
|
528
534
|
this._removeVoxelRTs(this._voxelMrtsXaxis);
|
|
529
535
|
this._removeVoxelRTs(this._voxelMrtsYaxis);
|
|
530
536
|
this._removeVoxelRTs(this._voxelMrtsZaxis);
|
|
537
|
+
this._removeVoxelRTs([this._voxelGridRT]);
|
|
531
538
|
}
|
|
532
539
|
_removeVoxelRTs(rts) {
|
|
533
540
|
// const currentRTs = this._scene.customRenderTargets;
|
|
@@ -560,7 +567,11 @@ export class _IblShadowsVoxelRenderer {
|
|
|
560
567
|
this._stopVoxelization();
|
|
561
568
|
this._includedMeshes = includedMeshes;
|
|
562
569
|
this._voxelizationInProgress = true;
|
|
563
|
-
if (this.
|
|
570
|
+
if (this._engine.isWebGPU) {
|
|
571
|
+
this._voxelGridRT.renderList = includedMeshes;
|
|
572
|
+
this._addRTsForRender([this._voxelGridRT], includedMeshes, 0);
|
|
573
|
+
}
|
|
574
|
+
else if (this._triPlanarVoxelization) {
|
|
564
575
|
this._addRTsForRender(this._voxelMrtsXaxis, includedMeshes, 0);
|
|
565
576
|
this._addRTsForRender(this._voxelMrtsYaxis, includedMeshes, 1);
|
|
566
577
|
this._addRTsForRender(this._voxelMrtsZaxis, includedMeshes, 2);
|
|
@@ -586,12 +597,24 @@ export class _IblShadowsVoxelRenderer {
|
|
|
586
597
|
allReady && (allReady = rttReady);
|
|
587
598
|
}
|
|
588
599
|
if (allReady) {
|
|
600
|
+
if (this._engine.isWebGPU) {
|
|
601
|
+
// Clear the voxel grid storage texture.
|
|
602
|
+
// Need to clear each layer individually.
|
|
603
|
+
// Would a compute shader be faster here to clear all layers in one go?
|
|
604
|
+
if (this._voxelGrid && this._voxelGrid.renderTarget) {
|
|
605
|
+
for (let layer = 0; layer < this._voxelResolution; layer++) {
|
|
606
|
+
this._engine.bindFramebuffer(this._voxelGrid.renderTarget, 0, undefined, undefined, true, 0, layer);
|
|
607
|
+
this._engine.clear(this._voxelClearColor, true, false, false);
|
|
608
|
+
this._engine.unBindFramebuffer(this._voxelGrid.renderTarget, true);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
589
612
|
for (const rt of this._renderTargets) {
|
|
590
613
|
rt.render();
|
|
591
614
|
}
|
|
592
615
|
this._stopVoxelization();
|
|
593
|
-
if (this._triPlanarVoxelization) {
|
|
594
|
-
this.
|
|
616
|
+
if (this._triPlanarVoxelization && !this._engine.isWebGPU) {
|
|
617
|
+
this._combinedVoxelGridPT.render();
|
|
595
618
|
}
|
|
596
619
|
this._generateMipMaps();
|
|
597
620
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then
|
|
@@ -638,6 +661,10 @@ export class _IblShadowsVoxelRenderer {
|
|
|
638
661
|
voxelMaterial.setFloat("nearPlane", nearPlane);
|
|
639
662
|
voxelMaterial.setFloat("farPlane", farPlane);
|
|
640
663
|
voxelMaterial.setFloat("stepSize", stepSize);
|
|
664
|
+
if (this._engine.isWebGPU) {
|
|
665
|
+
this._voxelMaterial.useVertexPulling = true;
|
|
666
|
+
this._voxelMaterial.setTexture("voxel_storage", this.getVoxelGrid());
|
|
667
|
+
}
|
|
641
668
|
});
|
|
642
669
|
// Set this material on every mesh in the scene (for this RT)
|
|
643
670
|
if (includedMeshes.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iblShadowsVoxelRenderer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsVoxelRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAGnF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGnE,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAE3F,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAK/E;;;;;GAKG;AACH,MAAM,OAAO,wBAAwB;IAcjC;;;OAGG;IACI,YAAY;QACf,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,YAAY,CAAC;QAC7B,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,eAAe,CAAC;QAChC,CAAC;IACL,CAAC;IAOD;;;OAGG;IACI,cAAc;QACjB,IAAI,CAAC,IAAI,CAAC,eAAe,EAA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I,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC;IACL,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC3I,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;QACrC,CAAC;QACD,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QACnC,CAAC;QACD,8CAA8C;IAClD,CAAC;CACJ","sourcesContent":["import { Constants } from \"../../Engines/constants\";\r\nimport { Engine } from \"../../Engines/engine\";\r\nimport { ShaderMaterial } from \"../../Materials/shaderMaterial\";\r\nimport { MultiRenderTarget } from \"../../Materials/Textures/multiRenderTarget\";\r\nimport { RenderTargetTexture } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport type { RenderTargetTextureOptions } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport type { TextureSize } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport { Color4 } from \"../../Maths/math.color\";\r\nimport { Matrix, Vector3, Vector4 } from \"../../Maths/math.vector\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../../PostProcesses/postProcess\";\r\nimport { ProceduralTexture } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../../Materials/effectRenderer\";\r\nimport type { IblShadowsRenderPipeline } from \"./iblShadowsRenderPipeline\";\r\nimport type { RenderTargetWrapper } from \"core/Engines\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Voxel-based shadow rendering for IBL's.\r\n * This should not be instanciated directly, as it is part of a scene component\r\n * @internal\r\n * @see https://playground.babylonjs.com/#8R5SSE#222\r\n */\r\nexport class _IblShadowsVoxelRenderer {\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n private _voxelGridRT: ProceduralTexture;\r\n private _voxelGridXaxis: RenderTargetTexture;\r\n private _voxelGridYaxis: RenderTargetTexture;\r\n private _voxelGridZaxis: RenderTargetTexture;\r\n private _voxelMrtsXaxis: MultiRenderTarget[] = [];\r\n private _voxelMrtsYaxis: MultiRenderTarget[] = [];\r\n private _voxelMrtsZaxis: MultiRenderTarget[] = [];\r\n private _isVoxelGrid3D: boolean = true;\r\n private _voxelMaterial: ShaderMaterial;\r\n private _voxelSlabDebugMaterial: ShaderMaterial;\r\n\r\n /**\r\n * Return the voxel grid texture.\r\n * @returns The voxel grid texture.\r\n */\r\n public getVoxelGrid(): ProceduralTexture | RenderTargetTexture {\r\n if (this._triPlanarVoxelization) {\r\n return this._voxelGridRT;\r\n } else {\r\n return this._voxelGridZaxis;\r\n }\r\n }\r\n\r\n /**\r\n * Observable that triggers when the voxelization is complete\r\n */\r\n public onVoxelizationCompleteObservable: Observable<void> = new Observable<void>();\r\n\r\n /**\r\n * The debug pass post process\r\n * @returns The debug pass post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._voxelDebugPass) {\r\n this._createDebugPass();\r\n }\r\n return this._voxelDebugPass;\r\n }\r\n\r\n private _maxDrawBuffers: number;\r\n private _renderTargets: RenderTargetTexture[] = [];\r\n\r\n private _triPlanarVoxelization: boolean = true;\r\n\r\n /**\r\n * Whether to use tri-planar voxelization. More expensive, but can help with artifacts.\r\n */\r\n public get triPlanarVoxelization(): boolean {\r\n return this._triPlanarVoxelization;\r\n }\r\n\r\n /**\r\n * Whether to use tri-planar voxelization. More expensive, but can help with artifacts.\r\n */\r\n public set triPlanarVoxelization(enabled: boolean) {\r\n if (this._triPlanarVoxelization === enabled) {\r\n return;\r\n }\r\n this._triPlanarVoxelization = enabled;\r\n this._disposeVoxelTextures();\r\n this._createTextures();\r\n }\r\n\r\n private _voxelizationInProgress: boolean = false;\r\n private _invWorldScaleMatrix: Matrix = Matrix.Identity();\r\n\r\n /**\r\n * Set the matrix to use for scaling the world space to voxel space\r\n * @param matrix The matrix to use for scaling the world space to voxel space\r\n */\r\n public setWorldScaleMatrix(matrix: Matrix) {\r\n this._invWorldScaleMatrix = matrix;\r\n }\r\n /**\r\n * @returns Whether voxelization is currently happening.\r\n */\r\n public isVoxelizationInProgress(): boolean {\r\n return this._voxelizationInProgress;\r\n }\r\n\r\n private _voxelResolution: number = 64;\r\n private _voxelResolutionExp: number = 6;\r\n\r\n /**\r\n * Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n */\r\n public get voxelResolutionExp(): number {\r\n return this._voxelResolutionExp;\r\n }\r\n\r\n /**\r\n * Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n */\r\n public set voxelResolutionExp(resolutionExp: number) {\r\n if (this._voxelResolutionExp === resolutionExp && this._voxelGridZaxis) {\r\n return;\r\n }\r\n this._voxelResolutionExp = Math.round(Math.min(Math.max(resolutionExp, 3), 9));\r\n this._voxelResolution = Math.pow(2.0, this._voxelResolutionExp);\r\n this._disposeVoxelTextures();\r\n this._createTextures();\r\n }\r\n\r\n private _copyMipEffectRenderer: EffectRenderer;\r\n private _copyMipEffectWrapper: EffectWrapper;\r\n private _mipArray: ProceduralTexture[] = [];\r\n\r\n private _voxelSlabDebugRT: RenderTargetTexture;\r\n private _voxelDebugPass: PostProcess;\r\n private _voxelDebugEnabled: boolean = false;\r\n\r\n /**\r\n * Shows only the voxels that were rendered along a particular axis (while using triPlanarVoxelization).\r\n * If not set, the combined voxel grid will be shown.\r\n * Note: This only works when the debugMipNumber is set to 0 because we don't generate mips for each axis.\r\n * @param axis The axis to show (0 = x, 1 = y, 2 = z)\r\n */\r\n public set voxelDebugAxis(axis: number) {\r\n this._voxelDebugAxis = axis;\r\n }\r\n\r\n public get voxelDebugAxis(): number {\r\n return this._voxelDebugAxis;\r\n }\r\n private _voxelDebugAxis: number = -1;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _includedMeshes: Mesh[] = [];\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n private _debugMipNumber: number = 0;\r\n /**\r\n * The mip level to show in the debug display\r\n * @param mipNum The mip level to show in the debug display\r\n */\r\n public setDebugMipNumber(mipNum: number) {\r\n this._debugMipNumber = mipNum;\r\n }\r\n private _debugPassName: string = \"Voxelization Debug Pass\";\r\n /**\r\n * Sets the name of the debug pass\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n\r\n /**\r\n * Enable or disable the debug view for this pass\r\n */\r\n public get voxelDebugEnabled(): boolean {\r\n return this._voxelDebugEnabled;\r\n }\r\n\r\n public set voxelDebugEnabled(enabled: boolean) {\r\n if (this._voxelDebugEnabled === enabled) {\r\n return;\r\n }\r\n this._voxelDebugEnabled = enabled;\r\n if (enabled) {\r\n this._voxelSlabDebugRT = new RenderTargetTexture(\"voxelSlabDebug\", { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() }, this._scene, {\r\n generateDepthBuffer: true,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n });\r\n this._voxelSlabDebugRT.noPrePassRenderer = true;\r\n }\r\n if (this._voxelSlabDebugRT) {\r\n this._removeVoxelRTs([this._voxelSlabDebugRT]);\r\n }\r\n // Add the slab debug RT if needed.\r\n if (this._voxelDebugEnabled) {\r\n this._addRTsForRender([this._voxelSlabDebugRT], this._includedMeshes, this._voxelDebugAxis, 1, true);\r\n this._setDebugBindingsBound = this._setDebugBindings.bind(this);\r\n this._scene.onBeforeRenderObservable.add(this._setDebugBindingsBound);\r\n } else {\r\n this._scene.onBeforeRenderObservable.removeCallback(this._setDebugBindingsBound);\r\n }\r\n }\r\n\r\n private _setDebugBindingsBound: () => void;\r\n /**\r\n * Creates the debug post process effect for this pass\r\n */\r\n private _createDebugPass() {\r\n const isWebGPU = this._engine.isWebGPU;\r\n if (!this._voxelDebugPass) {\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RGBA,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n uniforms: [\"sizeParams\", \"mipNumber\"],\r\n samplers: [\"voxelTexture\", \"voxelSlabTexture\"],\r\n engine: this._engine,\r\n reusable: false,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (this._isVoxelGrid3D) {\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblVoxelGrid3dDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblVoxelGrid3dDebug.fragment\"));\r\n }\r\n return;\r\n }\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblVoxelGrid2dArrayDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._voxelDebugPass = new PostProcess(this.debugPassName, this._isVoxelGrid3D ? \"iblVoxelGrid3dDebug\" : \"iblVoxelGrid2dArrayDebug\", debugOptions);\r\n this._voxelDebugPass.onApplyObservable.add((effect) => {\r\n if (this._voxelDebugAxis === 0) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridXaxis);\r\n } else if (this._voxelDebugAxis === 1) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridYaxis);\r\n } else if (this._voxelDebugAxis === 2) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridZaxis);\r\n } else {\r\n effect.setTexture(\"voxelTexture\", this.getVoxelGrid());\r\n }\r\n effect.setTexture(\"voxelSlabTexture\", this._voxelSlabDebugRT);\r\n effect.setVector4(\"sizeParams\", this._debugSizeParams);\r\n effect.setFloat(\"mipNumber\", this._debugMipNumber);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Instanciates the voxel renderer\r\n * @param scene Scene to attach to\r\n * @param iblShadowsRenderPipeline The render pipeline this pass is associated with\r\n * @param resolutionExp Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n * @param triPlanarVoxelization Whether to use tri-planar voxelization. More expensive, but can help with artifacts.\r\n * @returns The voxel renderer\r\n */\r\n constructor(scene: Scene, iblShadowsRenderPipeline: IblShadowsRenderPipeline, resolutionExp: number = 6, triPlanarVoxelization: boolean = true) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine() as Engine;\r\n this._triPlanarVoxelization = triPlanarVoxelization;\r\n if (!this._engine.getCaps().drawBuffersExtension) {\r\n Logger.Error(\"Can't do voxel rendering without the draw buffers extension.\");\r\n }\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n this._maxDrawBuffers = this._engine.getCaps().maxDrawBuffers || 0;\r\n\r\n this._copyMipEffectRenderer = new EffectRenderer(this._engine);\r\n this._copyMipEffectWrapper = new EffectWrapper({\r\n engine: this._engine,\r\n fragmentShader: \"copyTexture3DLayerToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"layerNum\"],\r\n samplerNames: [\"textureSampler\"],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/copyTexture3DLayerToTexture.fragment\");\r\n } else {\r\n await import(\"../../Shaders/copyTexture3DLayerToTexture.fragment\");\r\n }\r\n },\r\n });\r\n\r\n this.voxelResolutionExp = resolutionExp;\r\n }\r\n\r\n private _generateMipMaps() {\r\n const iterations = Math.ceil(Math.log2(this._voxelResolution));\r\n for (let i = 1; i < iterations + 1; i++) {\r\n this._generateMipMap(i);\r\n }\r\n }\r\n\r\n private _generateMipMap(lodLevel: number) {\r\n // Generate a mip map for the given level by triggering the render of the procedural mip texture.\r\n const mipTarget = this._mipArray[lodLevel - 1];\r\n if (!mipTarget) {\r\n return;\r\n }\r\n mipTarget.setTexture(\"srcMip\", lodLevel === 1 ? this.getVoxelGrid() : this._mipArray[lodLevel - 2]);\r\n mipTarget.render();\r\n }\r\n\r\n private _copyMipMaps() {\r\n const iterations = Math.ceil(Math.log2(this._voxelResolution));\r\n for (let i = 1; i < iterations + 1; i++) {\r\n this._copyMipMap(i);\r\n }\r\n }\r\n\r\n private _copyMipMap(lodLevel: number) {\r\n // Now, copy this mip into the mip chain of the voxel grid.\r\n // TODO - this currently isn't working. \"textureSampler\" isn't being properly set to mipTarget.\r\n const mipTarget = this._mipArray[lodLevel - 1];\r\n if (!mipTarget) {\r\n return;\r\n }\r\n const voxelGrid = this.getVoxelGrid();\r\n let rt: RenderTargetWrapper;\r\n if (voxelGrid instanceof RenderTargetTexture && voxelGrid.renderTarget) {\r\n rt = voxelGrid.renderTarget;\r\n } else {\r\n rt = (voxelGrid as any)._rtWrapper;\r\n }\r\n if (rt) {\r\n this._copyMipEffectRenderer.saveStates();\r\n const bindSize = mipTarget.getSize().width;\r\n\r\n // Render to each layer of the voxel grid.\r\n for (let layer = 0; layer < bindSize; layer++) {\r\n this._engine.bindFramebuffer(rt, 0, bindSize, bindSize, true, lodLevel, layer);\r\n this._copyMipEffectRenderer.applyEffectWrapper(this._copyMipEffectWrapper);\r\n this._copyMipEffectWrapper.effect.setTexture(\"textureSampler\", mipTarget);\r\n this._copyMipEffectWrapper.effect.setInt(\"layerNum\", layer);\r\n this._copyMipEffectRenderer.draw();\r\n this._engine.unBindFramebuffer(rt, true);\r\n }\r\n this._copyMipEffectRenderer.restoreStates();\r\n }\r\n }\r\n\r\n private _computeNumberOfSlabs(): number {\r\n return Math.ceil(this._voxelResolution / this._maxDrawBuffers);\r\n }\r\n\r\n private _createTextures() {\r\n const isWebGPU = this._engine.isWebGPU;\r\n const size: TextureSize = {\r\n width: this._voxelResolution,\r\n height: this._voxelResolution,\r\n layers: this._isVoxelGrid3D ? undefined : this._voxelResolution,\r\n depth: this._isVoxelGrid3D ? this._voxelResolution : undefined,\r\n };\r\n const voxelAxisOptions: RenderTargetTextureOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_R,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n };\r\n\r\n // We can render up to maxDrawBuffers voxel slices of the grid per render.\r\n // We call this a slab.\r\n const numSlabs = this._computeNumberOfSlabs();\r\n const voxelCombinedOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: true,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_R,\r\n samplingMode: Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/iblCombineVoxelGrids.fragment\");\r\n } else {\r\n await import(\"../../Shaders/iblCombineVoxelGrids.fragment\");\r\n }\r\n },\r\n };\r\n if (this._triPlanarVoxelization) {\r\n this._voxelGridXaxis = new RenderTargetTexture(\"voxelGridXaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelGridYaxis = new RenderTargetTexture(\"voxelGridYaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelGridZaxis = new RenderTargetTexture(\"voxelGridZaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelMrtsXaxis = this._createVoxelMRTs(\"x_axis_\", this._voxelGridXaxis, numSlabs);\r\n this._voxelMrtsYaxis = this._createVoxelMRTs(\"y_axis_\", this._voxelGridYaxis, numSlabs);\r\n this._voxelMrtsZaxis = this._createVoxelMRTs(\"z_axis_\", this._voxelGridZaxis, numSlabs);\r\n\r\n this._voxelGridRT = new ProceduralTexture(\"combinedVoxelGrid\", size, \"iblCombineVoxelGrids\", this._scene, voxelCombinedOptions, false);\r\n this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._voxelGridRT), 1);\r\n this._voxelGridRT.setFloat(\"layer\", 0.0);\r\n this._voxelGridRT.setTexture(\"voxelXaxisSampler\", this._voxelGridXaxis);\r\n this._voxelGridRT.setTexture(\"voxelYaxisSampler\", this._voxelGridYaxis);\r\n this._voxelGridRT.setTexture(\"voxelZaxisSampler\", this._voxelGridZaxis);\r\n // We will render this only after voxelization is completed for the 3 axes.\r\n this._voxelGridRT.autoClear = false;\r\n this._voxelGridRT.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this._voxelGridRT.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n } else {\r\n this._voxelGridZaxis = new RenderTargetTexture(\"voxelGridZaxis\", size, this._scene, voxelCombinedOptions);\r\n this._voxelMrtsZaxis = this._createVoxelMRTs(\"z_axis_\", this._voxelGridZaxis, numSlabs);\r\n }\r\n\r\n const generateVoxelMipOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_R,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/iblGenerateVoxelMip.fragment\");\r\n } else {\r\n await import(\"../../Shaders/iblGenerateVoxelMip.fragment\");\r\n }\r\n },\r\n };\r\n this._mipArray = new Array(Math.ceil(Math.log2(this._voxelResolution)));\r\n for (let mipIdx = 1; mipIdx <= this._mipArray.length; mipIdx++) {\r\n const mipDim = this._voxelResolution >> mipIdx;\r\n const mipSize: TextureSize = { width: mipDim, height: mipDim, depth: mipDim };\r\n this._mipArray[mipIdx - 1] = new ProceduralTexture(\"voxelMip\" + mipIdx, mipSize, \"iblGenerateVoxelMip\", this._scene, generateVoxelMipOptions, false);\r\n this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._mipArray[mipIdx - 1]), 1);\r\n\r\n const mipTarget = this._mipArray[mipIdx - 1];\r\n mipTarget.autoClear = false;\r\n mipTarget.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n mipTarget.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n mipTarget.setTexture(\"srcMip\", mipIdx > 1 ? this._mipArray[mipIdx - 2] : this.getVoxelGrid());\r\n mipTarget.setInt(\"layerNum\", 0);\r\n }\r\n\r\n this._createVoxelMaterials();\r\n }\r\n\r\n private _createVoxelMRTs(name: string, voxelRT: RenderTargetTexture, numSlabs: number): MultiRenderTarget[] {\r\n voxelRT.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n voxelRT.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n voxelRT.noPrePassRenderer = true;\r\n const mrtArray: MultiRenderTarget[] = [];\r\n const targetTypes = new Array(this._maxDrawBuffers).fill(this._isVoxelGrid3D ? Constants.TEXTURE_3D : Constants.TEXTURE_2D_ARRAY);\r\n\r\n for (let mrtIndex = 0; mrtIndex < numSlabs; mrtIndex++) {\r\n let layerIndices = new Array(this._maxDrawBuffers).fill(0);\r\n layerIndices = layerIndices.map((value, index) => mrtIndex * this._maxDrawBuffers + index);\r\n\r\n let textureNames = new Array(this._maxDrawBuffers).fill(\"\");\r\n textureNames = textureNames.map((value, index) => \"voxel_grid_\" + name + (mrtIndex * this._maxDrawBuffers + index));\r\n\r\n const mrt = new MultiRenderTarget(\r\n \"mrt_\" + name + mrtIndex,\r\n { width: this._voxelResolution, height: this._voxelResolution, depth: this._isVoxelGrid3D ? this._voxelResolution : undefined },\r\n this._maxDrawBuffers, // number of draw buffers\r\n this._scene,\r\n {\r\n types: new Array(this._maxDrawBuffers).fill(Constants.TEXTURETYPE_UNSIGNED_BYTE),\r\n samplingModes: new Array(this._maxDrawBuffers).fill(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE),\r\n generateMipMaps: false,\r\n targetTypes,\r\n formats: new Array(this._maxDrawBuffers).fill(Constants.TEXTUREFORMAT_R),\r\n faceIndex: new Array(this._maxDrawBuffers).fill(0),\r\n layerIndex: layerIndices,\r\n layerCounts: new Array(this._maxDrawBuffers).fill(this._voxelResolution),\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n },\r\n textureNames\r\n );\r\n\r\n mrt.clearColor = new Color4(0, 0, 0, 1);\r\n mrt.noPrePassRenderer = true;\r\n for (let i = 0; i < this._maxDrawBuffers; i++) {\r\n mrt.setInternalTexture(voxelRT.getInternalTexture()!, i);\r\n }\r\n\r\n mrtArray.push(mrt);\r\n }\r\n return mrtArray;\r\n }\r\n\r\n private _disposeVoxelTextures() {\r\n this._stopVoxelization();\r\n for (let i = 0; i < this._voxelMrtsZaxis.length; i++) {\r\n if (this._triPlanarVoxelization) {\r\n this._voxelMrtsXaxis[i].dispose(true);\r\n this._voxelMrtsYaxis[i].dispose(true);\r\n }\r\n this._voxelMrtsZaxis[i].dispose(true);\r\n }\r\n if (this._triPlanarVoxelization) {\r\n this._voxelGridXaxis?.dispose();\r\n this._voxelGridYaxis?.dispose();\r\n this._voxelGridRT?.dispose();\r\n }\r\n this._voxelGridZaxis?.dispose();\r\n for (const mip of this._mipArray) {\r\n mip.dispose();\r\n }\r\n this._voxelMaterial?.dispose();\r\n this._voxelSlabDebugMaterial?.dispose();\r\n this._mipArray = [];\r\n this._voxelMrtsXaxis = [];\r\n this._voxelMrtsYaxis = [];\r\n this._voxelMrtsZaxis = [];\r\n }\r\n\r\n private _createVoxelMaterials(): void {\r\n const isWebGPU = this._engine.isWebGPU;\r\n this._voxelMaterial = new ShaderMaterial(\"voxelization\", this._scene, \"iblVoxelGrid\", {\r\n uniforms: [\"world\", \"viewMatrix\", \"invWorldScale\", \"nearPlane\", \"farPlane\", \"stepSize\"],\r\n defines: [\"MAX_DRAW_BUFFERS \" + this._maxDrawBuffers],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblVoxelGrid.fragment\"), import(\"../../ShadersWGSL/iblVoxelGrid.vertex\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblVoxelGrid.fragment\"), import(\"../../Shaders/iblVoxelGrid.vertex\")]);\r\n }\r\n },\r\n });\r\n this._voxelMaterial.cullBackFaces = false;\r\n this._voxelMaterial.backFaceCulling = false;\r\n this._voxelMaterial.depthFunction = Engine.ALWAYS;\r\n\r\n this._voxelSlabDebugMaterial = new ShaderMaterial(\"voxelSlabDebug\", this._scene, \"iblVoxelSlabDebug\", {\r\n uniforms: [\"world\", \"viewMatrix\", \"cameraViewMatrix\", \"projection\", \"invWorldScale\", \"nearPlane\", \"farPlane\", \"stepSize\"],\r\n defines: [\"MAX_DRAW_BUFFERS \" + this._maxDrawBuffers],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblVoxelSlabDebug.fragment\"), import(\"../../ShadersWGSL/iblVoxelSlabDebug.vertex\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblVoxelSlabDebug.fragment\"), import(\"../../Shaders/iblVoxelSlabDebug.vertex\")]);\r\n }\r\n },\r\n });\r\n }\r\n\r\n private _setDebugBindings() {\r\n this._voxelSlabDebugMaterial.setMatrix(\"projection\", this._scene.activeCamera!.getProjectionMatrix());\r\n this._voxelSlabDebugMaterial.setMatrix(\"cameraViewMatrix\", this._scene.activeCamera!.getViewMatrix());\r\n }\r\n\r\n /**\r\n * Checks if the voxel renderer is ready to voxelize scene\r\n * @returns true if the voxel renderer is ready to voxelize scene\r\n */\r\n public isReady() {\r\n let allReady = this.getVoxelGrid().isReady();\r\n for (let i = 0; i < this._mipArray.length; i++) {\r\n const mipReady = this._mipArray[i].isReady();\r\n allReady &&= mipReady;\r\n }\r\n\r\n if (!allReady || this._voxelizationInProgress) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * If the MRT's are already in the list of render targets, this will\r\n * remove them so that they don't get rendered again.\r\n */\r\n private _stopVoxelization() {\r\n // If the MRT's are already in the list of render targets, remove them.\r\n this._removeVoxelRTs(this._voxelMrtsXaxis);\r\n this._removeVoxelRTs(this._voxelMrtsYaxis);\r\n this._removeVoxelRTs(this._voxelMrtsZaxis);\r\n }\r\n\r\n private _removeVoxelRTs(rts: RenderTargetTexture[]) {\r\n // const currentRTs = this._scene.customRenderTargets;\r\n const rtIdx = this._renderTargets.findIndex((rt) => {\r\n if (rt === rts[0]) {\r\n return true;\r\n }\r\n return false;\r\n });\r\n if (rtIdx >= 0) {\r\n this._renderTargets.splice(rtIdx, rts.length);\r\n } else {\r\n const rtIdx = this._scene.customRenderTargets.findIndex((rt) => {\r\n if (rt === rts[0]) {\r\n return true;\r\n }\r\n return false;\r\n });\r\n if (rtIdx >= 0) {\r\n this._scene.customRenderTargets.splice(rtIdx, rts.length);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Renders voxel grid of scene for IBL shadows\r\n * @param includedMeshes\r\n */\r\n public updateVoxelGrid(includedMeshes: Mesh[]) {\r\n this._stopVoxelization();\r\n this._includedMeshes = includedMeshes;\r\n this._voxelizationInProgress = true;\r\n\r\n if (this._triPlanarVoxelization) {\r\n this._addRTsForRender(this._voxelMrtsXaxis, includedMeshes, 0);\r\n this._addRTsForRender(this._voxelMrtsYaxis, includedMeshes, 1);\r\n this._addRTsForRender(this._voxelMrtsZaxis, includedMeshes, 2);\r\n } else {\r\n this._addRTsForRender(this._voxelMrtsZaxis, includedMeshes, 2);\r\n }\r\n if (this._voxelDebugEnabled) {\r\n this._addRTsForRender([this._voxelSlabDebugRT], includedMeshes, this._voxelDebugAxis, 1, true);\r\n }\r\n this._renderVoxelGridBound = this._renderVoxelGrid.bind(this);\r\n this._scene.onAfterRenderObservable.add(this._renderVoxelGridBound);\r\n }\r\n\r\n private _renderVoxelGridBound: () => void;\r\n\r\n private _renderVoxelGrid() {\r\n if (this._voxelizationInProgress) {\r\n let allReady = this.getVoxelGrid().isReady();\r\n for (let i = 0; i < this._mipArray.length; i++) {\r\n const mipReady = this._mipArray[i].isReady();\r\n allReady &&= mipReady;\r\n }\r\n for (let i = 0; i < this._renderTargets.length; i++) {\r\n const rttReady = this._renderTargets[i].isReadyForRendering();\r\n allReady &&= rttReady;\r\n }\r\n if (allReady) {\r\n for (const rt of this._renderTargets) {\r\n rt.render();\r\n }\r\n this._stopVoxelization();\r\n\r\n if (this._triPlanarVoxelization) {\r\n this._voxelGridRT.render();\r\n }\r\n this._generateMipMaps();\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._copyMipEffectWrapper.effect.whenCompiledAsync().then(() => {\r\n this._copyMipMaps();\r\n this._scene.onAfterRenderObservable.removeCallback(this._renderVoxelGridBound);\r\n this._voxelizationInProgress = false;\r\n this.onVoxelizationCompleteObservable.notifyObservers();\r\n });\r\n }\r\n }\r\n }\r\n\r\n private _addRTsForRender(mrts: RenderTargetTexture[], includedMeshes: Mesh[], axis: number, shaderType: number = 0, continuousRender: boolean = false) {\r\n const slabSize = 1.0 / this._computeNumberOfSlabs();\r\n let voxelMaterial: ShaderMaterial;\r\n if (shaderType === 0) {\r\n voxelMaterial = this._voxelMaterial;\r\n } else {\r\n voxelMaterial = this._voxelSlabDebugMaterial;\r\n }\r\n\r\n // We need to update the world scale uniform for every mesh being rendered to the voxel grid.\r\n for (let mrtIndex = 0; mrtIndex < mrts.length; mrtIndex++) {\r\n const mrt = mrts[mrtIndex];\r\n mrt.renderList = [];\r\n const nearPlane = mrtIndex * slabSize;\r\n const farPlane = (mrtIndex + 1) * slabSize;\r\n const stepSize = slabSize / this._maxDrawBuffers;\r\n\r\n const cameraPosition = new Vector3(0, 0, 0);\r\n let targetPosition = new Vector3(0, 0, 1);\r\n if (axis === 0) {\r\n targetPosition = new Vector3(1, 0, 0);\r\n } else if (axis === 1) {\r\n targetPosition = new Vector3(0, 1, 0);\r\n }\r\n let upDirection = new Vector3(0, 1, 0);\r\n if (axis === 1) {\r\n upDirection = new Vector3(1, 0, 0);\r\n }\r\n mrt.onBeforeRenderObservable.add(() => {\r\n voxelMaterial.setMatrix(\"viewMatrix\", Matrix.LookAtLH(cameraPosition, targetPosition, upDirection));\r\n voxelMaterial.setMatrix(\"invWorldScale\", this._invWorldScaleMatrix);\r\n voxelMaterial.setFloat(\"nearPlane\", nearPlane);\r\n voxelMaterial.setFloat(\"farPlane\", farPlane);\r\n voxelMaterial.setFloat(\"stepSize\", stepSize);\r\n });\r\n\r\n // Set this material on every mesh in the scene (for this RT)\r\n if (includedMeshes.length === 0) {\r\n return;\r\n }\r\n for (const mesh of includedMeshes) {\r\n if (mesh) {\r\n if (mesh.subMeshes && mesh.subMeshes.length > 0) {\r\n mrt.renderList?.push(mesh);\r\n mrt.setMaterialForRendering(mesh, voxelMaterial);\r\n }\r\n const meshes = mesh.getChildMeshes();\r\n for (const childMesh of meshes) {\r\n if (childMesh.subMeshes && childMesh.subMeshes.length > 0) {\r\n mrt.renderList?.push(childMesh);\r\n mrt.setMaterialForRendering(childMesh, voxelMaterial);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Add the MRT's to render.\r\n if (continuousRender) {\r\n for (const mrt of mrts) {\r\n if (this._scene.customRenderTargets.indexOf(mrt) === -1) {\r\n this._scene.customRenderTargets.push(mrt);\r\n }\r\n }\r\n } else {\r\n this._renderTargets = this._renderTargets.concat(mrts);\r\n }\r\n }\r\n\r\n /**\r\n * Called by the pipeline to resize resources.\r\n */\r\n public resize() {\r\n this._voxelSlabDebugRT?.resize({ width: this._scene.getEngine().getRenderWidth(), height: this._scene.getEngine().getRenderHeight() });\r\n }\r\n\r\n /**\r\n * Disposes the voxel renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeVoxelTextures();\r\n if (this._voxelSlabDebugRT) {\r\n this._removeVoxelRTs([this._voxelSlabDebugRT]);\r\n this._voxelSlabDebugRT.dispose();\r\n }\r\n if (this._voxelDebugPass) {\r\n this._voxelDebugPass.dispose();\r\n }\r\n // TODO - dispose all created voxel materials.\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"iblShadowsVoxelRenderer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsVoxelRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,C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CAAC,GAAG,CAAC,CAAC;gBAC9C,CAAC;YACL,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC;IACL,CAAC;IAED;;OAEG;IACI,MAAM;QACT,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC3I,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;QACrC,CAAC;QACD,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QACnC,CAAC;QACD,8CAA8C;IAClD,CAAC;CACJ","sourcesContent":["import { Constants } from \"../../Engines/constants\";\r\nimport { Engine } from \"../../Engines/engine\";\r\nimport { ShaderMaterial } from \"../../Materials/shaderMaterial\";\r\nimport { MultiRenderTarget } from \"../../Materials/Textures/multiRenderTarget\";\r\nimport { RenderTargetTexture } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport type { RenderTargetTextureOptions } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport type { TextureSize } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport { Color4 } from \"../../Maths/math.color\";\r\nimport { Matrix, Vector3, Vector4 } from \"../../Maths/math.vector\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../../PostProcesses/postProcess\";\r\nimport { ProceduralTexture } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../../Materials/effectRenderer\";\r\nimport type { IblShadowsRenderPipeline } from \"./iblShadowsRenderPipeline\";\r\nimport type { RenderTargetWrapper } from \"core/Engines\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Voxel-based shadow rendering for IBL's.\r\n * This should not be instanciated directly, as it is part of a scene component\r\n * @internal\r\n * @see https://playground.babylonjs.com/#8R5SSE#222\r\n */\r\nexport class _IblShadowsVoxelRenderer {\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n\r\n // WebGPU, single-pass voxelization.\r\n // See https://playground.babylonjs.com/#XSNYAU#133\r\n private _voxelGrid: RenderTargetTexture;\r\n private _voxelGridRT: RenderTargetTexture;\r\n\r\n // WebGL voxelization, including tri-planar voxelization.\r\n private _combinedVoxelGridPT: ProceduralTexture;\r\n private _voxelGridXaxis: RenderTargetTexture;\r\n private _voxelGridYaxis: RenderTargetTexture;\r\n private _voxelGridZaxis: RenderTargetTexture;\r\n private _voxelMrtsXaxis: MultiRenderTarget[] = [];\r\n private _voxelMrtsYaxis: MultiRenderTarget[] = [];\r\n private _voxelMrtsZaxis: MultiRenderTarget[] = [];\r\n\r\n private _voxelMaterial: ShaderMaterial;\r\n private _voxelSlabDebugMaterial: ShaderMaterial;\r\n private _voxelClearColor: Color4 = new Color4(0, 0, 0, 1);\r\n\r\n /**\r\n * Return the voxel grid texture.\r\n * @returns The voxel grid texture.\r\n */\r\n public getVoxelGrid(): ProceduralTexture | RenderTargetTexture {\r\n if (this._engine.isWebGPU) {\r\n return this._voxelGrid;\r\n } else if (this._triPlanarVoxelization) {\r\n return this._combinedVoxelGridPT;\r\n } else {\r\n return this._voxelGridZaxis;\r\n }\r\n }\r\n\r\n /**\r\n * Observable that triggers when the voxelization is complete\r\n */\r\n public onVoxelizationCompleteObservable: Observable<void> = new Observable<void>();\r\n\r\n /**\r\n * The debug pass post process\r\n * @returns The debug pass post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._voxelDebugPass) {\r\n this._createDebugPass();\r\n }\r\n return this._voxelDebugPass;\r\n }\r\n\r\n private _maxDrawBuffers: number;\r\n private _renderTargets: RenderTargetTexture[] = [];\r\n\r\n private _triPlanarVoxelization: boolean = true;\r\n\r\n /**\r\n * Whether to use tri-planar voxelization. More expensive, but can help with artifacts.\r\n */\r\n public get triPlanarVoxelization(): boolean {\r\n return this._triPlanarVoxelization;\r\n }\r\n\r\n /**\r\n * Whether to use tri-planar voxelization. More expensive, but can help with artifacts.\r\n */\r\n public set triPlanarVoxelization(enabled: boolean) {\r\n if (this._engine.isWebGPU) {\r\n // WebGPU only supports tri-planar voxelization.\r\n this._triPlanarVoxelization = true;\r\n return;\r\n }\r\n if (this._triPlanarVoxelization === enabled) {\r\n return;\r\n }\r\n this._triPlanarVoxelization = enabled;\r\n this._disposeVoxelTextures();\r\n this._createTextures();\r\n }\r\n\r\n private _voxelizationInProgress: boolean = false;\r\n private _invWorldScaleMatrix: Matrix = Matrix.Identity();\r\n\r\n /**\r\n * Set the matrix to use for scaling the world space to voxel space\r\n * @param matrix The matrix to use for scaling the world space to voxel space\r\n */\r\n public setWorldScaleMatrix(matrix: Matrix) {\r\n this._invWorldScaleMatrix = matrix;\r\n }\r\n /**\r\n * @returns Whether voxelization is currently happening.\r\n */\r\n public isVoxelizationInProgress(): boolean {\r\n return this._voxelizationInProgress;\r\n }\r\n\r\n private _voxelResolution: number = 64;\r\n private _voxelResolutionExp: number = 6;\r\n\r\n /**\r\n * Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n */\r\n public get voxelResolutionExp(): number {\r\n return this._voxelResolutionExp;\r\n }\r\n\r\n /**\r\n * Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n */\r\n public set voxelResolutionExp(resolutionExp: number) {\r\n if (this._voxelResolutionExp === resolutionExp && this._voxelGridZaxis) {\r\n return;\r\n }\r\n this._voxelResolutionExp = Math.round(Math.min(Math.max(resolutionExp, 3), 9));\r\n this._voxelResolution = Math.pow(2.0, this._voxelResolutionExp);\r\n this._disposeVoxelTextures();\r\n this._createTextures();\r\n }\r\n\r\n private _copyMipEffectRenderer: EffectRenderer;\r\n private _copyMipEffectWrapper: EffectWrapper;\r\n private _mipArray: ProceduralTexture[] = [];\r\n\r\n private _voxelSlabDebugRT: RenderTargetTexture;\r\n private _voxelDebugPass: PostProcess;\r\n private _voxelDebugEnabled: boolean = false;\r\n\r\n /**\r\n * Shows only the voxels that were rendered along a particular axis (while using triPlanarVoxelization).\r\n * If not set, the combined voxel grid will be shown.\r\n * Note: This only works when the debugMipNumber is set to 0 because we don't generate mips for each axis.\r\n * @param axis The axis to show (0 = x, 1 = y, 2 = z)\r\n */\r\n public set voxelDebugAxis(axis: number) {\r\n this._voxelDebugAxis = axis;\r\n }\r\n\r\n public get voxelDebugAxis(): number {\r\n return this._voxelDebugAxis;\r\n }\r\n private _voxelDebugAxis: number = -1;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n private _includedMeshes: Mesh[] = [];\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n private _debugMipNumber: number = 0;\r\n /**\r\n * The mip level to show in the debug display\r\n * @param mipNum The mip level to show in the debug display\r\n */\r\n public setDebugMipNumber(mipNum: number) {\r\n this._debugMipNumber = mipNum;\r\n }\r\n private _debugPassName: string = \"Voxelization Debug Pass\";\r\n /**\r\n * Sets the name of the debug pass\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n\r\n /**\r\n * Enable or disable the debug view for this pass\r\n */\r\n public get voxelDebugEnabled(): boolean {\r\n return this._voxelDebugEnabled;\r\n }\r\n\r\n public set voxelDebugEnabled(enabled: boolean) {\r\n if (this._voxelDebugEnabled === enabled) {\r\n return;\r\n }\r\n this._voxelDebugEnabled = enabled;\r\n if (enabled) {\r\n this._voxelSlabDebugRT = new RenderTargetTexture(\"voxelSlabDebug\", { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() }, this._scene, {\r\n generateDepthBuffer: true,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n });\r\n this._voxelSlabDebugRT.noPrePassRenderer = true;\r\n }\r\n if (this._voxelSlabDebugRT) {\r\n this._removeVoxelRTs([this._voxelSlabDebugRT]);\r\n }\r\n // Add the slab debug RT if needed.\r\n if (this._voxelDebugEnabled) {\r\n this._addRTsForRender([this._voxelSlabDebugRT], this._includedMeshes, this._voxelDebugAxis, 1, true);\r\n this._setDebugBindingsBound = this._setDebugBindings.bind(this);\r\n this._scene.onBeforeRenderObservable.add(this._setDebugBindingsBound);\r\n } else {\r\n this._scene.onBeforeRenderObservable.removeCallback(this._setDebugBindingsBound);\r\n }\r\n }\r\n\r\n private _setDebugBindingsBound: () => void;\r\n /**\r\n * Creates the debug post process effect for this pass\r\n */\r\n private _createDebugPass() {\r\n const isWebGPU = this._engine.isWebGPU;\r\n if (!this._voxelDebugPass) {\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RGBA,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n uniforms: [\"sizeParams\", \"mipNumber\"],\r\n samplers: [\"voxelTexture\", \"voxelSlabTexture\"],\r\n engine: this._engine,\r\n reusable: false,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblVoxelGrid3dDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblVoxelGrid3dDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._voxelDebugPass = new PostProcess(this.debugPassName, \"iblVoxelGrid3dDebug\", debugOptions);\r\n this._voxelDebugPass.onApplyObservable.add((effect) => {\r\n if (this._voxelDebugAxis === 0) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridXaxis);\r\n } else if (this._voxelDebugAxis === 1) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridYaxis);\r\n } else if (this._voxelDebugAxis === 2) {\r\n effect.setTexture(\"voxelTexture\", this._voxelGridZaxis);\r\n } else {\r\n effect.setTexture(\"voxelTexture\", this.getVoxelGrid());\r\n }\r\n effect.setTexture(\"voxelSlabTexture\", this._voxelSlabDebugRT);\r\n effect.setVector4(\"sizeParams\", this._debugSizeParams);\r\n effect.setFloat(\"mipNumber\", this._debugMipNumber);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Instanciates the voxel renderer\r\n * @param scene Scene to attach to\r\n * @param iblShadowsRenderPipeline The render pipeline this pass is associated with\r\n * @param resolutionExp Resolution of the voxel grid. The final resolution will be 2^resolutionExp.\r\n * @param triPlanarVoxelization Whether to use tri-planar voxelization. Only applies to WebGL. Voxelization will take longer but will reduce missing geometry.\r\n * @returns The voxel renderer\r\n */\r\n constructor(scene: Scene, iblShadowsRenderPipeline: IblShadowsRenderPipeline, resolutionExp: number = 6, triPlanarVoxelization: boolean = true) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine() as Engine;\r\n this._triPlanarVoxelization = this._engine.isWebGPU || triPlanarVoxelization;\r\n if (!this._engine.getCaps().drawBuffersExtension) {\r\n Logger.Error(\"Can't do voxel rendering without the draw buffers extension.\");\r\n }\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n this._maxDrawBuffers = this._engine.getCaps().maxDrawBuffers || 0;\r\n\r\n this._copyMipEffectRenderer = new EffectRenderer(this._engine);\r\n this._copyMipEffectWrapper = new EffectWrapper({\r\n engine: this._engine,\r\n fragmentShader: \"copyTexture3DLayerToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"layerNum\"],\r\n samplerNames: [\"textureSampler\"],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/copyTexture3DLayerToTexture.fragment\");\r\n } else {\r\n await import(\"../../Shaders/copyTexture3DLayerToTexture.fragment\");\r\n }\r\n },\r\n });\r\n\r\n this.voxelResolutionExp = resolutionExp;\r\n }\r\n\r\n private _generateMipMaps() {\r\n const iterations = Math.ceil(Math.log2(this._voxelResolution));\r\n for (let i = 1; i < iterations + 1; i++) {\r\n this._generateMipMap(i);\r\n }\r\n }\r\n\r\n private _generateMipMap(lodLevel: number) {\r\n // Generate a mip map for the given level by triggering the render of the procedural mip texture.\r\n const mipTarget = this._mipArray[lodLevel - 1];\r\n if (!mipTarget) {\r\n return;\r\n }\r\n mipTarget.setTexture(\"srcMip\", lodLevel === 1 ? this.getVoxelGrid() : this._mipArray[lodLevel - 2]);\r\n mipTarget.render();\r\n }\r\n\r\n private _copyMipMaps() {\r\n const iterations = Math.ceil(Math.log2(this._voxelResolution));\r\n for (let i = 1; i < iterations + 1; i++) {\r\n this._copyMipMap(i);\r\n }\r\n }\r\n\r\n private _copyMipMap(lodLevel: number) {\r\n // Now, copy this mip into the mip chain of the voxel grid.\r\n // TODO - this currently isn't working. \"textureSampler\" isn't being properly set to mipTarget.\r\n const mipTarget = this._mipArray[lodLevel - 1];\r\n if (!mipTarget) {\r\n return;\r\n }\r\n const voxelGrid = this.getVoxelGrid();\r\n let rt: RenderTargetWrapper;\r\n if (voxelGrid instanceof RenderTargetTexture && voxelGrid.renderTarget) {\r\n rt = voxelGrid.renderTarget;\r\n } else {\r\n rt = (voxelGrid as any)._rtWrapper;\r\n }\r\n if (rt) {\r\n this._copyMipEffectRenderer.saveStates();\r\n const bindSize = mipTarget.getSize().width;\r\n\r\n // Render to each layer of the voxel grid.\r\n for (let layer = 0; layer < bindSize; layer++) {\r\n this._engine.bindFramebuffer(rt, 0, bindSize, bindSize, true, lodLevel, layer);\r\n this._copyMipEffectRenderer.applyEffectWrapper(this._copyMipEffectWrapper);\r\n this._copyMipEffectWrapper.effect.setTexture(\"textureSampler\", mipTarget);\r\n this._copyMipEffectWrapper.effect.setInt(\"layerNum\", layer);\r\n this._copyMipEffectRenderer.draw();\r\n this._engine.unBindFramebuffer(rt, true);\r\n }\r\n this._copyMipEffectRenderer.restoreStates();\r\n }\r\n }\r\n\r\n private _computeNumberOfSlabs(): number {\r\n return Math.ceil(this._voxelResolution / this._maxDrawBuffers);\r\n }\r\n\r\n private _createTextures() {\r\n const isWebGPU = this._engine.isWebGPU;\r\n const size: TextureSize = {\r\n width: this._voxelResolution,\r\n height: this._voxelResolution,\r\n depth: this._voxelResolution,\r\n };\r\n const voxelAxisOptions: RenderTargetTextureOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n };\r\n\r\n // We can render up to maxDrawBuffers voxel slices of the grid per render.\r\n // We call this a slab.\r\n const numSlabs = this._computeNumberOfSlabs();\r\n const voxelCombinedOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: true,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_R,\r\n samplingMode: Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/iblCombineVoxelGrids.fragment\");\r\n } else {\r\n await import(\"../../Shaders/iblCombineVoxelGrids.fragment\");\r\n }\r\n },\r\n };\r\n if (this._engine.isWebGPU) {\r\n this._voxelGrid = new RenderTargetTexture(\"voxelGrid\", size, this._scene, {\r\n ...voxelCombinedOptions,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n creationFlags: Constants.TEXTURE_CREATIONFLAG_STORAGE,\r\n });\r\n this._voxelGridRT = new RenderTargetTexture(\r\n \"voxelGridRT\",\r\n { width: Math.min(size.width * 2.0, 2048), height: Math.min(size.height * 2.0, 2048) },\r\n this._scene,\r\n voxelAxisOptions\r\n );\r\n } else if (this._triPlanarVoxelization) {\r\n this._voxelGridXaxis = new RenderTargetTexture(\"voxelGridXaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelGridYaxis = new RenderTargetTexture(\"voxelGridYaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelGridZaxis = new RenderTargetTexture(\"voxelGridZaxis\", size, this._scene, voxelAxisOptions);\r\n this._voxelMrtsXaxis = this._createVoxelMRTs(\"x_axis_\", this._voxelGridXaxis, numSlabs);\r\n this._voxelMrtsYaxis = this._createVoxelMRTs(\"y_axis_\", this._voxelGridYaxis, numSlabs);\r\n this._voxelMrtsZaxis = this._createVoxelMRTs(\"z_axis_\", this._voxelGridZaxis, numSlabs);\r\n\r\n this._combinedVoxelGridPT = new ProceduralTexture(\"combinedVoxelGrid\", size, \"iblCombineVoxelGrids\", this._scene, voxelCombinedOptions, false);\r\n this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._combinedVoxelGridPT), 1);\r\n this._combinedVoxelGridPT.setFloat(\"layer\", 0.0);\r\n this._combinedVoxelGridPT.setTexture(\"voxelXaxisSampler\", this._voxelGridXaxis);\r\n this._combinedVoxelGridPT.setTexture(\"voxelYaxisSampler\", this._voxelGridYaxis);\r\n this._combinedVoxelGridPT.setTexture(\"voxelZaxisSampler\", this._voxelGridZaxis);\r\n // We will render this only after voxelization is completed for the 3 axes.\r\n this._combinedVoxelGridPT.autoClear = false;\r\n this._combinedVoxelGridPT.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this._combinedVoxelGridPT.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n } else {\r\n this._voxelGridZaxis = new RenderTargetTexture(\"voxelGridZaxis\", size, this._scene, voxelCombinedOptions);\r\n this._voxelMrtsZaxis = this._createVoxelMRTs(\"z_axis_\", this._voxelGridZaxis, numSlabs);\r\n }\r\n\r\n const generateVoxelMipOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_R,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await import(\"../../ShadersWGSL/iblGenerateVoxelMip.fragment\");\r\n } else {\r\n await import(\"../../Shaders/iblGenerateVoxelMip.fragment\");\r\n }\r\n },\r\n };\r\n this._mipArray = new Array(Math.ceil(Math.log2(this._voxelResolution)));\r\n for (let mipIdx = 1; mipIdx <= this._mipArray.length; mipIdx++) {\r\n const mipDim = this._voxelResolution >> mipIdx;\r\n const mipSize: TextureSize = { width: mipDim, height: mipDim, depth: mipDim };\r\n this._mipArray[mipIdx - 1] = new ProceduralTexture(\"voxelMip\" + mipIdx, mipSize, \"iblGenerateVoxelMip\", this._scene, generateVoxelMipOptions, false);\r\n this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._mipArray[mipIdx - 1]), 1);\r\n\r\n const mipTarget = this._mipArray[mipIdx - 1];\r\n mipTarget.autoClear = false;\r\n mipTarget.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n mipTarget.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n mipTarget.setTexture(\"srcMip\", mipIdx > 1 ? this._mipArray[mipIdx - 2] : this.getVoxelGrid());\r\n mipTarget.setInt(\"layerNum\", 0);\r\n }\r\n\r\n this._createVoxelMaterials();\r\n }\r\n\r\n private _createVoxelMRTs(name: string, voxelRT: RenderTargetTexture, numSlabs: number): MultiRenderTarget[] {\r\n voxelRT.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n voxelRT.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n voxelRT.noPrePassRenderer = true;\r\n const mrtArray: MultiRenderTarget[] = [];\r\n const targetTypes = new Array(this._maxDrawBuffers).fill(Constants.TEXTURE_3D);\r\n\r\n for (let mrtIndex = 0; mrtIndex < numSlabs; mrtIndex++) {\r\n let layerIndices = new Array(this._maxDrawBuffers).fill(0);\r\n layerIndices = layerIndices.map((value, index) => mrtIndex * this._maxDrawBuffers + index);\r\n\r\n let textureNames = new Array(this._maxDrawBuffers).fill(\"\");\r\n textureNames = textureNames.map((value, index) => \"voxel_grid_\" + name + (mrtIndex * this._maxDrawBuffers + index));\r\n\r\n const mrt = new MultiRenderTarget(\r\n \"mrt_\" + name + mrtIndex,\r\n { width: this._voxelResolution, height: this._voxelResolution, depth: this._voxelResolution },\r\n this._maxDrawBuffers, // number of draw buffers\r\n this._scene,\r\n {\r\n types: new Array(this._maxDrawBuffers).fill(Constants.TEXTURETYPE_UNSIGNED_BYTE),\r\n samplingModes: new Array(this._maxDrawBuffers).fill(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE),\r\n generateMipMaps: false,\r\n targetTypes,\r\n formats: new Array(this._maxDrawBuffers).fill(Constants.TEXTUREFORMAT_R),\r\n faceIndex: new Array(this._maxDrawBuffers).fill(0),\r\n layerIndex: layerIndices,\r\n layerCounts: new Array(this._maxDrawBuffers).fill(this._voxelResolution),\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n },\r\n textureNames\r\n );\r\n\r\n mrt.clearColor = new Color4(0, 0, 0, 1);\r\n mrt.noPrePassRenderer = true;\r\n for (let i = 0; i < this._maxDrawBuffers; i++) {\r\n mrt.setInternalTexture(voxelRT.getInternalTexture()!, i);\r\n }\r\n\r\n mrtArray.push(mrt);\r\n }\r\n return mrtArray;\r\n }\r\n\r\n private _disposeVoxelTextures() {\r\n this._stopVoxelization();\r\n for (let i = 0; i < this._voxelMrtsZaxis.length; i++) {\r\n if (this._triPlanarVoxelization) {\r\n this._voxelMrtsXaxis[i].dispose(true);\r\n this._voxelMrtsYaxis[i].dispose(true);\r\n }\r\n this._voxelMrtsZaxis[i].dispose(true);\r\n }\r\n if (this._triPlanarVoxelization) {\r\n this._voxelGridXaxis?.dispose();\r\n this._voxelGridYaxis?.dispose();\r\n this._combinedVoxelGridPT?.dispose();\r\n }\r\n this._voxelGridZaxis?.dispose();\r\n for (const mip of this._mipArray) {\r\n mip.dispose();\r\n }\r\n this._voxelMaterial?.dispose();\r\n this._voxelSlabDebugMaterial?.dispose();\r\n this._mipArray = [];\r\n this._voxelMrtsXaxis = [];\r\n this._voxelMrtsYaxis = [];\r\n this._voxelMrtsZaxis = [];\r\n }\r\n\r\n private _createVoxelMaterials(): void {\r\n const isWebGPU = this._engine.isWebGPU;\r\n this._voxelMaterial = new ShaderMaterial(\"voxelization\", this._scene, \"iblVoxelGrid\", {\r\n uniforms: [\"world\", \"viewMatrix\", \"invTransWorld\", \"invWorldScale\", \"nearPlane\", \"farPlane\", \"stepSize\"],\r\n defines: [\"MAX_DRAW_BUFFERS \" + this._maxDrawBuffers],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblVoxelGrid.fragment\"), import(\"../../ShadersWGSL/iblVoxelGrid.vertex\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblVoxelGrid.fragment\"), import(\"../../Shaders/iblVoxelGrid.vertex\")]);\r\n }\r\n },\r\n });\r\n this._voxelMaterial.cullBackFaces = false;\r\n this._voxelMaterial.backFaceCulling = false;\r\n this._voxelMaterial.depthFunction = Engine.ALWAYS;\r\n\r\n this._voxelSlabDebugMaterial = new ShaderMaterial(\"voxelSlabDebug\", this._scene, \"iblVoxelSlabDebug\", {\r\n uniforms: [\"world\", \"viewMatrix\", \"cameraViewMatrix\", \"projection\", \"invWorldScale\", \"nearPlane\", \"farPlane\", \"stepSize\"],\r\n defines: [\"MAX_DRAW_BUFFERS \" + this._maxDrawBuffers],\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblVoxelSlabDebug.fragment\"), import(\"../../ShadersWGSL/iblVoxelSlabDebug.vertex\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblVoxelSlabDebug.fragment\"), import(\"../../Shaders/iblVoxelSlabDebug.vertex\")]);\r\n }\r\n },\r\n });\r\n }\r\n\r\n private _setDebugBindings() {\r\n this._voxelSlabDebugMaterial.setMatrix(\"projection\", this._scene.activeCamera!.getProjectionMatrix());\r\n this._voxelSlabDebugMaterial.setMatrix(\"cameraViewMatrix\", this._scene.activeCamera!.getViewMatrix());\r\n }\r\n\r\n /**\r\n * Checks if the voxel renderer is ready to voxelize scene\r\n * @returns true if the voxel renderer is ready to voxelize scene\r\n */\r\n public isReady() {\r\n let allReady = this.getVoxelGrid().isReady();\r\n for (let i = 0; i < this._mipArray.length; i++) {\r\n const mipReady = this._mipArray[i].isReady();\r\n allReady &&= mipReady;\r\n }\r\n\r\n if (!allReady || this._voxelizationInProgress) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * If the MRT's are already in the list of render targets, this will\r\n * remove them so that they don't get rendered again.\r\n */\r\n private _stopVoxelization() {\r\n // If the MRT's are already in the list of render targets, remove them.\r\n this._removeVoxelRTs(this._voxelMrtsXaxis);\r\n this._removeVoxelRTs(this._voxelMrtsYaxis);\r\n this._removeVoxelRTs(this._voxelMrtsZaxis);\r\n this._removeVoxelRTs([this._voxelGridRT]);\r\n }\r\n\r\n private _removeVoxelRTs(rts: RenderTargetTexture[]) {\r\n // const currentRTs = this._scene.customRenderTargets;\r\n const rtIdx = this._renderTargets.findIndex((rt) => {\r\n if (rt === rts[0]) {\r\n return true;\r\n }\r\n return false;\r\n });\r\n if (rtIdx >= 0) {\r\n this._renderTargets.splice(rtIdx, rts.length);\r\n } else {\r\n const rtIdx = this._scene.customRenderTargets.findIndex((rt) => {\r\n if (rt === rts[0]) {\r\n return true;\r\n }\r\n return false;\r\n });\r\n if (rtIdx >= 0) {\r\n this._scene.customRenderTargets.splice(rtIdx, rts.length);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Renders voxel grid of scene for IBL shadows\r\n * @param includedMeshes\r\n */\r\n public updateVoxelGrid(includedMeshes: Mesh[]) {\r\n this._stopVoxelization();\r\n this._includedMeshes = includedMeshes;\r\n this._voxelizationInProgress = true;\r\n\r\n if (this._engine.isWebGPU) {\r\n this._voxelGridRT.renderList = includedMeshes;\r\n this._addRTsForRender([this._voxelGridRT], includedMeshes, 0);\r\n } else if (this._triPlanarVoxelization) {\r\n this._addRTsForRender(this._voxelMrtsXaxis, includedMeshes, 0);\r\n this._addRTsForRender(this._voxelMrtsYaxis, includedMeshes, 1);\r\n this._addRTsForRender(this._voxelMrtsZaxis, includedMeshes, 2);\r\n } else {\r\n this._addRTsForRender(this._voxelMrtsZaxis, includedMeshes, 2);\r\n }\r\n if (this._voxelDebugEnabled) {\r\n this._addRTsForRender([this._voxelSlabDebugRT], includedMeshes, this._voxelDebugAxis, 1, true);\r\n }\r\n this._renderVoxelGridBound = this._renderVoxelGrid.bind(this);\r\n this._scene.onAfterRenderObservable.add(this._renderVoxelGridBound);\r\n }\r\n\r\n private _renderVoxelGridBound: () => void;\r\n\r\n private _renderVoxelGrid() {\r\n if (this._voxelizationInProgress) {\r\n let allReady = this.getVoxelGrid().isReady();\r\n for (let i = 0; i < this._mipArray.length; i++) {\r\n const mipReady = this._mipArray[i].isReady();\r\n allReady &&= mipReady;\r\n }\r\n for (let i = 0; i < this._renderTargets.length; i++) {\r\n const rttReady = this._renderTargets[i].isReadyForRendering();\r\n allReady &&= rttReady;\r\n }\r\n if (allReady) {\r\n if (this._engine.isWebGPU) {\r\n // Clear the voxel grid storage texture.\r\n // Need to clear each layer individually.\r\n // Would a compute shader be faster here to clear all layers in one go?\r\n if (this._voxelGrid && this._voxelGrid.renderTarget) {\r\n for (let layer = 0; layer < this._voxelResolution; layer++) {\r\n this._engine.bindFramebuffer(this._voxelGrid.renderTarget, 0, undefined, undefined, true, 0, layer);\r\n this._engine.clear(this._voxelClearColor, true, false, false);\r\n this._engine.unBindFramebuffer(this._voxelGrid.renderTarget, true);\r\n }\r\n }\r\n }\r\n for (const rt of this._renderTargets) {\r\n rt.render();\r\n }\r\n this._stopVoxelization();\r\n\r\n if (this._triPlanarVoxelization && !this._engine.isWebGPU) {\r\n this._combinedVoxelGridPT.render();\r\n }\r\n this._generateMipMaps();\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._copyMipEffectWrapper.effect.whenCompiledAsync().then(() => {\r\n this._copyMipMaps();\r\n this._scene.onAfterRenderObservable.removeCallback(this._renderVoxelGridBound);\r\n this._voxelizationInProgress = false;\r\n this.onVoxelizationCompleteObservable.notifyObservers();\r\n });\r\n }\r\n }\r\n }\r\n\r\n private _addRTsForRender(mrts: RenderTargetTexture[], includedMeshes: Mesh[], axis: number, shaderType: number = 0, continuousRender: boolean = false) {\r\n const slabSize = 1.0 / this._computeNumberOfSlabs();\r\n let voxelMaterial: ShaderMaterial;\r\n if (shaderType === 0) {\r\n voxelMaterial = this._voxelMaterial;\r\n } else {\r\n voxelMaterial = this._voxelSlabDebugMaterial;\r\n }\r\n\r\n // We need to update the world scale uniform for every mesh being rendered to the voxel grid.\r\n for (let mrtIndex = 0; mrtIndex < mrts.length; mrtIndex++) {\r\n const mrt = mrts[mrtIndex];\r\n mrt.renderList = [];\r\n const nearPlane = mrtIndex * slabSize;\r\n const farPlane = (mrtIndex + 1) * slabSize;\r\n const stepSize = slabSize / this._maxDrawBuffers;\r\n\r\n const cameraPosition = new Vector3(0, 0, 0);\r\n let targetPosition = new Vector3(0, 0, 1);\r\n if (axis === 0) {\r\n targetPosition = new Vector3(1, 0, 0);\r\n } else if (axis === 1) {\r\n targetPosition = new Vector3(0, 1, 0);\r\n }\r\n let upDirection = new Vector3(0, 1, 0);\r\n if (axis === 1) {\r\n upDirection = new Vector3(1, 0, 0);\r\n }\r\n mrt.onBeforeRenderObservable.add(() => {\r\n voxelMaterial.setMatrix(\"viewMatrix\", Matrix.LookAtLH(cameraPosition, targetPosition, upDirection));\r\n voxelMaterial.setMatrix(\"invWorldScale\", this._invWorldScaleMatrix);\r\n voxelMaterial.setFloat(\"nearPlane\", nearPlane);\r\n voxelMaterial.setFloat(\"farPlane\", farPlane);\r\n voxelMaterial.setFloat(\"stepSize\", stepSize);\r\n if (this._engine.isWebGPU) {\r\n this._voxelMaterial.useVertexPulling = true;\r\n this._voxelMaterial.setTexture(\"voxel_storage\", this.getVoxelGrid());\r\n }\r\n });\r\n\r\n // Set this material on every mesh in the scene (for this RT)\r\n if (includedMeshes.length === 0) {\r\n return;\r\n }\r\n for (const mesh of includedMeshes) {\r\n if (mesh) {\r\n if (mesh.subMeshes && mesh.subMeshes.length > 0) {\r\n mrt.renderList?.push(mesh);\r\n mrt.setMaterialForRendering(mesh, voxelMaterial);\r\n }\r\n const meshes = mesh.getChildMeshes();\r\n for (const childMesh of meshes) {\r\n if (childMesh.subMeshes && childMesh.subMeshes.length > 0) {\r\n mrt.renderList?.push(childMesh);\r\n mrt.setMaterialForRendering(childMesh, voxelMaterial);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Add the MRT's to render.\r\n if (continuousRender) {\r\n for (const mrt of mrts) {\r\n if (this._scene.customRenderTargets.indexOf(mrt) === -1) {\r\n this._scene.customRenderTargets.push(mrt);\r\n }\r\n }\r\n } else {\r\n this._renderTargets = this._renderTargets.concat(mrts);\r\n }\r\n }\r\n\r\n /**\r\n * Called by the pipeline to resize resources.\r\n */\r\n public resize() {\r\n this._voxelSlabDebugRT?.resize({ width: this._scene.getEngine().getRenderWidth(), height: this._scene.getEngine().getRenderHeight() });\r\n }\r\n\r\n /**\r\n * Disposes the voxel renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeVoxelTextures();\r\n if (this._voxelSlabDebugRT) {\r\n this._removeVoxelRTs([this._voxelSlabDebugRT]);\r\n this._voxelSlabDebugRT.dispose();\r\n }\r\n if (this._voxelDebugPass) {\r\n this._voxelDebugPass.dispose();\r\n }\r\n // TODO - dispose all created voxel materials.\r\n }\r\n}\r\n"]}
|
|
@@ -126,7 +126,7 @@ export class UtilityLayerRenderer {
|
|
|
126
126
|
*/
|
|
127
127
|
this.onPointerOutObservable = new Observable();
|
|
128
128
|
// Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
|
|
129
|
-
this.utilityLayerScene = new Scene(originalScene.getEngine(), { virtual: true });
|
|
129
|
+
this.utilityLayerScene = new Scene(originalScene.getEngine(), { virtual: true, useFloatingOrigin: originalScene.floatingOriginMode });
|
|
130
130
|
this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
|
|
131
131
|
this.utilityLayerScene._allowPostProcessClearColor = false;
|
|
132
132
|
// Deactivate post processes
|