new ShaderMultispectral( [options])
Creates a new multispectral shader
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
options |
ShaderMultispectralOptions |
<optional> |
Configuration options |
- Source:
Extends
Methods
-
addFilter(filter)
-
Adds a filter to the shader pipeline.
Parameters:
Name Type Description filter
Object Filter to add
- Inherited From:
- Overrides:
- Source:
Fires:
-
allUniforms()
-
Returns all uniform variables associated with the shader and its filters. Combines uniforms from both the base shader and all active filters into a single object.
- Inherited From:
- Overrides:
- Source:
Returns:
Combined uniform variables
- Type
- Object.<string, Object>
-
clearFilters()
-
Clears all filters from the shader pipeline.
- Inherited From:
- Overrides:
- Source:
Fires:
-
fragShaderSrc()
-
Generate fragment shader source code
Creates optimized GLSL code for multispectral visualization. Uses texture() with normalized coordinates instead of texelFetch.
- Inherited From:
- Overrides:
- Source:
Returns:
GLSL fragment shader source code
- Type
- string
-
getUniform(name)
-
Gets a uniform variable by name. Searches both shader uniforms and filter uniforms.
Parameters:
Name Type Description name
string Uniform variable name
- Inherited From:
- Overrides:
- Source:
Returns:
Uniform object if found
- Type
- Object | undefined
-
init(info)
-
Initializes shader with multispectral configuration
Sets up wavelength information, calculates the number of required textures, and configures samplers for each texture.
Parameters:
Name Type Description info
Object Multispectral configuration object from info.json
- Source:
-
removeFilter(name)
-
Removes a filter from the pipeline by name.
Parameters:
Name Type Description name
string Name of filter to remove
- Inherited From:
- Overrides:
- Source:
Fires:
-
setMode(mode)
-
Sets the rendering mode
Changes how multispectral data is visualized:
- 'rgb': Uses CTW coefficients to create RGB visualization
- 'single_band': Shows a single spectral band
Parameters:
Name Type Description mode
string Visualization mode ('rgb', 'single_band')
- Overrides:
- Source:
Throws:
-
If mode is not recognized
- Type
- Error
-
setSingleBand(bandIndex, outputChannel)
-
Sets single band visualization
Configures the shader to display a specific spectral band on a chosen output channel.
Parameters:
Name Type Default Description bandIndex
number Index of band to view
outputChannel
number 0 Output channel (0=all/gray, 1=R, 2=G, 3=B)
- Source:
Throws:
-
If band index is out of range
- Type
- Error
-
setTextureSize()
-
Sets texture dimensions for calculations
No longer needed since we're using normalized coordinates
- Deprecated:
-
- Use normalized texture coordinates instead
- Source:
-
setTileSize(size)
-
Sets tile dimensions for shader calculations.
Parameters:
Name Type Description size
Array.<number> [width, height] of tile
- Inherited From:
- Overrides:
- Source:
-
setUniform(name, value)
-
Sets a uniform variable value.
Parameters:
Name Type Description name
string Uniform variable name
value
number | boolean | Array Value to set
- Inherited From:
- Overrides:
- Source:
Fires:
Throws:
-
If uniform doesn't exist
- Type
- Error
-
setupCTW(gl, redCTW, greenCTW, blueCTW)
-
Sets up Uniform Buffer Object for Color Twist Weights
Creates and configures a UBO for efficient handling of CTW coefficients. Uses WebGL2's std140 layout for optimal performance.
Parameters:
Name Type Description gl
WebGL2RenderingContext WebGL2 context
redCTW
Float32Array Red channel CTW coefficients
greenCTW
Float32Array Green channel CTW coefficients
blueCTW
Float32Array Blue channel CTW coefficients
- Source:
-
vertShaderSrc(gl)
-
Gets vertex shader source code. Default implementation provides basic vertex transformation and texture coordinate passing.
Parameters:
Name Type Description gl
WebGL2RenderingContext WebGL2 context
- Inherited From:
- Overrides:
- Source:
Returns:
Vertex shader source code
- Type
- string
Events
-
update
-
Fired when shader state changes (uniforms, filters, etc).
- Inherited From:
- Overrides:
- Source: