@babylonjs/core 8.38.0 → 8.39.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.
Files changed (109) hide show
  1. package/Animations/animation.d.ts +2 -1
  2. package/Animations/animation.js +3 -2
  3. package/Animations/animation.js.map +1 -1
  4. package/Behaviors/Cameras/autoRotationBehavior.d.ts +4 -0
  5. package/Behaviors/Cameras/autoRotationBehavior.js +7 -0
  6. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  7. package/Behaviors/Cameras/bouncingBehavior.d.ts +5 -0
  8. package/Behaviors/Cameras/bouncingBehavior.js +8 -0
  9. package/Behaviors/Cameras/bouncingBehavior.js.map +1 -1
  10. package/Behaviors/Cameras/framingBehavior.d.ts +4 -0
  11. package/Behaviors/Cameras/framingBehavior.js +7 -0
  12. package/Behaviors/Cameras/framingBehavior.js.map +1 -1
  13. package/Behaviors/Cameras/interpolatingBehavior.d.ts +7 -1
  14. package/Behaviors/Cameras/interpolatingBehavior.js +11 -3
  15. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
  16. package/Behaviors/Meshes/attachToBoxBehavior.d.ts +5 -0
  17. package/Behaviors/Meshes/attachToBoxBehavior.js +8 -1
  18. package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
  19. package/Behaviors/Meshes/baseSixDofDragBehavior.d.ts +5 -2
  20. package/Behaviors/Meshes/baseSixDofDragBehavior.js +8 -0
  21. package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
  22. package/Behaviors/Meshes/fadeInOutBehavior.d.ts +5 -0
  23. package/Behaviors/Meshes/fadeInOutBehavior.js +6 -0
  24. package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
  25. package/Behaviors/Meshes/handConstraintBehavior.d.ts +5 -0
  26. package/Behaviors/Meshes/handConstraintBehavior.js +8 -0
  27. package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
  28. package/Behaviors/Meshes/multiPointerScaleBehavior.d.ts +5 -0
  29. package/Behaviors/Meshes/multiPointerScaleBehavior.js +8 -0
  30. package/Behaviors/Meshes/multiPointerScaleBehavior.js.map +1 -1
  31. package/Behaviors/Meshes/sixDofDragBehavior.js +1 -1
  32. package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
  33. package/Behaviors/Meshes/surfaceMagnetismBehavior.d.ts +5 -0
  34. package/Behaviors/Meshes/surfaceMagnetismBehavior.js +7 -0
  35. package/Behaviors/Meshes/surfaceMagnetismBehavior.js.map +1 -1
  36. package/Behaviors/behavior.d.ts +4 -0
  37. package/Behaviors/behavior.js.map +1 -1
  38. package/Cameras/geospatialCamera.d.ts +11 -3
  39. package/Cameras/geospatialCamera.js +103 -36
  40. package/Cameras/geospatialCamera.js.map +1 -1
  41. package/Cameras/geospatialCameraMovement.d.ts +6 -2
  42. package/Cameras/geospatialCameraMovement.js +11 -11
  43. package/Cameras/geospatialCameraMovement.js.map +1 -1
  44. package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +2 -1
  45. package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -2
  46. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  47. package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -0
  48. package/Engines/WebGPU/webgpuTextureHelper.js +11 -0
  49. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  50. package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -0
  51. package/Engines/WebGPU/webgpuTextureManager.js +100 -9
  52. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  53. package/Engines/abstractEngine.js +2 -2
  54. package/Engines/abstractEngine.js.map +1 -1
  55. package/Engines/renderTargetWrapper.js +6 -1
  56. package/Engines/renderTargetWrapper.js.map +1 -1
  57. package/Engines/thinEngine.js +1 -1
  58. package/Engines/thinEngine.js.map +1 -1
  59. package/Engines/webgpuEngine.d.ts +7 -4
  60. package/Engines/webgpuEngine.js +45 -16
  61. package/Engines/webgpuEngine.js.map +1 -1
  62. package/FrameGraph/Node/nodeRenderGraph.d.ts +22 -5
  63. package/FrameGraph/Node/nodeRenderGraph.js +39 -18
  64. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  65. package/FrameGraph/Passes/pass.d.ts +2 -0
  66. package/FrameGraph/Passes/pass.js +2 -0
  67. package/FrameGraph/Passes/pass.js.map +1 -1
  68. package/FrameGraph/Passes/renderPass.d.ts +2 -0
  69. package/FrameGraph/Passes/renderPass.js +4 -0
  70. package/FrameGraph/Passes/renderPass.js.map +1 -1
  71. package/FrameGraph/frameGraph.d.ts +13 -4
  72. package/FrameGraph/frameGraph.js +45 -5
  73. package/FrameGraph/frameGraph.js.map +1 -1
  74. package/FrameGraph/frameGraphRenderTarget.d.ts +1 -0
  75. package/FrameGraph/frameGraphRenderTarget.js +3 -0
  76. package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
  77. package/FrameGraph/frameGraphTask.d.ts +6 -0
  78. package/FrameGraph/frameGraphTask.js +15 -0
  79. package/FrameGraph/frameGraphTask.js.map +1 -1
  80. package/FrameGraph/frameGraphTypes.d.ts +2 -0
  81. package/FrameGraph/frameGraphTypes.js.map +1 -1
  82. package/Helpers/sceneHelpers.js +1 -1
  83. package/Helpers/sceneHelpers.js.map +1 -1
  84. package/Lights/index.d.ts +1 -0
  85. package/Lights/index.js +1 -0
  86. package/Lights/index.js.map +1 -1
  87. package/Lights/lightingVolume.d.ts +89 -0
  88. package/Lights/lightingVolume.js +426 -0
  89. package/Lights/lightingVolume.js.map +1 -0
  90. package/Materials/Node/nodeMaterial.js +8 -2
  91. package/Materials/Node/nodeMaterial.js.map +1 -1
  92. package/Materials/floatingOriginMatrixOverrides.js +6 -5
  93. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  94. package/Meshes/mesh.js +1 -1
  95. package/Meshes/mesh.js.map +1 -1
  96. package/Misc/screenshotTools.js +2 -8
  97. package/Misc/screenshotTools.js.map +1 -1
  98. package/Particles/solidParticle.d.ts +9 -0
  99. package/Particles/solidParticle.js +11 -0
  100. package/Particles/solidParticle.js.map +1 -1
  101. package/Particles/solidParticleSystem.d.ts +28 -0
  102. package/Particles/solidParticleSystem.js +75 -0
  103. package/Particles/solidParticleSystem.js.map +1 -1
  104. package/ShadersWGSL/lightingVolume.compute.d.ts +5 -0
  105. package/ShadersWGSL/lightingVolume.compute.js +27 -0
  106. package/ShadersWGSL/lightingVolume.compute.js.map +1 -0
  107. package/package.json +1 -1
  108. package/scene.js +6 -4
  109. package/scene.js.map +1 -1
@@ -863,7 +863,8 @@ export declare class WebGPUEngine extends ThinWebGPUEngine {
863
863
  flushFramebuffer(): void;
864
864
  /** @internal */
865
865
  _currentFrameBufferIsDefaultFrameBuffer(): boolean;
866
- private _startRenderTargetRenderPass;
866
+ /** @internal */
867
+ _startRenderTargetRenderPass(renderTargetWrapper: RenderTargetWrapper, setClearStates: boolean, clearColor: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
867
868
  private _startMainRenderPass;
868
869
  /**
869
870
  * Binds the frame buffer to the specified texture.
@@ -883,17 +884,19 @@ export declare class WebGPUEngine extends ThinWebGPUEngine {
883
884
  * @param onBeforeUnbind defines a function which will be called before the effective unbind
884
885
  */
885
886
  unBindFramebuffer(texture: RenderTargetWrapper, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
887
+ private _resolveAndGenerateMipMapsFramebuffer;
886
888
  /**
887
889
  * Generates mipmaps for the texture of the (single) render target
888
890
  * @param texture The render target containing the texture to generate the mipmaps for
889
891
  */
890
892
  generateMipMapsFramebuffer(texture: RenderTargetWrapper): void;
891
893
  /**
892
- * Resolves the MSAA texture of the (single) render target into its non-MSAA version.
894
+ * Resolves the MSAA texture of the render target into its non-MSAA version.
893
895
  * Note that if "texture" is not a MSAA render target, no resolve is performed.
894
- * @param _texture The render target texture containing the MSAA texture to resolve
896
+ * @param texture The render target texture containing the MSAA texture to resolve
897
+ * @param resolveColors If true, resolve the color textures (default: true) - still subject to texture.resolveMSAAColors
895
898
  */
896
- resolveFramebuffer(_texture: RenderTargetWrapper): void;
899
+ resolveFramebuffer(texture: RenderTargetWrapper, resolveColors?: boolean): void;
897
900
  /**
898
901
  * Unbind the current render target and bind the default framebuffer
899
902
  */
@@ -2374,6 +2374,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2374
2374
  //------------------------------------------------------------------------------
2375
2375
  // Render Pass
2376
2376
  //------------------------------------------------------------------------------
2377
+ /** @internal */
2377
2378
  _startRenderTargetRenderPass(renderTargetWrapper, setClearStates, clearColor, clearDepth, clearStencil) {
2378
2379
  this._endCurrentRenderPass();
2379
2380
  const rtWrapper = renderTargetWrapper;
@@ -2381,9 +2382,11 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2381
2382
  const gpuDepthStencilWrapper = depthStencilTexture?._hardwareTexture;
2382
2383
  const gpuDepthStencilTexture = gpuDepthStencilWrapper?.underlyingResource;
2383
2384
  const gpuDepthStencilMSAATexture = gpuDepthStencilWrapper?.getMSAATexture(0);
2384
- const depthTextureView = gpuDepthStencilTexture?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2385
2385
  const depthMSAATextureView = gpuDepthStencilMSAATexture?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2386
- const depthTextureHasStencil = gpuDepthStencilWrapper ? WebGPUTextureHelper.HasStencilAspect(gpuDepthStencilWrapper.format) : false;
2386
+ const depthTextureView = depthMSAATextureView ? undefined : gpuDepthStencilTexture?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2387
+ // We use the MSAA texture format (if available) to determine if it has a stencil aspect or not because, for MSAA depth textures,
2388
+ // the format of the "resolve" texture (gpuDepthStencilWrapper.format) is a single red channel format, not a depth-stencil format.
2389
+ const depthTextureHasStencil = gpuDepthStencilWrapper ? WebGPUTextureHelper.HasStencilAspect(gpuDepthStencilMSAATexture?.format ?? gpuDepthStencilWrapper.format) : false;
2387
2390
  const colorAttachments = [];
2388
2391
  if (this.useReverseDepthBuffer) {
2389
2392
  this.setDepthFunctionToGreaterOrEqual();
@@ -2428,7 +2431,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2428
2431
  const colorMSAATextureView = gpuMSAATexture?.createView(msaaViewDescriptor);
2429
2432
  colorAttachments.push({
2430
2433
  view: colorMSAATextureView ? colorMSAATextureView : colorTextureView,
2431
- resolveTarget: gpuMSAATexture ? colorTextureView : undefined,
2434
+ resolveTarget: gpuMSAATexture && !rtWrapper.disableAutomaticMSAAResolve ? colorTextureView : undefined,
2432
2435
  depthSlice: mrtTexture.is3D ? (rtWrapper.layerIndices?.[i] ?? 0) : undefined,
2433
2436
  clearValue: index !== 0 && mustClearColor ? (isRtInteger ? clearColorForIntegerRt : clearColor) : undefined,
2434
2437
  loadOp: index !== 0 && mustClearColor ? "clear" /* WebGPUConstants.LoadOp.Clear */ : "load" /* WebGPUConstants.LoadOp.Load */,
@@ -2456,7 +2459,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2456
2459
  const isRtInteger = internalTexture.type === 7 || internalTexture.type === 5;
2457
2460
  colorAttachments.push({
2458
2461
  view: colorMSAATextureView ? colorMSAATextureView : colorTextureView,
2459
- resolveTarget: gpuMSAATexture ? colorTextureView : undefined,
2462
+ resolveTarget: gpuMSAATexture && !rtWrapper.disableAutomaticMSAAResolve ? colorTextureView : undefined,
2460
2463
  depthSlice,
2461
2464
  clearValue: mustClearColor ? (isRtInteger ? clearColorForIntegerRt : clearColor) : undefined,
2462
2465
  loadOp: mustClearColor ? "clear" /* WebGPUConstants.LoadOp.Clear */ : "load" /* WebGPUConstants.LoadOp.Load */,
@@ -2607,6 +2610,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2607
2610
  this._setDepthTextureFormat(this._rttRenderPassWrapper);
2608
2611
  this._setColorFormat(this._rttRenderPassWrapper);
2609
2612
  this._rttRenderPassWrapper.colorAttachmentViewDescriptor = {
2613
+ label: texture.label ? texture.label + " - Color Attachment View" : "RTT - Color Attachment View",
2610
2614
  format: this._colorFormat,
2611
2615
  dimension: texture.is3D ? "3d" /* WebGPUConstants.TextureViewDimension.E3d */ : "2d" /* WebGPUConstants.TextureViewDimension.E2d */,
2612
2616
  mipLevelCount: 1,
@@ -2616,6 +2620,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2616
2620
  aspect: "all" /* WebGPUConstants.TextureAspect.All */,
2617
2621
  };
2618
2622
  this._rttRenderPassWrapper.depthAttachmentViewDescriptor = {
2623
+ label: texture.label ? texture.label + " - Depth Attachment View" : "RTT - Depth Attachment View",
2619
2624
  format: this._depthTextureFormat,
2620
2625
  dimension: depthStencilTexture && depthStencilTexture.is3D ? "3d" /* WebGPUConstants.TextureViewDimension.E3d */ : "2d" /* WebGPUConstants.TextureViewDimension.E2d */,
2621
2626
  mipLevelCount: 1,
@@ -2689,14 +2694,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2689
2694
  }
2690
2695
  this._currentRenderTarget = saveCrt;
2691
2696
  this._endCurrentRenderPass();
2692
- if (!disableGenerateMipMaps) {
2693
- if (texture.isMulti) {
2694
- this.generateMipMapsMultiFramebuffer(texture);
2695
- }
2696
- else {
2697
- this.generateMipMapsFramebuffer(texture);
2698
- }
2699
- }
2697
+ this._resolveAndGenerateMipMapsFramebuffer(texture, disableGenerateMipMaps);
2700
2698
  this._currentRenderTarget = null;
2701
2699
  if (this.dbgVerboseLogsForFirstFrames) {
2702
2700
  if (this._count === undefined) {
@@ -2710,6 +2708,21 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2710
2708
  this._cacheRenderPipeline.setMRT([]);
2711
2709
  this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);
2712
2710
  }
2711
+ _resolveAndGenerateMipMapsFramebuffer(texture, disableGenerateMipMaps = false) {
2712
+ const webglRtWrapper = texture;
2713
+ if (!webglRtWrapper.disableAutomaticMSAAResolve) {
2714
+ // we pass false as the second parameter because the color resolve has already been done automatically when the render pass ended
2715
+ this.resolveFramebuffer(texture, false);
2716
+ }
2717
+ if (!disableGenerateMipMaps) {
2718
+ if (texture.isMulti) {
2719
+ this.generateMipMapsMultiFramebuffer(texture);
2720
+ }
2721
+ else {
2722
+ this.generateMipMapsFramebuffer(texture);
2723
+ }
2724
+ }
2725
+ }
2713
2726
  /**
2714
2727
  * Generates mipmaps for the texture of the (single) render target
2715
2728
  * @param texture The render target containing the texture to generate the mipmaps for
@@ -2720,12 +2733,28 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2720
2733
  }
2721
2734
  }
2722
2735
  /**
2723
- * Resolves the MSAA texture of the (single) render target into its non-MSAA version.
2736
+ * Resolves the MSAA texture of the render target into its non-MSAA version.
2724
2737
  * Note that if "texture" is not a MSAA render target, no resolve is performed.
2725
- * @param _texture The render target texture containing the MSAA texture to resolve
2738
+ * @param texture The render target texture containing the MSAA texture to resolve
2739
+ * @param resolveColors If true, resolve the color textures (default: true) - still subject to texture.resolveMSAAColors
2726
2740
  */
2727
- resolveFramebuffer(_texture) {
2728
- throw new Error("resolveFramebuffer is not yet implemented in WebGPU!");
2741
+ resolveFramebuffer(texture, resolveColors = true) {
2742
+ if (texture.samples <= 1) {
2743
+ return;
2744
+ }
2745
+ if (texture.resolveMSAAColors && resolveColors) {
2746
+ const disableAutomaticMSAAResolve = texture.disableAutomaticMSAAResolve;
2747
+ texture.disableAutomaticMSAAResolve = false;
2748
+ // Simply bind and unbind the framebuffer to trigger the resolve
2749
+ this.bindFramebuffer(texture);
2750
+ this._startRenderTargetRenderPass(this._currentRenderTarget, false, null, false, false);
2751
+ this.unBindFramebuffer(texture);
2752
+ texture.disableAutomaticMSAAResolve = disableAutomaticMSAAResolve;
2753
+ }
2754
+ if (texture.resolveMSAADepth && texture._depthStencilTexture) {
2755
+ const gpuTextureWrapper = texture._depthStencilTexture._hardwareTexture;
2756
+ this._textureHelper.resolveMSAADepthTexture(gpuTextureWrapper.getMSAATexture(0), gpuTextureWrapper.underlyingResource, this._renderEncoder);
2757
+ }
2729
2758
  }
2730
2759
  /**
2731
2760
  * Unbind the current render target and bind the default framebuffer