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

Effect

Extends:

three~EventDispatcher → Effect

Indirect Subclass:

SelectiveBloomEffect

An abstract effect.

Effects can be combined using the EffectPass.

Constructor Summary

Public Constructor
public

constructor(name: String, fragmentShader: String, options: Object)

Constructs a new effect.

Member Summary

Public Members
public

The blend mode of this effect.

public

Preprocessor macro definitions.

public

WebGL extensions that are required by this 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

The name of this effect.

public get

outputColorSpace: ColorSpace

this get is experimental.

The output color space.

public

uniforms: Map<String, Uniform>

Shader uniforms.

Protected Members
protected set

inputColorSpace: ColorSpace

this set is experimental.
protected set

outputColorSpace: ColorSpace

this set is experimental.
protected

renderer: WebGLRenderer

this member was deprecated.

The renderer.

Method Summary

Public Methods
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 Methods
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(name: String, fragmentShader: String, options: Object) source

Constructs a new effect.

Params:

NameTypeAttributeDescription
name String

The name of this effect. Doesn't have to be unique.

fragmentShader String

The fragment shader. This shader is required.

options Object
  • optional

Additional options.

options.attributes EffectAttribute
  • optional
  • default: EffectAttribute.NONE

The effect attributes that determine the execution priority and resource requirements.

options.blendFunction BlendFunction
  • optional
  • default: BlendFunction.NORMAL

The blend function of this effect.

options.defines Map<String, String>
  • optional

Custom preprocessor macro definitions. Keys are names and values are code.

options.uniforms Map<String, Uniform>
  • optional

Custom shader uniforms. Keys are names and values are uniforms.

options.extensions Set<WebGLExtension>
  • optional

WebGL extensions.

options.vertexShader String
  • optional
  • default: null

The vertex shader. Most effects don't need one.

Public Members

public blendMode: BlendMode source

The blend mode of this effect.

public defines: Map<String, String> source

Preprocessor macro definitions.

Call Effect.setChanged after changing macro definitions.

public extensions: Set<WebGLExtension> source

WebGL extensions that are required by this effect.

Call Effect.setChanged after adding or removing extensions.

public get inputColorSpace: ColorSpace source

this get is experimental.

The input color space.

public set mainCamera: Camera source

Sets the main camera.

public set mainScene: Scene source

Sets the main scene.

public name: String source

The name of this effect.

public get outputColorSpace: ColorSpace source

this get is experimental.

The output color space.

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

public uniforms: Map<String, Uniform> source

Shader uniforms.

Call Effect.setChanged after adding or removing uniforms.

Protected Members

protected set inputColorSpace: ColorSpace source

this set is experimental.

protected set outputColorSpace: ColorSpace source

this set is experimental.

protected renderer: WebGLRenderer source

this member was deprecated.

The renderer.

Public Methods

public dispose() source

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

The EffectComposer calls this method when it is being destroyed.

public getAttributes(): EffectAttribute source

Returns the effect attributes.

Return:

EffectAttribute

The attributes.

public getBlendMode(): BlendMode source

this method was deprecated. Use blendMode instead.

Returns the blend mode.

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

Return:

BlendMode

The blend mode.

public getDefines(): Map<String, String> source

this method was deprecated. Use defines instead.

Returns the preprocessor macro definitions.

Return:

Map<String, String>

The extensions.

public getExtensions(): Set<WebGLExtension> source

this method was deprecated. Use extensions instead.

Returns the WebGL extensions that are required by this effect.

Return:

Set<WebGLExtension>

The extensions.

public getFragmentShader(): String source

Returns the fragment shader.

Return:

String

The fragment shader.

public getName(): String source

this method was deprecated. Use name instead.

Returns the name of this effect.

Return:

String

The name.

public getUniforms(): Map<String, Uniform> source

this method was deprecated. Use uniforms instead.

Returns the uniforms of this effect.

Return:

Map<String, Uniform>

The extensions.

public getVertexShader(): String source

Returns the vertex shader.

Return:

String

The vertex shader.

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

Performs initialization tasks.

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

Params:

NameTypeAttributeDescription
renderer WebGLRenderer

The renderer.

alpha Boolean

Whether the renderer uses the alpha channel or not.

frameBufferType Number

The type of the main frame buffers.

Example:

if(!alpha && frameBufferType === UnsignedByteType) { this.myRenderTarget.texture.format = RGBFormat; }

public setDepthTexture(depthTexture: Texture, depthPacking: DepthPackingStrategies) source

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.

Params:

NameTypeAttributeDescription
depthTexture Texture

A depth texture.

depthPacking DepthPackingStrategies
  • optional
  • default: BasicDepthPacking

The depth packing.

public setRenderer(renderer: WebGLRenderer) source

this method was deprecated.

Sets the renderer.

Params:

NameTypeAttributeDescription
renderer WebGLRenderer

The renderer.

public setSize(width: Number, height: Number) source

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.

Params:

NameTypeAttributeDescription
width Number

The width.

height Number

The height.

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

Updates this effect by performing supporting operations.

This method is called by the EffectPass right before the main fullscreen render operation, even if the blend function is set to SKIP.

You may override this method if you need to update custom uniforms or render additional off-screen textures.

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.

Protected Methods

protected setAttributes(attributes: EffectAttribute) source

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.

Params:

NameTypeAttributeDescription
attributes EffectAttribute

The attributes.

protected setChanged() source

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

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

protected setFragmentShader(fragmentShader: String) source

Sets the fragment shader.

Params:

NameTypeAttributeDescription
fragmentShader String

The fragment shader.

protected setVertexShader(vertexShader: String) source

Sets the vertex shader.

Params:

NameTypeAttributeDescription
vertexShader String

The vertex shader.