Class: ShaderFilter

ShaderFilter

Base class for WebGL shader filters in OpenLIME. Provides infrastructure for creating modular shader effects that can be chained together.

Features:

  • Modular filter architecture
  • Automatic uniform management
  • Dynamic mode switching
  • Texture sampling support
  • GLSL code generation
  • Unique naming conventions

Technical Implementation:

  • Generates unique names for uniforms and samplers
  • Manages WebGL resource lifecycle
  • Supports multiple filter modes
  • Handles shader program integration

new ShaderFilter( [options])

Creates a new shader filter

Parameters:
Name Type Argument Description
options Object <optional>

Filter configuration

Properties
Name Type Argument Default Description
modes ShaderFilter~Mode <optional>
{}

Available filter modes

uniforms Object <optional>
{}

Filter uniform variables

samplers Array.<ShaderFilter~Sampler> <optional>
[]

Texture samplers

Source:

Methods


<abstract> fragDataSrc(gl)

Generates filter-specific GLSL function

Parameters:
Name Type Description
gl WebGLRenderingContext

WebGL context

Source:
Returns:

GLSL function definition

Type
string | null

getSampler(name)

Finds a sampler by name

Parameters:
Name Type Description
name string

Base sampler name

Source:
Returns:

Found sampler or undefined

Type
ShaderFilter~Sampler | undefined

setMode(mode, id)

Sets the active mode for the filter

Parameters:
Name Type Description
mode string

Mode category to modify

id string

Specific mode ID to enable

Source:
Throws:

If shader not registered or mode doesn't exist

Type
Error

setUniform(name, value)

Sets a uniform variable value

Parameters:
Name Type Description
name string

Base name of uniform variable

value number | boolean | Array

Value to set

Source:
Throws:

If shader not registered

Type
Error

Type Definitions


Mode

A shader filter mode configuration

Type:
  • Object
Properties:
Name Type Description
id string

Unique identifier for the mode

enable boolean

Whether the mode is active

src string

GLSL source code for the mode

Source:

Sampler

A texture sampler used by the filter

Type:
  • Object
Properties:
Name Type Argument Description
name string

Unique name for the sampler

texture WebGLTexture <optional>

Associated WebGL texture

location WebGLUniformLocation <optional>

GPU location for the sampler

Source: