Class MaterialHelper
Hierarchy
- MaterialHelper
Index
Methods
- Bind
Bones Parameters - Bind
Clip Plane - Bind
Eye Position - Bind
Fog Parameters - Bind
Light - Bind
Light Properties - Bind
Lights - Bind
Log Depth - Bind
Morph Target Parameters - Bind
Texture Matrix - Get
Fog State - Handle
Fallbacks For Shadows - Prepare
Attributes For Bones - Prepare
Attributes For Instances - Prepare
Attributes For Morph Targets - Prepare
Attributes For Morph Targets Influencers - Prepare
Defines For Attributes - Prepare
Defines For Bones - Prepare
Defines For Frame Bound Values - Prepare
Defines For Light - Prepare
Defines For Lights - Prepare
Defines For MergedUV - Prepare
Defines For Misc - Prepare
Defines For Morph Targets - Prepare
Defines For Multiview - Prepare
Defines For Pre Pass - Prepare
Uniforms And Samplers For Light - Prepare
Uniforms And Samplers List - Push
Attributes For Instances
Methods
Static Bind Bones ParametersSearch playground for BindBonesParameters
-
Binds the bones information from the mesh to the effect.
Parameters
-
Optional mesh: AbstractMesh
The mesh we are binding the information to render
-
Optional effect: Effect
The effect we are binding the data to
-
Optional prePassConfiguration: PrePassConfiguration
Configuration for the prepass, in case prepass is activated
Returns void
-
Static Bind Clip PlaneSearch playground for BindClipPlane
Static Bind Eye PositionSearch playground for BindEyePosition
-
Bind the current view position to an effect.
Parameters
-
effect: Nullable<Effect>
The effect to be bound
-
scene: Scene
The scene the eyes position is used from
-
Optional variableName: string
name of the shader variable that will hold the eye position
-
Optional isVector3: boolean
true to indicates that variableName is a Vector3 and not a Vector4
Returns Vector4
the computed eye position
-
Static Bind Fog ParametersSearch playground for BindFogParameters
-
Binds the fog information from the scene to the effect for the given mesh.
Parameters
-
scene: Scene
The scene the lights belongs to
-
mesh: AbstractMesh
The mesh we are binding the information to render
-
effect: Effect
The effect we are binding the data to
-
Optional linearSpace: boolean
Defines if the fog effect is applied in linear space
Returns void
-
Static Bind LightSearch playground for BindLight
-
Binds the lights information from the scene to the effect for the given mesh.
Parameters
-
light: Light
Light to bind
-
lightIndex: number
Light index
-
scene: Scene
The scene where the light belongs to
-
effect: Effect
The effect we are binding the data to
-
useSpecular: boolean
Defines if specular is supported
-
Optional rebuildInParallel: boolean
Specifies whether the shader is rebuilding in parallel
Returns void
-
Static Bind Light PropertiesSearch playground for BindLightProperties
Static Bind LightsSearch playground for BindLights
-
Binds the lights information from the scene to the effect for the given mesh.
Parameters
-
scene: Scene
The scene the lights belongs to
-
mesh: AbstractMesh
The mesh we are binding the information to render
-
effect: Effect
The effect we are binding the data to
-
defines: any
The generated defines for the effect
-
Optional maxSimultaneousLights: number
The maximum number of light that can be bound to the effect
-
Optional rebuildInParallel: boolean
Specifies whether the shader is rebuilding in parallel
Returns void
-
Static Bind Log DepthSearch playground for BindLogDepth
Static Bind Morph Target ParametersSearch playground for BindMorphTargetParameters
-
Binds the morph targets information from the mesh to the effect.
Parameters
-
abstractMesh: AbstractMesh
The mesh we are binding the information to render
-
effect: Effect
The effect we are binding the data to
Returns void
-
Static Bind Texture MatrixSearch playground for BindTextureMatrix
-
Binds a texture matrix value to its corrsponding uniform
Parameters
-
texture: BaseTexture
The texture to bind the matrix for
-
uniformBuffer: UniformBuffer
The uniform buffer receivin the data
-
key: string
The channel key "diffuse", "specular"... used in the shader
Returns void
-
Static Get Fog StateSearch playground for GetFogState
-
Gets the current status of the fog (should it be enabled?)
Parameters
-
mesh: AbstractMesh
defines the mesh to evaluate for fog support
-
scene: Scene
defines the hosting scene
Returns boolean
true if fog must be enabled
-
Static Handle Fallbacks For ShadowsSearch playground for HandleFallbacksForShadows
-
This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
Parameters
-
defines: any
The defines to update while falling back
-
fallbacks: EffectFallbacks
The authorized effect fallbacks
-
Optional maxSimultaneousLights: number
The maximum number of lights allowed
-
Optional rank: number
the current rank of the Effect
Returns number
The newly affected rank
-
Static Prepare Attributes For BonesSearch playground for PrepareAttributesForBones
-
Prepares the list of attributes required for bones according to the effect defines.
Parameters
-
attribs: string[]
The current list of supported attribs
-
mesh: AbstractMesh
The mesh to prepare the bones attributes for
-
defines: any
The current Defines of the effect
-
fallbacks: EffectFallbacks
The current efffect fallback strategy
Returns void
-
Static Prepare Attributes For InstancesSearch playground for PrepareAttributesForInstances
-
Check and prepare the list of attributes required for instances according to the effect defines.
Parameters
-
attribs: string[]
The current list of supported attribs
-
defines: MaterialDefines
The current MaterialDefines of the effect
Returns void
-
Static Prepare Attributes For Morph TargetsSearch playground for PrepareAttributesForMorphTargets
-
Prepares the list of attributes required for morph targets according to the effect defines.
Parameters
-
attribs: string[]
The current list of supported attribs
-
mesh: AbstractMesh
The mesh to prepare the morph targets attributes for
-
defines: any
The current Defines of the effect
Returns void
-
Static Prepare Attributes For Morph Targets InfluencersSearch playground for PrepareAttributesForMorphTargetsInfluencers
-
Prepares the list of attributes required for morph targets according to the effect defines.
Parameters
-
attribs: string[]
The current list of supported attribs
-
mesh: AbstractMesh
The mesh to prepare the morph targets attributes for
-
influencers: number
The number of influencers
Returns void
-
Static Prepare Defines For AttributesSearch playground for PrepareDefinesForAttributes
-
Prepares the defines used in the shader depending on the attributes data available in the mesh
Parameters
-
mesh: AbstractMesh
The mesh containing the geometry data we will draw
-
defines: any
The defines to update
-
useVertexColor: boolean
Precise whether vertex colors should be used or not (override mesh info)
-
useBones: boolean
Precise whether bones should be used or not (override mesh info)
-
Optional useMorphTargets: boolean
Precise whether morph targets should be used or not (override mesh info)
-
Optional useVertexAlpha: boolean
Precise whether vertex alpha should be used or not (override mesh info)
Returns boolean
false if defines are considered not dirty and have not been checked
-
Static Prepare Defines For BonesSearch playground for PrepareDefinesForBones
-
Prepares the defines for bones
Parameters
-
mesh: AbstractMesh
The mesh containing the geometry data we will draw
-
defines: any
The defines to update
Returns void
-
Static Prepare Defines For Frame Bound ValuesSearch playground for PrepareDefinesForFrameBoundValues
-
Helper used to prepare the list of defines associated with frame values for shader compilation
Parameters
-
scene: Scene
defines the current scene
-
engine: Engine
defines the current engine
-
defines: any
specifies the list of active defines
-
useInstances: boolean
defines if instances have to be turned on
-
Optional useClipPlane: Nullable<boolean>
defines if clip plane have to be turned on
-
Optional useThinInstances: boolean
defines if thin instances have to be turned on
Returns void
-
Static Prepare Defines For LightSearch playground for PrepareDefinesForLight
-
Prepares the defines related to the light information passed in parameter
Parameters
-
scene: Scene
The scene we are intending to draw
-
mesh: AbstractMesh
The mesh the effect is compiling for
-
light: Light
The light the effect is compiling for
-
lightIndex: number
The index of the light
-
defines: any
The defines to update
-
specularSupported: boolean
Specifies whether specular is supported or not (override lights data)
-
state: { lightmapMode: boolean; needNormals: boolean; needRebuild: boolean; shadowEnabled: boolean; specularEnabled: boolean }
Defines the current state regarding what is needed (normals, etc...)
-
lightmap
Mode: boolean -
need
Normals: boolean -
need
Rebuild: boolean -
shadow
Enabled: boolean -
specular
Enabled: boolean
-
Returns void
-
Static Prepare Defines For LightsSearch playground for PrepareDefinesForLights
-
Prepares the defines related to the light information passed in parameter
Parameters
-
scene: Scene
The scene we are intending to draw
-
mesh: AbstractMesh
The mesh the effect is compiling for
-
defines: any
The defines to update
-
specularSupported: boolean
Specifies whether specular is supported or not (override lights data)
-
Optional maxSimultaneousLights: number
Specfies how manuy lights can be added to the effect at max
-
Optional disableLighting: boolean
Specifies whether the lighting is disabled (override scene and light)
Returns boolean
true if normals will be required for the rest of the effect
-
Static Prepare Defines For MergedUVSearch playground for PrepareDefinesForMergedUV
-
Helps preparing the defines values about the UVs in used in the effect. UVs are shared as much as we can accross channels in the shaders.
Parameters
-
texture: BaseTexture
The texture we are preparing the UVs for
-
defines: any
The defines to update
-
key: string
The channel key "diffuse", "specular"... used in the shader
Returns void
-
Static Prepare Defines For MiscSearch playground for PrepareDefinesForMisc
-
Helper used to prepare the list of defines associated with misc. values for shader compilation
Parameters
-
mesh: AbstractMesh
defines the current mesh
-
scene: Scene
defines the current scene
-
useLogarithmicDepth: boolean
defines if logarithmic depth has to be turned on
-
pointsCloud: boolean
defines if point cloud rendering has to be turned on
-
fogEnabled: boolean
defines if fog has to be turned on
-
alphaTest: boolean
defines if alpha testing has to be turned on
-
defines: any
defines the current list of defines
Returns void
-
Static Prepare Defines For Morph TargetsSearch playground for PrepareDefinesForMorphTargets
-
Prepares the defines for morph targets
Parameters
-
mesh: AbstractMesh
The mesh containing the geometry data we will draw
-
defines: any
The defines to update
Returns void
-
Static Prepare Defines For MultiviewSearch playground for PrepareDefinesForMultiview
-
Prepares the defines related to multiview
Parameters
-
scene: Scene
The scene we are intending to draw
-
defines: any
The defines to update
Returns void
-
Static Prepare Defines For Pre PassSearch playground for PrepareDefinesForPrePass
-
Prepares the defines related to the prepass
Parameters
-
scene: Scene
The scene we are intending to draw
-
defines: any
The defines to update
-
canRenderToMRT: boolean
Indicates if this material renders to several textures in the prepass
Returns void
-
Static Prepare Uniforms And Samplers For LightSearch playground for PrepareUniformsAndSamplersForLight
-
Prepares the uniforms and samplers list to be used in the effect (for a specific light)
Parameters
-
lightIndex: number
defines the light index
-
uniformsList: string[]
The uniform list
-
samplersList: string[]
The sampler list
-
Optional projectedLightTexture: any
defines if projected texture must be used
-
Optional uniformBuffersList: Nullable<string[]>
defines an optional list of uniform buffers
-
Optional updateOnlyBuffersList: boolean
True to only update the uniformBuffersList array
Returns void
-
Static Prepare Uniforms And Samplers ListSearch playground for PrepareUniformsAndSamplersList
-
Prepares the uniforms and samplers list to be used in the effect
Parameters
-
uniformsListOrOptions: string[] | IEffectCreationOptions
The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
-
Optional samplersList: string[]
The sampler list
-
Optional defines: any
The defines helping in the list generation
-
Optional maxSimultaneousLights: number
The maximum number of simultanous light allowed in the effect
Returns void
-
Static Push Attributes For InstancesSearch playground for PushAttributesForInstances
-
Add the list of attributes required for instances to the attribs array.
Parameters
-
attribs: string[]
The current list of supported attribs
Returns void
-
"Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.