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

Pass

An abstract pass.

Passes that do not rely on the depth buffer should explicitly disable the depth test and depth write flags of their fullscreen shader material.

Fullscreen passes use a shared fullscreen triangle: https://michaldrobot.com/2014/04/01/gcn-execution-patterns-in-full-screen-passes/

Constructor Summary

Public Constructor
public

constructor(name: String, scene: Scene, camera: Camera)

Constructs a new pass.

Member Summary

Public Members
public

Indicates whether this pass should be executed.

public

The name of this pass.

public

Indicates whether the EffectComposer should prepare a depth texture for this pass.

public

Only relevant for subclassing.

public

Indicates whether this pass should render to screen.

Protected Members
protected

camera: Camera

The camera.

protected

scene: Scene

The scene to render.

Method Summary

Public Methods
public

Performs a shallow search for disposable properties and deletes them.

public

getDepthTexture(): Texture

Returns the current depth texture.

public

getFullscreenMaterial(): Material

Returns the current fullscreen material.

public

initialize(renderer: WebGLRenderer, alpha: Boolean)

Performs initialization tasks.

public abstract

render(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, outputBuffer: WebGLRenderTarget, deltaTime: Number, stencilTest: Boolean)

Renders the effect.

public

setDepthTexture(depthTexture: Texture, depthPacking: Number)

Sets the depth texture.

public

setSize(width: Number, height: Number)

Updates this pass with the renderer's size.

You may override this method in case you want to be informed about the size of the main frame buffer.

The EffectComposer calls this method before this pass is initialized and every time its own size is updated.

Protected Methods
protected

setFullscreenMaterial(material: Material)

Sets the fullscreen material.

Public Constructors

public constructor(name: String, scene: Scene, camera: Camera) source

Constructs a new pass.

Params:

NameTypeAttributeDescription
name String
  • optional

The name of this pass. Does not have to be unique.

scene Scene
  • optional

The scene to render. The default scene contains a single mesh that fills the screen.

camera Camera
  • optional

The camera. The default camera perfectly captures the screen mesh.

Public Members

public enabled: Boolean source

Indicates whether this pass should be executed.

public name: String source

The name of this pass.

public needsDepthTexture: Boolean source

Indicates whether the EffectComposer should prepare a depth texture for this pass.

Set this to true if this pass relies on depth information from a preceding RenderPass.

public needsSwap: Boolean source

Only relevant for subclassing.

Indicates whether the EffectComposer should swap the frame buffers after this pass has finished rendering.

Set this to false if this pass doesn't render to the output buffer or the screen. Otherwise, the contents of the input buffer will be lost.

public renderToScreen: Boolean source

Indicates whether this pass should render to screen.

Protected Members

protected camera: Camera source

The camera.

protected scene: Scene source

The scene to render.

Public Methods

public dispose() source

Performs a shallow search for disposable properties and deletes them. The pass will be inoperative after this method was called!

Disposable objects:

  • WebGLRenderTarget
  • Material
  • Texture

The EffectComposer calls this method when it is being destroyed. You may, however, use it independently to free memory when you are certain that you don't need this pass anymore.

public getDepthTexture(): Texture source

Returns the current depth texture.

Return:

Texture

The current depth texture, or null if there is none.

public getFullscreenMaterial(): Material source

Returns the current fullscreen material.

Return:

Material

The current fullscreen material, or null if there is none.

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

Performs initialization tasks.

By overriding this method you gain access to the renderer. You'll also be able to configure your custom render targets to use the appropriate format (RGB or RGBA).

The provided renderer can be used to warm up special off-screen render targets by performing a preliminary render operation.

The EffectComposer calls this method when this pass is added to its queue, but not before its size has been set.

Params:

NameTypeAttributeDescription
renderer WebGLRenderer

The renderer.

alpha Boolean

Whether the renderer uses the alpha channel or not.

Example:

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

public abstract render(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, outputBuffer: WebGLRenderTarget, deltaTime: Number, stencilTest: Boolean) source

Renders the effect.

This is an abstract method that must be overridden.

Params:

NameTypeAttributeDescription
renderer WebGLRenderer

The renderer.

inputBuffer WebGLRenderTarget

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

outputBuffer WebGLRenderTarget

A frame buffer that serves as the output render target unless this pass renders to screen.

deltaTime Number
  • optional

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

stencilTest Boolean
  • optional

Indicates whether a stencil mask is active.

Throw:

Error

An error is thrown if the method is not overridden.

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

Sets the depth texture.

You may override this method if your pass relies on the depth information of a preceding RenderPass.

Params:

NameTypeAttributeDescription
depthTexture Texture

A depth texture.

depthPacking Number
  • optional
  • default: 0

The depth packing.

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

Updates this pass with the renderer's size.

You may override this method in case you want to be informed about the size of the main frame buffer.

The EffectComposer calls this method before this pass is initialized and every time its own size is updated.

Params:

NameTypeAttributeDescription
width Number

The renderer's width.

height Number

The renderer's height.

Example:

this.myRenderTarget.setSize(width, height);

Protected Methods

protected setFullscreenMaterial(material: Material) source

Sets the fullscreen material.

The material will be assigned to a mesh that fills the screen. The mesh will be created once a material is assigned via this method.

Params:

NameTypeAttributeDescription
material Material

A fullscreen material.