new ShaderNeural( [options])
Creates a new neural network shader
Parameters:
Name | Type | Argument | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Configuration options Properties
|
- 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:
-
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()
-
Initializes default weights
- 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:
-
setLight(light)
-
Sets the light direction for relighting
Parameters:
Name Type Description light
Array.<number> Light direction vector [x, y]
- Source:
-
setMode(mode)
-
Sets the current shader mode.
Parameters:
Name Type Description mode
string Mode identifier (must be in options.modes)
- Inherited From:
- Overrides:
- Source:
Throws:
-
If mode is not recognized
- Type
- Error
-
setShaderInfo(samples, planes, n, c, colorspace)
-
Configures shader for specific network architecture
Parameters:
Name Type Description samples
Array.<number> Input samples
planes
number Number of coefficient planes
n
number Neurons per layer
c
number Input channels
colorspace
string Color space for processing
- 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
Type Definitions
-
NetworkConfig
-
Configuration for neural network weights and parameters
Type:
- Object
- Source:
Properties:
Name Type Description n
number Number of neurons per layer (padded to multiple of 4)
c
number Number of input channels (padded to multiple of 4)
colorspace
string Color space for processing ('rgb'|'xyz'|etc)
nplanes
number Number of coefficient planes
scale
number Dequantization scale factor
bias
number Dequantization bias
Events
-
update
-
Fired when shader state changes (uniforms, filters, etc).
- Inherited From:
- Overrides:
- Source: