Class: ShaderCombiner

ShaderCombiner

ShaderCombiner module provides texture combination operations for OpenLIME. Supports both WebGL 1.0 and 2.0/3.0 GLSL specifications with automatic version detection.

ShaderCombiner class manages the combination of two input textures using various operations. Features:

  • Multiple combination modes (first, second, mean, diff)
  • Automatic texture sampling
  • WebGL 1.0 and 2.0 compatibility
  • Alpha channel preservation

new ShaderCombiner( [options])

Creates a new ShaderCombiner instance.

Parameters:
Name Type Argument Description
options Object <optional>

Configuration options

Properties
Name Type Argument Default Description
mode string <optional>
'mean'

Combination mode to use

samplers Array.<Object> <optional>

Texture sampler definitions (inherited from Shader)

uniforms Object <optional>

Shader uniform variables (inherited from Shader)

label string <optional>

Display label for the shader (inherited from Shader)

debug boolean <optional>

Enable debug output (inherited from Shader)

Source:
Fires:

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:

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

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


Operation

A shader operation that combines two textures.

Type:
  • Object
Properties:
Name Type Description
first string

Assigns first texture as output (cout = c1)

second string

Assigns second texture as output (cout = c2)

mean string

Calculates average of textures (cout = (c1 + c2)/2.0)

diff string

Calculates difference between textures (cout = c2.rgb - c1.rgb)

Source:

Events


update

Fired when shader combination mode changes.

Type: Object
Properties:
Name Type Description
mode string

New combination mode

previousMode string

Previous combination mode

Overrides:
Source: