Home Reference Source
import {ToneMappingPass} from 'postprocessing/src/passes/ToneMappingPass.js'
public class | source

ToneMappingPass

Extends:

Pass → ToneMappingPass

Indirect Implements:

A tone mapping pass that supports adaptive luminosity.

If adaptivity is enabled, this pass generates a texture that represents the luminosity of the current scene and adjusts it over time to simulate the optic nerve responding to the amount of light it is receiving.

Reference: GDC2007 - Wolfgang Engel, Post-Processing Pipeline http://perso.univ-lyon1.fr/jean-claude.iehl/Public/educ/GAMA/2007/gdc07/Post-Processing_Pipeline.pdf

Constructor Summary

Public Constructor
public

constructor(options: Object)

Constructs a new tone mapping pass.

Member Summary

Public Members
public get

Whether this pass uses adaptive luminosity.

public set

Whether this pass should use adaptive luminosity.

public get

Indicates whether dithering is enabled.

public set

If enabled, the result will be dithered to remove banding artifacts.

public get

The resolution of the render targets.

public set

The resolution of the render targets.

Private Members
private

An adaptive luminance shader material.

private

Copy shader material used for saving the luminance map.

private

A luminosity shader material.

private

renderTargetAdapted: WebGLRenderTarget

The render target for adapted luminosity.

private

renderTargetLuminosity: WebGLRenderTarget

The render target for the current luminosity.

private

renderTargetPrevious: WebGLRenderTarget

A render target that holds a copy of the adapted limonosity.

private

A tone mapping shader material.

Method Summary

Public Methods
public

initialize(renderer: WebGLRenderer, alpha: Boolean)

Performs initialization tasks.

public

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

Renders the effect.

Inherited Summary

From class Pass
public get

material: Material

this get was deprecated. Use getFullscreenMaterial() instead.

The fullscreen material.

protected set

material: Material

this set was deprecated. Use setFullscreenMaterial(Material) instead.
public

[key]: *

public

Indicates whether this pass should be executed.

public

The name of this pass.

public

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

public

Indicates whether this pass should render to screen.

protected

camera: Camera

The camera.

protected

scene: Scene

The scene to render.

private

quad: Mesh

A quad mesh that fills the screen.

public

Performs a shallow search for disposable properties and deletes them.

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, delta: Number, stencilTest: Boolean)

Renders the effect.

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 main render size.

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

protected

setFullscreenMaterial(material: Material)

Sets the fullscreen material.

Public Constructors

public constructor(options: Object) source

Constructs a new tone mapping pass.

Override:

Pass#constructor

Params:

NameTypeAttributeDescription
options Object
  • optional

The options.

options.adaptive Boolean
  • optional
  • default: true

Whether the tone mapping should use an adaptive luminance map.

options.resolution Number
  • optional
  • default: 256

The render texture resolution.

options.distinction Number
  • optional
  • default: 1.0

A luminance distinction factor.

Public Members

public get adaptive: Boolean source

Whether this pass uses adaptive luminosity.

public set adaptive: Boolean source

Whether this pass should use adaptive luminosity.

public get dithering: Boolean source

Indicates whether dithering is enabled.

public set dithering: Boolean source

If enabled, the result will be dithered to remove banding artifacts.

public get resolution: Number source

The resolution of the render targets.

public set resolution: Number source

The resolution of the render targets. Must be a power of two for mipmaps.

Private Members

private adaptiveLuminosityMaterial: AdaptiveLuminosityMaterial source

An adaptive luminance shader material.

private copyMaterial: CopyMaterial source

Copy shader material used for saving the luminance map.

private luminosityMaterial: LuminosityMaterial source

A luminosity shader material.

private renderTargetAdapted: WebGLRenderTarget source

The render target for adapted luminosity.

private renderTargetLuminosity: WebGLRenderTarget source

The render target for the current luminosity.

TODO:

  • Use RED format in WebGL 2.0.

private renderTargetPrevious: WebGLRenderTarget source

A render target that holds a copy of the adapted limonosity.

private toneMappingMaterial: ToneMappingMaterial source

A tone mapping shader material.

Public Methods

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

Performs initialization tasks.

Override:

Pass#initialize

Params:

NameTypeAttributeDescription
renderer WebGLRenderer

The renderer.

alpha Boolean

Whether the renderer uses the alpha channel or not.

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

Renders the effect.

Override:

Pass#render

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.

delta Number
  • optional

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

stencilTest Boolean
  • optional

Indicates whether a stencil mask is active.