Class: ShaderRTI

ShaderRTI

ShaderRTI implements various Reflectance Transformation Imaging techniques. Works in conjunction with LayerRTI for interactive relighting of cultural heritage objects.

Supported Basis Types:

  • PTM (Polynomial Texture Maps)
  • HSH (Hemispherical Harmonics)
  • SH (Spherical Harmonics)
  • RBF (Radial Basis Functions)
  • BLN (Bilinear Interpolation)

Features:

  • Multiple rendering modes (light, normals, diffuse, specular)
  • Various color space support
  • Automatic basis selection
  • Real-time coefficient interpolation
  • Normal map visualization
  • Material property control

Technical Implementation:

  • Efficient GPU-based relighting
  • Dynamic shader generation
  • Coefficient plane management
  • Light vector transformation
  • Color space conversion

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
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:

<abstract> fragShaderSrc(gl)

Gets fragment shader source code. Must be overridden in derived classes for custom shading.

Parameters:
Name Type Description
gl WebGLRenderingContext

WebGL context

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
name string

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
relight Object

RTI configuration data

Properties
Name Type Description
type string

Basis type

colorspace string

Color space

material Object

Material parameters

basis Array.<number>

Optional PCA basis

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)

Updates light direction for relighting

Parameters:
Name Type Description
light Array.<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
mode string

One of: 'light', 'normals', '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
value number

Specular exponent

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

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

Type Definitions


Basis

Configuration data for basis functions

Type:
  • Object
Properties:
Name Type Argument Description
basis Float32Array <optional>

PCA basis for rbf and bln modes

lights Array.<Array.<number>> <optional>

Light directions for rbf interpolation

sigma number <optional>

RBF interpolation parameter

ndimensions number <optional>

PCA dimension space

Source:

Options

Configuration options for RTI shader

Type:
  • Object
Properties:
Name Type Argument Default Description
mode string <optional>
'normal'

Initial rendering mode

type string <optional>

Basis type: 'ptm'|'hsh'|'sh'|'rbf'|'bln'

colorspace string <optional>

Color space: 'lrgb'|'rgb'|'mrgb'|'mycc'

nplanes number <optional>

Number of coefficient planes

yccplanes Array.<number> <optional>

Number of planes for YCC components

material Object <optional>

Material parameters for dequantization

Source:

Events


update

Fired when shader state changes (uniforms, filters, etc).

Inherited From:
Overrides:
Source: