@babylonjs/core 8.37.3 → 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 (127) hide show
  1. package/Animations/animation.d.ts +3 -1
  2. package/Animations/animation.js +5 -4
  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 +21 -6
  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/Inputs/geospatialCameraPointersInput.js +3 -5
  39. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  40. package/Cameras/geospatialCamera.d.ts +19 -1
  41. package/Cameras/geospatialCamera.js +117 -28
  42. package/Cameras/geospatialCamera.js.map +1 -1
  43. package/Cameras/geospatialCameraMovement.d.ts +7 -2
  44. package/Cameras/geospatialCameraMovement.js +46 -10
  45. package/Cameras/geospatialCameraMovement.js.map +1 -1
  46. package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +2 -1
  47. package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -2
  48. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  49. package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -0
  50. package/Engines/WebGPU/webgpuTextureHelper.js +11 -0
  51. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  52. package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -0
  53. package/Engines/WebGPU/webgpuTextureManager.js +100 -9
  54. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  55. package/Engines/abstractEngine.js +2 -2
  56. package/Engines/abstractEngine.js.map +1 -1
  57. package/Engines/renderTargetWrapper.js +6 -1
  58. package/Engines/renderTargetWrapper.js.map +1 -1
  59. package/Engines/thinEngine.js +1 -1
  60. package/Engines/thinEngine.js.map +1 -1
  61. package/Engines/webgpuEngine.d.ts +7 -4
  62. package/Engines/webgpuEngine.js +45 -16
  63. package/Engines/webgpuEngine.js.map +1 -1
  64. package/FrameGraph/Node/nodeRenderGraph.d.ts +22 -5
  65. package/FrameGraph/Node/nodeRenderGraph.js +39 -18
  66. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  67. package/FrameGraph/Passes/pass.d.ts +2 -0
  68. package/FrameGraph/Passes/pass.js +2 -0
  69. package/FrameGraph/Passes/pass.js.map +1 -1
  70. package/FrameGraph/Passes/renderPass.d.ts +2 -0
  71. package/FrameGraph/Passes/renderPass.js +4 -0
  72. package/FrameGraph/Passes/renderPass.js.map +1 -1
  73. package/FrameGraph/frameGraph.d.ts +13 -4
  74. package/FrameGraph/frameGraph.js +45 -5
  75. package/FrameGraph/frameGraph.js.map +1 -1
  76. package/FrameGraph/frameGraphRenderTarget.d.ts +1 -0
  77. package/FrameGraph/frameGraphRenderTarget.js +3 -0
  78. package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
  79. package/FrameGraph/frameGraphTask.d.ts +6 -0
  80. package/FrameGraph/frameGraphTask.js +15 -0
  81. package/FrameGraph/frameGraphTask.js.map +1 -1
  82. package/FrameGraph/frameGraphTypes.d.ts +2 -0
  83. package/FrameGraph/frameGraphTypes.js.map +1 -1
  84. package/Helpers/sceneHelpers.js +1 -1
  85. package/Helpers/sceneHelpers.js.map +1 -1
  86. package/Lights/index.d.ts +1 -0
  87. package/Lights/index.js +1 -0
  88. package/Lights/index.js.map +1 -1
  89. package/Lights/lightingVolume.d.ts +89 -0
  90. package/Lights/lightingVolume.js +426 -0
  91. package/Lights/lightingVolume.js.map +1 -0
  92. package/Materials/Node/nodeMaterial.js +8 -2
  93. package/Materials/Node/nodeMaterial.js.map +1 -1
  94. package/Materials/floatingOriginMatrixOverrides.js +6 -5
  95. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  96. package/Meshes/mesh.js +1 -1
  97. package/Meshes/mesh.js.map +1 -1
  98. package/Misc/screenshotTools.js +2 -8
  99. package/Misc/screenshotTools.js.map +1 -1
  100. package/Particles/Node/Blocks/index.d.ts +1 -0
  101. package/Particles/Node/Blocks/index.js +1 -0
  102. package/Particles/Node/Blocks/index.js.map +1 -1
  103. package/Particles/Node/Blocks/particleFloatToIntBlock.d.ts +46 -0
  104. package/Particles/Node/Blocks/particleFloatToIntBlock.js +120 -0
  105. package/Particles/Node/Blocks/particleFloatToIntBlock.js.map +1 -0
  106. package/Particles/Node/Blocks/systemBlock.d.ts +4 -4
  107. package/Particles/Node/Blocks/systemBlock.js +22 -16
  108. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  109. package/Particles/Node/nodeParticleBuildState.js +1 -1
  110. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  111. package/Particles/Node/nodeParticleSystemSet.helper.js +61 -30
  112. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  113. package/Particles/solidParticle.d.ts +9 -0
  114. package/Particles/solidParticle.js +11 -0
  115. package/Particles/solidParticle.js.map +1 -1
  116. package/Particles/solidParticleSystem.d.ts +28 -0
  117. package/Particles/solidParticleSystem.js +75 -0
  118. package/Particles/solidParticleSystem.js.map +1 -1
  119. package/Particles/thinParticleSystem.d.ts +6 -0
  120. package/Particles/thinParticleSystem.js +21 -12
  121. package/Particles/thinParticleSystem.js.map +1 -1
  122. package/ShadersWGSL/lightingVolume.compute.d.ts +5 -0
  123. package/ShadersWGSL/lightingVolume.compute.js +27 -0
  124. package/ShadersWGSL/lightingVolume.compute.js.map +1 -0
  125. package/package.json +1 -1
  126. package/scene.js +6 -4
  127. package/scene.js.map +1 -1
@@ -44,6 +44,7 @@ export declare class WebGPUTextureManager {
44
44
  generateMipmaps(gpuOrHdwTexture: GPUTexture | WebGPUHardwareTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, is3D?: boolean, commandEncoder?: GPUCommandEncoder): void;
45
45
  createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number, creationFlags?: number, dontCreateMSAATexture?: boolean): WebGPUHardwareTexture;
46
46
  createMSAATexture(texture: InternalTexture, samples: number, releaseExisting?: boolean, index?: number): void;
47
+ resolveMSAADepthTexture(msaaTexture: GPUTexture, outputTexture: GPUTexture, commandEncoder?: GPUCommandEncoder): void;
47
48
  updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number): void;
48
49
  updateTexture(imageBitmap: ImageBitmap | Uint8Array | ImageData | HTMLImageElement | HTMLVideoElement | VideoFrame | HTMLCanvasElement | OffscreenCanvas, texture: GPUTexture | InternalTexture, width: number, height: number, layers: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, allowGPUOptimization?: boolean): void;
49
50
  readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>, noDataConversion?: boolean): Promise<ArrayBufferView>;
@@ -129,7 +129,6 @@ const clearVertexSource = `
129
129
  const clearFragmentSource = `
130
130
  uniform color: vec4f;
131
131
 
132
-
133
132
  @fragment
134
133
  fn main(input: FragmentInputs) -> FragmentOutputs {
135
134
  fragmentOutputs.color = uniforms.color;
@@ -188,12 +187,40 @@ const copyVideoToTextureInvertYFragmentSource = `
188
187
  return textureSampleBaseClampToEdge(videoTexture, videoSampler, vec2<f32>(fragUV.x, 1.0 - fragUV.y));
189
188
  }
190
189
  `;
190
+ const resolveDepthVertexSource = `
191
+ const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));
192
+
193
+ @vertex
194
+ fn main(input : VertexInputs) -> FragmentInputs {
195
+ vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);
196
+ }
197
+ `;
198
+ const resolveDepthFragmentSource = `
199
+ var msaaDepthTexture: texture_depth_multisampled_2d;
200
+
201
+ @fragment
202
+ fn main(input: FragmentInputs) -> FragmentOutputs {
203
+ #ifdef USE_MIN
204
+ let numSamples = textureNumSamples(msaaDepthTexture);
205
+ var depth = 1.0;
206
+
207
+ for (var i = 0u; i < numSamples; i = i + 1u) {
208
+ depth = min(depth, textureLoad(msaaDepthTexture, vec2u(input.position.xy), i));
209
+ }
210
+
211
+ fragmentOutputs.color = vec4f(depth);
212
+ #else
213
+ fragmentOutputs.color = vec4f(textureLoad(msaaDepthTexture, vec2u(input.position.xy), 0)); // do like WebGL, take the first sample
214
+ #endif
215
+ }
216
+ `;
191
217
  var PipelineType;
192
218
  (function (PipelineType) {
193
219
  PipelineType[PipelineType["MipMap"] = 0] = "MipMap";
194
220
  PipelineType[PipelineType["InvertYPremultiplyAlpha"] = 1] = "InvertYPremultiplyAlpha";
195
221
  PipelineType[PipelineType["Clear"] = 2] = "Clear";
196
222
  PipelineType[PipelineType["InvertYPremultiplyAlphaWithOfst"] = 3] = "InvertYPremultiplyAlphaWithOfst";
223
+ PipelineType[PipelineType["ResolveDepth"] = 4] = "ResolveDepth";
197
224
  })(PipelineType || (PipelineType = {}));
198
225
  var VideoPipelineType;
199
226
  (function (VideoPipelineType) {
@@ -205,6 +232,7 @@ const shadersForPipelineType = [
205
232
  { vertex: invertYPreMultiplyAlphaVertexSource, fragment: invertYPreMultiplyAlphaFragmentSource },
206
233
  { vertex: clearVertexSource, fragment: clearFragmentSource },
207
234
  { vertex: invertYPreMultiplyAlphaWithOfstVertexSource, fragment: invertYPreMultiplyAlphaWithOfstFragmentSource },
235
+ { vertex: resolveDepthVertexSource, fragment: resolveDepthFragmentSource },
208
236
  ];
209
237
  /**
210
238
  * Map a (renderable) texture format (GPUTextureFormat) to an index for fast lookup (in caches for eg)
@@ -291,7 +319,9 @@ export class WebGPUTextureManager {
291
319
  ? 1 << 3
292
320
  : type === PipelineType.InvertYPremultiplyAlphaWithOfst
293
321
  ? ((params.invertY ? 1 : 0) << 4) + ((params.premultiplyAlpha ? 1 : 0) << 5)
294
- : 0;
322
+ : type === PipelineType.ResolveDepth
323
+ ? 1 << 6
324
+ : 0;
295
325
  if (!this._pipelines[format]) {
296
326
  this._pipelines[format] = [];
297
327
  }
@@ -772,9 +802,29 @@ export class WebGPUTextureManager {
772
802
  if (depth === undefined) {
773
803
  depth = texture.depth;
774
804
  }
805
+ texture.width = texture.baseWidth = width;
806
+ texture.height = texture.baseHeight = height;
807
+ texture.depth = texture.baseDepth = depth;
775
808
  const gpuTextureWrapper = texture._hardwareTexture;
776
809
  const isStorageTexture = ((creationFlags ?? 0) & 1) !== 0;
777
810
  gpuTextureWrapper.format = WebGPUTextureHelper.GetWebGPUTextureFormat(texture.type, texture.format, texture._useSRGBBuffer);
811
+ if (!dontCreateMSAATexture) {
812
+ this.createMSAATexture(texture, texture.samples);
813
+ }
814
+ if (texture.samples > 1) {
815
+ // In case of a MSAA texture, the current texture will be the "resolve" texture, which cannot have a depth format
816
+ switch (gpuTextureWrapper.format) {
817
+ case "depth16unorm" /* WebGPUConstants.TextureFormat.Depth16Unorm */:
818
+ gpuTextureWrapper.format = "r16unorm" /* WebGPUConstants.TextureFormat.R16Unorm */;
819
+ break;
820
+ case "depth24plus" /* WebGPUConstants.TextureFormat.Depth24Plus */:
821
+ case "depth24plus-stencil8" /* WebGPUConstants.TextureFormat.Depth24PlusStencil8 */:
822
+ case "depth32float" /* WebGPUConstants.TextureFormat.Depth32Float */:
823
+ case "depth32float-stencil8" /* WebGPUConstants.TextureFormat.Depth32FloatStencil8 */:
824
+ gpuTextureWrapper.format = "r32float" /* WebGPUConstants.TextureFormat.R32Float */;
825
+ break;
826
+ }
827
+ }
778
828
  gpuTextureWrapper.textureUsages =
779
829
  texture._source === 5 /* InternalTextureSource.RenderTarget */ || texture.source === 6 /* InternalTextureSource.MultiRenderTarget */
780
830
  ? 4 /* WebGPUConstants.TextureUsage.TextureBinding */ | 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 16 /* WebGPUConstants.TextureUsage.RenderAttachment */
@@ -831,12 +881,6 @@ export class WebGPUTextureManager {
831
881
  aspect,
832
882
  }, isStorageTexture);
833
883
  }
834
- texture.width = texture.baseWidth = width;
835
- texture.height = texture.baseHeight = height;
836
- texture.depth = texture.baseDepth = depth;
837
- if (!dontCreateMSAATexture) {
838
- this.createMSAATexture(texture, texture.samples);
839
- }
840
884
  return gpuTextureWrapper;
841
885
  }
842
886
  createMSAATexture(texture, samples, releaseExisting = true, index = 0) {
@@ -849,9 +893,56 @@ export class WebGPUTextureManager {
849
893
  }
850
894
  const width = texture.width;
851
895
  const height = texture.height;
852
- const gpuMSAATexture = this.createTexture({ width, height, layers: 1 }, false, false, false, false, false, gpuTextureWrapper.format, samples, this._commandEncoderForCreation, 16 /* WebGPUConstants.TextureUsage.RenderAttachment */, 0, texture.label ? "MSAA_" + texture.label : "MSAA");
896
+ const gpuMSAATexture = this.createTexture({ width, height, layers: 1 }, false, false, false, false, false, gpuTextureWrapper.format, samples, this._commandEncoderForCreation, 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ | 4 /* WebGPUConstants.TextureUsage.TextureBinding */, 0, texture.label ? "MSAA_" + texture.label : "MSAA");
853
897
  gpuTextureWrapper.setMSAATexture(gpuMSAATexture, index);
854
898
  }
899
+ resolveMSAADepthTexture(msaaTexture, outputTexture, commandEncoder) {
900
+ const format = outputTexture.format;
901
+ const useOwnCommandEncoder = commandEncoder === undefined;
902
+ const [pipeline, bindGroupLayout] = this._getPipeline(format, PipelineType.ResolveDepth);
903
+ if (useOwnCommandEncoder) {
904
+ commandEncoder = this._device.createCommandEncoder({});
905
+ }
906
+ commandEncoder.pushDebugGroup(`resolve MSAA Depth texture${msaaTexture.label ? " - " + msaaTexture.label : ""}`);
907
+ const renderPassDescriptor = {
908
+ label: `BabylonWebGPUDevice${this._engine.uniqueId}_resolveMSAADepthTexture${msaaTexture.label ? "_" + msaaTexture.label : ""}`,
909
+ colorAttachments: [
910
+ {
911
+ view: outputTexture,
912
+ loadOp: "load" /* WebGPUConstants.LoadOp.Load */,
913
+ storeOp: "store" /* WebGPUConstants.StoreOp.Store */,
914
+ },
915
+ ],
916
+ };
917
+ const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
918
+ const descriptor = {
919
+ layout: bindGroupLayout,
920
+ entries: [
921
+ {
922
+ binding: 0,
923
+ resource: msaaTexture.createView({
924
+ format: WebGPUTextureHelper.GetDepthFormatOnly(msaaTexture.format),
925
+ dimension: "2d" /* WebGPUConstants.TextureViewDimension.E2d */,
926
+ mipLevelCount: 1,
927
+ baseArrayLayer: 0,
928
+ baseMipLevel: 0,
929
+ arrayLayerCount: 1,
930
+ aspect: "depth-only" /* WebGPUConstants.TextureAspect.DepthOnly */,
931
+ }),
932
+ },
933
+ ],
934
+ };
935
+ const bindGroup = this._device.createBindGroup(descriptor);
936
+ passEncoder.setPipeline(pipeline);
937
+ passEncoder.setBindGroup(0, bindGroup);
938
+ passEncoder.draw(4, 1, 0, 0);
939
+ passEncoder.end();
940
+ commandEncoder.popDebugGroup();
941
+ if (useOwnCommandEncoder) {
942
+ this._device.queue.submit([commandEncoder.finish()]);
943
+ commandEncoder = null;
944
+ }
945
+ }
855
946
  //------------------------------------------------------------------------------
856
947
  // Update
857
948
  //------------------------------------------------------------------------------