# DofEffect

Class · extends [`CameraFrameEffect`](https://api.playcanvas.com/engine/classes/CameraFrameEffect.md) · category: Graphics

Source: https://github.com/playcanvas/engine/blob/64089771243fe28a9b9d2b4de538b99b07c75097/src/extras/effects/dof/dof-effect.js#L24

The Depth of Field (DOF) effect, a technique used to simulate the optical effect where objects
at certain distances appear sharp while others are blurred, enhancing the perception of focus
and depth in the rendered scene.

The blur is generated by passes the effect owns, from the scene depth and the scene color, and
mixed into the scene in linear HDR space, before tone mapping.

Every [CameraFrame](https://api.playcanvas.com/engine/classes/CameraFrame.md) constructs and registers one, available as [CameraFrame#dof](https://api.playcanvas.com/engine/classes/CameraFrame.md#dof).

## Constructors

### constructor

```ts
new DofEffect(device: GraphicsDevice)
```

**Parameters**

- `device` ([`GraphicsDevice`](https://api.playcanvas.com/engine/classes/GraphicsDevice.md)): The graphics device.

## Properties

### blurRadius

```ts
blurRadius: number = 3
```

The radius of the blur effect, typically 2-10 range. Defaults to 3.

### blurRingPoints

```ts
blurRingPoints: number = 5
```

The number of points in each ring of the blur effect, typically 3-8 range. Defaults to 5.

### blurRings

```ts
blurRings: number = 4
```

The number of rings in the blur effect, typically 3-8 range. Defaults to 4.

### enabled

```ts
enabled: boolean = false
```

Whether DoF is enabled. Defaults to false.

### focusDistance

```ts
focusDistance: number = 100
```

The distance at which the focus is set. Defaults to 100.

### focusRange

```ts
focusRange: number = 10
```

The range around the focus distance where the focus is sharp. Defaults to 10.

### highQuality

```ts
highQuality: boolean = true
```

Whether the high quality implementation is used, which blurs the full resolution scene
instead of a half resolution copy of it. This will have a higher performance cost, but will
produce better quality results. Defaults to true.

### nearBlur

```ts
nearBlur: boolean = false
```

Whether the near blur is enabled. Defaults to false.

## Methods

### frameUpdate

```ts
frameUpdate(frame: CameraFrameEffectContext): void
```

**Parameters**

- `frame` ([`CameraFrameEffectContext`](https://api.playcanvas.com/engine/interfaces/CameraFrameEffectContext.md)): The values of this frame.

### update

```ts
update(): void
```

Applies the effect's parameters. Called by [CameraFrame#update](https://api.playcanvas.com/engine/classes/CameraFrame.md#update) while the effect is
active: set the uniform values with [CameraFrameEffect#setUniform](https://api.playcanvas.com/engine/classes/CameraFrameEffect.md#setuniform) here, and the
defines which depend on the parameters.
Everything it sets is what the frames rendered until the next update use.

## Inherited from [CameraFrameEffect](https://api.playcanvas.com/engine/classes/CameraFrameEffect.md)

- `cameraFrame: CameraFrame | null = null`
- `device: GraphicsDevice`
- `get active(): boolean`
- `get cameraExposureScale(): number`
- `get chunkName(): string`
- `get debugViews(): string[]`
- `get defineName(): string`
- `get entryPoint(): string`
- `get glsl(): string | null`
- `get id(): string`
- `get requires(): string[]`
- `get slot(): string | null`
- `get wgsl(): string | null`
- `destroy(): void`
- `getChunk(shaderLanguage: string): string | null`
- `resolveScene(scene: CameraFrameEffectScene): void`
- `setDefine(name: string, value: any): void`
- `setUniform(name: string, value: number | number[] | ArrayBufferView<ArrayBufferLike> | Texture): void`
