DepthOfFieldEffect
Extends:
Indirect Implements:
A depth of field effect.
Based on a graphics study by Adrian Courrèges and an article by Steve Avery: https://www.adriancourreges.com/blog/2016/09/09/doom-2016-graphics-study/ https://pixelmischiefblog.wordpress.com/2016/11/25/bokeh-depth-of-field/
Constructor Summary
Public Constructor | ||
public |
constructor(camera: Camera, options: Object) Constructs a new depth of field effect. |
Member Summary
Public Members | ||
public |
This pass blurs the foreground CoC buffer to soften edges. |
|
public get |
The current bokeh scale. |
|
public set |
Sets the bokeh scale. |
|
public get |
The circle of confusion material. |
|
public get |
The resolution of this effect. |
|
public |
target: Vector3 A target position that should be kept in focus. |
Method Summary
Public Methods | ||
public |
calculateFocusDistance(target: Vector3): Number Calculates the focus distance from the camera to the given position. |
|
public |
initialize(renderer: WebGLRenderer, alpha: Boolean, frameBufferType: Number) Performs initialization tasks. |
|
public |
setDepthTexture(depthTexture: Texture, depthPacking: Number) Sets the depth texture. |
|
public |
Updates the size of internal render targets. |
|
public |
Updates this effect. |
Inherited Summary
From class Effect | ||
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. |
|
public |
dispose() Performs a shallow search for properties that define a dispose method and deletes them. |
|
public |
Returns the effect attributes. |
|
public |
Returns the fragment shader. |
|
public |
Returns the vertex shader. |
|
public |
initialize(renderer: WebGLRenderer, alpha: Boolean, frameBufferType: Number) Performs initialization tasks. |
|
public |
setDepthTexture(depthTexture: Texture, depthPacking: Number) Sets the depth texture. |
|
public |
Updates the size of this effect. |
|
public |
Updates the effect by performing supporting operations. |
|
protected |
setAttributes(attributes: EffectAttribute) Sets the effect attributes. |
|
protected |
Informs the associated EffectPass that this effect has changed in a way that requires a shader recompilation. |
|
protected |
setFragmentShader(fragmentShader: String) Sets the fragment shader. |
|
protected |
setVertexShader(vertexShader: String) Sets the vertex shader. |
Public Constructors
public constructor(camera: Camera, options: Object) source
Constructs a new depth of field effect.
Override:
Effect#constructorParams:
Name | Type | Attribute | Description |
camera | Camera | The main camera. |
|
options | Object |
|
The options. |
options.blendFunction | BlendFunction |
|
The blend function of this effect. |
options.focusDistance | Number |
|
The normalized focus distance. Range is [0.0, 1.0]. |
options.focalLength | Number |
|
The focal length. Range is [0.0, 1.0]. |
options.bokehScale | Number |
|
The scale of the bokeh blur. |
options.width | Number |
|
The render width. |
options.height | Number |
|
The render height. |
Public Members
public get circleOfConfusionMaterial: CircleOfConfusionMaterial source
The circle of confusion material.
public target: Vector3 source
A target position that should be kept in focus.
Set this to null
to disable auto focus.
Public Methods
public calculateFocusDistance(target: Vector3): Number source
Calculates the focus distance from the camera to the given position.
Params:
Name | Type | Attribute | Description |
target | Vector3 | The target. |
public initialize(renderer: WebGLRenderer, alpha: Boolean, frameBufferType: Number) source
Performs initialization tasks.
Override:
Effect#initializepublic setDepthTexture(depthTexture: Texture, depthPacking: Number) source
Sets the depth texture.
Override:
Effect#setDepthTextureParams:
Name | Type | Attribute | Description |
depthTexture | Texture | A depth texture. |
|
depthPacking | Number |
|
The depth packing. |
public setSize(width: Number, height: Number) source
Updates the size of internal render targets.
Override:
Effect#setSizepublic 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. |