API Docs for:
Show:

LS.Shaders Class

Defined in: ../src/shaders.js:8
Module: LS

Shaders is the static class in charge of loading, compiling and storing shaders for reuse.

Constructor

LS.Shaders

()

Defined in ../src/shaders.js:8

Methods

compileShader

(
  • vs_code
  • fs_code
  • name
)
GL.Shader

Compiles a shader, the vertex and fragment shader are cached indepently to speed up compilations but a unique name must be provided

Parameters:

  • vs_code String

    the final source code for the vertex shader

  • fs_code String

    the final source code for the fragment shader

  • name String

    an unique name that should be associated with this shader

Returns:

GL.Shader:

shader

getShaderBlock

(
  • id
)
LS.ShaderBlock

register a shaderblock with the given id

Parameters:

  • id String | Number

Returns:

LS.ShaderBlock:

shader_block

getSnippet

(
  • id
)
String

Returns the code of a snipper

Parameters:

  • id String

Returns:

String:

code

init

(
  • url
)

Initializes the shader manager

Parameters:

  • url String

    a url to a shaders.xml can be specified to load the shaders

registerShaderBlock

(
  • id
  • shader_block
)

register a shaderblock in the global container so it can be used by shadermaterials

Parameters:

registerSnippet

(
  • id
  • code
)

Register a code snippet ready to be used by the #import clause in the shader

Parameters:

  • id String
  • code String

reloadShaders

(
  • on_complete
)

Reloads the XML file with the shaders, useful when editing the file

Parameters:

  • on_complete Function

    call when the shaders have been reloaded