@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
296 lines (295 loc) • 17 kB
TypeScript
import type { Scene } from "../scene.js";
import type { Effect, IEffectCreationOptions } from "./effect.js";
import type { AbstractMesh } from "../Meshes/abstractMesh.js";
import type { UniformBuffer } from "./uniformBuffer.js";
import type { BaseTexture } from "./Textures/baseTexture.js";
import type { PrePassConfiguration } from "./prePassConfiguration.js";
import type { Light } from "../Lights/light.js";
import type { MaterialDefines } from "./materialDefines.js";
import type { EffectFallbacks } from "./effectFallbacks.js";
import type { AbstractEngine } from "../Engines/abstractEngine.js";
import type { Material } from "./material.js";
import type { Nullable } from "../types.js";
import type { MorphTargetManager } from "../Morph/morphTargetManager.js";
/**
* Binds the logarithmic depth information from the scene to the effect for the given defines.
* @param defines The generated defines used in the effect
* @param effect The effect we are binding the data to
* @param scene The scene we are willing to render with logarithmic scale for
*/
export declare function BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
/**
* Binds the fog information from the scene to the effect for the given mesh.
* @param scene The scene the lights belongs to
* @param mesh The mesh we are binding the information to render
* @param effect The effect we are binding the data to
* @param linearSpace Defines if the fog effect is applied in linear space
*/
export declare function BindFogParameters(scene: Scene, mesh?: AbstractMesh, effect?: Effect, linearSpace?: boolean): void;
/**
* Prepares the list of attributes and defines required for morph targets.
* @param morphTargetManager The manager for the morph targets
* @param defines The current list of defines
* @param attribs The current list of attributes
* @param mesh The mesh to prepare the defines and attributes for
* @param usePositionMorph Whether the position morph target is used
* @param useNormalMorph Whether the normal morph target is used
* @param useTangentMorph Whether the tangent morph target is used
* @param useUVMorph Whether the UV morph target is used
* @param useUV2Morph Whether the UV2 morph target is used
* @param useColorMorph Whether the color morph target is used
* @returns The maxSimultaneousMorphTargets for the effect
*/
export declare function PrepareDefinesAndAttributesForMorphTargets(morphTargetManager: MorphTargetManager, defines: string[], attribs: string[], mesh: AbstractMesh, usePositionMorph: boolean, useNormalMorph: boolean, useTangentMorph: boolean, useUVMorph: boolean, useUV2Morph: boolean, useColorMorph: boolean): number;
/**
* Prepares the list of attributes required for morph targets according to the effect defines.
* @param attribs The current list of supported attribs
* @param mesh The mesh to prepare the morph targets attributes for
* @param influencers The number of influencers
*/
export declare function PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
/**
* Prepares the list of attributes required for morph targets according to the effect defines.
* @param attribs The current list of supported attribs
* @param mesh The mesh to prepare the morph targets attributes for
* @param defines The current Defines of the effect
* @param usePositionMorph Whether the position morph target is used
*/
export declare function PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any, usePositionMorph?: boolean): void;
/**
* Add the list of attributes required for instances to the attribs array.
* @param attribs The current list of supported attribs
* @param needsPreviousMatrices If the shader needs previous matrices
*/
export declare function PushAttributesForInstances(attribs: string[], needsPreviousMatrices?: boolean): void;
/**
* Binds the morph targets information from the mesh to the effect.
* @param abstractMesh The mesh we are binding the information to render
* @param effect The effect we are binding the data to
*/
export declare function BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
/**
* Binds the scene's uniform buffer to the effect.
* @param effect defines the effect to bind to the scene uniform buffer
* @param sceneUbo defines the uniform buffer storing scene data
*/
export declare function BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
/**
* Helps preparing the defines values about the UVs in used in the effect.
* UVs are shared as much as we can across channels in the shaders.
* @param texture The texture we are preparing the UVs for
* @param defines The defines to update
* @param key The channel key "diffuse", "specular"... used in the shader
*/
export declare function PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
/**
* Binds a texture matrix value to its corresponding uniform
* @param texture The texture to bind the matrix for
* @param uniformBuffer The uniform buffer receiving the data
* @param key The channel key "diffuse", "specular"... used in the shader
*/
export declare function BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
/**
* Prepares the list of attributes required for baked vertex animations according to the effect defines.
* @param attribs The current list of supported attribs
* @param mesh The mesh to prepare for baked vertex animations
* @param defines The current Defines of the effect
*/
export declare function PrepareAttributesForBakedVertexAnimation(attribs: string[], mesh: AbstractMesh, defines: any): void;
/**
* Binds the bones information from the mesh to the effect.
* @param mesh The mesh we are binding the information to render
* @param effect The effect we are binding the data to
* @param prePassConfiguration Configuration for the prepass, in case prepass is activated
*/
export declare function BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
/**
* Binds the light information to the effect.
* @param light The light containing the generator
* @param effect The effect we are binding the data to
* @param lightIndex The light index in the effect used to render
*/
export declare function BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
/**
* Binds the lights information from the scene to the effect for the given mesh.
* @param light Light to bind
* @param lightIndex Light index
* @param scene The scene where the light belongs to
* @param effect The effect we are binding the data to
* @param useSpecular Defines if specular is supported
* @param receiveShadows Defines if the effect (mesh) we bind the light for receives shadows
*/
export declare function BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, receiveShadows?: boolean): void;
/**
* Binds the lights information from the scene to the effect for the given mesh.
* @param scene The scene the lights belongs to
* @param mesh The mesh we are binding the information to render
* @param effect The effect we are binding the data to
* @param defines The generated defines for the effect
* @param maxSimultaneousLights The maximum number of light that can be bound to the effect
*/
export declare function BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number): void;
/**
* Prepares the list of attributes required for bones according to the effect defines.
* @param attribs The current list of supported attribs
* @param mesh The mesh to prepare the bones attributes for
* @param defines The current Defines of the effect
* @param fallbacks The current effect fallback strategy
*/
export declare function PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
/**
* Check and prepare the list of attributes required for instances according to the effect defines.
* @param attribs The current list of supported attribs
* @param defines The current MaterialDefines of the effect
*/
export declare function PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
/**
* This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
* @param defines The defines to update while falling back
* @param fallbacks The authorized effect fallbacks
* @param maxSimultaneousLights The maximum number of lights allowed
* @param rank the current rank of the Effect
* @returns The newly affected rank
*/
export declare function HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
/**
* Gets the current status of the fog (should it be enabled?)
* @param mesh defines the mesh to evaluate for fog support
* @param scene defines the hosting scene
* @returns true if fog must be enabled
*/
export declare function GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
/**
* Helper used to prepare the list of defines associated with misc. values for shader compilation
* @param mesh defines the current mesh
* @param scene defines the current scene
* @param useLogarithmicDepth defines if logarithmic depth has to be turned on
* @param pointsCloud defines if point cloud rendering has to be turned on
* @param fogEnabled defines if fog has to be turned on
* @param alphaTest defines if alpha testing has to be turned on
* @param defines defines the current list of defines
* @param applyDecalAfterDetail Defines if the decal is applied after or before the detail
* @param useVertexPulling Defines if vertex pulling is used
* @param renderingMesh The mesh used for rendering
*/
export declare function PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any, applyDecalAfterDetail?: boolean, useVertexPulling?: boolean, renderingMesh?: AbstractMesh): void;
/**
* Prepares the defines related to the light information passed in parameter
* @param scene The scene we are intending to draw
* @param mesh The mesh the effect is compiling for
* @param defines The defines to update
* @param specularSupported Specifies whether specular is supported or not (override lights data)
* @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
* @param disableLighting Specifies whether the lighting is disabled (override scene and light)
* @returns true if normals will be required for the rest of the effect
*/
export declare function PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
/**
* Prepares the defines related to the light information passed in parameter
* @param scene The scene we are intending to draw
* @param mesh The mesh the effect is compiling for
* @param light The light the effect is compiling for
* @param lightIndex The index of the light
* @param defines The defines to update
* @param specularSupported Specifies whether specular is supported or not (override lights data)
* @param state Defines the current state regarding what is needed (normals, etc...)
* @param state.needNormals
* @param state.needRebuild
* @param state.shadowEnabled
* @param state.specularEnabled
* @param state.lightmapMode
*/
export declare function PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
needNormals: boolean;
needRebuild: boolean;
shadowEnabled: boolean;
specularEnabled: boolean;
lightmapMode: boolean;
}): void;
/**
* Helper used to prepare the list of defines associated with frame values for shader compilation
* @param scene defines the current scene
* @param engine defines the current engine
* @param material defines the material we are compiling the shader for
* @param defines specifies the list of active defines
* @param useInstances defines if instances have to be turned on
* @param useClipPlane defines if clip plane have to be turned on
* @param useThinInstances defines if thin instances have to be turned on
*/
export declare function PrepareDefinesForFrameBoundValues(scene: Scene, engine: AbstractEngine, material: Material, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
/**
* Prepares the defines for bones
* @param mesh The mesh containing the geometry data we will draw
* @param defines The defines to update
*/
export declare function PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
/**
* Prepares the defines for morph targets
* @param mesh The mesh containing the geometry data we will draw
* @param defines The defines to update
*/
export declare function PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
/**
* Prepares the defines for baked vertex animation
* @param mesh The mesh containing the geometry data we will draw
* @param defines The defines to update
*/
export declare function PrepareDefinesForBakedVertexAnimation(mesh: AbstractMesh, defines: any): void;
/**
* Prepares the defines used in the shader depending on the attributes data available in the mesh
* @param mesh The mesh containing the geometry data we will draw
* @param defines The defines to update
* @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
* @param useBones Precise whether bones should be used or not (override mesh info)
* @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
* @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
* @param useBakedVertexAnimation Precise whether baked vertex animation should be used or not (override mesh info)
* @returns false if defines are considered not dirty and have not been checked
*/
export declare function PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean, useBakedVertexAnimation?: boolean): boolean;
/**
* Prepares the defines related to multiview
* @param scene The scene we are intending to draw
* @param defines The defines to update
*/
export declare function PrepareDefinesForMultiview(scene: Scene, defines: any): void;
/**
* Prepares the defines related to order independant transparency
* @param scene The scene we are intending to draw
* @param defines The defines to update
* @param needAlphaBlending Determines if the material needs alpha blending
*/
export declare function PrepareDefinesForOIT(scene: Scene, defines: any, needAlphaBlending: boolean): void;
/**
* Prepares the defines related to the prepass
* @param scene The scene we are intending to draw
* @param defines The defines to update
* @param canRenderToMRT Indicates if this material renders to several textures in the prepass
*/
export declare function PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
/**
* Helper used to prepare the defines relative to the active camera
* @param scene defines the current scene
* @param defines specifies the list of active defines
* @returns true if the defines have been updated, else false
*/
export declare function PrepareDefinesForCamera(scene: Scene, defines: any): boolean;
/**
* Prepares the uniforms and samplers list to be used in the effect (for a specific light)
* @param lightIndex defines the light index
* @param uniformsList The uniform list
* @param samplersList The sampler list
* @param projectedLightTexture defines if projected texture must be used
* @param uniformBuffersList defines an optional list of uniform buffers
* @param updateOnlyBuffersList True to only update the uniformBuffersList array
* @param iesLightTexture defines if IES texture must be used
*/
export declare function PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean, iesLightTexture?: boolean): void;
/**
* Prepares the uniforms and samplers list to be used in the effect
* @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
* @param samplersList The sampler list
* @param defines The defines helping in the list generation
* @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
*/
export declare function PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;