Home Reference Source
import {GlitchEffect} from 'postprocessing'
public class | source

GlitchEffect

Extends:

three~EventDispatcherEffect → GlitchEffect

Indirect Implements:

A glitch effect.

This effect can be used in conjunction with the ChromaticAberrationEffect.

Reference: https://github.com/staffantan/unityglitch

Constructor Summary

Public Constructor
public

constructor(options: Object)

Constructs a new glitch effect.

Member Summary

Public Members
public get

Indicates whether the glitch effect is currently active.

public

The chromatic aberration offset.

public get

The glitch column size.

public set
public

delay: Vector2

this member was deprecated. Use minDelay and maxDelay instead.

The minimum and maximum delay between glitch activations in seconds.

public

duration: Vector2

this member was deprecated. Use minDuration and maxDuration instead.

The minimum and maximum duration of a glitch in seconds.

public get

The maximum delay between glitch activations.

public set
public get

The maximum duration of sporadic glitches.

public set
public get

The strength of strong glitches.

public set
public get

The minimum delay between glitch activations.

public set
public get

The minimum duration of sporadic glitches.

public set
public get

The strength of weak glitches.

public set
public

The effect mode.

public get

perturbationMap: Texture

The perturbation map.

public set
public

The ratio between weak (0.0) and strong (1.0) glitches.

public

strength: Vector2

this member was deprecated. Use minStrength and maxStrength instead.

The strength of weak and strong glitches.

Method Summary

Public Methods
public

Deletes generated resources.

public

generatePerturbationMap(value: Number): DataTexture

this method was deprecated. Use NoiseTexture instead.

Generates a perturbation map.

public
this method was deprecated. Use chromaticAberrationOffset instead.

Returns the chromatic aberration offset.

public
this method was deprecated. Use columns instead.

Returns the glitch column size.

public
this method was deprecated. Use ratio instead.

Returns the glitch ratio.

public
this method was deprecated. Use maxDelay instead.

Returns the maximum delay between glitch activations.

public
this method was deprecated. Use maxDuration instead.

Returns the maximum duration of sporadic glitches.

public
this method was deprecated. Use maxStrength instead.

Returns the strength of strong glitches.

public
this method was deprecated. Use minDelay instead.

Returns the minimum delay between glitch activations.

public
this method was deprecated. Use minDuration instead.

Returns the minimum duration of sporadic glitches.

public
this method was deprecated. Use minStrength instead.

Returns the strength of weak glitches.

public
this method was deprecated. Use mode instead.

Returns the current glitch mode.

public

getPerturbationMap(): Texture

this method was deprecated. Use perturbationMap instead.

Returns the current perturbation map.

public
this method was deprecated. Use active instead.

Indicates whether the glitch effect is currently active.

public
this method was deprecated. Use chromaticAberrationOffset instead.

Sets the chromatic aberration offset.

public
this method was deprecated. Use columns instead.

Sets the glitch column size.

public
this method was deprecated. Use ratio instead.

Sets the ratio of weak (0.0) and strong (1.0) glitches.

public
this method was deprecated. Use maxDelay instead.

Sets the maximum delay between glitch activations.

public
this method was deprecated. Use maxDuration instead.

Sets the maximum duration of sporadic glitches.

public
this method was deprecated. Use maxStrength instead.

Sets the strength of strong glitches.

public
this method was deprecated. Use minDelay instead.

Sets the minimum delay between glitch activations.

public
this method was deprecated. Use minDuration instead.

Sets the minimum duration of sporadic glitches.

public
this method was deprecated. Use minStrength instead.

Sets the strength of weak glitches.

public
this method was deprecated. Use mode instead.

Sets the current glitch mode.

public

setPerturbationMap(value: Texture)

this method was deprecated. Use perturbationMap instead.

Replaces the current perturbation map with the given one.

public

update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, deltaTime: Number)

Updates this effect.

Inherited Summary

From class Effect
public get

inputColorSpace: ColorSpace

this get is experimental.

The input color space.

public set

mainCamera: Camera

Sets the main camera.

public set

mainScene: Scene

Sets the main scene.

public get

outputColorSpace: ColorSpace

this get is experimental.

The output color space.

protected set

inputColorSpace: ColorSpace

this set is experimental.
protected set

outputColorSpace: ColorSpace

this set is experimental.
public

The blend mode of this effect.

public

Preprocessor macro definitions.

public

WebGL extensions that are required by this effect.

public

The name of this effect.

public

uniforms: Map<String, Uniform>

Shader uniforms.

protected

renderer: WebGLRenderer

this member was deprecated.

The renderer.

public

Performs a shallow search for properties that define a dispose method and deletes them.

public

Returns the effect attributes.

public
this method was deprecated. Use blendMode instead.

Returns the blend mode.

public
this method was deprecated. Use defines instead.

Returns the preprocessor macro definitions.

public
this method was deprecated. Use extensions instead.

Returns the WebGL extensions that are required by this effect.

public

Returns the fragment shader.

public
this method was deprecated. Use name instead.

Returns the name of this effect.

public

getUniforms(): Map<String, Uniform>

this method was deprecated. Use uniforms instead.

Returns the uniforms of this effect.

public

Returns the vertex shader.

public

initialize(renderer: WebGLRenderer, alpha: Boolean, frameBufferType: Number)

Performs initialization tasks.

public

setDepthTexture(depthTexture: Texture, depthPacking: DepthPackingStrategies)

Sets the depth texture.

public

setRenderer(renderer: WebGLRenderer)

this method was deprecated.

Sets the renderer.

public

setSize(width: Number, height: Number)

Updates the size of this effect.

public

update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, deltaTime: Number)

Updates this effect by performing supporting operations.

protected

Sets the effect attributes.

protected

Informs the associated EffectPass that this effect requires a shader recompilation.

protected

setFragmentShader(fragmentShader: String)

Sets the fragment shader.

protected

setVertexShader(vertexShader: String)

Sets the vertex shader.

Public Constructors

public constructor(options: Object) source

Constructs a new glitch effect.

TODO Change ratio to 0.15.

Override:

Effect#constructor

Params:

NameTypeAttributeDescription
options Object
  • optional

The options.

options.chromaticAberrationOffset Vector2
  • optional

A chromatic aberration offset. If provided, the glitch effect will influence this offset.

options.delay Vector2
  • optional

The minimum and maximum delay between glitch activations in seconds.

options.duration Vector2
  • optional

The minimum and maximum duration of a glitch in seconds.

options.strength Vector2
  • optional

The strength of weak and strong glitches.

options.perturbationMap Texture
  • optional

A perturbation map. If none is provided, a noise texture will be created.

options.dtSize Number
  • optional
  • default: 64

The size of the generated noise map. Will be ignored if a perturbation map is provided.

options.columns Number
  • optional
  • default: 0.05

The scale of the blocky glitch columns.

options.ratio Number
  • optional
  • default: 0.85

The threshold for strong glitches.

Public Members

public get active: Boolean source

Indicates whether the glitch effect is currently active.

public chromaticAberrationOffset: Vector2 source

The chromatic aberration offset.

public get columns: Number source

The glitch column size.

public set columns source

public delay: Vector2 source

this member was deprecated. Use minDelay and maxDelay instead.

The minimum and maximum delay between glitch activations in seconds.

public duration: Vector2 source

this member was deprecated. Use minDuration and maxDuration instead.

The minimum and maximum duration of a glitch in seconds.

public get maxDelay: Number source

The maximum delay between glitch activations.

public set maxDelay source

public get maxDuration: Number source

The maximum duration of sporadic glitches.

public set maxDuration source

public get maxStrength: Number source

The strength of strong glitches.

public set maxStrength source

public get minDelay: Number source

The minimum delay between glitch activations.

public set minDelay source

public get minDuration: Number source

The minimum duration of sporadic glitches.

public set minDuration source

public get minStrength: Number source

The strength of weak glitches.

public set minStrength source

public mode: GlitchMode source

The effect mode.

public get perturbationMap: Texture source

The perturbation map.

public set perturbationMap source

public ratio: Number source

The ratio between weak (0.0) and strong (1.0) glitches. Range is [0.0, 1.0].

This value is currently being treated as a threshold for strong glitches, i.e. it's inverted.

TODO Resolve inversion.

public strength: Vector2 source

this member was deprecated. Use minStrength and maxStrength instead.

The strength of weak and strong glitches.

Public Methods

public dispose() source

Deletes generated resources.

Override:

Effect#dispose

public generatePerturbationMap(value: Number): DataTexture source

this method was deprecated. Use NoiseTexture instead.

Generates a perturbation map.

Params:

NameTypeAttributeDescription
value Number
  • optional
  • default: 64

The texture size.

Return:

DataTexture

The perturbation map.

public getChromaticAberrationOffset(): Vector2 source

this method was deprecated. Use chromaticAberrationOffset instead.

Returns the chromatic aberration offset.

Return:

Vector2

The offset.

public getGlitchColumns(): Number source

this method was deprecated. Use columns instead.

Returns the glitch column size.

Return:

Number

The glitch column size.

public getGlitchRatio(): Number source

this method was deprecated. Use ratio instead.

Returns the glitch ratio.

Return:

Number

The ratio.

public getMaxDelay(): Number source

this method was deprecated. Use maxDelay instead.

Returns the maximum delay between glitch activations.

Return:

Number

The maximum delay in seconds.

public getMaxDuration(): Number source

this method was deprecated. Use maxDuration instead.

Returns the maximum duration of sporadic glitches.

Return:

Number

The maximum duration in seconds.

public getMaxStrength(): Number source

this method was deprecated. Use maxStrength instead.

Returns the strength of strong glitches.

Return:

Number

The strength.

public getMinDelay(): Number source

this method was deprecated. Use minDelay instead.

Returns the minimum delay between glitch activations.

Return:

Number

The minimum delay in seconds.

public getMinDuration(): Number source

this method was deprecated. Use minDuration instead.

Returns the minimum duration of sporadic glitches.

Return:

Number

The minimum duration in seconds.

public getMinStrength(): Number source

this method was deprecated. Use minStrength instead.

Returns the strength of weak glitches.

Return:

Number

The strength.

public getMode(): GlitchMode source

this method was deprecated. Use mode instead.

Returns the current glitch mode.

Return:

GlitchMode

The mode.

public getPerturbationMap(): Texture source

this method was deprecated. Use perturbationMap instead.

Returns the current perturbation map.

Return:

Texture

The current perturbation map.

public isActive(): Boolean source

this method was deprecated. Use active instead.

Indicates whether the glitch effect is currently active.

Return:

Boolean

Whether the glitch effect is active.

public setChromaticAberrationOffset(value: Vector2) source

this method was deprecated. Use chromaticAberrationOffset instead.

Sets the chromatic aberration offset.

Params:

NameTypeAttributeDescription
value Vector2

The offset.

public setGlitchColumns(value: Number) source

this method was deprecated. Use columns instead.

Sets the glitch column size.

Params:

NameTypeAttributeDescription
value Number

The glitch column size.

public setGlitchRatio(value: Number) source

this method was deprecated. Use ratio instead.

Sets the ratio of weak (0.0) and strong (1.0) glitches.

Params:

NameTypeAttributeDescription
value Number

The ratio. Range is [0.0, 1.0].

public setMaxDelay(value: Number) source

this method was deprecated. Use maxDelay instead.

Sets the maximum delay between glitch activations.

Params:

NameTypeAttributeDescription
value Number

The maximum delay in seconds.

public setMaxDuration(value: Number) source

this method was deprecated. Use maxDuration instead.

Sets the maximum duration of sporadic glitches.

Params:

NameTypeAttributeDescription
value Number

The maximum duration in seconds.

public setMaxStrength(value: Number) source

this method was deprecated. Use maxStrength instead.

Sets the strength of strong glitches.

Params:

NameTypeAttributeDescription
value Number

The strength.

public setMinDelay(value: Number) source

this method was deprecated. Use minDelay instead.

Sets the minimum delay between glitch activations.

Params:

NameTypeAttributeDescription
value Number

The minimum delay in seconds.

public setMinDuration(value: Number) source

this method was deprecated. Use minDuration instead.

Sets the minimum duration of sporadic glitches.

Params:

NameTypeAttributeDescription
value Number

The minimum duration in seconds.

public setMinStrength(value: Number) source

this method was deprecated. Use minStrength instead.

Sets the strength of weak glitches.

Params:

NameTypeAttributeDescription
value Number

The strength.

public setMode(value: GlitchMode) source

this method was deprecated. Use mode instead.

Sets the current glitch mode.

Params:

NameTypeAttributeDescription
value GlitchMode

The mode.

public setPerturbationMap(value: Texture) source

this method was deprecated. Use perturbationMap instead.

Replaces the current perturbation map with the given one.

The current map will be disposed if it was generated by this effect.

Params:

NameTypeAttributeDescription
value Texture

The new perturbation map.

public update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, deltaTime: Number) source

Updates this effect.

Override:

Effect#update

Params:

NameTypeAttributeDescription
renderer WebGLRenderer

The renderer.

inputBuffer WebGLRenderTarget

A frame buffer that contains the result of the previous pass.

deltaTime Number
  • optional

The time between the last frame and the current one in seconds.