new ShaderBRDF( [options])
Creates a new ShaderBRDF instance.
Parameters:
Name | Type | Argument | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
{} | Configuration options for the shader. Properties
|
- Source:
Examples
// Create a basic BRDF shader with default settings const shader = new ShaderBRDF({});
// Create a BRDF shader with custom settings const shader = new ShaderBRDF({ mode: 'color', colorspaces: { kd: 'sRGB', ks: 'linear' }, brightness: 1.2, gamma: 2.2, alphaLimits: [0.05, 0.4], kAmbient: 0.03 });
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
-
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, light[0, light[1, light[2, light[3)
-
Sets the light properties for the shader.
Parameters:
Name Type Description light
Array.<number> 4D vector containing light information
light[0
number X coordinate of light position/direction
light[1
number Y coordinate of light position/direction
light[2
number Z coordinate of light position/direction
light[3
number Light type flag (0 for directional, 1 for spot)
- Source:
-
setMode(mode)
-
Sets the rendering mode for the shader.
Parameters:
Name Type Description mode
string The rendering mode to use
- Overrides:
- Source:
Throws:
-
If an invalid mode is specified
- Type
- Error
-
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
-
vertShaderSrc(gl)
-
Gets vertex shader source code. Default implementation provides basic vertex transformation and texture coordinate passing.
Parameters:
Name Type Description gl
WebGLRenderingContext WebGL 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: