new ShaderRTI( [options])
Creates a new RTI shader
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
options |
ShaderRTI~Options |
<optional> |
Configuration options |
- Source:
Example
```javascript
// Create PTM shader
const shader = new ShaderRTI({
type: 'ptm',
colorspace: 'rgb',
mode: 'light'
});
```
Extends
Methods
-
addFilter(filter)
-
Adds a filter to the shader pipeline.
Parameters:
Name Type Description filterObject 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:
-
<abstract> fragShaderSrc()
-
Gets fragment shader source code. Must be overridden in derived classes for custom shading.
- Inherited From:
- Overrides:
- Source:
Returns:
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 namestring Uniform variable name
- Inherited From:
- Overrides:
- Source:
Returns:
Uniform object if found
- Type
- Object | undefined
-
init(relight)
-
Initializes shader with RTI configuration
Parameters:
Name Type Description relightObject RTI configuration data
Properties
Name Type Description typestring Basis type
colorspacestring Color space
materialObject Material parameters
basisArray.<number> Optional PCA basis
- Source:
-
removeFilter(name)
-
Removes a filter from the pipeline by name.
Parameters:
Name Type Description namestring Name of filter to remove
- Inherited From:
- Overrides:
- Source:
Fires:
-
setLight(light)
-
Updates light direction for relighting
Parameters:
Name Type Description lightArray.<number> Light vector [x, y], automatically normalized
- Source:
Throws:
-
If shader is not initialized
- Type
- Error
-
setMode(mode)
-
Sets the rendering mode
Parameters:
Name Type Description modestring One of: 'light', 'normals', 'diffuse', 'gray_diffuse', 'specular'
- Overrides:
- Source:
Throws:
-
If mode is not recognized
- Type
- Error
-
setSpecularExp(value)
-
Sets specular exponent for specular enhancement mode
Parameters:
Name Type Description valuenumber Specular exponent
- Source:
-
setTileSize(size)
-
Sets tile dimensions for shader calculations.
Parameters:
Name Type Description sizeArray.<number> [width, height] of tile in pixels
- Inherited From:
- Overrides:
- Source:
Fires:
-
setUniform(name, value)
-
Sets a uniform variable value.
Parameters:
Name Type Description namestring Uniform variable name
valuenumber | 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 glWebGL2RenderingContext WebGL2 context
- Inherited From:
- Overrides:
- Source:
Returns:
Vertex shader source code
- Type
- string
Type Definitions
-
Basis
-
Configuration data for basis functions
Type:
- Object
- Source:
Properties:
Name Type Argument Description basisFloat32Array <optional>
PCA basis for rbf and bln modes
lightsArray.<Array.<number>> <optional>
Light directions for rbf interpolation
sigmanumber <optional>
RBF interpolation parameter
ndimensionsnumber <optional>
PCA dimension space
-
Options
-
Configuration options for RTI shader
Type:
- Object
- Source:
Properties:
Name Type Argument Default Description modestring <optional>
'normal' Initial rendering mode
typestring <optional>
Basis type: 'ptm'|'hsh'|'sh'|'rbf'|'bln'
colorspacestring <optional>
Color space: 'lrgb'|'rgb'|'mrgb'|'mycc'
nplanesnumber <optional>
Number of coefficient planes
yccplanesArray.<number> <optional>
Number of planes for YCC components
materialObject <optional>
Material parameters for dequantization
Events
-
update
-
Fired when shader state changes (uniforms, filters, etc).
- Inherited From:
- Overrides:
- Source: