ShaderCache

new Cesium.ShaderCache()

Methods

getShaderProgram(options)ShaderProgram

Returns a shader program from the cache, or creates and caches a new shader program, given the GLSL vertex and fragment shader source and attribute locations.
Name Type Description
options Object Object with the following properties:
Name Type Description
vertexShaderSource String | ShaderSource The GLSL source for the vertex shader.
fragmentShaderSource String | ShaderSource The GLSL source for the fragment shader.
attributeLocations Object Indices for the attribute inputs to the vertex shader.
Returns:
The cached or newly created shader program.

replaceShaderProgram(options)ShaderProgram

Returns a shader program from the cache, or creates and caches a new shader program, given the GLSL vertex and fragment shader source and attribute locations.

The difference between this and ShaderCache#getShaderProgram, is this is used to replace an existing reference to a shader program, which is passed as the first argument.

Name Type Description
options Object Object with the following properties:
Name Type Description
shaderProgram ShaderProgram optional The shader program that is being reassigned.
vertexShaderSource String | ShaderSource The GLSL source for the vertex shader.
fragmentShaderSource String | ShaderSource The GLSL source for the fragment shader.
attributeLocations Object Indices for the attribute inputs to the vertex shader.
Returns:
The cached or newly created shader program.
Example:
this._shaderProgram = context.shaderCache.replaceShaderProgram({
    shaderProgram : this._shaderProgram,
    vertexShaderSource : vs,
    fragmentShaderSource : fs,
    attributeLocations : attributeLocations
});
See: