Shader

Shader

A shader class to assist in compiling and linking webgl shaders, storing attribute and uniform locations, and buffering uniforms.

Constructor

new Shader(spec, callback)

Instantiates a Shader object.
Source:
Parameters:
Name Type Description
spec Object The shader specification object.
Name Type Description
common String | Array.<String> | Object Sources / URLs to be shared by both vertex and fragment shaders.
vert String | Array.<String> | Object The vertex shader sources / URLs.
frag String | Array.<String> | Object The fragment shader sources / URLs.
define Object Any `#define` definitions to be injected into the glsl.
attributes Array.<String> The attribute index orderings.
callback function The callback function to execute once the shader has been successfully compiled and linked.

Methods

setUniform(name, value) → {Shader}

Buffer a uniform value by name.
Source:
Parameters:
Name Type Description
name string The uniform name in the shader source.
value * The uniform value to buffer.
Returns:
Type:
Shader
- The shader object, for chaining.

setUniforms(uniforms) → {Shader}

Buffer a map of uniform values.
Source:
Parameters:
Name Type Description
uniforms Object The map of uniforms keyed by name.
Returns:
Type:
Shader
The shader object, for chaining.

use() → {Shader}

Binds the shader program for use.
Source:
Returns:
Type:
Shader
The shader object, for chaining.