MCPcopy Create free account
hub / github.com/pmndrs/postprocessing / DepthOfFieldEffect

Class DepthOfFieldEffect

src/effects/DepthOfFieldEffect.js:26–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24 */
25
26export class DepthOfFieldEffect extends Effect {
27
28 /**
29 * Constructs a new depth of field effect.
30 *
31 * @param {Camera} camera - The main camera.
32 * @param {Object} [options] - The options.
33 * @param {BlendFunction} [options.blendFunction] - The blend function of this effect.
34 * @param {Number} [options.worldFocusDistance] - Deprecated. Use focusRange instead.
35 * @param {Number} [options.worldFocusRange] - Deprecated. Use focusRange instead.
36 * @param {Number} [options.focusDistance=3.0] - The focus distance in world units.
37 * @param {Number} [options.focusRange=2.0] - The focus range in world units.
38 * @param {Number} [options.focalLength] - Deprecated. Use focusRange instead.
39 * @param {Number} [options.bokehScale=1.0] - The scale of the bokeh blur.
40 * @param {Number} [options.resolutionScale=0.5] - The resolution scale.
41 * @param {Number} [options.resolutionX=Resolution.AUTO_SIZE] - The horizontal resolution.
42 * @param {Number} [options.resolutionY=Resolution.AUTO_SIZE] - The vertical resolution.
43 * @param {Number} [options.width=Resolution.AUTO_SIZE] - Deprecated. Use resolutionX instead.
44 * @param {Number} [options.height=Resolution.AUTO_SIZE] - Deprecated. Use resolutionY instead.
45 */
46
47 constructor(camera, {
48 blendFunction,
49 worldFocusDistance,
50 worldFocusRange,
51 focalLength,
52 focusDistance = worldFocusDistance || 3.0,
53 focusRange = worldFocusRange || focalLength || 2.0,
54 bokehScale = 1.0,
55 resolutionScale = 0.5,
56 width,
57 height,
58 resolutionX = width || Resolution.AUTO_SIZE,
59 resolutionY = height || Resolution.AUTO_SIZE
60 } = {}) {
61
62 super("DepthOfFieldEffect", fragmentShader, {
63 blendFunction,
64 attributes: EffectAttribute.DEPTH,
65 uniforms: new Map([
66 ["nearColorBuffer", new Uniform(null)],
67 ["farColorBuffer", new Uniform(null)],
68 ["nearCoCBuffer", new Uniform(null)],
69 ["farCoCBuffer", new Uniform(null)],
70 ["scale", new Uniform(1.0)]
71 ])
72 });
73
74 /**
75 * The main camera.
76 *
77 * @type {Camera}
78 * @private
79 */
80
81 this.camera = camera;
82
83 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…