pbrBaseMaterial.d.ts 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. import type { Nullable } from "../../types";
  2. import { Scene } from "../../scene";
  3. import type { Matrix } from "../../Maths/math.vector";
  4. import type { SubMesh } from "../../Meshes/subMesh";
  5. import type { AbstractMesh } from "../../Meshes/abstractMesh";
  6. import type { Mesh } from "../../Meshes/mesh";
  7. import { PBRBRDFConfiguration } from "./pbrBRDFConfiguration";
  8. import { PrePassConfiguration } from "../prePassConfiguration";
  9. import { Color3 } from "../../Maths/math.color";
  10. import type { IImageProcessingConfigurationDefines } from "../../Materials/imageProcessingConfiguration.defines";
  11. import { ImageProcessingConfiguration } from "../../Materials/imageProcessingConfiguration";
  12. import type { IMaterialCompilationOptions } from "../../Materials/material";
  13. import { Material } from "../../Materials/material";
  14. import { MaterialDefines } from "../../Materials/materialDefines";
  15. import { PushMaterial } from "../../Materials/pushMaterial";
  16. import type { BaseTexture } from "../../Materials/Textures/baseTexture";
  17. import type { IAnimatable } from "../../Animations/animatable.interface";
  18. import "../../Materials/Textures/baseTexture.polynomial";
  19. import "../../Shaders/pbr.fragment";
  20. import "../../Shaders/pbr.vertex";
  21. import { PBRClearCoatConfiguration } from "./pbrClearCoatConfiguration";
  22. import { PBRIridescenceConfiguration } from "./pbrIridescenceConfiguration";
  23. import { PBRAnisotropicConfiguration } from "./pbrAnisotropicConfiguration";
  24. import { PBRSheenConfiguration } from "./pbrSheenConfiguration";
  25. import { PBRSubSurfaceConfiguration } from "./pbrSubSurfaceConfiguration";
  26. import { DetailMapConfiguration } from "../material.detailMapConfiguration";
  27. /**
  28. * Manages the defines for the PBR Material.
  29. * @internal
  30. */
  31. export declare class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  32. PBR: boolean;
  33. NUM_SAMPLES: string;
  34. REALTIME_FILTERING: boolean;
  35. MAINUV1: boolean;
  36. MAINUV2: boolean;
  37. MAINUV3: boolean;
  38. MAINUV4: boolean;
  39. MAINUV5: boolean;
  40. MAINUV6: boolean;
  41. UV1: boolean;
  42. UV2: boolean;
  43. UV3: boolean;
  44. UV4: boolean;
  45. UV5: boolean;
  46. UV6: boolean;
  47. ALBEDO: boolean;
  48. GAMMAALBEDO: boolean;
  49. ALBEDODIRECTUV: number;
  50. VERTEXCOLOR: boolean;
  51. BAKED_VERTEX_ANIMATION_TEXTURE: boolean;
  52. AMBIENT: boolean;
  53. AMBIENTDIRECTUV: number;
  54. AMBIENTINGRAYSCALE: boolean;
  55. OPACITY: boolean;
  56. VERTEXALPHA: boolean;
  57. OPACITYDIRECTUV: number;
  58. OPACITYRGB: boolean;
  59. ALPHATEST: boolean;
  60. DEPTHPREPASS: boolean;
  61. ALPHABLEND: boolean;
  62. ALPHAFROMALBEDO: boolean;
  63. ALPHATESTVALUE: string;
  64. SPECULAROVERALPHA: boolean;
  65. RADIANCEOVERALPHA: boolean;
  66. ALPHAFRESNEL: boolean;
  67. LINEARALPHAFRESNEL: boolean;
  68. PREMULTIPLYALPHA: boolean;
  69. EMISSIVE: boolean;
  70. EMISSIVEDIRECTUV: number;
  71. GAMMAEMISSIVE: boolean;
  72. REFLECTIVITY: boolean;
  73. REFLECTIVITY_GAMMA: boolean;
  74. REFLECTIVITYDIRECTUV: number;
  75. SPECULARTERM: boolean;
  76. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  77. MICROSURFACEAUTOMATIC: boolean;
  78. LODBASEDMICROSFURACE: boolean;
  79. MICROSURFACEMAP: boolean;
  80. MICROSURFACEMAPDIRECTUV: number;
  81. METALLICWORKFLOW: boolean;
  82. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  83. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  84. METALLNESSSTOREINMETALMAPBLUE: boolean;
  85. AOSTOREINMETALMAPRED: boolean;
  86. METALLIC_REFLECTANCE: boolean;
  87. METALLIC_REFLECTANCE_GAMMA: boolean;
  88. METALLIC_REFLECTANCEDIRECTUV: number;
  89. METALLIC_REFLECTANCE_USE_ALPHA_ONLY: boolean;
  90. REFLECTANCE: boolean;
  91. REFLECTANCE_GAMMA: boolean;
  92. REFLECTANCEDIRECTUV: number;
  93. ENVIRONMENTBRDF: boolean;
  94. ENVIRONMENTBRDF_RGBD: boolean;
  95. NORMAL: boolean;
  96. TANGENT: boolean;
  97. BUMP: boolean;
  98. BUMPDIRECTUV: number;
  99. OBJECTSPACE_NORMALMAP: boolean;
  100. PARALLAX: boolean;
  101. PARALLAX_RHS: boolean;
  102. PARALLAXOCCLUSION: boolean;
  103. NORMALXYSCALE: boolean;
  104. LIGHTMAP: boolean;
  105. LIGHTMAPDIRECTUV: number;
  106. USELIGHTMAPASSHADOWMAP: boolean;
  107. GAMMALIGHTMAP: boolean;
  108. RGBDLIGHTMAP: boolean;
  109. REFLECTION: boolean;
  110. REFLECTIONMAP_3D: boolean;
  111. REFLECTIONMAP_SPHERICAL: boolean;
  112. REFLECTIONMAP_PLANAR: boolean;
  113. REFLECTIONMAP_CUBIC: boolean;
  114. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  115. REFLECTIONMAP_PROJECTION: boolean;
  116. REFLECTIONMAP_SKYBOX: boolean;
  117. REFLECTIONMAP_EXPLICIT: boolean;
  118. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  119. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  120. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  121. INVERTCUBICMAP: boolean;
  122. USESPHERICALFROMREFLECTIONMAP: boolean;
  123. USEIRRADIANCEMAP: boolean;
  124. USESPHERICALINVERTEX: boolean;
  125. REFLECTIONMAP_OPPOSITEZ: boolean;
  126. LODINREFLECTIONALPHA: boolean;
  127. GAMMAREFLECTION: boolean;
  128. RGBDREFLECTION: boolean;
  129. LINEARSPECULARREFLECTION: boolean;
  130. RADIANCEOCCLUSION: boolean;
  131. HORIZONOCCLUSION: boolean;
  132. INSTANCES: boolean;
  133. THIN_INSTANCES: boolean;
  134. INSTANCESCOLOR: boolean;
  135. PREPASS: boolean;
  136. PREPASS_IRRADIANCE: boolean;
  137. PREPASS_IRRADIANCE_INDEX: number;
  138. PREPASS_ALBEDO_SQRT: boolean;
  139. PREPASS_ALBEDO_SQRT_INDEX: number;
  140. PREPASS_DEPTH: boolean;
  141. PREPASS_DEPTH_INDEX: number;
  142. PREPASS_NORMAL: boolean;
  143. PREPASS_NORMAL_INDEX: number;
  144. PREPASS_NORMAL_WORLDSPACE: boolean;
  145. PREPASS_POSITION: boolean;
  146. PREPASS_POSITION_INDEX: number;
  147. PREPASS_VELOCITY: boolean;
  148. PREPASS_VELOCITY_INDEX: number;
  149. PREPASS_REFLECTIVITY: boolean;
  150. PREPASS_REFLECTIVITY_INDEX: number;
  151. SCENE_MRT_COUNT: number;
  152. NUM_BONE_INFLUENCERS: number;
  153. BonesPerMesh: number;
  154. BONETEXTURE: boolean;
  155. BONES_VELOCITY_ENABLED: boolean;
  156. NONUNIFORMSCALING: boolean;
  157. MORPHTARGETS: boolean;
  158. MORPHTARGETS_NORMAL: boolean;
  159. MORPHTARGETS_TANGENT: boolean;
  160. MORPHTARGETS_UV: boolean;
  161. NUM_MORPH_INFLUENCERS: number;
  162. MORPHTARGETS_TEXTURE: boolean;
  163. IMAGEPROCESSING: boolean;
  164. VIGNETTE: boolean;
  165. VIGNETTEBLENDMODEMULTIPLY: boolean;
  166. VIGNETTEBLENDMODEOPAQUE: boolean;
  167. TONEMAPPING: boolean;
  168. TONEMAPPING_ACES: boolean;
  169. CONTRAST: boolean;
  170. COLORCURVES: boolean;
  171. COLORGRADING: boolean;
  172. COLORGRADING3D: boolean;
  173. SAMPLER3DGREENDEPTH: boolean;
  174. SAMPLER3DBGRMAP: boolean;
  175. DITHER: boolean;
  176. IMAGEPROCESSINGPOSTPROCESS: boolean;
  177. SKIPFINALCOLORCLAMP: boolean;
  178. EXPOSURE: boolean;
  179. MULTIVIEW: boolean;
  180. ORDER_INDEPENDENT_TRANSPARENCY: boolean;
  181. ORDER_INDEPENDENT_TRANSPARENCY_16BITS: boolean;
  182. USEPHYSICALLIGHTFALLOFF: boolean;
  183. USEGLTFLIGHTFALLOFF: boolean;
  184. TWOSIDEDLIGHTING: boolean;
  185. SHADOWFLOAT: boolean;
  186. CLIPPLANE: boolean;
  187. CLIPPLANE2: boolean;
  188. CLIPPLANE3: boolean;
  189. CLIPPLANE4: boolean;
  190. CLIPPLANE5: boolean;
  191. CLIPPLANE6: boolean;
  192. POINTSIZE: boolean;
  193. FOG: boolean;
  194. LOGARITHMICDEPTH: boolean;
  195. CAMERA_ORTHOGRAPHIC: boolean;
  196. CAMERA_PERSPECTIVE: boolean;
  197. FORCENORMALFORWARD: boolean;
  198. SPECULARAA: boolean;
  199. UNLIT: boolean;
  200. DECAL_AFTER_DETAIL: boolean;
  201. DEBUGMODE: number;
  202. /**
  203. * Initializes the PBR Material defines.
  204. * @param externalProperties The external properties
  205. */
  206. constructor(externalProperties?: {
  207. [name: string]: {
  208. type: string;
  209. default: any;
  210. };
  211. });
  212. /**
  213. * Resets the PBR Material defines.
  214. */
  215. reset(): void;
  216. }
  217. /**
  218. * The Physically based material base class of BJS.
  219. *
  220. * This offers the main features of a standard PBR material.
  221. * For more information, please refer to the documentation :
  222. * https://doc.babylonjs.com/features/featuresDeepDive/materials/using/introToPBR
  223. */
  224. export declare abstract class PBRBaseMaterial extends PushMaterial {
  225. /**
  226. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  227. */
  228. static readonly PBRMATERIAL_OPAQUE = 0;
  229. /**
  230. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  231. */
  232. static readonly PBRMATERIAL_ALPHATEST = 1;
  233. /**
  234. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  235. */
  236. static readonly PBRMATERIAL_ALPHABLEND = 2;
  237. /**
  238. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  239. * They are also discarded below the alpha cutoff threshold to improve performances.
  240. */
  241. static readonly PBRMATERIAL_ALPHATESTANDBLEND = 3;
  242. /**
  243. * Defines the default value of how much AO map is occluding the analytical lights
  244. * (point spot...).
  245. */
  246. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  247. /**
  248. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  249. */
  250. static readonly LIGHTFALLOFF_PHYSICAL = 0;
  251. /**
  252. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  253. * to enhance interoperability with other engines.
  254. */
  255. static readonly LIGHTFALLOFF_GLTF = 1;
  256. /**
  257. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  258. * to enhance interoperability with other materials.
  259. */
  260. static readonly LIGHTFALLOFF_STANDARD = 2;
  261. /**
  262. * Intensity of the direct lights e.g. the four lights available in your scene.
  263. * This impacts both the direct diffuse and specular highlights.
  264. * @internal
  265. */
  266. _directIntensity: number;
  267. /**
  268. * Intensity of the emissive part of the material.
  269. * This helps controlling the emissive effect without modifying the emissive color.
  270. * @internal
  271. */
  272. _emissiveIntensity: number;
  273. /**
  274. * Intensity of the environment e.g. how much the environment will light the object
  275. * either through harmonics for rough material or through the reflection for shiny ones.
  276. * @internal
  277. */
  278. _environmentIntensity: number;
  279. /**
  280. * This is a special control allowing the reduction of the specular highlights coming from the
  281. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  282. * @internal
  283. */
  284. _specularIntensity: number;
  285. /**
  286. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  287. */
  288. private _lightingInfos;
  289. /**
  290. * Debug Control allowing disabling the bump map on this material.
  291. * @internal
  292. */
  293. _disableBumpMap: boolean;
  294. /**
  295. * AKA Diffuse Texture in standard nomenclature.
  296. * @internal
  297. */
  298. _albedoTexture: Nullable<BaseTexture>;
  299. /**
  300. * AKA Occlusion Texture in other nomenclature.
  301. * @internal
  302. */
  303. _ambientTexture: Nullable<BaseTexture>;
  304. /**
  305. * AKA Occlusion Texture Intensity in other nomenclature.
  306. * @internal
  307. */
  308. _ambientTextureStrength: number;
  309. /**
  310. * Defines how much the AO map is occluding the analytical lights (point spot...).
  311. * 1 means it completely occludes it
  312. * 0 mean it has no impact
  313. * @internal
  314. */
  315. _ambientTextureImpactOnAnalyticalLights: number;
  316. /**
  317. * Stores the alpha values in a texture.
  318. * @internal
  319. */
  320. _opacityTexture: Nullable<BaseTexture>;
  321. /**
  322. * Stores the reflection values in a texture.
  323. * @internal
  324. */
  325. _reflectionTexture: Nullable<BaseTexture>;
  326. /**
  327. * Stores the emissive values in a texture.
  328. * @internal
  329. */
  330. _emissiveTexture: Nullable<BaseTexture>;
  331. /**
  332. * AKA Specular texture in other nomenclature.
  333. * @internal
  334. */
  335. _reflectivityTexture: Nullable<BaseTexture>;
  336. /**
  337. * Used to switch from specular/glossiness to metallic/roughness workflow.
  338. * @internal
  339. */
  340. _metallicTexture: Nullable<BaseTexture>;
  341. /**
  342. * Specifies the metallic scalar of the metallic/roughness workflow.
  343. * Can also be used to scale the metalness values of the metallic texture.
  344. * @internal
  345. */
  346. _metallic: Nullable<number>;
  347. /**
  348. * Specifies the roughness scalar of the metallic/roughness workflow.
  349. * Can also be used to scale the roughness values of the metallic texture.
  350. * @internal
  351. */
  352. _roughness: Nullable<number>;
  353. /**
  354. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  355. * By default the indexOfrefraction is used to compute F0;
  356. *
  357. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  358. *
  359. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  360. * F90 = metallicReflectanceColor;
  361. * @internal
  362. */
  363. _metallicF0Factor: number;
  364. /**
  365. * In metallic workflow, specifies an F0 color.
  366. * By default the F90 is always 1;
  367. *
  368. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  369. *
  370. * F0 = defaultF0_from_IOR * metallicF0Factor * metallicReflectanceColor
  371. * F90 = metallicF0Factor;
  372. * @internal
  373. */
  374. _metallicReflectanceColor: Color3;
  375. /**
  376. * Specifies that only the A channel from _metallicReflectanceTexture should be used.
  377. * If false, both RGB and A channels will be used
  378. * @internal
  379. */
  380. _useOnlyMetallicFromMetallicReflectanceTexture: boolean;
  381. /**
  382. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  383. * This is multiply against the scalar values defined in the material.
  384. * @internal
  385. */
  386. _metallicReflectanceTexture: Nullable<BaseTexture>;
  387. /**
  388. * Defines to store reflectanceColor in RGB
  389. * This is multiplied against the scalar values defined in the material.
  390. * If both _reflectanceTexture and _metallicReflectanceTexture textures are provided and _useOnlyMetallicFromMetallicReflectanceTexture
  391. * is false, _metallicReflectanceTexture takes precedence and _reflectanceTexture is not used
  392. * @internal
  393. */
  394. _reflectanceTexture: Nullable<BaseTexture>;
  395. /**
  396. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  397. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  398. * @internal
  399. */
  400. _microSurfaceTexture: Nullable<BaseTexture>;
  401. /**
  402. * Stores surface normal data used to displace a mesh in a texture.
  403. * @internal
  404. */
  405. _bumpTexture: Nullable<BaseTexture>;
  406. /**
  407. * Stores the pre-calculated light information of a mesh in a texture.
  408. * @internal
  409. */
  410. _lightmapTexture: Nullable<BaseTexture>;
  411. /**
  412. * The color of a material in ambient lighting.
  413. * @internal
  414. */
  415. _ambientColor: Color3;
  416. /**
  417. * AKA Diffuse Color in other nomenclature.
  418. * @internal
  419. */
  420. _albedoColor: Color3;
  421. /**
  422. * AKA Specular Color in other nomenclature.
  423. * @internal
  424. */
  425. _reflectivityColor: Color3;
  426. /**
  427. * The color applied when light is reflected from a material.
  428. * @internal
  429. */
  430. _reflectionColor: Color3;
  431. /**
  432. * The color applied when light is emitted from a material.
  433. * @internal
  434. */
  435. _emissiveColor: Color3;
  436. /**
  437. * AKA Glossiness in other nomenclature.
  438. * @internal
  439. */
  440. _microSurface: number;
  441. /**
  442. * Specifies that the material will use the light map as a show map.
  443. * @internal
  444. */
  445. _useLightmapAsShadowmap: boolean;
  446. /**
  447. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  448. * makes the reflect vector face the model (under horizon).
  449. * @internal
  450. */
  451. _useHorizonOcclusion: boolean;
  452. /**
  453. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  454. * too much the area relying on ambient texture to define their ambient occlusion.
  455. * @internal
  456. */
  457. _useRadianceOcclusion: boolean;
  458. /**
  459. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  460. * @internal
  461. */
  462. _useAlphaFromAlbedoTexture: boolean;
  463. /**
  464. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  465. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  466. * @internal
  467. */
  468. _useSpecularOverAlpha: boolean;
  469. /**
  470. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  471. * @internal
  472. */
  473. _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  474. /**
  475. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  476. * @internal
  477. */
  478. _useRoughnessFromMetallicTextureAlpha: boolean;
  479. /**
  480. * Specifies if the metallic texture contains the roughness information in its green channel.
  481. * @internal
  482. */
  483. _useRoughnessFromMetallicTextureGreen: boolean;
  484. /**
  485. * Specifies if the metallic texture contains the metallness information in its blue channel.
  486. * @internal
  487. */
  488. _useMetallnessFromMetallicTextureBlue: boolean;
  489. /**
  490. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  491. * @internal
  492. */
  493. _useAmbientOcclusionFromMetallicTextureRed: boolean;
  494. /**
  495. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  496. * @internal
  497. */
  498. _useAmbientInGrayScale: boolean;
  499. /**
  500. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  501. * The material will try to infer what glossiness each pixel should be.
  502. * @internal
  503. */
  504. _useAutoMicroSurfaceFromReflectivityMap: boolean;
  505. /**
  506. * Defines the falloff type used in this material.
  507. * It by default is Physical.
  508. * @internal
  509. */
  510. _lightFalloff: number;
  511. /**
  512. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  513. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  514. * @internal
  515. */
  516. _useRadianceOverAlpha: boolean;
  517. /**
  518. * Allows using an object space normal map (instead of tangent space).
  519. * @internal
  520. */
  521. _useObjectSpaceNormalMap: boolean;
  522. /**
  523. * Allows using the bump map in parallax mode.
  524. * @internal
  525. */
  526. _useParallax: boolean;
  527. /**
  528. * Allows using the bump map in parallax occlusion mode.
  529. * @internal
  530. */
  531. _useParallaxOcclusion: boolean;
  532. /**
  533. * Controls the scale bias of the parallax mode.
  534. * @internal
  535. */
  536. _parallaxScaleBias: number;
  537. /**
  538. * If sets to true, disables all the lights affecting the material.
  539. * @internal
  540. */
  541. _disableLighting: boolean;
  542. /**
  543. * Number of Simultaneous lights allowed on the material.
  544. * @internal
  545. */
  546. _maxSimultaneousLights: number;
  547. /**
  548. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  549. * @internal
  550. */
  551. _invertNormalMapX: boolean;
  552. /**
  553. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  554. * @internal
  555. */
  556. _invertNormalMapY: boolean;
  557. /**
  558. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  559. * @internal
  560. */
  561. _twoSidedLighting: boolean;
  562. /**
  563. * Defines the alpha limits in alpha test mode.
  564. * @internal
  565. */
  566. _alphaCutOff: number;
  567. /**
  568. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  569. * @internal
  570. */
  571. _forceAlphaTest: boolean;
  572. /**
  573. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  574. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  575. * @internal
  576. */
  577. _useAlphaFresnel: boolean;
  578. /**
  579. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  580. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  581. * @internal
  582. */
  583. _useLinearAlphaFresnel: boolean;
  584. /**
  585. * Specifies the environment BRDF texture used to compute the scale and offset roughness values
  586. * from cos theta and roughness:
  587. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  588. * @internal
  589. */
  590. _environmentBRDFTexture: Nullable<BaseTexture>;
  591. /**
  592. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  593. * @internal
  594. */
  595. _forceIrradianceInFragment: boolean;
  596. private _realTimeFiltering;
  597. /**
  598. * Enables realtime filtering on the texture.
  599. */
  600. get realTimeFiltering(): boolean;
  601. set realTimeFiltering(b: boolean);
  602. private _realTimeFilteringQuality;
  603. /**
  604. * Quality switch for realtime filtering
  605. */
  606. get realTimeFilteringQuality(): number;
  607. set realTimeFilteringQuality(n: number);
  608. /**
  609. * Can this material render to several textures at once
  610. */
  611. get canRenderToMRT(): boolean;
  612. /**
  613. * Force normal to face away from face.
  614. * @internal
  615. */
  616. _forceNormalForward: boolean;
  617. /**
  618. * Enables specular anti aliasing in the PBR shader.
  619. * It will both interacts on the Geometry for analytical and IBL lighting.
  620. * It also prefilter the roughness map based on the bump values.
  621. * @internal
  622. */
  623. _enableSpecularAntiAliasing: boolean;
  624. /**
  625. * Default configuration related to image processing available in the PBR Material.
  626. */
  627. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  628. /**
  629. * Keep track of the image processing observer to allow dispose and replace.
  630. */
  631. private _imageProcessingObserver;
  632. /**
  633. * Attaches a new image processing configuration to the PBR Material.
  634. * @param configuration
  635. */
  636. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  637. /**
  638. * Stores the available render targets.
  639. */
  640. private _renderTargets;
  641. /**
  642. * Sets the global ambient color for the material used in lighting calculations.
  643. */
  644. private _globalAmbientColor;
  645. /**
  646. * If set to true, no lighting calculations will be applied.
  647. */
  648. private _unlit;
  649. /**
  650. * If sets to true, the decal map will be applied after the detail map. Else, it is applied before (default: false)
  651. */
  652. private _applyDecalMapAfterDetailMap;
  653. private _debugMode;
  654. /**
  655. * @internal
  656. * This is reserved for the inspector.
  657. * Defines the material debug mode.
  658. * It helps seeing only some components of the material while troubleshooting.
  659. */
  660. debugMode: number;
  661. /**
  662. * @internal
  663. * This is reserved for the inspector.
  664. * Specify from where on screen the debug mode should start.
  665. * The value goes from -1 (full screen) to 1 (not visible)
  666. * It helps with side by side comparison against the final render
  667. * This defaults to -1
  668. */
  669. debugLimit: number;
  670. /**
  671. * @internal
  672. * This is reserved for the inspector.
  673. * As the default viewing range might not be enough (if the ambient is really small for instance)
  674. * You can use the factor to better multiply the final value.
  675. */
  676. debugFactor: number;
  677. /**
  678. * Defines the clear coat layer parameters for the material.
  679. */
  680. readonly clearCoat: PBRClearCoatConfiguration;
  681. /**
  682. * Defines the iridescence layer parameters for the material.
  683. */
  684. readonly iridescence: PBRIridescenceConfiguration;
  685. /**
  686. * Defines the anisotropic parameters for the material.
  687. */
  688. readonly anisotropy: PBRAnisotropicConfiguration;
  689. /**
  690. * Defines the BRDF parameters for the material.
  691. */
  692. readonly brdf: PBRBRDFConfiguration;
  693. /**
  694. * Defines the Sheen parameters for the material.
  695. */
  696. readonly sheen: PBRSheenConfiguration;
  697. /**
  698. * Defines the SubSurface parameters for the material.
  699. */
  700. readonly subSurface: PBRSubSurfaceConfiguration;
  701. /**
  702. * Defines additional PrePass parameters for the material.
  703. */
  704. readonly prePassConfiguration: PrePassConfiguration;
  705. /**
  706. * Defines the detail map parameters for the material.
  707. */
  708. readonly detailMap: DetailMapConfiguration;
  709. protected _cacheHasRenderTargetTextures: boolean;
  710. /**
  711. * Instantiates a new PBRMaterial instance.
  712. *
  713. * @param name The material name
  714. * @param scene The scene the material will be use in.
  715. */
  716. constructor(name: string, scene?: Scene);
  717. /**
  718. * Gets a boolean indicating that current material needs to register RTT
  719. */
  720. get hasRenderTargetTextures(): boolean;
  721. /**
  722. * Can this material render to prepass
  723. */
  724. get isPrePassCapable(): boolean;
  725. /**
  726. * @returns the name of the material class.
  727. */
  728. getClassName(): string;
  729. /**
  730. * Returns true if alpha blending should be disabled.
  731. */
  732. protected get _disableAlphaBlending(): boolean;
  733. /**
  734. * @returns whether or not this material should be rendered in alpha blend mode.
  735. */
  736. needAlphaBlending(): boolean;
  737. /**
  738. * @returns whether or not this material should be rendered in alpha test mode.
  739. */
  740. needAlphaTesting(): boolean;
  741. /**
  742. * @returns whether or not the alpha value of the albedo texture should be used for alpha blending.
  743. */
  744. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  745. /**
  746. * @returns whether or not there is a usable alpha channel for transparency.
  747. */
  748. protected _hasAlphaChannel(): boolean;
  749. /**
  750. * @returns the texture used for the alpha test.
  751. */
  752. getAlphaTestTexture(): Nullable<BaseTexture>;
  753. /**
  754. * Specifies that the submesh is ready to be used.
  755. * @param mesh - BJS mesh.
  756. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  757. * @param useInstances - Specifies that instances should be used.
  758. * @returns - boolean indicating that the submesh is ready or not.
  759. */
  760. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  761. /**
  762. * Specifies if the material uses metallic roughness workflow.
  763. * @returns boolean specifying if the material uses metallic roughness workflow.
  764. */
  765. isMetallicWorkflow(): boolean;
  766. private _prepareEffect;
  767. private _prepareDefines;
  768. /**
  769. * Force shader compilation
  770. * @param mesh - Define the mesh we want to force the compilation for
  771. * @param onCompiled - Define a callback triggered when the compilation completes
  772. * @param options - Define the options used to create the compilation
  773. */
  774. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  775. /**
  776. * Initializes the uniform buffer layout for the shader.
  777. */
  778. buildUniformLayout(): void;
  779. /**
  780. * Binds the submesh data.
  781. * @param world - The world matrix.
  782. * @param mesh - The BJS mesh.
  783. * @param subMesh - A submesh of the BJS mesh.
  784. */
  785. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  786. /**
  787. * Returns the animatable textures.
  788. * If material have animatable metallic texture, then reflectivity texture will not be returned, even if it has animations.
  789. * @returns - Array of animatable textures.
  790. */
  791. getAnimatables(): IAnimatable[];
  792. /**
  793. * Returns the texture used for reflections.
  794. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  795. */
  796. private _getReflectionTexture;
  797. /**
  798. * Returns an array of the actively used textures.
  799. * @returns - Array of BaseTextures
  800. */
  801. getActiveTextures(): BaseTexture[];
  802. /**
  803. * Checks to see if a texture is used in the material.
  804. * @param texture - Base texture to use.
  805. * @returns - Boolean specifying if a texture is used in the material.
  806. */
  807. hasTexture(texture: BaseTexture): boolean;
  808. /**
  809. * Sets the required values to the prepass renderer.
  810. * It can't be sets when subsurface scattering of this material is disabled.
  811. * When scene have ability to enable subsurface prepass effect, it will enable.
  812. * @returns - If prepass is enabled or not.
  813. */
  814. setPrePassRenderer(): boolean;
  815. /**
  816. * Disposes the resources of the material.
  817. * @param forceDisposeEffect - Forces the disposal of effects.
  818. * @param forceDisposeTextures - Forces the disposal of all textures.
  819. */
  820. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  821. }