GlitchEffect
Extends:
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 |
chromaticAberrationOffset: Vector2 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 |
dispose() Deletes generated resources. |
|
public |
generatePerturbationMap(value: Number): DataTexture this method was deprecated. Use NoiseTexture instead.
Generates a perturbation map. |
|
public |
getChromaticAberrationOffset(): Vector2 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 |
setChromaticAberrationOffset(value: Vector2) this method was deprecated. Use chromaticAberrationOffset instead.
Sets the chromatic aberration offset. |
|
public |
setGlitchColumns(value: Number) this method was deprecated. Use columns instead.
Sets the glitch column size. |
|
public |
setGlitchRatio(value: Number) this method was deprecated. Use ratio instead.
Sets the ratio of weak (0.0) and strong (1.0) glitches. |
|
public |
setMaxDelay(value: Number) this method was deprecated. Use maxDelay instead.
Sets the maximum delay between glitch activations. |
|
public |
setMaxDuration(value: Number) this method was deprecated. Use maxDuration instead.
Sets the maximum duration of sporadic glitches. |
|
public |
setMaxStrength(value: Number) this method was deprecated. Use maxStrength instead.
Sets the strength of strong glitches. |
|
public |
setMinDelay(value: Number) this method was deprecated. Use minDelay instead.
Sets the minimum delay between glitch activations. |
|
public |
setMinDuration(value: Number) this method was deprecated. Use minDuration instead.
Sets the minimum duration of sporadic glitches. |
|
public |
setMinStrength(value: Number) this method was deprecated. Use minStrength instead.
Sets the strength of weak glitches. |
|
public |
setMode(value: GlitchMode) 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 |
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 |
Shader uniforms. |
|
protected |
renderer: WebGLRenderer this member was deprecated.
The renderer. |
|
public |
dispose() 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 |
getDefines(): Map<String, String> 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 |
Updates the size of this effect. |
|
public |
Updates this effect by performing supporting operations. |
|
protected |
setAttributes(attributes: EffectAttribute) 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#constructorParams:
Name | Type | Attribute | Description |
options | Object |
|
The options. |
options.chromaticAberrationOffset | Vector2 |
|
A chromatic aberration offset. If provided, the glitch effect will influence this offset. |
options.delay | Vector2 |
|
The minimum and maximum delay between glitch activations in seconds. |
options.duration | Vector2 |
|
The minimum and maximum duration of a glitch in seconds. |
options.strength | Vector2 |
|
The strength of weak and strong glitches. |
options.perturbationMap | Texture |
|
A perturbation map. If none is provided, a noise texture will be created. |
options.dtSize | Number |
|
The size of the generated noise map. Will be ignored if a perturbation map is provided. |
options.columns | Number |
|
The scale of the blocky glitch columns. |
options.ratio | Number |
|
The threshold for strong glitches. |
Public Members
public set columns source
public delay: Vector2 source
The minimum and maximum delay between glitch activations in seconds.
public duration: Vector2 source
The minimum and maximum duration of a glitch in seconds.
public set maxDelay source
public set maxDuration source
public set maxStrength source
public set minDelay source
public set minDuration source
public set minStrength source
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
The strength of weak and strong glitches.
Public Methods
public generatePerturbationMap(value: Number): DataTexture source
Generates a perturbation map.
Params:
Name | Type | Attribute | Description |
value | Number |
|
The texture size. |
Return:
DataTexture | The perturbation map. |
public getChromaticAberrationOffset(): Vector2 source
Returns the chromatic aberration offset.
Return:
Vector2 | The offset. |
public getGlitchColumns(): Number source
Returns the glitch column size.
public getGlitchRatio(): Number source
Returns the glitch ratio.
public getMaxDelay(): Number source
Returns the maximum delay between glitch activations.
public getMaxDuration(): Number source
Returns the maximum duration of sporadic glitches.
public getMaxStrength(): Number source
Returns the strength of strong glitches.
public getMinDelay(): Number source
Returns the minimum delay between glitch activations.
public getMinDuration(): Number source
Returns the minimum duration of sporadic glitches.
public getMinStrength(): Number source
Returns the strength of weak glitches.
public getMode(): GlitchMode source
Returns the current glitch mode.
public getPerturbationMap(): Texture source
Returns the current perturbation map.
Return:
Texture | The current perturbation map. |
public isActive(): Boolean source
Indicates whether the glitch effect is currently active.
public setChromaticAberrationOffset(value: Vector2) source
Sets the chromatic aberration offset.
Params:
Name | Type | Attribute | Description |
value | Vector2 | The offset. |
public setGlitchColumns(value: Number) source
Sets the glitch column size.
Params:
Name | Type | Attribute | Description |
value | Number | The glitch column size. |
public setGlitchRatio(value: Number) source
Sets the ratio of weak (0.0) and strong (1.0) glitches.
Params:
Name | Type | Attribute | Description |
value | Number | The ratio. Range is [0.0, 1.0]. |
public setMaxDelay(value: Number) source
Sets the maximum delay between glitch activations.
Params:
Name | Type | Attribute | Description |
value | Number | The maximum delay in seconds. |
public setMaxDuration(value: Number) source
Sets the maximum duration of sporadic glitches.
Params:
Name | Type | Attribute | Description |
value | Number | The maximum duration in seconds. |
public setMaxStrength(value: Number) source
Sets the strength of strong glitches.
Params:
Name | Type | Attribute | Description |
value | Number | The strength. |
public setMinDelay(value: Number) source
Sets the minimum delay between glitch activations.
Params:
Name | Type | Attribute | Description |
value | Number | The minimum delay in seconds. |
public setMinDuration(value: Number) source
Sets the minimum duration of sporadic glitches.
Params:
Name | Type | Attribute | Description |
value | Number | The minimum duration in seconds. |
public setMinStrength(value: Number) source
Sets the strength of weak glitches.
Params:
Name | Type | Attribute | Description |
value | Number | The strength. |
public setMode(value: GlitchMode) source
Sets the current glitch mode.
Params:
Name | Type | Attribute | Description |
value | GlitchMode | The mode. |
public setPerturbationMap(value: Texture) source
Replaces the current perturbation map with the given one.
The current map will be disposed if it was generated by this effect.
Params:
Name | Type | Attribute | Description |
value | Texture | The new perturbation map. |
public update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, deltaTime: Number) source
Updates this effect.
Override:
Effect#updateParams:
Name | Type | Attribute | Description |
renderer | WebGLRenderer | The renderer. |
|
inputBuffer | WebGLRenderTarget | A frame buffer that contains the result of the previous pass. |
|
deltaTime | Number |
|
The time between the last frame and the current one in seconds. |