@babylonjs/core 9.4.1 → 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 (185) hide show
  1. package/Cameras/Inputs/freeCameraTouchInput.js +5 -3
  2. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  3. package/Cameras/Inputs/freeCameraVirtualJoystickInput.js +11 -7
  4. package/Cameras/Inputs/freeCameraVirtualJoystickInput.js.map +1 -1
  5. package/Cameras/arcRotateCamera.js +2 -1
  6. package/Cameras/arcRotateCamera.js.map +1 -1
  7. package/Cameras/camera.js +1 -0
  8. package/Cameras/camera.js.map +1 -1
  9. package/Cameras/followCamera.js +1 -1
  10. package/Cameras/followCamera.js.map +1 -1
  11. package/Collisions/gpuPicker.d.ts +12 -0
  12. package/Collisions/gpuPicker.js +51 -0
  13. package/Collisions/gpuPicker.js.map +1 -1
  14. package/Compute/computeEffect.js +2 -2
  15. package/Compute/computeEffect.js.map +1 -1
  16. package/Culling/ray.core.js +46 -2
  17. package/Culling/ray.core.js.map +1 -1
  18. package/Debug/debugLayer.js +1 -1
  19. package/Debug/debugLayer.js.map +1 -1
  20. package/Engines/Native/nativeHelpers.js +26 -0
  21. package/Engines/Native/nativeHelpers.js.map +1 -1
  22. package/Engines/WebGPU/webgpuTextureHelper.js +26 -0
  23. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  24. package/Engines/abstractEngine.js +2 -2
  25. package/Engines/abstractEngine.js.map +1 -1
  26. package/Engines/constants.d.ts +52 -0
  27. package/Engines/constants.js +52 -0
  28. package/Engines/constants.js.map +1 -1
  29. package/Engines/engine.d.ts +13 -0
  30. package/Engines/thinEngine.js +52 -0
  31. package/Engines/thinEngine.js.map +1 -1
  32. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +10 -3
  33. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  34. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.d.ts +1 -0
  35. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js +36 -3
  36. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
  37. package/FlowGraph/flowGraphEventBlock.d.ts +13 -0
  38. package/FlowGraph/flowGraphEventBlock.js +21 -2
  39. package/FlowGraph/flowGraphEventBlock.js.map +1 -1
  40. package/FrameGraph/Node/nodeRenderGraph.js +11 -3
  41. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  42. package/FrameGraph/frameGraphTextureManager.js +26 -0
  43. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  44. package/Layers/layer.js +5 -1
  45. package/Layers/layer.js.map +1 -1
  46. package/LensFlares/lensFlareSystem.js +1 -0
  47. package/LensFlares/lensFlareSystem.js.map +1 -1
  48. package/Lights/Clustered/clusteredLightContainer.js +19 -1
  49. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  50. package/Lights/light.d.ts +5 -0
  51. package/Lights/light.js +18 -2
  52. package/Lights/light.js.map +1 -1
  53. package/Loading/Plugins/babylonFileLoader.js +14 -0
  54. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  55. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.d.ts +1 -0
  56. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js +6 -3
  57. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js.map +1 -1
  58. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +2 -0
  59. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +10 -3
  60. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  61. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.d.ts +2 -1
  62. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js +10 -4
  63. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js.map +1 -1
  64. package/Materials/Node/nodeMaterial.js +10 -2
  65. package/Materials/Node/nodeMaterial.js.map +1 -1
  66. package/Materials/PBR/openpbrMaterial.d.ts +42 -0
  67. package/Materials/PBR/openpbrMaterial.js +108 -13
  68. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  69. package/Materials/Textures/Loaders/ktxTextureLoader.js +26 -0
  70. package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
  71. package/Materials/Textures/envCubeTexture.js +33 -15
  72. package/Materials/Textures/envCubeTexture.js.map +1 -1
  73. package/Materials/effect.functions.js +4 -4
  74. package/Materials/effect.functions.js.map +1 -1
  75. package/Materials/material.d.ts +16 -1
  76. package/Materials/material.js +16 -1
  77. package/Materials/material.js.map +1 -1
  78. package/Materials/standardMaterial.js +4 -2
  79. package/Materials/standardMaterial.js.map +1 -1
  80. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -1
  81. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +16 -18
  82. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  83. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.d.ts +24 -0
  84. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js +93 -18
  85. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js.map +1 -1
  86. package/Meshes/Node/nodeGeometry.js +10 -2
  87. package/Meshes/Node/nodeGeometry.js.map +1 -1
  88. package/Meshes/abstractMesh.js +1 -0
  89. package/Meshes/abstractMesh.js.map +1 -1
  90. package/Meshes/mesh.js +3 -0
  91. package/Meshes/mesh.js.map +1 -1
  92. package/Meshes/transformNode.d.ts +6 -0
  93. package/Meshes/transformNode.js +6 -0
  94. package/Meshes/transformNode.js.map +1 -1
  95. package/Misc/brdfTextureTools.d.ts +12 -0
  96. package/Misc/brdfTextureTools.js +22 -0
  97. package/Misc/brdfTextureTools.js.map +1 -1
  98. package/Misc/depthReducer.js +1 -1
  99. package/Misc/depthReducer.js.map +1 -1
  100. package/Misc/snapshotRenderingHelper.d.ts +29 -2
  101. package/Misc/snapshotRenderingHelper.js +108 -1
  102. package/Misc/snapshotRenderingHelper.js.map +1 -1
  103. package/Misc/textureTools.js +26 -0
  104. package/Misc/textureTools.js.map +1 -1
  105. package/Misc/tools.js +1 -1
  106. package/Misc/tools.js.map +1 -1
  107. package/Particles/Node/Blocks/Update/updateFlowMapBlock.js +17 -10
  108. package/Particles/Node/Blocks/Update/updateFlowMapBlock.js.map +1 -1
  109. package/Particles/Node/Blocks/Update/updateNoiseBlock.js +14 -0
  110. package/Particles/Node/Blocks/Update/updateNoiseBlock.js.map +1 -1
  111. package/Particles/Node/Blocks/particleSourceTextureBlock.js +114 -12
  112. package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
  113. package/Particles/Node/nodeParticleBuildState.d.ts +11 -0
  114. package/Particles/Node/nodeParticleBuildState.js +15 -0
  115. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  116. package/Particles/Node/nodeParticleSystemSet.js +33 -24
  117. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  118. package/Particles/gpuParticleSystem.js +1 -0
  119. package/Particles/gpuParticleSystem.js.map +1 -1
  120. package/Particles/thinParticleSystem.d.ts +13 -0
  121. package/Particles/thinParticleSystem.js +42 -6
  122. package/Particles/thinParticleSystem.js.map +1 -1
  123. package/PostProcesses/postProcessManager.d.ts +2 -0
  124. package/PostProcesses/postProcessManager.js +14 -8
  125. package/PostProcesses/postProcessManager.js.map +1 -1
  126. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +12 -9
  127. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  128. package/Rendering/depthRendererSceneComponent.js +6 -6
  129. package/Rendering/depthRendererSceneComponent.js.map +1 -1
  130. package/Rendering/iblCdfGeneratorSceneComponent.d.ts +6 -0
  131. package/Rendering/iblCdfGeneratorSceneComponent.js +16 -0
  132. package/Rendering/iblCdfGeneratorSceneComponent.js.map +1 -1
  133. package/Rendering/prePassRenderer.d.ts +4 -1
  134. package/Rendering/prePassRenderer.js +31 -9
  135. package/Rendering/prePassRenderer.js.map +1 -1
  136. package/Shaders/ShadersInclude/hdrFilteringFunctions.js +1 -1
  137. package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
  138. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +20 -7
  139. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
  140. package/Shaders/ShadersInclude/openpbrDirectLighting.js +20 -12
  141. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  142. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +44 -16
  143. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  144. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js +4 -1
  145. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js.map +1 -1
  146. package/Shaders/ShadersInclude/openpbrIblFunctions.js +8 -5
  147. package/Shaders/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  148. package/Shaders/ShadersInclude/openpbrNormalMapFragment.js +2 -0
  149. package/Shaders/ShadersInclude/openpbrNormalMapFragment.js.map +1 -1
  150. package/Shaders/ShadersInclude/openpbrVolumeFunctions.js +1 -1
  151. package/Shaders/ShadersInclude/openpbrVolumeFunctions.js.map +1 -1
  152. package/Shaders/ShadersInclude/pbrBRDFFunctions.js +12 -7
  153. package/Shaders/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
  154. package/Shaders/openpbr.fragment.js +14 -15
  155. package/Shaders/openpbr.fragment.js.map +1 -1
  156. package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +1 -1
  157. package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
  158. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +20 -7
  159. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
  160. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +21 -13
  161. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  162. package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js +3 -3
  163. package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js.map +1 -1
  164. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +44 -16
  165. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  166. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +5 -3
  167. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  168. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js +2 -0
  169. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js.map +1 -1
  170. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js +1 -1
  171. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js.map +1 -1
  172. package/ShadersWGSL/ShadersInclude/openpbrVolumeFunctions.js +1 -1
  173. package/ShadersWGSL/ShadersInclude/openpbrVolumeFunctions.js.map +1 -1
  174. package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +10 -10
  175. package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
  176. package/ShadersWGSL/ShadersInclude/shadowsVertex.js +4 -0
  177. package/ShadersWGSL/ShadersInclude/shadowsVertex.js.map +1 -1
  178. package/ShadersWGSL/openpbr.fragment.js +16 -17
  179. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  180. package/Sprites/spriteManager.js +1 -0
  181. package/Sprites/spriteManager.js.map +1 -1
  182. package/package.json +1 -1
  183. package/scene.d.ts +16 -0
  184. package/scene.js +13 -0
  185. package/scene.js.map +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,15 @@ 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;
217
+ /**
218
+ * Indicates that the irradiance texture is from the legacy GeometryBufferRenderer.
219
+ * We use this to handle direct lights which don't render in the legacy GBuffer irradiance.
220
+ */
221
+ USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER: boolean;
208
222
  /**
209
223
  * Enables transmission slab
210
224
  */
@@ -812,6 +826,20 @@ export declare class OpenPBRMaterial extends OpenPBRMaterialBase {
812
826
  */
813
827
  ambientOcclusionTexture: Nullable<BaseTexture>;
814
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);
815
843
  private _sssIrradianceTexture;
816
844
  /**
817
845
  * Defines the irradiance texture used for subsurface scattering.
@@ -834,6 +862,12 @@ export declare class OpenPBRMaterial extends OpenPBRMaterialBase {
834
862
  set sssDepthTexture(value: Nullable<ThinTexture>);
835
863
  private _propertyList;
836
864
  private _uniformsList;
865
+ /**
866
+ * Flat array view of `_uniformsList`, populated once at construction. Used
867
+ * by the per-frame bind loop to avoid `Object.values()` allocation and
868
+ * closure creation on every submesh binding.
869
+ */
870
+ private _uniformsArray;
837
871
  private _samplersList;
838
872
  private _samplerDefines;
839
873
  private static _noiseTextures;
@@ -1175,6 +1209,14 @@ export declare class OpenPBRMaterial extends OpenPBRMaterialBase {
1175
1209
  */
1176
1210
  get backgroundRefractionTexture(): Nullable<BaseTexture>;
1177
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);
1178
1220
  /**
1179
1221
  * Force the shader to compute irradiance in the fragment shader in order to take normal mapping into account.
1180
1222
  * @internal
@@ -1,7 +1,7 @@
1
1
  import { __decorate } from "../../tslib.es6.js";
2
2
  /* eslint-disable @typescript-eslint/naming-convention */
3
3
  import { serialize, expandToProperty, addAccessorsForMaterialProperty } from "../../Misc/decorators.js";
4
- import { GetEnvironmentBRDFTexture, GetEnvironmentFuzzBRDFTexture } from "../../Misc/brdfTextureTools.js";
4
+ import { GetEnvironmentFuzzBRDFTexture, GetOpenPBREnvironmentBRDFTexture } from "../../Misc/brdfTextureTools.js";
5
5
  import { Color3 } from "../../Maths/math.color.js";
6
6
  import { ImageProcessingConfiguration } from "../imageProcessingConfiguration.js";
7
7
  import { Texture } from "../Textures/texture.js";
@@ -56,6 +56,13 @@ class Uniform {
56
56
  }
57
57
  constructor(name, componentNum) {
58
58
  this.linkedProperties = {};
59
+ /**
60
+ * Cached key of the first entry of `linkedProperties`, set when the first
61
+ * property is linked. Used by the per-frame bind loop to avoid an
62
+ * `Object.keys(linkedProperties)[0]` allocation when reading scalar
63
+ * uniforms.
64
+ */
65
+ this.firstLinkedKey = "";
59
66
  this.name = name;
60
67
  this.numComponents = componentNum;
61
68
  }
@@ -73,8 +80,11 @@ class Property {
73
80
  * @param targetUniformComponentNum The number of components in the target uniform. All properties that are
74
81
  * packed into the same uniform must agree on the size of the target uniform.
75
82
  * @param targetUniformComponentOffset The offset in the uniform where this property will be packed.
83
+ * @param requiredDefine Optional define name. When provided, the per-frame
84
+ * bind loop will skip pushing the owning uniform to the UBO unless
85
+ * `defines[requiredDefine]` is true.
76
86
  */
77
- constructor(name, defaultValue, targetUniformName, targetUniformComponentNum, targetUniformComponentOffset = 0) {
87
+ constructor(name, defaultValue, targetUniformName, targetUniformComponentNum, targetUniformComponentOffset = 0, requiredDefine) {
78
88
  // public includeAlphaFromProp: string = "";
79
89
  /**
80
90
  * If not given a type, there will be no uniform defined for this property and
@@ -88,6 +98,7 @@ class Property {
88
98
  this.value = defaultValue;
89
99
  this.targetUniformComponentNum = targetUniformComponentNum;
90
100
  this.targetUniformComponentOffset = targetUniformComponentOffset;
101
+ this.requiredDefine = requiredDefine;
91
102
  }
92
103
  /**
93
104
  * Returns the number of components of the property based on its default value type.
@@ -217,6 +228,11 @@ export class OpenPBRMaterialDefines extends ImageProcessingDefinesMixin(OpenPBRM
217
228
  * Number of samples to use for the fuzz IBL lighting calculations
218
229
  */
219
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;
220
236
  /**
221
237
  * Tells the shader to enable the fuzz layer
222
238
  */
@@ -242,6 +258,15 @@ export class OpenPBRMaterialDefines extends ImageProcessingDefinesMixin(OpenPBRM
242
258
  * Enables the use of screen-space irradiance texture for scattering
243
259
  */
244
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;
265
+ /**
266
+ * Indicates that the irradiance texture is from the legacy GeometryBufferRenderer.
267
+ * We use this to handle direct lights which don't render in the legacy GBuffer irradiance.
268
+ */
269
+ this.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER = false;
245
270
  /**
246
271
  * Enables transmission slab
247
272
  */
@@ -377,6 +402,20 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
377
402
  set geometryCoatTangentAngle(value) {
378
403
  this.geometryCoatTangent = new Vector2(Math.cos(value), Math.sin(value));
379
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
+ }
380
419
  /**
381
420
  * Defines the irradiance texture used for subsurface scattering.
382
421
  * If it's not provided, the irradiance will be looked for in the scene.geometryBufferRenderer.
@@ -480,6 +519,20 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
480
519
  this._backgroundRefractionTexture = texture;
481
520
  this._markAllSubMeshesAsTexturesDirty();
482
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
+ }
483
536
  /**
484
537
  * Enables realtime filtering on the texture.
485
538
  */
@@ -554,14 +607,14 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
554
607
  this._transmissionDispersionScale = new Property("transmission_dispersion_scale", 0.0, "vTransmissionDispersionScale", 1, 0);
555
608
  this._transmissionDispersionScaleTexture = new Sampler("transmission_dispersion_scale", "transmissionDispersionScale", "TRANSMISSION_DISPERSION_SCALE");
556
609
  this._transmissionDispersionAbbeNumber = new Property("transmission_dispersion_abbe_number", 20.0, "vTransmissionDispersionAbbeNumber", 1, 0);
557
- this._subsurfaceWeight = new Property("subsurface_weight", 0.0, "vSubsurfaceWeight", 1, 0);
610
+ this._subsurfaceWeight = new Property("subsurface_weight", 0.0, "vSubsurfaceWeight", 1, 0, "SUBSURFACE_SLAB");
558
611
  this._subsurfaceWeightTexture = new Sampler("subsurface_weight", "subsurfaceWeight", "SUBSURFACE_WEIGHT");
559
- this._subsurfaceColor = new Property("subsurface_color", new Color3(0.8, 0.8, 0.8), "vSubsurfaceColor", 3, 0);
612
+ this._subsurfaceColor = new Property("subsurface_color", new Color3(0.8, 0.8, 0.8), "vSubsurfaceColor", 3, 0, "SUBSURFACE_SLAB");
560
613
  this._subsurfaceColorTexture = new Sampler("subsurface_color", "subsurfaceColor", "SUBSURFACE_COLOR");
561
- this._subsurfaceRadius = new Property("subsurface_radius", 1.0, "vSubsurfaceRadius", 1, 0);
562
- this._subsurfaceRadiusScale = new Property("subsurface_radius_scale", new Color3(1, 0.5, 0.25), "vSubsurfaceRadiusScale", 3, 0);
614
+ this._subsurfaceRadius = new Property("subsurface_radius", 0.1, "vSubsurfaceRadius", 1, 0, "SUBSURFACE_SLAB");
615
+ this._subsurfaceRadiusScale = new Property("subsurface_radius_scale", new Color3(1, 0.5, 0.25), "vSubsurfaceRadiusScale", 3, 0, "SUBSURFACE_SLAB");
563
616
  this._subsurfaceRadiusScaleTexture = new Sampler("subsurface_radius_scale", "subsurfaceRadiusScale", "SUBSURFACE_RADIUS_SCALE");
564
- this._subsurfaceScatterAnisotropy = new Property("subsurface_scatter_anisotropy", 0.0, "vSubsurfaceScatterAnisotropy", 1, 0);
617
+ this._subsurfaceScatterAnisotropy = new Property("subsurface_scatter_anisotropy", 0.0, "vSubsurfaceScatterAnisotropy", 1, 0, "SUBSURFACE_SLAB");
565
618
  this._coatWeight = new Property("coat_weight", 0.0, "vCoatWeight", 1, 0);
566
619
  this._coatWeightTexture = new Sampler("coat_weight", "coatWeight", "COAT_WEIGHT");
567
620
  this._coatColor = new Property("coat_color", Color3.White(), "vCoatColor", 3, 0);
@@ -605,9 +658,16 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
605
658
  this._thinFilmThicknessTexture = new Sampler("thin_film_thickness", "thinFilmThickness", "THIN_FILM_THICKNESS");
606
659
  this._thinFilmIor = new Property("thin_film_ior", 1.4, "vThinFilmIor", 1, 0);
607
660
  this._ambientOcclusionTexture = new Sampler("ambient_occlusion", "ambientOcclusion", "AMBIENT_OCCLUSION");
661
+ this._sssQuality = OpenPBRMaterial.SSS_QUALITY_MEDIUM;
608
662
  this._sssIrradianceTexture = null;
609
663
  this._sssDepthTexture = null;
610
664
  this._uniformsList = {};
665
+ /**
666
+ * Flat array view of `_uniformsList`, populated once at construction. Used
667
+ * by the per-frame bind loop to avoid `Object.values()` allocation and
668
+ * closure creation on every submesh binding.
669
+ */
670
+ this._uniformsArray = [];
611
671
  this._samplersList = {};
612
672
  this._samplerDefines = {};
613
673
  /**
@@ -909,6 +969,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
909
969
  */
910
970
  this._environmentFuzzBRDFTexture = null;
911
971
  this._backgroundRefractionTexture = null;
972
+ this._refractionHighQualityBlur = true;
912
973
  /**
913
974
  * Force the shader to compute irradiance in the fragment shader in order to take normal mapping into account.
914
975
  * @internal
@@ -995,7 +1056,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
995
1056
  this._callbackPluginEventFillRenderTargetTextures(this._eventInfo);
996
1057
  return this._renderTargets;
997
1058
  };
998
- this._environmentBRDFTexture = GetEnvironmentBRDFTexture(this.getScene());
1059
+ this._environmentBRDFTexture = GetOpenPBREnvironmentBRDFTexture(this.getScene());
999
1060
  this._environmentFuzzBRDFTexture = GetEnvironmentFuzzBRDFTexture(this.getScene());
1000
1061
  this.prePassConfiguration = new PrePassConfiguration();
1001
1062
  // Build the internal property list that can be used to generate and update the uniform buffer
@@ -1014,13 +1075,23 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1014
1075
  let uniform = this._uniformsList[prop.targetUniformName];
1015
1076
  if (!uniform) {
1016
1077
  uniform = new Uniform(prop.targetUniformName, prop.targetUniformComponentNum);
1078
+ uniform.requiredDefine = prop.requiredDefine;
1017
1079
  this._uniformsList[prop.targetUniformName] = uniform;
1018
1080
  }
1019
1081
  else if (uniform.numComponents !== prop.targetUniformComponentNum) {
1020
1082
  Logger.Error(`Uniform ${prop.targetUniformName} already exists of size ${uniform.numComponents}, but trying to set it to ${prop.targetUniformComponentNum}.`);
1021
1083
  }
1084
+ else if (uniform.requiredDefine !== prop.requiredDefine) {
1085
+ // Properties packed into the same uniform must share the same gating
1086
+ // define, otherwise we cannot safely skip the per-frame UBO update.
1087
+ uniform.requiredDefine = undefined;
1088
+ }
1089
+ if (uniform.firstLinkedKey === "") {
1090
+ uniform.firstLinkedKey = prop.name;
1091
+ }
1022
1092
  uniform.linkedProperties[prop.name] = prop;
1023
1093
  });
1094
+ this._uniformsArray = Object.values(this._uniformsList);
1024
1095
  // Build the internal list of samplers
1025
1096
  this._samplersList = {};
1026
1097
  for (const key of Object.getOwnPropertyNames(this)) {
@@ -1505,7 +1576,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1505
1576
  BindTextureMatrix(sampler.value, ubo, sampler.samplerPrefix);
1506
1577
  }
1507
1578
  }
1508
- if (this.geometryNormalTexture) {
1579
+ if (this.geometryNormalTexture || this.geometryCoatNormalTexture) {
1509
1580
  if (scene._mirroredCameraPosition) {
1510
1581
  ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
1511
1582
  }
@@ -1519,7 +1590,16 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1519
1590
  if (this.pointsCloud) {
1520
1591
  ubo.updateFloat("pointSize", this.pointSize);
1521
1592
  }
1522
- Object.values(this._uniformsList).forEach((uniform) => {
1593
+ const uniformsArray = this._uniformsArray;
1594
+ for (let i = 0, len = uniformsArray.length; i < len; i++) {
1595
+ const uniform = uniformsArray[i];
1596
+ // Skip uniforms whose define is currently inactive. The shader only
1597
+ // reads them inside the same #ifdef block, so the UBO bytes can stay
1598
+ // stale. The full update will happen on the next bind once the
1599
+ // define becomes active again.
1600
+ if (uniform.requiredDefine !== undefined && !defines[uniform.requiredDefine]) {
1601
+ continue;
1602
+ }
1523
1603
  // If the property actually defines a uniform, update it.
1524
1604
  if (uniform.numComponents === 4) {
1525
1605
  uniform.populateVectorFromLinkedProperties(TmpVectors.Vector4[0]);
@@ -1534,9 +1614,9 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1534
1614
  ubo.updateFloat2(uniform.name, TmpVectors.Vector2[0].x, TmpVectors.Vector2[0].y);
1535
1615
  }
1536
1616
  else if (uniform.numComponents === 1) {
1537
- ubo.updateFloat(uniform.name, uniform.linkedProperties[Object.keys(uniform.linkedProperties)[0]].value);
1617
+ ubo.updateFloat(uniform.name, uniform.linkedProperties[uniform.firstLinkedKey].value);
1538
1618
  }
1539
- });
1619
+ }
1540
1620
  // Misc
1541
1621
  this._lightingInfos.x = this.directIntensity;
1542
1622
  this._lightingInfos.y = this.emissionLuminance;
@@ -1693,7 +1773,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1693
1773
  dispose(forceDisposeEffect, forceDisposeTextures) {
1694
1774
  this._breakShaderLoadedCheck = true;
1695
1775
  if (forceDisposeTextures) {
1696
- if (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture) {
1776
+ if (this._environmentBRDFTexture && this.getScene().openPBREnvironmentBRDFTexture !== this._environmentBRDFTexture) {
1697
1777
  this._environmentBRDFTexture.dispose();
1698
1778
  }
1699
1779
  if (this._environmentFuzzBRDFTexture && this.getScene().environmentFuzzBRDFTexture !== this._environmentFuzzBRDFTexture) {
@@ -2022,6 +2102,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2022
2102
  }
2023
2103
  if (this.hasTransparency) {
2024
2104
  defines.REFRACTED_BACKGROUND = !!this._backgroundRefractionTexture && MaterialFlags.RefractionTextureEnabled;
2105
+ defines.REFRACTION_HIGH_QUALITY_BLUR = this._refractionHighQualityBlur;
2025
2106
  defines.REFRACTED_LIGHTS = true;
2026
2107
  const radianceTexture = this._getRadianceTexture();
2027
2108
  if (radianceTexture) {
@@ -2105,22 +2186,30 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2105
2186
  defines.IRIDESCENCE = this.thinFilmWeight > 0.0;
2106
2187
  defines.DISPERSION = this.transmissionDispersionScale > 0.0;
2107
2188
  defines.SCATTERING = this.hasScattering;
2189
+ const _sssSampleCounts = [8, 16, 32];
2190
+ defines.SSS_SAMPLE_COUNT = _sssSampleCounts[this._sssQuality] ?? 16;
2108
2191
  defines.TRANSMISSION_SLAB = this.transmissionWeight > 0;
2109
2192
  defines.TRANSMISSION_SLAB_VOLUME = this.transmissionWeight > 0 && this.transmissionDepth > 0;
2110
2193
  defines.SUBSURFACE_SLAB = this.subsurfaceWeight > 0;
2111
2194
  // Determine whether we should use the prepass irradiance texture for scattering.
2112
2195
  // If this IS a prepass, we don't want to use the irradiance texture as it won't be available yet.
2113
2196
  if (!defines.PREPASS && (defines.SUBSURFACE_SLAB || defines.TRANSMISSION_SLAB_VOLUME)) {
2197
+ let usingGBuffer = false;
2114
2198
  if (!this.sssIrradianceTexture && scene.geometryBufferRenderer) {
2115
2199
  const irradianceTextureIndex = scene.geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.IRRADIANCE_TEXTURE_TYPE);
2116
2200
  this.sssIrradianceTexture = scene.geometryBufferRenderer.getGBuffer().textures[irradianceTextureIndex];
2201
+ usingGBuffer = true;
2117
2202
  }
2118
2203
  if (!this.sssDepthTexture && scene.geometryBufferRenderer) {
2119
2204
  const depthIndex = scene.geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.SCREENSPACE_DEPTH_TEXTURE_TYPE);
2120
2205
  this.sssDepthTexture = scene.geometryBufferRenderer.getGBuffer().textures[depthIndex];
2206
+ usingGBuffer = true;
2121
2207
  }
2122
2208
  if (this.sssIrradianceTexture && this.sssDepthTexture) {
2123
2209
  defines.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING = true;
2210
+ if (usingGBuffer) {
2211
+ defines.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER = true;
2212
+ }
2124
2213
  }
2125
2214
  }
2126
2215
  defines.FUZZ = this.fuzzWeight > 0 && MaterialFlags.ReflectionTextureEnabled;
@@ -2156,6 +2245,12 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2156
2245
  this._callbackPluginEventPrepareDefines(this._eventInfo);
2157
2246
  }
2158
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;
2159
2254
  OpenPBRMaterial._noiseTextures = {};
2160
2255
  /**
2161
2256
  * Force all the PBR materials to compile to glsl even on WebGPU engines.