@babylonjs/core 8.47.0 → 8.47.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 (161) hide show
  1. package/Behaviors/Cameras/geospatialClippingBehavior.d.ts +39 -0
  2. package/Behaviors/Cameras/geospatialClippingBehavior.js +75 -0
  3. package/Behaviors/Cameras/geospatialClippingBehavior.js.map +1 -0
  4. package/Behaviors/Cameras/index.d.ts +2 -0
  5. package/Behaviors/Cameras/index.js +2 -0
  6. package/Behaviors/Cameras/index.js.map +1 -1
  7. package/Cameras/Inputs/geospatialCameraPointersInput.js +6 -4
  8. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  9. package/Cameras/Limits/geospatialLimits.d.ts +25 -1
  10. package/Cameras/Limits/geospatialLimits.js +60 -3
  11. package/Cameras/Limits/geospatialLimits.js.map +1 -1
  12. package/Cameras/geospatialCamera.d.ts +33 -9
  13. package/Cameras/geospatialCamera.js +114 -42
  14. package/Cameras/geospatialCamera.js.map +1 -1
  15. package/Cameras/geospatialCameraMovement.d.ts +1 -3
  16. package/Cameras/geospatialCameraMovement.js +10 -4
  17. package/Cameras/geospatialCameraMovement.js.map +1 -1
  18. package/Debug/debugLayer.js +11 -3
  19. package/Debug/debugLayer.js.map +1 -1
  20. package/Engines/abstractEngine.js +2 -2
  21. package/Engines/abstractEngine.js.map +1 -1
  22. package/Engines/thinEngine.d.ts +3 -2
  23. package/Engines/thinEngine.js.map +1 -1
  24. package/IAssetContainer.d.ts +5 -0
  25. package/IAssetContainer.js.map +1 -1
  26. package/Lights/Clustered/clusteredLightContainer.js +1 -1
  27. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  28. package/Loading/Plugins/babylonFileLoader.js +2 -0
  29. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  30. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -1
  31. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  32. package/Materials/PBR/openpbrMaterial.d.ts +135 -5
  33. package/Materials/PBR/openpbrMaterial.js +205 -22
  34. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  35. package/Materials/effectRenderer.d.ts +2 -1
  36. package/Materials/effectRenderer.js +2 -12
  37. package/Materials/effectRenderer.js.map +1 -1
  38. package/Materials/materialHelper.functions.js +1 -0
  39. package/Materials/materialHelper.functions.js.map +1 -1
  40. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +6 -1
  41. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +21 -17
  42. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  43. package/Misc/sceneRecorder.d.ts +6 -2
  44. package/Misc/sceneRecorder.js +7 -0
  45. package/Misc/sceneRecorder.js.map +1 -1
  46. package/Particles/Node/Blocks/index.d.ts +3 -0
  47. package/Particles/Node/Blocks/index.js +3 -0
  48. package/Particles/Node/Blocks/index.js.map +1 -1
  49. package/Particles/Node/Blocks/particleNLerpBlock.d.ts +35 -0
  50. package/Particles/Node/Blocks/particleNLerpBlock.js +97 -0
  51. package/Particles/Node/Blocks/particleNLerpBlock.js.map +1 -0
  52. package/Particles/Node/Blocks/particleSmoothStepBlock.d.ts +34 -0
  53. package/Particles/Node/Blocks/particleSmoothStepBlock.js +91 -0
  54. package/Particles/Node/Blocks/particleSmoothStepBlock.js.map +1 -0
  55. package/Particles/Node/Blocks/particleStepBlock.d.ts +30 -0
  56. package/Particles/Node/Blocks/particleStepBlock.js +84 -0
  57. package/Particles/Node/Blocks/particleStepBlock.js.map +1 -0
  58. package/Particles/solidParticleSystem.d.ts +3 -0
  59. package/Particles/solidParticleSystem.js +7 -4
  60. package/Particles/solidParticleSystem.js.map +1 -1
  61. package/Rendering/IBLShadows/iblShadowsPluginMaterial.js +8 -10
  62. package/Rendering/IBLShadows/iblShadowsPluginMaterial.js.map +1 -1
  63. package/Shaders/ShadersInclude/hdrFilteringFunctions.js +7 -9
  64. package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
  65. package/Shaders/ShadersInclude/helperFunctions.js +4 -0
  66. package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
  67. package/Shaders/ShadersInclude/{openpbrBlockAmbientOcclusion.d.ts → openpbrAmbientOcclusionData.d.ts} +1 -1
  68. package/Shaders/ShadersInclude/openpbrAmbientOcclusionData.js +15 -0
  69. package/Shaders/ShadersInclude/openpbrAmbientOcclusionData.js.map +1 -0
  70. package/{ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.d.ts → Shaders/ShadersInclude/openpbrAmbientOcclusionFunctions.d.ts} +1 -1
  71. package/Shaders/ShadersInclude/openpbrAmbientOcclusionFunctions.js +13 -0
  72. package/Shaders/ShadersInclude/openpbrAmbientOcclusionFunctions.js.map +1 -0
  73. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.d.ts +5 -0
  74. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +26 -0
  75. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -0
  76. package/Shaders/ShadersInclude/openpbrBaseLayerData.js +18 -7
  77. package/Shaders/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
  78. package/Shaders/ShadersInclude/openpbrDirectLighting.js +52 -6
  79. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  80. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +109 -6
  81. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  82. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.d.ts +1 -0
  83. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js +24 -4
  84. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js.map +1 -1
  85. package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js +10 -1
  86. package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -1
  87. package/Shaders/ShadersInclude/openpbrIblFunctions.js +9 -2
  88. package/Shaders/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  89. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.js +1 -0
  90. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.js.map +1 -1
  91. package/Shaders/ShadersInclude/openpbrTransmissionLayerData.d.ts +5 -0
  92. package/Shaders/ShadersInclude/openpbrTransmissionLayerData.js +47 -0
  93. package/Shaders/ShadersInclude/openpbrTransmissionLayerData.js.map +1 -0
  94. package/Shaders/ShadersInclude/openpbrUboDeclaration.js +1 -1
  95. package/Shaders/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
  96. package/Shaders/ShadersInclude/openpbrVertexDeclaration.d.ts +1 -0
  97. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +17 -4
  98. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -1
  99. package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
  100. package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  101. package/Shaders/ShadersInclude/pbrHelperFunctions.js +1 -1
  102. package/Shaders/ShadersInclude/pbrHelperFunctions.js.map +1 -1
  103. package/Shaders/openpbr.fragment.d.ts +4 -1
  104. package/Shaders/openpbr.fragment.js +33 -15
  105. package/Shaders/openpbr.fragment.js.map +1 -1
  106. package/Shaders/openpbr.vertex.js +30 -18
  107. package/Shaders/openpbr.vertex.js.map +1 -1
  108. package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +10 -12
  109. package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
  110. package/ShadersWGSL/ShadersInclude/helperFunctions.js +4 -0
  111. package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
  112. package/ShadersWGSL/ShadersInclude/importanceSampling.js +1 -1
  113. package/ShadersWGSL/ShadersInclude/importanceSampling.js.map +1 -1
  114. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionData.d.ts +5 -0
  115. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionData.js +15 -0
  116. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionData.js.map +1 -0
  117. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionFunctions.d.ts +5 -0
  118. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionFunctions.js +13 -0
  119. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionFunctions.js.map +1 -0
  120. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.d.ts +5 -0
  121. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +25 -0
  122. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -0
  123. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js +18 -7
  124. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
  125. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +52 -6
  126. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  127. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +115 -7
  128. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  129. package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js +10 -1
  130. package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -1
  131. package/ShadersWGSL/ShadersInclude/openpbrFuzzLayerData.js +4 -4
  132. package/ShadersWGSL/ShadersInclude/openpbrFuzzLayerData.js.map +1 -1
  133. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +10 -3
  134. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  135. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.js +1 -0
  136. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.js.map +1 -1
  137. package/ShadersWGSL/ShadersInclude/openpbrTransmissionLayerData.d.ts +5 -0
  138. package/ShadersWGSL/ShadersInclude/openpbrTransmissionLayerData.js +47 -0
  139. package/ShadersWGSL/ShadersInclude/openpbrTransmissionLayerData.js.map +1 -0
  140. package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js +1 -1
  141. package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
  142. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
  143. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  144. package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js +1 -1
  145. package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js.map +1 -1
  146. package/ShadersWGSL/openpbr.fragment.d.ts +4 -1
  147. package/ShadersWGSL/openpbr.fragment.js +33 -15
  148. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  149. package/ShadersWGSL/openpbr.vertex.js +12 -0
  150. package/ShadersWGSL/openpbr.vertex.js.map +1 -1
  151. package/Sprites/spriteManager.d.ts +3 -0
  152. package/Sprites/spriteManager.js +9 -0
  153. package/Sprites/spriteManager.js.map +1 -1
  154. package/assetContainer.d.ts +5 -0
  155. package/assetContainer.js +32 -0
  156. package/assetContainer.js.map +1 -1
  157. package/package.json +2 -2
  158. package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.js +0 -35
  159. package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.js.map +0 -1
  160. package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.js +0 -36
  161. package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.js.map +0 -1
@@ -2,7 +2,6 @@ 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
4
  import { GetEnvironmentBRDFTexture, GetEnvironmentFuzzBRDFTexture } from "../../Misc/brdfTextureTools.js";
5
- import { Scene } from "../../scene.js";
6
5
  import { Color3 } from "../../Maths/math.color.js";
7
6
  import { ImageProcessingConfiguration } from "../imageProcessingConfiguration.js";
8
7
  import { Texture } from "../Textures/texture.js";
@@ -169,10 +168,8 @@ export class OpenPBRMaterialDefines extends ImageProcessingDefinesMixin(OpenPBRM
169
168
  this.REFLECTIVITYDIRECTUV = 0;
170
169
  this.SPECULARTERM = false;
171
170
  this.LODBASEDMICROSFURACE = true;
172
- this.METALLICWORKFLOW = true;
173
- this.ROUGHNESSSTOREINMETALMAPALPHA = false;
174
- this.ROUGHNESSSTOREINMETALMAPGREEN = false;
175
- this.METALLNESSSTOREINMETALMAPBLUE = false;
171
+ this.SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN = false;
172
+ this.BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE = false;
176
173
  this.AOSTOREINMETALMAPRED = false;
177
174
  this.SPECULAR_WEIGHT_IN_ALPHA = false;
178
175
  this.SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE = false;
@@ -182,6 +179,7 @@ export class OpenPBRMaterialDefines extends ImageProcessingDefinesMixin(OpenPBRM
182
179
  this.USE_GLTF_STYLE_ANISOTROPY = false;
183
180
  this.THIN_FILM_THICKNESS_FROM_THIN_FILM_TEXTURE = false;
184
181
  this.FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA = false;
182
+ this.GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL = false;
185
183
  this.ENVIRONMENTBRDF = false;
186
184
  this.ENVIRONMENTBRDF_RGBD = false;
187
185
  this.FUZZENVIRONMENTBRDF = false;
@@ -225,6 +223,28 @@ export class OpenPBRMaterialDefines extends ImageProcessingDefinesMixin(OpenPBRM
225
223
  * Iridescence is the name of thin film interference in the PBR material.
226
224
  */
227
225
  this.IRIDESCENCE = false;
226
+ /**
227
+ * Tells the shader to enable dispersion in refraction
228
+ */
229
+ this.DISPERSION = false;
230
+ /**
231
+ * Enables subsurface scattering
232
+ */
233
+ this.SCATTERING = false;
234
+ /**
235
+ * Refraction of the 2D background texture. Might include the rest of the scene or just the background.
236
+ */
237
+ this.REFRACTED_BACKGROUND = false;
238
+ /**
239
+ * Refraction of direct lights.
240
+ */
241
+ this.REFRACTED_LIGHTS = false;
242
+ /**
243
+ * Refraction of the environment texture (IBL).
244
+ */
245
+ this.REFRACTED_ENVIRONMENT = false;
246
+ this.REFRACTED_ENVIRONMENT_OPPOSITEZ = false;
247
+ this.REFRACTED_ENVIRONMENT_LOCAL_CUBE = false;
228
248
  this.REFLECTION = false;
229
249
  this.REFLECTIONMAP_3D = false;
230
250
  this.REFLECTIONMAP_SPHERICAL = false;
@@ -426,6 +446,17 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
426
446
  }
427
447
  }
428
448
  }
449
+ /**
450
+ * Set the texture used for refraction of the background of transparent materials
451
+ * @internal
452
+ */
453
+ get backgroundRefractionTexture() {
454
+ return this._backgroundRefractionTexture;
455
+ }
456
+ set backgroundRefractionTexture(texture) {
457
+ this._backgroundRefractionTexture = texture;
458
+ this._markAllSubMeshesAsTexturesDirty();
459
+ }
429
460
  /**
430
461
  * Enables realtime filtering on the texture.
431
462
  */
@@ -488,6 +519,18 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
488
519
  this._specularRoughnessAnisotropy = new Property("specular_roughness_anisotropy", 0, "vSpecularAnisotropy", 3, 2);
489
520
  this._specularRoughnessAnisotropyTexture = new Sampler("specular_roughness_anisotropy", "specularRoughnessAnisotropy", "SPECULAR_ROUGHNESS_ANISOTROPY");
490
521
  this._specularIor = new Property("specular_ior", 1.5, "vReflectanceInfo", 4, 2);
522
+ this._transmissionWeight = new Property("transmission_weight", 0.0, "vTransmissionWeight", 1);
523
+ this._transmissionWeightTexture = new Sampler("transmission_weight", "transmissionWeight", "TRANSMISSION_WEIGHT");
524
+ this._transmissionColor = new Property("transmission_color", Color3.White(), "vTransmissionColor", 3, 0);
525
+ this._transmissionColorTexture = new Sampler("transmission_color", "transmissionColor", "TRANSMISSION_COLOR");
526
+ this._transmissionDepth = new Property("transmission_depth", 0.0, "vTransmissionDepth", 1, 0);
527
+ this._transmissionDepthTexture = new Sampler("transmission_depth", "transmissionDepth", "TRANSMISSION_DEPTH");
528
+ this._transmissionScatter = new Property("transmission_scatter", Color3.Black(), "vTransmissionScatter", 3, 0);
529
+ this._transmissionScatterTexture = new Sampler("transmission_scatter", "transmissionScatter", "TRANSMISSION_SCATTER");
530
+ this._transmissionScatterAnisotropy = new Property("transmission_scatter_anisotropy", 0.0, "vTransmissionScatterAnisotropy", 1, 0);
531
+ this._transmissionDispersionScale = new Property("transmission_dispersion_scale", 0.0, "vTransmissionDispersionScale", 1, 0);
532
+ this._transmissionDispersionScaleTexture = new Sampler("transmission_dispersion_scale", "transmissionDispersionScale", "TRANSMISSION_DISPERSION_SCALE");
533
+ this._transmissionDispersionAbbeNumber = new Property("transmission_dispersion_abbe_number", 20.0, "vTransmissionDispersionAbbeNumber", 1, 0);
491
534
  this._coatWeight = new Property("coat_weight", 0.0, "vCoatWeight", 1, 0);
492
535
  this._coatWeightTexture = new Sampler("coat_weight", "coatWeight", "COAT_WEIGHT");
493
536
  this._coatColor = new Property("coat_color", Color3.White(), "vCoatColor", 3, 0);
@@ -518,6 +561,8 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
518
561
  this._geometryCoatTangentTexture = new Sampler("geometry_coat_tangent", "geometryCoatTangent", "GEOMETRY_COAT_TANGENT");
519
562
  this._geometryOpacity = new Property("geometry_opacity", 1.0, "vBaseColor", 4, 3);
520
563
  this._geometryOpacityTexture = new Sampler("geometry_opacity", "geometryOpacity", "GEOMETRY_OPACITY");
564
+ this._geometryThickness = new Property("geometry_thickness", 0.0, "vGeometryThickness", 1, 0);
565
+ this._geometryThicknessTexture = new Sampler("geometry_thickness", "geometryThickness", "GEOMETRY_THICKNESS");
521
566
  this._emissionLuminance = new Property("emission_luminance", 1.0, "vLightingIntensity", 4, 1);
522
567
  this._emissionColor = new Property("emission_color", Color3.Black(), "vEmissionColor", 3);
523
568
  this._emissionColorTexture = new Sampler("emission_color", "emissionColor", "EMISSION_COLOR");
@@ -737,8 +782,16 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
737
782
  this._useMetallicFromMetallicTextureBlue = false;
738
783
  /**
739
784
  * Specifies if the thin film thickness is stored in the green channel of the thin film thickness texture.
785
+ * This is for compatibility with glTF.
786
+ * @internal
740
787
  */
741
788
  this._useThinFilmThicknessFromTextureGreen = false;
789
+ /**
790
+ * Specifies if the geometry thickness is stored in the green channel of the geometry thickness texture.
791
+ * This is for compatibility with glTF.
792
+ * @internal
793
+ */
794
+ this._useGeometryThicknessFromGreenChannel = false;
742
795
  /**
743
796
  * Defines the falloff type used in this material.
744
797
  * It by default is Physical.
@@ -821,6 +874,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
821
874
  * @internal
822
875
  */
823
876
  this._environmentFuzzBRDFTexture = null;
877
+ this._backgroundRefractionTexture = null;
824
878
  /**
825
879
  * Force the shader to compute irradiance in the fragment shader in order to take normal mapping into account.
826
880
  * @internal
@@ -899,6 +953,9 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
899
953
  if (MaterialFlags.ReflectionTextureEnabled && this._radianceTexture && this._radianceTexture.isRenderTarget) {
900
954
  this._renderTargets.push(this._radianceTexture);
901
955
  }
956
+ if (MaterialFlags.RefractionTextureEnabled && this._backgroundRefractionTexture && this._backgroundRefractionTexture.isRenderTarget) {
957
+ this._renderTargets.push(this._backgroundRefractionTexture);
958
+ }
902
959
  this._eventInfo.renderTargets = this._renderTargets;
903
960
  this._callbackPluginEventFillRenderTargetTextures(this._eventInfo);
904
961
  return this._renderTargets;
@@ -963,6 +1020,18 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
963
1020
  this._specularRoughnessTexture;
964
1021
  this._specularRoughnessAnisotropy;
965
1022
  this._specularRoughnessAnisotropyTexture;
1023
+ this._transmissionWeight;
1024
+ this._transmissionWeightTexture;
1025
+ this._transmissionColor;
1026
+ this._transmissionColorTexture;
1027
+ this._transmissionDepth;
1028
+ this._transmissionDepthTexture;
1029
+ this._transmissionScatter;
1030
+ this._transmissionScatterTexture;
1031
+ this._transmissionScatterAnisotropy;
1032
+ this._transmissionDispersionScale;
1033
+ this._transmissionDispersionScaleTexture;
1034
+ this._transmissionDispersionAbbeNumber;
966
1035
  this._coatWeight;
967
1036
  this._coatWeightTexture;
968
1037
  this._coatColor;
@@ -988,6 +1057,8 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
988
1057
  this._geometryCoatTangentTexture;
989
1058
  this._geometryOpacity;
990
1059
  this._geometryOpacityTexture;
1060
+ this._geometryThickness;
1061
+ this._geometryThicknessTexture;
991
1062
  this._thinFilmWeight;
992
1063
  this._thinFilmWeightTexture;
993
1064
  this._thinFilmThickness;
@@ -1006,6 +1077,9 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1006
1077
  if (MaterialFlags.ReflectionTextureEnabled && this._radianceTexture && this._radianceTexture.isRenderTarget) {
1007
1078
  return true;
1008
1079
  }
1080
+ if (MaterialFlags.RefractionTextureEnabled && this._backgroundRefractionTexture && this._backgroundRefractionTexture.isRenderTarget) {
1081
+ return true;
1082
+ }
1009
1083
  return this._cacheHasRenderTargetTextures;
1010
1084
  }
1011
1085
  /**
@@ -1200,6 +1274,11 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1200
1274
  return false;
1201
1275
  }
1202
1276
  }
1277
+ if (this._backgroundRefractionTexture && MaterialFlags.RefractionTextureEnabled) {
1278
+ if (!this._backgroundRefractionTexture.isReadyOrNotBlocking()) {
1279
+ return false;
1280
+ }
1281
+ }
1203
1282
  if (OpenPBRMaterial._noiseTextures[scene.uniqueId]) {
1204
1283
  if (!OpenPBRMaterial._noiseTextures[scene.uniqueId].isReady()) {
1205
1284
  return false;
@@ -1277,6 +1356,8 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1277
1356
  ubo.addUniform("pointSize", 1);
1278
1357
  ubo.addUniform("vDebugMode", 2);
1279
1358
  ubo.addUniform("cameraInfo", 4);
1359
+ ubo.addUniform("backgroundRefractionMatrix", 16);
1360
+ ubo.addUniform("vBackgroundRefractionInfos", 3);
1280
1361
  PrepareUniformLayoutForIBL(ubo, true, true, true, true, true);
1281
1362
  Object.values(this._uniformsList).forEach((uniform) => {
1282
1363
  ubo.addUniform(uniform.name, uniform.numComponents);
@@ -1287,6 +1368,24 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1287
1368
  });
1288
1369
  super.buildUniformLayout();
1289
1370
  }
1371
+ /**
1372
+ * Binds the material data (this function is called even if mustRebind() returns false)
1373
+ * @param uniformBuffer defines the Uniform buffer to fill in.
1374
+ * @param scene defines the scene the material belongs to.
1375
+ * @param engine defines the engine the material belongs to.
1376
+ * @param subMesh the submesh to bind data for
1377
+ */
1378
+ bindPropertiesForSubMesh(uniformBuffer, scene, engine, subMesh) {
1379
+ // If min/max thickness is 0, avoid decomposing to determine the scaled thickness (it's always zero).
1380
+ if (this.geometryThickness === 0.0) {
1381
+ uniformBuffer.updateFloat("vGeometryThickness", 0);
1382
+ }
1383
+ else {
1384
+ subMesh.getRenderingMesh().getWorldMatrix().decompose(TmpVectors.Vector3[0]);
1385
+ const thicknessScale = Math.max(Math.abs(TmpVectors.Vector3[0].x), Math.abs(TmpVectors.Vector3[0].y), Math.abs(TmpVectors.Vector3[0].z));
1386
+ uniformBuffer.updateFloat("vGeometryThickness", this.geometryThickness * thicknessScale);
1387
+ }
1388
+ }
1290
1389
  /**
1291
1390
  * Binds the submesh data.
1292
1391
  * @param world - The world matrix.
@@ -1321,6 +1420,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1321
1420
  }
1322
1421
  this._eventInfo.subMesh = subMesh;
1323
1422
  this._callbackPluginEventHardBindForSubMesh(this._eventInfo);
1423
+ this.bindPropertiesForSubMesh(this._uniformBuffer, scene, scene.getEngine(), subMesh);
1324
1424
  // Normal Matrix
1325
1425
  if (defines.OBJECTSPACE_NORMALMAP) {
1326
1426
  world.toNormalMatrix(this._normalMatrix);
@@ -1401,7 +1501,13 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1401
1501
  if (defines.FUZZENVIRONMENTBRDF) {
1402
1502
  ubo.setTexture("environmentFuzzBrdfSampler", this._environmentFuzzBRDFTexture);
1403
1503
  }
1404
- if (defines.ANISOTROPIC || defines.FUZZ) {
1504
+ if (defines.REFRACTED_BACKGROUND) {
1505
+ ubo.setTexture("backgroundRefractionSampler", this._backgroundRefractionTexture);
1506
+ ubo.updateMatrix("backgroundRefractionMatrix", this._backgroundRefractionTexture.getReflectionTextureMatrix());
1507
+ TmpVectors.Vector3[1].set(Math.log2(this._backgroundRefractionTexture.getSize().width), 0, 0);
1508
+ ubo.updateVector3("vBackgroundRefractionInfos", TmpVectors.Vector3[1]);
1509
+ }
1510
+ if (defines.ANISOTROPIC || defines.FUZZ || defines.REFRACTED_BACKGROUND) {
1405
1511
  ubo.setTexture("blueNoiseSampler", OpenPBRMaterial._noiseTextures[this.getScene().uniqueId]);
1406
1512
  }
1407
1513
  }
@@ -1424,9 +1530,9 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1424
1530
  BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights);
1425
1531
  }
1426
1532
  // View
1427
- if ((scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) || radianceTexture || mesh.receiveShadows || defines.PREPASS) {
1428
- this.bindView(effect);
1429
- }
1533
+ // if ((scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) || radianceTexture || mesh.receiveShadows || defines.PREPASS) {
1534
+ this.bindView(effect);
1535
+ // }
1430
1536
  // Fog
1431
1537
  BindFogParameters(scene, mesh, this._activeEffect, true);
1432
1538
  // Morph targets
@@ -1525,6 +1631,8 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1525
1631
  if (this._environmentFuzzBRDFTexture && this.getScene().environmentFuzzBRDFTexture !== this._environmentFuzzBRDFTexture) {
1526
1632
  this._environmentFuzzBRDFTexture.dispose();
1527
1633
  }
1634
+ // The refraction texture will be cleaned up by the transmission helper.
1635
+ this._backgroundRefractionTexture = null;
1528
1636
  // Loop through samplers and dispose the textures
1529
1637
  for (const key in this._samplersList) {
1530
1638
  const sampler = this._samplersList[key];
@@ -1652,23 +1760,22 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1652
1760
  "morphTargetTextureInfo",
1653
1761
  "morphTargetTextureIndices",
1654
1762
  "cameraInfo",
1763
+ "backgroundRefractionMatrix",
1764
+ "vBackgroundRefractionInfos",
1655
1765
  ];
1656
1766
  for (const uniformName in this._uniformsList) {
1657
1767
  uniforms.push(uniformName);
1658
1768
  }
1659
- const samplers = [
1660
- "environmentBrdfSampler",
1661
- "blueNoiseSampler",
1662
- "boneSampler",
1663
- "morphTargets",
1664
- "oitDepthSampler",
1665
- "oitFrontColorSampler",
1666
- "areaLightsLTC1Sampler",
1667
- "areaLightsLTC2Sampler",
1668
- ];
1769
+ const samplers = ["environmentBrdfSampler", "boneSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler", "areaLightsLTC1Sampler", "areaLightsLTC2Sampler"];
1669
1770
  if (defines.FUZZENVIRONMENTBRDF) {
1670
1771
  samplers.push("environmentFuzzBrdfSampler");
1671
1772
  }
1773
+ if (defines.REFRACTED_BACKGROUND) {
1774
+ samplers.push("backgroundRefractionSampler");
1775
+ }
1776
+ if (defines.ANISOTROPIC || defines.FUZZ || defines.REFRACTED_BACKGROUND) {
1777
+ samplers.push("blueNoiseSampler");
1778
+ }
1672
1779
  for (const key in this._samplersList) {
1673
1780
  const sampler = this._samplersList[key];
1674
1781
  samplers.push(sampler.samplerName);
@@ -1755,7 +1862,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1755
1862
  PrepareDefinesForOIT(scene, defines, oit);
1756
1863
  MaterialHelperGeometryRendering.PrepareDefines(engine.currentRenderPassId, mesh, defines);
1757
1864
  // Textures
1758
- defines.METALLICWORKFLOW = true;
1759
1865
  if (defines._areTexturesDirty) {
1760
1866
  defines._needUVs = false;
1761
1867
  for (let i = 1; i <= 6; ++i) {
@@ -1788,10 +1894,11 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1788
1894
  defines.SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE = this._useSpecularRoughnessAnisotropyFromTangentTexture;
1789
1895
  defines.COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE = this._useCoatRoughnessAnisotropyFromTangentTexture;
1790
1896
  defines.COAT_ROUGHNESS_FROM_GREEN_CHANNEL = this._useCoatRoughnessFromGreenChannel;
1791
- defines.ROUGHNESSSTOREINMETALMAPGREEN = this._useRoughnessFromMetallicTextureGreen;
1897
+ defines.SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN = this._useRoughnessFromMetallicTextureGreen;
1792
1898
  defines.FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA = this._useFuzzRoughnessFromTextureAlpha;
1793
- defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallicFromMetallicTextureBlue;
1899
+ defines.BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE = this._useMetallicFromMetallicTextureBlue;
1794
1900
  defines.THIN_FILM_THICKNESS_FROM_THIN_FILM_TEXTURE = this._useThinFilmThicknessFromTextureGreen;
1901
+ defines.GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL = this._useGeometryThicknessFromGreenChannel;
1795
1902
  if (this.geometryNormalTexture) {
1796
1903
  if (this._useParallax && this.baseColorTexture && MaterialFlags.DiffuseTextureEnabled) {
1797
1904
  defines.PARALLAX = true;
@@ -1823,6 +1930,24 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1823
1930
  else {
1824
1931
  defines.FUZZENVIRONMENTBRDF = false;
1825
1932
  }
1933
+ if (this.transmissionWeight > 0) {
1934
+ defines.REFRACTED_BACKGROUND = !!this._backgroundRefractionTexture && MaterialFlags.RefractionTextureEnabled;
1935
+ defines.REFRACTED_LIGHTS = true;
1936
+ const radianceTexture = this._getRadianceTexture();
1937
+ if (radianceTexture) {
1938
+ defines.REFRACTED_ENVIRONMENT = MaterialFlags.RefractionTextureEnabled;
1939
+ defines.REFRACTED_ENVIRONMENT_OPPOSITEZ = this.getScene().useRightHandedSystem ? !radianceTexture.invertZ : radianceTexture.invertZ;
1940
+ defines.REFRACTED_ENVIRONMENT_LOCAL_CUBE = radianceTexture.isCube && radianceTexture.boundingBoxSize;
1941
+ }
1942
+ else {
1943
+ defines.REFRACTED_ENVIRONMENT = false;
1944
+ }
1945
+ }
1946
+ else {
1947
+ defines.REFRACTED_BACKGROUND = false;
1948
+ defines.REFRACTED_LIGHTS = false;
1949
+ defines.REFRACTED_ENVIRONMENT = false;
1950
+ }
1826
1951
  if (this._shouldUseAlphaFromBaseColorTexture()) {
1827
1952
  defines.ALPHA_FROM_BASE_COLOR_TEXTURE = true;
1828
1953
  }
@@ -1888,6 +2013,8 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1888
2013
  }
1889
2014
  defines.THIN_FILM = this.thinFilmWeight > 0.0;
1890
2015
  defines.IRIDESCENCE = this.thinFilmWeight > 0.0;
2016
+ defines.DISPERSION = this.transmissionDispersionScale > 0.0;
2017
+ defines.SCATTERING = !this.transmissionScatter.equals(Color3.BlackReadOnly);
1891
2018
  defines.FUZZ = this.fuzzWeight > 0 && MaterialFlags.ReflectionTextureEnabled;
1892
2019
  if (defines.FUZZ) {
1893
2020
  if (!mesh.isVerticesDataPresent(VertexBuffer.TangentKind)) {
@@ -1994,6 +2121,54 @@ __decorate([
1994
2121
  addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "specularIor")
1995
2122
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1996
2123
  ], OpenPBRMaterial.prototype, "_specularIor", void 0);
2124
+ __decorate([
2125
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionWeight")
2126
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2127
+ ], OpenPBRMaterial.prototype, "_transmissionWeight", void 0);
2128
+ __decorate([
2129
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionWeightTexture")
2130
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2131
+ ], OpenPBRMaterial.prototype, "_transmissionWeightTexture", void 0);
2132
+ __decorate([
2133
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionColor")
2134
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2135
+ ], OpenPBRMaterial.prototype, "_transmissionColor", void 0);
2136
+ __decorate([
2137
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionColorTexture")
2138
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2139
+ ], OpenPBRMaterial.prototype, "_transmissionColorTexture", void 0);
2140
+ __decorate([
2141
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionDepth")
2142
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2143
+ ], OpenPBRMaterial.prototype, "_transmissionDepth", void 0);
2144
+ __decorate([
2145
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionDepthTexture")
2146
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2147
+ ], OpenPBRMaterial.prototype, "_transmissionDepthTexture", void 0);
2148
+ __decorate([
2149
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionScatter")
2150
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2151
+ ], OpenPBRMaterial.prototype, "_transmissionScatter", void 0);
2152
+ __decorate([
2153
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionScatterTexture")
2154
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2155
+ ], OpenPBRMaterial.prototype, "_transmissionScatterTexture", void 0);
2156
+ __decorate([
2157
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionScatterAnisotropy")
2158
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2159
+ ], OpenPBRMaterial.prototype, "_transmissionScatterAnisotropy", void 0);
2160
+ __decorate([
2161
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionDispersionScale")
2162
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2163
+ ], OpenPBRMaterial.prototype, "_transmissionDispersionScale", void 0);
2164
+ __decorate([
2165
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionDispersionScaleTexture")
2166
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2167
+ ], OpenPBRMaterial.prototype, "_transmissionDispersionScaleTexture", void 0);
2168
+ __decorate([
2169
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "transmissionDispersionAbbeNumber")
2170
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2171
+ ], OpenPBRMaterial.prototype, "_transmissionDispersionAbbeNumber", void 0);
1997
2172
  __decorate([
1998
2173
  addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "coatWeight")
1999
2174
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -2094,6 +2269,14 @@ __decorate([
2094
2269
  addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "geometryOpacityTexture")
2095
2270
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2096
2271
  ], OpenPBRMaterial.prototype, "_geometryOpacityTexture", void 0);
2272
+ __decorate([
2273
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "geometryThickness")
2274
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2275
+ ], OpenPBRMaterial.prototype, "_geometryThickness", void 0);
2276
+ __decorate([
2277
+ addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "geometryThicknessTexture")
2278
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2279
+ ], OpenPBRMaterial.prototype, "_geometryThicknessTexture", void 0);
2097
2280
  __decorate([
2098
2281
  addAccessorsForMaterialProperty("_markAllSubMeshesAsTexturesDirty", "emissionLuminance")
2099
2282
  // eslint-disable-next-line @typescript-eslint/no-unused-vars