CLASSES
TagsA - Z

ShaderMaterial

Material

Description

class ShaderMaterial extends Material

Constructor

new ShaderMaterial(name, scene, shaderPath, options)

A material using a shader to render a special effect. When you create a ShaderMaterial, you have to specify the DOM element used to store the shaders or the base name of the files where the shaders are. If you choose to use files, you must create a file for each shader and use the following pattern basename.vertex.fx and basename.fragment,.fx. A tutorial abouth ShaderMaterials can be found here : http://blogs.msdn.com/b/eternalcoding/archive/2014/04/17/learning-shaders-create-your-own-shaders-with-babylon-js.aspx

Parameters

Name Type Description
name string Name of the matrix
scene Scene Scene which contain this material
shaderPath any The path to shader files if any

Methods

getClassName() string

needAlphaBlending() boolean

Function to know if material need alpha blending @return boolean True if need alpha blending ; False if not

needAlphaTesting() boolean

Function to know if material need alpha testing @return boolean True if need alpha testing ; False if not

setTexture(name, texture) ShaderMaterial

Set a texture to the material @return ShaderMaterial Return a new shaderMaterial

Parameters

Name Type Description
name string Name of the matrix
texture Texture Texture to set to the material

setTextureArray(name, textures) ShaderMaterial

Parameters

Name Type Description
name string Name of the matrix
textures Texture[]

setFloat(name, value) ShaderMaterial

Set float to the material @return ShaderMaterial Return a new shaderMaterial

Parameters

Name Type Description
name string Name of the matrix
value number The matrix

setFloats(name, value) ShaderMaterial

Set floats to the material @return ShaderMaterial Return a new shaderMaterial

Parameters

Name Type Description
name string Name of the matrix
value number[] The matrix

setColor3(name, value) ShaderMaterial

Set color3 to the material @return ShaderMaterial Return a new shaderMaterial

Parameters

Name Type Description
name string Name of the matrix
value Color3 The matrix

setColor4(name, value) ShaderMaterial

Set color4 to the material @return ShaderMaterial Return a new shaderMaterial

Parameters

Name Type Description
name string Name of the matrix
value Color4 The matrix

setVector2(name, value) ShaderMaterial

Set a vector2 to the material @return ShaderMaterial Return a new shaderMaterial

Parameters

Name Type Description
name string Name of the matrix
value Vector2 The matrix

setVector3(name, value) ShaderMaterial

Set a vector3 to the material

Parameters

Name Type Description
name string Name of the matrix
value Vector3 The matrix

setVector4(name, value) ShaderMaterial

Parameters

Name Type Description
name string Name of the matrix
value Vector4 The matrix

setMatrix(name, value) ShaderMaterial

Set a matrix to the material

Parameters

Name Type Description
name string Name of the matrix
value Matrix The matrix

setMatrix3x3(name, value) ShaderMaterial

Parameters

Name Type Description
name string Name of the matrix
value Float32Array The matrix

setMatrix2x2(name, value) ShaderMaterial

Parameters

Name Type Description
name string Name of the matrix
value Float32Array The matrix

setArray3(name, value) ShaderMaterial

Parameters

Name Type Description
name string Name of the matrix
value number[] The matrix

isReady(mesh, useInstances) boolean

Function to know if the material is ready @return True if the material is ready ; False if not

Parameters

Name Type Description
optional mesh AbstractMesh
optional useInstances boolean

bindOnlyWorldMatrix(world) void

Parameters

Name Type Description
world Matrix Matrix to bind the material

bind(world, mesh) void

Function to bind the material

Parameters

Name Type Description
world Matrix Matrix to bind the material
optional mesh Mesh

clone(name) ShaderMaterial

Parameters

Name Type Description
name string Name of the matrix

dispose(forceDisposeEffect, forceDisposeTextures) void

Parameters

Name Type Description
optional forceDisposeEffect boolean True to force the dispose
optional forceDisposeTextures boolean

serialize() any

static Parse(source, scene, rootUrl) ShaderMaterial

Parameters

Name Type Description
source any
scene Scene Scene which contain this material
rootUrl string