ShaderManager

ShaderManager is the static class in charge of loading, compiling and storing shaders for reuse. The global ShaderManager is accessed via Loki.shaderManager.

Constructor

new L3D.ShaderManager()

Methods

compileShader(vsCode, fsCode)GLShader

Compiles a shader, the vertex and fragment shader are cached indepently to speed up compilations but a unique name must be provided. Shaders compiled with the ShaderManager will be compiled as #version 300 es and if the float precision hasn't been set, default to highp precision.

Parameters
vsCode String

GLSL code for the vertex shader.

fsCode String

GLSL code for the fragment shader.

Returns
GLShader

Shader object.

deviceShaderCode(gl, code) → String

Prepends device specific code to the shader.

Parameters
gl GLContext
code String
Returns
String

getGlobalExtraShaderCode(gl) → String

Returns extra code to prepend to shaders to include initializing common extensions, etc.

Parameters
gl GLContext

The WebGL context the shader will be compiled with.

Returns
String

getShaderBlock(id) → nullable ShaderBlock

Returns the shaderblock with the given id.

Parameters
id String
Returns
ShaderBlock

getShaderBlockMask(id)

Return the compilation mask for the given shader block.

Parameters
id String

registerShaderBlock(id, shaderBlock)

Register a shaderblock in the global container so it can be used by materials.

Parameters
id String

Unique name for the shader block

shaderBlock ShaderBlock

The shader block to register.