@babylonjs/core 8.46.2 → 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 (243) 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/constants.d.ts +1 -1
  23. package/Engines/constants.js +1 -1
  24. package/Engines/constants.js.map +1 -1
  25. package/Engines/thinEngine.d.ts +3 -2
  26. package/Engines/thinEngine.js.map +1 -1
  27. package/IAssetContainer.d.ts +5 -0
  28. package/IAssetContainer.js.map +1 -1
  29. package/Lights/Clustered/clusteredLightContainer.js +1 -1
  30. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  31. package/Lights/areaLight.d.ts +1 -1
  32. package/Lights/areaLight.js +1 -1
  33. package/Lights/areaLight.js.map +1 -1
  34. package/Lights/rectAreaLight.d.ts +20 -0
  35. package/Lights/rectAreaLight.js +45 -0
  36. package/Lights/rectAreaLight.js.map +1 -1
  37. package/Loading/Plugins/babylonFileLoader.js +2 -0
  38. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  39. package/Materials/Node/Blocks/Dual/lightBlock.js +1 -1
  40. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  41. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -1
  42. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  43. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +6 -3
  44. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
  45. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +1 -1
  46. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  47. package/Materials/PBR/openpbrMaterial.d.ts +135 -5
  48. package/Materials/PBR/openpbrMaterial.js +205 -22
  49. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  50. package/Materials/effectRenderer.d.ts +2 -1
  51. package/Materials/effectRenderer.js +2 -12
  52. package/Materials/effectRenderer.js.map +1 -1
  53. package/Materials/material.d.ts +1 -1
  54. package/Materials/material.js +1 -1
  55. package/Materials/material.js.map +1 -1
  56. package/Materials/materialHelper.functions.d.ts +2 -1
  57. package/Materials/materialHelper.functions.js +7 -2
  58. package/Materials/materialHelper.functions.js.map +1 -1
  59. package/Materials/materialPluginManager.js +2 -2
  60. package/Materials/materialPluginManager.js.map +1 -1
  61. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +6 -1
  62. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +21 -17
  63. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  64. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +1 -5
  65. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
  66. package/Misc/areaLightsTextureTools.d.ts +52 -0
  67. package/Misc/areaLightsTextureTools.js +227 -0
  68. package/Misc/areaLightsTextureTools.js.map +1 -0
  69. package/Misc/decorators.serialization.js +6 -1
  70. package/Misc/decorators.serialization.js.map +1 -1
  71. package/Misc/index.d.ts +3 -0
  72. package/Misc/index.js +4 -0
  73. package/Misc/index.js.map +1 -1
  74. package/Misc/sceneRecorder.d.ts +6 -2
  75. package/Misc/sceneRecorder.js +7 -0
  76. package/Misc/sceneRecorder.js.map +1 -1
  77. package/Particles/Node/Blocks/index.d.ts +3 -0
  78. package/Particles/Node/Blocks/index.js +3 -0
  79. package/Particles/Node/Blocks/index.js.map +1 -1
  80. package/Particles/Node/Blocks/particleNLerpBlock.d.ts +35 -0
  81. package/Particles/Node/Blocks/particleNLerpBlock.js +97 -0
  82. package/Particles/Node/Blocks/particleNLerpBlock.js.map +1 -0
  83. package/Particles/Node/Blocks/particleSmoothStepBlock.d.ts +34 -0
  84. package/Particles/Node/Blocks/particleSmoothStepBlock.js +91 -0
  85. package/Particles/Node/Blocks/particleSmoothStepBlock.js.map +1 -0
  86. package/Particles/Node/Blocks/particleSourceTextureBlock.d.ts +4 -0
  87. package/Particles/Node/Blocks/particleSourceTextureBlock.js +9 -3
  88. package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
  89. package/Particles/Node/Blocks/particleStepBlock.d.ts +30 -0
  90. package/Particles/Node/Blocks/particleStepBlock.js +84 -0
  91. package/Particles/Node/Blocks/particleStepBlock.js.map +1 -0
  92. package/Particles/Node/nodeParticleSystemSet.d.ts +2 -0
  93. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  94. package/Particles/solidParticleSystem.d.ts +3 -0
  95. package/Particles/solidParticleSystem.js +7 -4
  96. package/Particles/solidParticleSystem.js.map +1 -1
  97. package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -0
  98. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  99. package/Physics/v2/Plugins/havokPlugin.d.ts +10 -0
  100. package/Physics/v2/Plugins/havokPlugin.js +13 -0
  101. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  102. package/Physics/v2/physicsBody.d.ts +10 -0
  103. package/Physics/v2/physicsBody.js +12 -0
  104. package/Physics/v2/physicsBody.js.map +1 -1
  105. package/Physics/v2/physicsEngineComponent.d.ts +5 -0
  106. package/Physics/v2/physicsEngineComponent.js +13 -0
  107. package/Physics/v2/physicsEngineComponent.js.map +1 -1
  108. package/Rendering/IBLShadows/iblShadowsPluginMaterial.js +8 -10
  109. package/Rendering/IBLShadows/iblShadowsPluginMaterial.js.map +1 -1
  110. package/Rendering/utilityLayerRenderer.d.ts +6 -0
  111. package/Rendering/utilityLayerRenderer.js +14 -5
  112. package/Rendering/utilityLayerRenderer.js.map +1 -1
  113. package/Shaders/ShadersInclude/hdrFilteringFunctions.js +7 -9
  114. package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
  115. package/Shaders/ShadersInclude/helperFunctions.js +4 -0
  116. package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
  117. package/Shaders/ShadersInclude/lightFragment.js +13 -0
  118. package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
  119. package/Shaders/ShadersInclude/lightFragmentDeclaration.js +3 -0
  120. package/Shaders/ShadersInclude/lightFragmentDeclaration.js.map +1 -1
  121. package/Shaders/ShadersInclude/lightUboDeclaration.js +3 -0
  122. package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
  123. package/Shaders/ShadersInclude/lightsFragmentFunctions.js +6 -0
  124. package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
  125. package/Shaders/ShadersInclude/ltcHelperFunctions.js +17 -1
  126. package/Shaders/ShadersInclude/ltcHelperFunctions.js.map +1 -1
  127. package/Shaders/ShadersInclude/{openpbrBlockAmbientOcclusion.d.ts → openpbrAmbientOcclusionData.d.ts} +1 -1
  128. package/Shaders/ShadersInclude/openpbrAmbientOcclusionData.js +15 -0
  129. package/Shaders/ShadersInclude/openpbrAmbientOcclusionData.js.map +1 -0
  130. package/{ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.d.ts → Shaders/ShadersInclude/openpbrAmbientOcclusionFunctions.d.ts} +1 -1
  131. package/Shaders/ShadersInclude/openpbrAmbientOcclusionFunctions.js +13 -0
  132. package/Shaders/ShadersInclude/openpbrAmbientOcclusionFunctions.js.map +1 -0
  133. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.d.ts +5 -0
  134. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +26 -0
  135. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -0
  136. package/Shaders/ShadersInclude/openpbrBaseLayerData.js +18 -7
  137. package/Shaders/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
  138. package/Shaders/ShadersInclude/openpbrDirectLighting.js +52 -6
  139. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  140. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +109 -6
  141. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  142. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.d.ts +1 -0
  143. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js +24 -4
  144. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js.map +1 -1
  145. package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js +10 -1
  146. package/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -1
  147. package/Shaders/ShadersInclude/openpbrIblFunctions.js +9 -2
  148. package/Shaders/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  149. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.js +1 -0
  150. package/Shaders/ShadersInclude/openpbrThinFilmLayerData.js.map +1 -1
  151. package/Shaders/ShadersInclude/openpbrTransmissionLayerData.d.ts +5 -0
  152. package/Shaders/ShadersInclude/openpbrTransmissionLayerData.js +47 -0
  153. package/Shaders/ShadersInclude/openpbrTransmissionLayerData.js.map +1 -0
  154. package/Shaders/ShadersInclude/openpbrUboDeclaration.js +1 -1
  155. package/Shaders/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
  156. package/Shaders/ShadersInclude/openpbrVertexDeclaration.d.ts +1 -0
  157. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +17 -4
  158. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -1
  159. package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
  160. package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  161. package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js +6 -0
  162. package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
  163. package/Shaders/ShadersInclude/pbrHelperFunctions.js +1 -1
  164. package/Shaders/ShadersInclude/pbrHelperFunctions.js.map +1 -1
  165. package/Shaders/areaLightTextureProcessing.fragment.d.ts +5 -0
  166. package/Shaders/areaLightTextureProcessing.fragment.js +13 -0
  167. package/Shaders/areaLightTextureProcessing.fragment.js.map +1 -0
  168. package/Shaders/openpbr.fragment.d.ts +4 -1
  169. package/Shaders/openpbr.fragment.js +33 -15
  170. package/Shaders/openpbr.fragment.js.map +1 -1
  171. package/Shaders/openpbr.vertex.js +30 -18
  172. package/Shaders/openpbr.vertex.js.map +1 -1
  173. package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +10 -12
  174. package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
  175. package/ShadersWGSL/ShadersInclude/helperFunctions.js +4 -0
  176. package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
  177. package/ShadersWGSL/ShadersInclude/importanceSampling.js +1 -1
  178. package/ShadersWGSL/ShadersInclude/importanceSampling.js.map +1 -1
  179. package/ShadersWGSL/ShadersInclude/lightFragment.js +14 -0
  180. package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
  181. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +3 -0
  182. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
  183. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +6 -0
  184. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
  185. package/ShadersWGSL/ShadersInclude/ltcHelperFunctions.js +19 -1
  186. package/ShadersWGSL/ShadersInclude/ltcHelperFunctions.js.map +1 -1
  187. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionData.d.ts +5 -0
  188. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionData.js +15 -0
  189. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionData.js.map +1 -0
  190. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionFunctions.d.ts +5 -0
  191. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionFunctions.js +13 -0
  192. package/ShadersWGSL/ShadersInclude/openpbrAmbientOcclusionFunctions.js.map +1 -0
  193. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.d.ts +5 -0
  194. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +25 -0
  195. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -0
  196. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js +18 -7
  197. package/ShadersWGSL/ShadersInclude/openpbrBaseLayerData.js.map +1 -1
  198. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +52 -6
  199. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  200. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +115 -7
  201. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  202. package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js +10 -1
  203. package/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.js.map +1 -1
  204. package/ShadersWGSL/ShadersInclude/openpbrFuzzLayerData.js +4 -4
  205. package/ShadersWGSL/ShadersInclude/openpbrFuzzLayerData.js.map +1 -1
  206. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +10 -3
  207. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  208. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.js +1 -0
  209. package/ShadersWGSL/ShadersInclude/openpbrThinFilmLayerData.js.map +1 -1
  210. package/ShadersWGSL/ShadersInclude/openpbrTransmissionLayerData.d.ts +5 -0
  211. package/ShadersWGSL/ShadersInclude/openpbrTransmissionLayerData.js +47 -0
  212. package/ShadersWGSL/ShadersInclude/openpbrTransmissionLayerData.js.map +1 -0
  213. package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js +1 -1
  214. package/ShadersWGSL/ShadersInclude/openpbrUboDeclaration.js.map +1 -1
  215. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
  216. package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
  217. package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js +5 -0
  218. package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
  219. package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js +1 -1
  220. package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js.map +1 -1
  221. package/ShadersWGSL/areaLightTextureProcessing.fragment.d.ts +5 -0
  222. package/ShadersWGSL/areaLightTextureProcessing.fragment.js +12 -0
  223. package/ShadersWGSL/areaLightTextureProcessing.fragment.js.map +1 -0
  224. package/ShadersWGSL/iblVoxelGrid.vertex.js +2 -2
  225. package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
  226. package/ShadersWGSL/openpbr.fragment.d.ts +4 -1
  227. package/ShadersWGSL/openpbr.fragment.js +33 -15
  228. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  229. package/ShadersWGSL/openpbr.vertex.js +12 -0
  230. package/ShadersWGSL/openpbr.vertex.js.map +1 -1
  231. package/Sprites/spriteManager.d.ts +3 -0
  232. package/Sprites/spriteManager.js +9 -0
  233. package/Sprites/spriteManager.js.map +1 -1
  234. package/States/alphaCullingState.js +0 -1
  235. package/States/alphaCullingState.js.map +1 -1
  236. package/assetContainer.d.ts +5 -0
  237. package/assetContainer.js +32 -0
  238. package/assetContainer.js.map +1 -1
  239. package/package.json +2 -2
  240. package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.js +0 -35
  241. package/Shaders/ShadersInclude/openpbrBlockAmbientOcclusion.js.map +0 -1
  242. package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.js +0 -36
  243. package/ShadersWGSL/ShadersInclude/openpbrBlockAmbientOcclusion.js.map +0 -1
@@ -1,9 +1,10 @@
1
1
  import type { Nullable } from "../../types.js";
2
- import { Scene } from "../../scene.js";
2
+ import type { Scene } from "../../scene.js";
3
3
  import { Color3 } from "../../Maths/math.color.js";
4
4
  import { ImageProcessingConfiguration } from "../imageProcessingConfiguration.js";
5
5
  import type { BaseTexture } from "../../Materials/Textures/baseTexture.js";
6
6
  import { Material } from "../material.js";
7
+ import type { Engine } from "../../Engines/engine.js";
7
8
  import type { AbstractMesh } from "../../Meshes/abstractMesh.js";
8
9
  import { MaterialDefines } from "../materialDefines.js";
9
10
  import { PrePassConfiguration } from "../prePassConfiguration.js";
@@ -14,6 +15,7 @@ import type { Matrix } from "../../Maths/math.vector.js";
14
15
  import type { Mesh } from "../../Meshes/mesh.js";
15
16
  import { PushMaterial } from "../pushMaterial.js";
16
17
  import type { IAnimatable } from "../../Animations/animatable.interface.js";
18
+ import type { UniformBuffer } from "../../Materials/uniformBuffer.js";
17
19
  declare const OpenPBRMaterialDefinesBase_base: {
18
20
  new (...args: any[]): {
19
21
  MAINUV1: boolean;
@@ -72,10 +74,8 @@ export declare class OpenPBRMaterialDefines extends OpenPBRMaterialDefines_base
72
74
  REFLECTIVITYDIRECTUV: number;
73
75
  SPECULARTERM: boolean;
74
76
  LODBASEDMICROSFURACE: boolean;
75
- METALLICWORKFLOW: boolean;
76
- ROUGHNESSSTOREINMETALMAPALPHA: boolean;
77
- ROUGHNESSSTOREINMETALMAPGREEN: boolean;
78
- METALLNESSSTOREINMETALMAPBLUE: boolean;
77
+ SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN: boolean;
78
+ BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE: boolean;
79
79
  AOSTOREINMETALMAPRED: boolean;
80
80
  SPECULAR_WEIGHT_IN_ALPHA: boolean;
81
81
  SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE: boolean;
@@ -85,6 +85,7 @@ export declare class OpenPBRMaterialDefines extends OpenPBRMaterialDefines_base
85
85
  USE_GLTF_STYLE_ANISOTROPY: boolean;
86
86
  THIN_FILM_THICKNESS_FROM_THIN_FILM_TEXTURE: boolean;
87
87
  FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA: boolean;
88
+ GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL: boolean;
88
89
  ENVIRONMENTBRDF: boolean;
89
90
  ENVIRONMENTBRDF_RGBD: boolean;
90
91
  FUZZENVIRONMENTBRDF: boolean;
@@ -128,6 +129,28 @@ export declare class OpenPBRMaterialDefines extends OpenPBRMaterialDefines_base
128
129
  * Iridescence is the name of thin film interference in the PBR material.
129
130
  */
130
131
  IRIDESCENCE: boolean;
132
+ /**
133
+ * Tells the shader to enable dispersion in refraction
134
+ */
135
+ DISPERSION: boolean;
136
+ /**
137
+ * Enables subsurface scattering
138
+ */
139
+ SCATTERING: boolean;
140
+ /**
141
+ * Refraction of the 2D background texture. Might include the rest of the scene or just the background.
142
+ */
143
+ REFRACTED_BACKGROUND: boolean;
144
+ /**
145
+ * Refraction of direct lights.
146
+ */
147
+ REFRACTED_LIGHTS: boolean;
148
+ /**
149
+ * Refraction of the environment texture (IBL).
150
+ */
151
+ REFRACTED_ENVIRONMENT: boolean;
152
+ REFRACTED_ENVIRONMENT_OPPOSITEZ: boolean;
153
+ REFRACTED_ENVIRONMENT_LOCAL_CUBE: boolean;
131
154
  REFLECTION: boolean;
132
155
  REFLECTIONMAP_3D: boolean;
133
156
  REFLECTIONMAP_SPHERICAL: boolean;
@@ -379,6 +402,78 @@ export declare class OpenPBRMaterial extends OpenPBRMaterialBase {
379
402
  */
380
403
  specularIor: number;
381
404
  private _specularIor;
405
+ /**
406
+ * Transmission weight of the surface.
407
+ * See OpenPBR's specs for transmission_weight
408
+ */
409
+ transmissionWeight: number;
410
+ private _transmissionWeight;
411
+ /**
412
+ * Transmission weight texture.
413
+ * See OpenPBR's specs for transmission_weight
414
+ */
415
+ transmissionWeightTexture: Nullable<BaseTexture>;
416
+ private _transmissionWeightTexture;
417
+ /**
418
+ * Transmission color of the surface.
419
+ * See OpenPBR's specs for transmission_color
420
+ */
421
+ transmissionColor: Color3;
422
+ private _transmissionColor;
423
+ /**
424
+ * Transmission color texture.
425
+ * See OpenPBR's specs for transmission_color
426
+ */
427
+ transmissionColorTexture: Nullable<BaseTexture>;
428
+ private _transmissionColorTexture;
429
+ /**
430
+ * Transmission depth of the volume
431
+ * See OpenPBR's specs for transmission_depth
432
+ */
433
+ transmissionDepth: number;
434
+ private _transmissionDepth;
435
+ /**
436
+ * Transmission depth texture.
437
+ * See OpenPBR's specs for transmission_depth
438
+ */
439
+ transmissionDepthTexture: Nullable<BaseTexture>;
440
+ private _transmissionDepthTexture;
441
+ /**
442
+ * Transmission scatter of the surface.
443
+ * See OpenPBR's specs for transmission_scatter
444
+ */
445
+ transmissionScatter: Color3;
446
+ private _transmissionScatter;
447
+ /**
448
+ * Transmission scatter texture.
449
+ * See OpenPBR's specs for transmission_scatter
450
+ */
451
+ transmissionScatterTexture: Nullable<BaseTexture>;
452
+ private _transmissionScatterTexture;
453
+ /**
454
+ * Transmission scatter anisotropy
455
+ * See OpenPBR's specs for transmission_scatter_anisotropy
456
+ */
457
+ transmissionScatterAnisotropy: number;
458
+ private _transmissionScatterAnisotropy;
459
+ /**
460
+ * Transmission Dispersion Scale factor.
461
+ * See OpenPBR's specs for transmission_dispersion_scale
462
+ */
463
+ transmissionDispersionScale: number;
464
+ private _transmissionDispersionScale;
465
+ /**
466
+ * Transmission Dispersion Scale texture.
467
+ * See OpenPBR's specs for transmission_dispersion_scale
468
+ */
469
+ transmissionDispersionScaleTexture: Nullable<BaseTexture>;
470
+ private _transmissionDispersionScaleTexture;
471
+ /**
472
+ * Transmission Dispersion Abbe number.
473
+ * See OpenPBR's specs for transmission_dispersion_abbe_number
474
+ */
475
+ transmissionDispersionAbbeNumber: number;
476
+ private _transmissionDispersionAbbeNumber;
382
477
  /**
383
478
  * Defines the amount of clear coat on the surface.
384
479
  * See OpenPBR's specs for coat_weight
@@ -552,6 +647,18 @@ export declare class OpenPBRMaterial extends OpenPBRMaterialBase {
552
647
  */
553
648
  geometryOpacityTexture: Nullable<BaseTexture>;
554
649
  private _geometryOpacityTexture;
650
+ /**
651
+ * Defines the thickness of the material's geometry.
652
+ * Not part of OpenPBR's specs but useful for rasterization approximations of volume.
653
+ */
654
+ geometryThickness: number;
655
+ private _geometryThickness;
656
+ /**
657
+ * Defines the thickness of the material's geometry.
658
+ * Not part of OpenPBR's specs but useful for rasterization approximations of volume.
659
+ */
660
+ geometryThicknessTexture: Nullable<BaseTexture>;
661
+ private _geometryThicknessTexture;
555
662
  /**
556
663
  * Defines the luminance of the material's emission.
557
664
  * See OpenPBR's specs for emission_luminance
@@ -845,8 +952,16 @@ export declare class OpenPBRMaterial extends OpenPBRMaterialBase {
845
952
  _useMetallicFromMetallicTextureBlue: boolean;
846
953
  /**
847
954
  * Specifies if the thin film thickness is stored in the green channel of the thin film thickness texture.
955
+ * This is for compatibility with glTF.
956
+ * @internal
848
957
  */
849
958
  _useThinFilmThicknessFromTextureGreen: boolean;
959
+ /**
960
+ * Specifies if the geometry thickness is stored in the green channel of the geometry thickness texture.
961
+ * This is for compatibility with glTF.
962
+ * @internal
963
+ */
964
+ _useGeometryThicknessFromGreenChannel: boolean;
850
965
  /**
851
966
  * Defines the falloff type used in this material.
852
967
  * It by default is Physical.
@@ -929,6 +1044,13 @@ export declare class OpenPBRMaterial extends OpenPBRMaterialBase {
929
1044
  * @internal
930
1045
  */
931
1046
  _environmentFuzzBRDFTexture: Nullable<BaseTexture>;
1047
+ private _backgroundRefractionTexture;
1048
+ /**
1049
+ * Set the texture used for refraction of the background of transparent materials
1050
+ * @internal
1051
+ */
1052
+ get backgroundRefractionTexture(): Nullable<BaseTexture>;
1053
+ set backgroundRefractionTexture(texture: Nullable<BaseTexture>);
932
1054
  /**
933
1055
  * Force the shader to compute irradiance in the fragment shader in order to take normal mapping into account.
934
1056
  * @internal
@@ -1082,6 +1204,14 @@ export declare class OpenPBRMaterial extends OpenPBRMaterialBase {
1082
1204
  * Initializes the uniform buffer layout for the shader.
1083
1205
  */
1084
1206
  buildUniformLayout(): void;
1207
+ /**
1208
+ * Binds the material data (this function is called even if mustRebind() returns false)
1209
+ * @param uniformBuffer defines the Uniform buffer to fill in.
1210
+ * @param scene defines the scene the material belongs to.
1211
+ * @param engine defines the engine the material belongs to.
1212
+ * @param subMesh the submesh to bind data for
1213
+ */
1214
+ bindPropertiesForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, subMesh: SubMesh): void;
1085
1215
  /**
1086
1216
  * Binds the submesh data.
1087
1217
  * @param world - The world matrix.
@@ -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