Class GlitchEffect

A glitch effect.

This effect can be used in conjunction with the ChromaticAberrationEffect.

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

Hierarchy (view full)

Constructors

  • Constructs a new glitch effect.

    TODO Change ratio to 0.15.

    Parameters

    • Optional options: {
          blendFunction?: BlendFunction;
          chromaticAberrationOffset?: Vector2;
          columns?: number;
          delay?: Vector2;
          dtSize?: number;
          duration?: Vector2;
          perturbationMap?: Texture;
          ratio?: number;
          strength?: Vector2;
      }

      The options.

      • Optional blendFunction?: BlendFunction

        The blend function of this effect.

      • Optional chromaticAberrationOffset?: Vector2

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

      • Optional columns?: number

        The scale of the blocky glitch columns.

      • Optional delay?: Vector2

        The minimum and maximum delay between glitch activations in seconds.

      • Optional dtSize?: number

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

      • Optional duration?: Vector2

        The minimum and maximum duration of a glitch in seconds.

      • Optional perturbationMap?: Texture

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

      • Optional ratio?: number

        The threshold for strong glitches.

      • Optional strength?: Vector2

        The strength of weak and strong glitches.

    Returns GlitchEffect

Properties

blendMode: BlendMode

The blend mode of this effect.

chromaticAberrationOffset: Vector2

The chromatic aberration offset.

defines: Map<string, string>

Preprocessor macro definitions.

Call Effect.setChanged after changing macro definitions.

delay: Vector2

The minimum and maximum delay between glitch activations in seconds.

Deprecated

Use minDelay and maxDelay instead.

duration: Vector2

The minimum and maximum duration of a glitch in seconds.

Deprecated

Use minDuration and maxDuration instead.

extensions: Set<WebGLExtension>

WebGL extensions that are required by this effect.

Call Effect.setChanged after adding or removing extensions.

The effect mode.

name: string

The name of this effect.

ratio: number

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.

renderer: WebGLRenderer

The renderer.

Deprecated

strength: Vector2

The strength of weak and strong glitches.

Deprecated

Use minStrength and maxStrength instead.

uniforms: Map<string, Uniform<any>>

Shader uniforms.

Call Effect.setChanged after adding or removing uniforms.

Accessors

  • get active(): boolean
  • Indicates whether the glitch effect is currently active.

    Returns boolean

  • get columns(): number
  • The glitch column size.

    Returns number

  • set columns(arg): void
  • Parameters

    • arg: number

    Returns void

  • get inputColorSpace(): ColorSpace
  • Experimental

    The input color space.

    Returns ColorSpace

  • set inputColorSpace(arg): void
  • Protected Experimental

    Parameters

    • arg: ColorSpace

    Returns void

  • set mainCamera(arg): void
  • Sets the main camera.

    Parameters

    • arg: Camera

    Returns void

  • set mainScene(arg): void
  • Sets the main scene.

    Parameters

    • arg: Scene

    Returns void

  • get maxDelay(): number
  • The maximum delay between glitch activations.

    Returns number

  • set maxDelay(arg): void
  • Parameters

    • arg: number

    Returns void

  • get maxDuration(): number
  • The maximum duration of sporadic glitches.

    Returns number

  • set maxDuration(arg): void
  • Parameters

    • arg: number

    Returns void

  • get maxStrength(): number
  • The strength of strong glitches.

    Returns number

  • set maxStrength(arg): void
  • Parameters

    • arg: number

    Returns void

  • get minDelay(): number
  • The minimum delay between glitch activations.

    Returns number

  • set minDelay(arg): void
  • Parameters

    • arg: number

    Returns void

  • get minDuration(): number
  • The minimum duration of sporadic glitches.

    Returns number

  • set minDuration(arg): void
  • Parameters

    • arg: number

    Returns void

  • get minStrength(): number
  • The strength of weak glitches.

    Returns number

  • set minStrength(arg): void
  • Parameters

    • arg: number

    Returns void

  • get outputColorSpace(): ColorSpace
  • Experimental

    The output color space.

    Should only be changed if this effect converts the input colors to a different color space.

    Returns ColorSpace

  • set outputColorSpace(arg): void
  • Protected Experimental

    Parameters

    • arg: ColorSpace

    Returns void

  • get perturbationMap(): Texture
  • The perturbation map.

    Returns Texture

  • set perturbationMap(arg): void
  • Parameters

    • arg: Texture

    Returns void

Methods

  • Deletes generated resources.

    Returns void

  • Generates a perturbation map.

    Parameters

    • Optional value: number

      The texture size.

    Returns DataTexture

    The perturbation map.

    Deprecated

    Use NoiseTexture instead.

  • Returns the blend mode.

    The result of this effect will be blended with the result of the previous effect using this blend mode.

    Returns BlendMode

    The blend mode.

    Deprecated

    Use blendMode instead.

  • Returns the chromatic aberration offset.

    Returns Vector2

    The offset.

    Deprecated

    Use chromaticAberrationOffset instead.

  • Returns the preprocessor macro definitions.

    Returns Map<string, string>

    The extensions.

    Deprecated

    Use defines instead.

  • Returns the WebGL extensions that are required by this effect.

    Returns Set<WebGLExtension>

    The extensions.

    Deprecated

    Use extensions instead.

  • Returns the fragment shader.

    Returns string

    The fragment shader.

  • Returns the glitch column size.

    Returns number

    The glitch column size.

    Deprecated

    Use columns instead.

  • Returns the glitch ratio.

    Returns number

    The ratio.

    Deprecated

    Use ratio instead.

  • Returns the maximum delay between glitch activations.

    Returns number

    The maximum delay in seconds.

    Deprecated

    Use maxDelay instead.

  • Returns the maximum duration of sporadic glitches.

    Returns number

    The maximum duration in seconds.

    Deprecated

    Use maxDuration instead.

  • Returns the strength of strong glitches.

    Returns number

    The strength.

    Deprecated

    Use maxStrength instead.

  • Returns the minimum delay between glitch activations.

    Returns number

    The minimum delay in seconds.

    Deprecated

    Use minDelay instead.

  • Returns the minimum duration of sporadic glitches.

    Returns number

    The minimum duration in seconds.

    Deprecated

    Use minDuration instead.

  • Returns the strength of weak glitches.

    Returns number

    The strength.

    Deprecated

    Use minStrength instead.

  • Returns the current glitch mode.

    Returns GlitchMode

    The mode.

    Deprecated

    Use mode instead.

  • Returns the name of this effect.

    Returns string

    The name.

    Deprecated

    Use name instead.

  • Returns the current perturbation map.

    Returns Texture

    The current perturbation map.

    Deprecated

    Use perturbationMap instead.

  • Returns the uniforms of this effect.

    Returns Map<string, Uniform<any>>

    The extensions.

    Deprecated

    Use uniforms instead.

  • Returns the vertex shader.

    Returns string

    The vertex shader.

  • Performs initialization tasks.

    This method is called when the associated EffectPass is added to an EffectComposer.

    Parameters

    • renderer: WebGLRenderer

      The renderer.

    • alpha: boolean

      Whether the renderer uses the alpha channel or not.

    • frameBufferType: number

      The type of the main frame buffers.

    Returns void

    Example

    if(!alpha && frameBufferType === UnsignedByteType) { this.myRenderTarget.texture.format = RGBFormat; }
    
  • Indicates whether the glitch effect is currently active.

    Returns boolean

    Whether the glitch effect is active.

    Deprecated

    Use active instead.

  • Protected

    Sets the effect attributes.

    Effects that have the same attributes will be executed in the order in which they were registered. Some attributes imply a higher priority.

    Parameters

    Returns void

  • Protected

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

    Should be called after changing macros or extensions and after adding/removing uniforms.

    Returns void

  • Sets the chromatic aberration offset.

    Parameters

    • value: Vector2

      The offset.

    Returns void

    Deprecated

    Use chromaticAberrationOffset instead.

  • Sets the depth texture.

    You may override this method if your effect requires direct access to the depth texture that is bound to the associated EffectPass.

    Parameters

    • depthTexture: Texture

      A depth texture.

    • Optional depthPacking: DepthPackingStrategies

      The depth packing.

    Returns void

  • Protected

    Sets the fragment shader.

    Parameters

    • fragmentShader: string

      The fragment shader.

    Returns void

  • Sets the glitch column size.

    Parameters

    • value: number

      The glitch column size.

    Returns void

    Deprecated

    Use columns instead.

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

    Parameters

    • value: number

      The ratio. Range is [0.0, 1.0].

    Returns void

    Deprecated

    Use ratio instead.

  • Sets the maximum delay between glitch activations.

    Parameters

    • value: number

      The maximum delay in seconds.

    Returns void

    Deprecated

    Use maxDelay instead.

  • Sets the maximum duration of sporadic glitches.

    Parameters

    • value: number

      The maximum duration in seconds.

    Returns void

    Deprecated

    Use maxDuration instead.

  • Sets the strength of strong glitches.

    Parameters

    • value: number

      The strength.

    Returns void

    Deprecated

    Use maxStrength instead.

  • Sets the minimum delay between glitch activations.

    Parameters

    • value: number

      The minimum delay in seconds.

    Returns void

    Deprecated

    Use minDelay instead.

  • Sets the minimum duration of sporadic glitches.

    Parameters

    • value: number

      The minimum duration in seconds.

    Returns void

    Deprecated

    Use minDuration instead.

  • Sets the strength of weak glitches.

    Parameters

    • value: number

      The strength.

    Returns void

    Deprecated

    Use minStrength instead.

  • Sets the current glitch mode.

    Parameters

    Returns void

    Deprecated

    Use mode instead.

  • Replaces the current perturbation map with the given one.

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

    Parameters

    • value: Texture

      The new perturbation map.

    Returns void

    Deprecated

    Use perturbationMap instead.

  • Sets the renderer.

    Parameters

    • renderer: WebGLRenderer

      The renderer.

    Returns void

    Deprecated

  • Updates the size of this effect.

    You may override this method if you want to be informed about the size of the backbuffer/canvas. This method is called before initialize and every time the size of the EffectComposer changes.

    Parameters

    • width: number

      The width.

    • height: number

      The height.

    Returns void

  • Protected

    Sets the vertex shader.

    Parameters

    • vertexShader: string

      The vertex shader.

    Returns void

  • Updates this effect.

    Parameters

    • renderer: WebGLRenderer

      The renderer.

    • inputBuffer: WebGLRenderTarget<Texture>

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

    • Optional deltaTime: number

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

    Returns void