@babylonjs/core 9.5.0 → 9.5.1

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 (67) hide show
  1. package/Compute/computeEffect.js +2 -2
  2. package/Compute/computeEffect.js.map +1 -1
  3. package/Debug/debugLayer.js +1 -1
  4. package/Debug/debugLayer.js.map +1 -1
  5. package/Engines/abstractEngine.js +2 -2
  6. package/Engines/abstractEngine.js.map +1 -1
  7. package/FrameGraph/Node/nodeRenderGraph.js +11 -3
  8. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  9. package/Lights/Clustered/clusteredLightContainer.js +8 -0
  10. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  11. package/Lights/light.d.ts +5 -0
  12. package/Lights/light.js +18 -2
  13. package/Lights/light.js.map +1 -1
  14. package/Materials/Node/nodeMaterial.js +10 -2
  15. package/Materials/Node/nodeMaterial.js.map +1 -1
  16. package/Materials/PBR/openpbrMaterial.d.ts +31 -0
  17. package/Materials/PBR/openpbrMaterial.js +50 -2
  18. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  19. package/Materials/effect.functions.js +4 -4
  20. package/Materials/effect.functions.js.map +1 -1
  21. package/Meshes/Node/nodeGeometry.js +10 -2
  22. package/Meshes/Node/nodeGeometry.js.map +1 -1
  23. package/Misc/snapshotRenderingHelper.d.ts +22 -1
  24. package/Misc/snapshotRenderingHelper.js +101 -0
  25. package/Misc/snapshotRenderingHelper.js.map +1 -1
  26. package/Misc/tools.js +1 -1
  27. package/Misc/tools.js.map +1 -1
  28. package/Particles/Node/nodeParticleSystemSet.js +10 -2
  29. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  30. package/Particles/thinParticleSystem.d.ts +13 -0
  31. package/Particles/thinParticleSystem.js +41 -6
  32. package/Particles/thinParticleSystem.js.map +1 -1
  33. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +20 -7
  34. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
  35. package/Shaders/ShadersInclude/openpbrDirectLighting.js +2 -2
  36. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  37. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +8 -2
  38. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  39. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js +4 -1
  40. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js.map +1 -1
  41. package/Shaders/ShadersInclude/openpbrNormalMapFragment.js +2 -0
  42. package/Shaders/ShadersInclude/openpbrNormalMapFragment.js.map +1 -1
  43. package/Shaders/ShadersInclude/openpbrVolumeFunctions.js +1 -1
  44. package/Shaders/ShadersInclude/openpbrVolumeFunctions.js.map +1 -1
  45. package/Shaders/ShadersInclude/pbrBRDFFunctions.js +2 -1
  46. package/Shaders/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
  47. package/Shaders/openpbr.fragment.js +1 -1
  48. package/Shaders/openpbr.fragment.js.map +1 -1
  49. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +20 -7
  50. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
  51. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +2 -2
  52. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  53. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +9 -3
  54. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  55. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js +2 -0
  56. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js.map +1 -1
  57. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js +1 -1
  58. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js.map +1 -1
  59. package/ShadersWGSL/ShadersInclude/openpbrVolumeFunctions.js +1 -1
  60. package/ShadersWGSL/ShadersInclude/openpbrVolumeFunctions.js.map +1 -1
  61. package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +5 -4
  62. package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
  63. package/ShadersWGSL/ShadersInclude/shadowsVertex.js +4 -0
  64. package/ShadersWGSL/ShadersInclude/shadowsVertex.js.map +1 -1
  65. package/ShadersWGSL/openpbr.fragment.js +1 -1
  66. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  67. package/package.json +1 -1
@@ -180,6 +180,11 @@ export declare class OpenPBRMaterialDefines extends OpenPBRMaterialDefines_base
180
180
  * Number of samples to use for the fuzz IBL lighting calculations
181
181
  */
182
182
  FUZZ_IBL_SAMPLES: number;
183
+ /**
184
+ * Enables the 4-tap rotated-grid kernel for refractive background blur.
185
+ * When false, a single dithered sample is used instead.
186
+ */
187
+ REFRACTION_HIGH_QUALITY_BLUR: boolean;
183
188
  /**
184
189
  * Tells the shader to enable the fuzz layer
185
190
  */
@@ -205,6 +210,10 @@ export declare class OpenPBRMaterialDefines extends OpenPBRMaterialDefines_base
205
210
  * Enables the use of screen-space irradiance texture for scattering
206
211
  */
207
212
  USE_IRRADIANCE_TEXTURE_FOR_SCATTERING: boolean;
213
+ /**
214
+ * Number of samples used by the screen-space SSS convolution kernel.
215
+ */
216
+ SSS_SAMPLE_COUNT: number;
208
217
  /**
209
218
  * Indicates that the irradiance texture is from the legacy GeometryBufferRenderer.
210
219
  * We use this to handle direct lights which don't render in the legacy GBuffer irradiance.
@@ -817,6 +826,20 @@ export declare class OpenPBRMaterial extends OpenPBRMaterialBase {
817
826
  */
818
827
  ambientOcclusionTexture: Nullable<BaseTexture>;
819
828
  private _ambientOcclusionTexture;
829
+ /** SSS convolution uses 8 samples. */
830
+ static readonly SSS_QUALITY_LOW = 0;
831
+ /** SSS convolution uses 16 samples (default). */
832
+ static readonly SSS_QUALITY_MEDIUM = 1;
833
+ /** SSS convolution uses 32 samples. */
834
+ static readonly SSS_QUALITY_HIGH = 2;
835
+ private _sssQuality;
836
+ /**
837
+ * Controls the sample count of the screen-space SSS convolution kernel.
838
+ * Use the SSS_QUALITY_LOW / MEDIUM / HIGH constants (8 / 16 / 32 samples).
839
+ * Higher quality reduces noise at the cost of GPU time. Default: MEDIUM.
840
+ */
841
+ get sssQuality(): number;
842
+ set sssQuality(value: number);
820
843
  private _sssIrradianceTexture;
821
844
  /**
822
845
  * Defines the irradiance texture used for subsurface scattering.
@@ -1186,6 +1209,14 @@ export declare class OpenPBRMaterial extends OpenPBRMaterialBase {
1186
1209
  */
1187
1210
  get backgroundRefractionTexture(): Nullable<BaseTexture>;
1188
1211
  set backgroundRefractionTexture(texture: Nullable<BaseTexture>);
1212
+ private _refractionHighQualityBlur;
1213
+ /**
1214
+ * When true, uses a 4-tap rotated-grid kernel for refractive background blur,
1215
+ * eliminating bilinear block artifacts at the cost of 3 extra texture samples.
1216
+ * When false, a single dithered sample is used. Default: true.
1217
+ */
1218
+ get refractionHighQualityBlur(): boolean;
1219
+ set refractionHighQualityBlur(value: boolean);
1189
1220
  /**
1190
1221
  * Force the shader to compute irradiance in the fragment shader in order to take normal mapping into account.
1191
1222
  * @internal
@@ -228,6 +228,11 @@ export class OpenPBRMaterialDefines extends ImageProcessingDefinesMixin(OpenPBRM
228
228
  * Number of samples to use for the fuzz IBL lighting calculations
229
229
  */
230
230
  this.FUZZ_IBL_SAMPLES = 6;
231
+ /**
232
+ * Enables the 4-tap rotated-grid kernel for refractive background blur.
233
+ * When false, a single dithered sample is used instead.
234
+ */
235
+ this.REFRACTION_HIGH_QUALITY_BLUR = false;
231
236
  /**
232
237
  * Tells the shader to enable the fuzz layer
233
238
  */
@@ -253,6 +258,10 @@ export class OpenPBRMaterialDefines extends ImageProcessingDefinesMixin(OpenPBRM
253
258
  * Enables the use of screen-space irradiance texture for scattering
254
259
  */
255
260
  this.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING = false;
261
+ /**
262
+ * Number of samples used by the screen-space SSS convolution kernel.
263
+ */
264
+ this.SSS_SAMPLE_COUNT = 16;
256
265
  /**
257
266
  * Indicates that the irradiance texture is from the legacy GeometryBufferRenderer.
258
267
  * We use this to handle direct lights which don't render in the legacy GBuffer irradiance.
@@ -393,6 +402,20 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
393
402
  set geometryCoatTangentAngle(value) {
394
403
  this.geometryCoatTangent = new Vector2(Math.cos(value), Math.sin(value));
395
404
  }
405
+ /**
406
+ * Controls the sample count of the screen-space SSS convolution kernel.
407
+ * Use the SSS_QUALITY_LOW / MEDIUM / HIGH constants (8 / 16 / 32 samples).
408
+ * Higher quality reduces noise at the cost of GPU time. Default: MEDIUM.
409
+ */
410
+ get sssQuality() {
411
+ return this._sssQuality;
412
+ }
413
+ set sssQuality(value) {
414
+ if (this._sssQuality !== value) {
415
+ this._sssQuality = value;
416
+ this.markAsDirty(1);
417
+ }
418
+ }
396
419
  /**
397
420
  * Defines the irradiance texture used for subsurface scattering.
398
421
  * If it's not provided, the irradiance will be looked for in the scene.geometryBufferRenderer.
@@ -496,6 +519,20 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
496
519
  this._backgroundRefractionTexture = texture;
497
520
  this._markAllSubMeshesAsTexturesDirty();
498
521
  }
522
+ /**
523
+ * When true, uses a 4-tap rotated-grid kernel for refractive background blur,
524
+ * eliminating bilinear block artifacts at the cost of 3 extra texture samples.
525
+ * When false, a single dithered sample is used. Default: true.
526
+ */
527
+ get refractionHighQualityBlur() {
528
+ return this._refractionHighQualityBlur;
529
+ }
530
+ set refractionHighQualityBlur(value) {
531
+ if (this._refractionHighQualityBlur !== value) {
532
+ this._refractionHighQualityBlur = value;
533
+ this.markAsDirty(1);
534
+ }
535
+ }
499
536
  /**
500
537
  * Enables realtime filtering on the texture.
501
538
  */
@@ -574,7 +611,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
574
611
  this._subsurfaceWeightTexture = new Sampler("subsurface_weight", "subsurfaceWeight", "SUBSURFACE_WEIGHT");
575
612
  this._subsurfaceColor = new Property("subsurface_color", new Color3(0.8, 0.8, 0.8), "vSubsurfaceColor", 3, 0, "SUBSURFACE_SLAB");
576
613
  this._subsurfaceColorTexture = new Sampler("subsurface_color", "subsurfaceColor", "SUBSURFACE_COLOR");
577
- this._subsurfaceRadius = new Property("subsurface_radius", 1.0, "vSubsurfaceRadius", 1, 0, "SUBSURFACE_SLAB");
614
+ this._subsurfaceRadius = new Property("subsurface_radius", 0.1, "vSubsurfaceRadius", 1, 0, "SUBSURFACE_SLAB");
578
615
  this._subsurfaceRadiusScale = new Property("subsurface_radius_scale", new Color3(1, 0.5, 0.25), "vSubsurfaceRadiusScale", 3, 0, "SUBSURFACE_SLAB");
579
616
  this._subsurfaceRadiusScaleTexture = new Sampler("subsurface_radius_scale", "subsurfaceRadiusScale", "SUBSURFACE_RADIUS_SCALE");
580
617
  this._subsurfaceScatterAnisotropy = new Property("subsurface_scatter_anisotropy", 0.0, "vSubsurfaceScatterAnisotropy", 1, 0, "SUBSURFACE_SLAB");
@@ -621,6 +658,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
621
658
  this._thinFilmThicknessTexture = new Sampler("thin_film_thickness", "thinFilmThickness", "THIN_FILM_THICKNESS");
622
659
  this._thinFilmIor = new Property("thin_film_ior", 1.4, "vThinFilmIor", 1, 0);
623
660
  this._ambientOcclusionTexture = new Sampler("ambient_occlusion", "ambientOcclusion", "AMBIENT_OCCLUSION");
661
+ this._sssQuality = OpenPBRMaterial.SSS_QUALITY_MEDIUM;
624
662
  this._sssIrradianceTexture = null;
625
663
  this._sssDepthTexture = null;
626
664
  this._uniformsList = {};
@@ -931,6 +969,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
931
969
  */
932
970
  this._environmentFuzzBRDFTexture = null;
933
971
  this._backgroundRefractionTexture = null;
972
+ this._refractionHighQualityBlur = true;
934
973
  /**
935
974
  * Force the shader to compute irradiance in the fragment shader in order to take normal mapping into account.
936
975
  * @internal
@@ -1537,7 +1576,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1537
1576
  BindTextureMatrix(sampler.value, ubo, sampler.samplerPrefix);
1538
1577
  }
1539
1578
  }
1540
- if (this.geometryNormalTexture) {
1579
+ if (this.geometryNormalTexture || this.geometryCoatNormalTexture) {
1541
1580
  if (scene._mirroredCameraPosition) {
1542
1581
  ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
1543
1582
  }
@@ -2063,6 +2102,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2063
2102
  }
2064
2103
  if (this.hasTransparency) {
2065
2104
  defines.REFRACTED_BACKGROUND = !!this._backgroundRefractionTexture && MaterialFlags.RefractionTextureEnabled;
2105
+ defines.REFRACTION_HIGH_QUALITY_BLUR = this._refractionHighQualityBlur;
2066
2106
  defines.REFRACTED_LIGHTS = true;
2067
2107
  const radianceTexture = this._getRadianceTexture();
2068
2108
  if (radianceTexture) {
@@ -2146,6 +2186,8 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2146
2186
  defines.IRIDESCENCE = this.thinFilmWeight > 0.0;
2147
2187
  defines.DISPERSION = this.transmissionDispersionScale > 0.0;
2148
2188
  defines.SCATTERING = this.hasScattering;
2189
+ const _sssSampleCounts = [8, 16, 32];
2190
+ defines.SSS_SAMPLE_COUNT = _sssSampleCounts[this._sssQuality] ?? 16;
2149
2191
  defines.TRANSMISSION_SLAB = this.transmissionWeight > 0;
2150
2192
  defines.TRANSMISSION_SLAB_VOLUME = this.transmissionWeight > 0 && this.transmissionDepth > 0;
2151
2193
  defines.SUBSURFACE_SLAB = this.subsurfaceWeight > 0;
@@ -2203,6 +2245,12 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2203
2245
  this._callbackPluginEventPrepareDefines(this._eventInfo);
2204
2246
  }
2205
2247
  }
2248
+ /** SSS convolution uses 8 samples. */
2249
+ OpenPBRMaterial.SSS_QUALITY_LOW = 0;
2250
+ /** SSS convolution uses 16 samples (default). */
2251
+ OpenPBRMaterial.SSS_QUALITY_MEDIUM = 1;
2252
+ /** SSS convolution uses 32 samples. */
2253
+ OpenPBRMaterial.SSS_QUALITY_HIGH = 2;
2206
2254
  OpenPBRMaterial._noiseTextures = {};
2207
2255
  /**
2208
2256
  * Force all the PBR materials to compile to glsl even on WebGPU engines.