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

RealisticBokehMaterial

Extends:

three~ShaderMaterial → RealisticBokehMaterial

Depth of Field shader v2.4.

Original shader code by Martins Upitis: http://blenderartists.org/forum/showthread.php?237488-GLSL-depth-of-field-with-bokeh-v2-4-(update)

Constructor Summary

Public Constructor
public

constructor(camera: PerspectiveCamera, options: Object)

Constructs a new bokeh2 material.

Member Summary

Public Members
public

Method Summary

Public Methods
public

adoptCameraSettings(camera: PerspectiveCamera)

Adopts the near and far plane and the focal length of the given camera.

public

Defines whether manual Depth of Field should be enabled.

public

Defines whether the dithering should compute noise.

public

Defines whether the pentagonal blur effect should be enabled.

public

Enables or disables the automatic shader focus.

public

Defines whether the focus should be shown.

public

Sets the texel size.

public

Defines whether the Vignette effect should be enabled.

Public Constructors

public constructor(camera: PerspectiveCamera, options: Object) source

Constructs a new bokeh2 material.

Params:

NameTypeAttributeDescription
camera PerspectiveCamera
  • optional

The main camera.

options Object
  • optional

Additional options.

options.texelSize Vector2
  • optional

The absolute screen texel size.

options.rings Boolean
  • optional
  • default: 3

The number of blurring iterations.

options.samples Boolean
  • optional
  • default: 2

The amount of samples taken per ring.

options.showFocus Boolean
  • optional
  • default: false

Whether the focus point should be highlighted.

options.manualDoF Boolean
  • optional
  • default: false

Enables manual depth of field blur.

options.vignette Boolean
  • optional
  • default: false

Enables a vignette effect.

options.pentagon Boolean
  • optional
  • default: false

Enable to use a pentagonal shape to scale gathered texels.

options.shaderFocus Boolean
  • optional
  • default: true

Disable if you compute your own focalDepth (in metres!).

options.noise Boolean
  • optional
  • default: true

Disable if you don't want noise patterns for dithering.

options.maxBlur Number
  • optional
  • default: 1.0

The maximum blur strength.

options.luminanceThreshold Number
  • optional
  • default: 0.5

A luminance threshold.

options.luminanceGain Number
  • optional
  • default: 2.0

A luminance gain factor.

options.bias Number
  • optional
  • default: 0.5

A blur bias.

options.fringe Number
  • optional
  • default: 0.7

A blur offset.

options.ditherStrength Number
  • optional
  • default: 0.0001

The dither strength.

Public Members

public needsUpdate: boolean source

Public Methods

public adoptCameraSettings(camera: PerspectiveCamera) source

Adopts the near and far plane and the focal length of the given camera.

Params:

NameTypeAttributeDescription
camera PerspectiveCamera

The main camera.

public setManualDepthOfFieldEnabled(enabled: Boolean) source

Defines whether manual Depth of Field should be enabled.

Params:

NameTypeAttributeDescription
enabled Boolean

Whether manual DoF should be enabled.

public setNoiseEnabled(enabled: Boolean) source

Defines whether the dithering should compute noise.

Params:

NameTypeAttributeDescription
enabled Boolean

Whether noise-based dithering should be enabled.

public setPentagonEnabled(enabled: Boolean) source

Defines whether the pentagonal blur effect should be enabled.

Params:

NameTypeAttributeDescription
enabled Boolean

Whether the pentagonal blur effect should be enabled.

public setShaderFocusEnabled(enabled: Boolean) source

Enables or disables the automatic shader focus.

Params:

NameTypeAttributeDescription
enabled Boolean

Whether the shader focus should be enabled.

public setShowFocusEnabled(enabled: Boolean) source

Defines whether the focus should be shown.

Params:

NameTypeAttributeDescription
enabled Boolean

True if the focus should be shown, false otherwise.

public setTexelSize(x: Number, y: Number) source

Sets the texel size.

Params:

NameTypeAttributeDescription
x Number

The texel width.

y Number

The texel height.

public setVignetteEnabled(enabled: Boolean) source

Defines whether the Vignette effect should be enabled.

Params:

NameTypeAttributeDescription
enabled Boolean

Whether the Vignette effect should be enabled.