materialHelper.functions.d.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. import type { Scene } from "../scene";
  2. import type { Effect, IEffectCreationOptions } from "./effect";
  3. import type { AbstractMesh } from "../Meshes/abstractMesh";
  4. import type { UniformBuffer } from "./uniformBuffer";
  5. import type { BaseTexture } from "./Textures/baseTexture";
  6. import type { PrePassConfiguration } from "./prePassConfiguration";
  7. import type { Light } from "../Lights/light";
  8. import type { MaterialDefines } from "./materialDefines";
  9. import type { EffectFallbacks } from "./effectFallbacks";
  10. import type { AbstractEngine } from "../Engines/abstractEngine";
  11. import type { Material } from "./material";
  12. import type { Nullable } from "../types";
  13. /**
  14. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  15. * @param defines The generated defines used in the effect
  16. * @param effect The effect we are binding the data to
  17. * @param scene The scene we are willing to render with logarithmic scale for
  18. */
  19. export declare function BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20. /**
  21. * Binds the fog information from the scene to the effect for the given mesh.
  22. * @param scene The scene the lights belongs to
  23. * @param mesh The mesh we are binding the information to render
  24. * @param effect The effect we are binding the data to
  25. * @param linearSpace Defines if the fog effect is applied in linear space
  26. */
  27. export declare function BindFogParameters(scene: Scene, mesh?: AbstractMesh, effect?: Effect, linearSpace?: boolean): void;
  28. /**
  29. * Prepares the list of attributes required for morph targets according to the effect defines.
  30. * @param attribs The current list of supported attribs
  31. * @param mesh The mesh to prepare the morph targets attributes for
  32. * @param influencers The number of influencers
  33. */
  34. export declare function PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  35. /**
  36. * Prepares the list of attributes required for morph targets according to the effect defines.
  37. * @param attribs The current list of supported attribs
  38. * @param mesh The mesh to prepare the morph targets attributes for
  39. * @param defines The current Defines of the effect
  40. */
  41. export declare function PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  42. /**
  43. * Add the list of attributes required for instances to the attribs array.
  44. * @param attribs The current list of supported attribs
  45. * @param needsPreviousMatrices If the shader needs previous matrices
  46. */
  47. export declare function PushAttributesForInstances(attribs: string[], needsPreviousMatrices?: boolean): void;
  48. /**
  49. * Binds the morph targets information from the mesh to the effect.
  50. * @param abstractMesh The mesh we are binding the information to render
  51. * @param effect The effect we are binding the data to
  52. */
  53. export declare function BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  54. /**
  55. * Binds the scene's uniform buffer to the effect.
  56. * @param effect defines the effect to bind to the scene uniform buffer
  57. * @param sceneUbo defines the uniform buffer storing scene data
  58. */
  59. export declare function BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  60. /**
  61. * Helps preparing the defines values about the UVs in used in the effect.
  62. * UVs are shared as much as we can across channels in the shaders.
  63. * @param texture The texture we are preparing the UVs for
  64. * @param defines The defines to update
  65. * @param key The channel key "diffuse", "specular"... used in the shader
  66. */
  67. export declare function PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68. /**
  69. * Binds a texture matrix value to its corresponding uniform
  70. * @param texture The texture to bind the matrix for
  71. * @param uniformBuffer The uniform buffer receiving the data
  72. * @param key The channel key "diffuse", "specular"... used in the shader
  73. */
  74. export declare function BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75. /**
  76. * Prepares the list of attributes required for baked vertex animations according to the effect defines.
  77. * @param attribs The current list of supported attribs
  78. * @param mesh The mesh to prepare for baked vertex animations
  79. * @param defines The current Defines of the effect
  80. */
  81. export declare function PrepareAttributesForBakedVertexAnimation(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82. /**
  83. * Binds the bones information from the mesh to the effect.
  84. * @param mesh The mesh we are binding the information to render
  85. * @param effect The effect we are binding the data to
  86. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  87. */
  88. export declare function BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  89. /**
  90. * Binds the light information to the effect.
  91. * @param light The light containing the generator
  92. * @param effect The effect we are binding the data to
  93. * @param lightIndex The light index in the effect used to render
  94. */
  95. export declare function BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  96. /**
  97. * Binds the lights information from the scene to the effect for the given mesh.
  98. * @param light Light to bind
  99. * @param lightIndex Light index
  100. * @param scene The scene where the light belongs to
  101. * @param effect The effect we are binding the data to
  102. * @param useSpecular Defines if specular is supported
  103. * @param receiveShadows Defines if the effect (mesh) we bind the light for receives shadows
  104. */
  105. export declare function BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, receiveShadows?: boolean): void;
  106. /**
  107. * Binds the lights information from the scene to the effect for the given mesh.
  108. * @param scene The scene the lights belongs to
  109. * @param mesh The mesh we are binding the information to render
  110. * @param effect The effect we are binding the data to
  111. * @param defines The generated defines for the effect
  112. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  113. */
  114. export declare function BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number): void;
  115. /**
  116. * Prepares the list of attributes required for bones according to the effect defines.
  117. * @param attribs The current list of supported attribs
  118. * @param mesh The mesh to prepare the bones attributes for
  119. * @param defines The current Defines of the effect
  120. * @param fallbacks The current effect fallback strategy
  121. */
  122. export declare function PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  123. /**
  124. * Check and prepare the list of attributes required for instances according to the effect defines.
  125. * @param attribs The current list of supported attribs
  126. * @param defines The current MaterialDefines of the effect
  127. */
  128. export declare function PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  129. /**
  130. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  131. * @param defines The defines to update while falling back
  132. * @param fallbacks The authorized effect fallbacks
  133. * @param maxSimultaneousLights The maximum number of lights allowed
  134. * @param rank the current rank of the Effect
  135. * @returns The newly affected rank
  136. */
  137. export declare function HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  138. /**
  139. * Gets the current status of the fog (should it be enabled?)
  140. * @param mesh defines the mesh to evaluate for fog support
  141. * @param scene defines the hosting scene
  142. * @returns true if fog must be enabled
  143. */
  144. export declare function GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  145. /**
  146. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  147. * @param mesh defines the current mesh
  148. * @param scene defines the current scene
  149. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  150. * @param pointsCloud defines if point cloud rendering has to be turned on
  151. * @param fogEnabled defines if fog has to be turned on
  152. * @param alphaTest defines if alpha testing has to be turned on
  153. * @param defines defines the current list of defines
  154. * @param applyDecalAfterDetail Defines if the decal is applied after or before the detail
  155. */
  156. export declare function PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any, applyDecalAfterDetail?: boolean): void;
  157. /**
  158. * Prepares the defines related to the light information passed in parameter
  159. * @param scene The scene we are intending to draw
  160. * @param mesh The mesh the effect is compiling for
  161. * @param defines The defines to update
  162. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  163. * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
  164. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  165. * @returns true if normals will be required for the rest of the effect
  166. */
  167. export declare function PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  168. /**
  169. * Prepares the defines related to the light information passed in parameter
  170. * @param scene The scene we are intending to draw
  171. * @param mesh The mesh the effect is compiling for
  172. * @param light The light the effect is compiling for
  173. * @param lightIndex The index of the light
  174. * @param defines The defines to update
  175. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  176. * @param state Defines the current state regarding what is needed (normals, etc...)
  177. * @param state.needNormals
  178. * @param state.needRebuild
  179. * @param state.shadowEnabled
  180. * @param state.specularEnabled
  181. * @param state.lightmapMode
  182. */
  183. export declare function PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  184. needNormals: boolean;
  185. needRebuild: boolean;
  186. shadowEnabled: boolean;
  187. specularEnabled: boolean;
  188. lightmapMode: boolean;
  189. }): void;
  190. /**
  191. * Helper used to prepare the list of defines associated with frame values for shader compilation
  192. * @param scene defines the current scene
  193. * @param engine defines the current engine
  194. * @param material defines the material we are compiling the shader for
  195. * @param defines specifies the list of active defines
  196. * @param useInstances defines if instances have to be turned on
  197. * @param useClipPlane defines if clip plane have to be turned on
  198. * @param useThinInstances defines if thin instances have to be turned on
  199. */
  200. export declare function PrepareDefinesForFrameBoundValues(scene: Scene, engine: AbstractEngine, material: Material, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  201. /**
  202. * Prepares the defines for bones
  203. * @param mesh The mesh containing the geometry data we will draw
  204. * @param defines The defines to update
  205. */
  206. export declare function PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  207. /**
  208. * Prepares the defines for morph targets
  209. * @param mesh The mesh containing the geometry data we will draw
  210. * @param defines The defines to update
  211. */
  212. export declare function PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  213. /**
  214. * Prepares the defines for baked vertex animation
  215. * @param mesh The mesh containing the geometry data we will draw
  216. * @param defines The defines to update
  217. */
  218. export declare function PrepareDefinesForBakedVertexAnimation(mesh: AbstractMesh, defines: any): void;
  219. /**
  220. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  221. * @param mesh The mesh containing the geometry data we will draw
  222. * @param defines The defines to update
  223. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  224. * @param useBones Precise whether bones should be used or not (override mesh info)
  225. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  226. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  227. * @param useBakedVertexAnimation Precise whether baked vertex animation should be used or not (override mesh info)
  228. * @returns false if defines are considered not dirty and have not been checked
  229. */
  230. export declare function PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean, useBakedVertexAnimation?: boolean): boolean;
  231. /**
  232. * Prepares the defines related to multiview
  233. * @param scene The scene we are intending to draw
  234. * @param defines The defines to update
  235. */
  236. export declare function PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  237. /**
  238. * Prepares the defines related to order independant transparency
  239. * @param scene The scene we are intending to draw
  240. * @param defines The defines to update
  241. * @param needAlphaBlending Determines if the material needs alpha blending
  242. */
  243. export declare function PrepareDefinesForOIT(scene: Scene, defines: any, needAlphaBlending: boolean): void;
  244. /**
  245. * Prepares the defines related to the prepass
  246. * @param scene The scene we are intending to draw
  247. * @param defines The defines to update
  248. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  249. */
  250. export declare function PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  251. /**
  252. * Helper used to prepare the defines relative to the active camera
  253. * @param scene defines the current scene
  254. * @param defines specifies the list of active defines
  255. * @returns true if the defines have been updated, else false
  256. */
  257. export declare function PrepareDefinesForCamera(scene: Scene, defines: any): boolean;
  258. /**
  259. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  260. * @param lightIndex defines the light index
  261. * @param uniformsList The uniform list
  262. * @param samplersList The sampler list
  263. * @param projectedLightTexture defines if projected texture must be used
  264. * @param uniformBuffersList defines an optional list of uniform buffers
  265. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  266. */
  267. export declare function PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  268. /**
  269. * Prepares the uniforms and samplers list to be used in the effect
  270. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
  271. * @param samplersList The sampler list
  272. * @param defines The defines helping in the list generation
  273. * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
  274. */
  275. export declare function PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;