MaterialHelper

"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.

Hierarchy

  • MaterialHelper

Index

Methods

Static 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

    Returns void

Static BindClipPlane

  • Binds the clip plane information from the scene to the effect.

    Parameters

    • effect: Effect

      The effect we are binding the data to

    • scene: Scene

      The scene the clip plane information are extracted from

    Returns void

Static BindEyePosition

  • Bind the current view position to an effect.

    Parameters

    • effect: Effect

      The effect to be bound

    • scene: Scene

      The scene the eyes position is used from

    Returns void

Static 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

    Returns void

Static BindLightProperties

  • BindLightProperties(light: Light, effect: Effect, lightIndex: number): void
  • Binds the light information to the effect.

    Parameters

    • light: Light

      The light containing the generator

    • effect: Effect

      The effect we are binding the data to

    • lightIndex: number

      The light index in the effect used to render

    Returns void

Static BindLightShadow

  • Binds the light shadow information to the effect for the given mesh.

    Parameters

    • light: Light

      The light containing the generator

    • scene: Scene

      The scene the lights belongs to

    • mesh: AbstractMesh

      The mesh we are binding the information to render

    • lightIndex: string

      The light index in the effect used to render the mesh

    • effect: Effect

      The effect we are binding the data to

    Returns void

Static BindLights

  • BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void
  • 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 usePhysicalLightFalloff: boolean

      Specifies whether the light falloff is defined physically or not

    Returns void

Static BindLogDepth

  • BindLogDepth(defines: any, effect: Effect, scene: Scene): void
  • Binds the logarithmic depth information from the scene to the effect for the given defines.

    Parameters

    • defines: any

      The generated defines used in the effect

    • effect: Effect

      The effect we are binding the data to

    • scene: Scene

      The scene we are willing to render with logarithmic scale for

    Returns void

Static 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 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 chanel key "diffuse", "specular"... used in the shader

    Returns void

Static HandleFallbacksForShadows

  • HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number
  • 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 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 PrepareAttributesForInstances

  • PrepareAttributesForInstances(attribs: string[], defines: any): void
  • Prepares the list of attributes required for instances according to the effect defines.

    Parameters

    • attribs: string[]

      The current list of supported attribs

    • defines: any

      The current Defines of the effect

    Returns void

Static PrepareAttributesForMorphTargets

  • PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void
  • 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 PrepareDefinesForAttributes

  • PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean
  • 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 PrepareDefinesForFrameBoundValues

  • PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void
  • 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

    Returns void

Static PrepareDefinesForLights

  • 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

    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 PrepareDefinesForMergedUV

  • PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void
  • Helps preparing the defines values about the UVs in used in the effect. UVs are shared as much as we can accross chanels in the shaders.

    Parameters

    • texture: BaseTexture

      The texture we are preparing the UVs for

    • defines: any

      The defines to update

    • key: string

      The chanel key "diffuse", "specular"... used in the shader

    Returns void

Static PrepareDefinesForMisc

  • PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void
  • 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 PrepareUniformsAndSamplersList

  • PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void
  • Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms that won t be acctive due to defines being turned off.

    Parameters

    • uniformsListOrOptions: string[] | EffectCreationOptions

      The uniform names to prepare or an EffectCreationOptions containing the liist and extra information

    • Optional samplersList: string[]

      The samplers 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

Generated using TypeDoc