Class: Shader

PIXI. Shader

new PIXI.Shader(shaderManager, vertexSrc, fragmentSrc, uniforms, attributes)

Base shader class for PIXI managed shaders.

Name Type Description
shaderManager PIXI.ShaderManager

The webgl shader manager this shader works for.

vertexSrc string optional

The source of the vertex shader.

fragmentSrc string optional

The source of the fragment shader.

uniforms object optional

Uniforms for this shader.

attributes object optional

Attributes for this shader.

Members

fragmentSrcstring

The fragment shader as an array of strings

readonlyglWebGLRenderingContext

The current WebGL drawing context

readonlyprogramWebGLProgram

The WebGL program.

readonlyuidnumber

A unique id

vertexSrcstring

The vertex shader as an array of strings

Methods

cacheAttributeLocations(keys)

Caches the locations of the attribute for reuse.

Name Type Description
keys string

the attributes to cache

cacheUniformLocations(keys)

Caches the locations of the uniform for reuse.

Name Type Description
keys string

the uniforms to cache

Attaches the shaders and creates the program.

Returns:
Type Description
WebGLProgram

Destroys the shader.

Creates the shader and uses it

Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded)

Adds a new uniform

Name Type Description
uniform object

the new uniform to attach

Updates the shader uniform values.