# SsaoEffect

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

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

The Screen Space Ambient Occlusion (SSAO) effect, a postprocessing technique that approximates
ambient occlusion by calculating how exposed each point in the screen space is to ambient light,
enhancing depth perception and adding subtle shadowing in crevices and between objects.

The occlusion is generated from the scene depth by a pass the effect owns. With
[SSAOTYPE_LIGHTING](https://api.playcanvas.com/engine/variables/SSAOTYPE_LIGHTING.md) it is applied by the lit materials as the scene renders, and with
[SSAOTYPE_COMBINE](https://api.playcanvas.com/engine/variables/SSAOTYPE_COMBINE.md) it is applied to the rendered 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#ssao](https://api.playcanvas.com/engine/classes/CameraFrame.md#ssao).

## Constructors

### constructor

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

**Parameters**

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

## Properties

### blurEnabled

```ts
blurEnabled: boolean = true
```

Whether the SSAO effect is blurred. Defaults to true.

### intensity

```ts
intensity: number = 0.5
```

The intensity of the SSAO effect, 0-1 range. Defaults to 0.5.

### minAngle

```ts
minAngle: number = 10
```

The minimum angle of the SSAO effect, 1-90 range. Defaults to 10.

### power

```ts
power: number = 6
```

The power of the SSAO effect, 0.1-10 range. Defaults to 6.

### radius

```ts
radius: number = 30
```

The radius of the SSAO effect, 0-100 range. Defaults to 30.

### randomize

```ts
randomize: boolean = false
```

Whether the SSAO sampling is randomized. Useful when used instead of blur effect together
with TAA. Defaults to false.

### samples

```ts
samples: number = 12
```

The number of samples of the SSAO effect, 1-64 range. Defaults to 12.

### scale

```ts
scale: number = 1
```

The scale of the SSAO effect, 0.5-1 range. Defaults to 1.

### type

```ts
type: string = SSAOTYPE_NONE
```

The type of the SSAO, which determines how it is applied in the rendering process. Defaults
to [SSAOTYPE_NONE](https://api.playcanvas.com/engine/variables/SSAOTYPE_NONE.md), making it disabled. Can be:

- [SSAOTYPE_NONE](https://api.playcanvas.com/engine/variables/SSAOTYPE_NONE.md)
- [SSAOTYPE_LIGHTING](https://api.playcanvas.com/engine/variables/SSAOTYPE_LIGHTING.md)
- [SSAOTYPE_COMBINE](https://api.playcanvas.com/engine/variables/SSAOTYPE_COMBINE.md)

## Accessors

### active

```ts
get active(): boolean
```

Gets whether the effect contributes to the frame. [SSAOTYPE_NONE](https://api.playcanvas.com/engine/variables/SSAOTYPE_NONE.md) disables it, the
type being the effect's on/off control.

### requires

```ts
get requires(): string[]
```

Gets the frame resources the effect needs: the scene depth, rendered by a prepass when the
type is [SSAOTYPE_LIGHTING](https://api.playcanvas.com/engine/variables/SSAOTYPE_LIGHTING.md), as the occlusion is then generated before the scene
renders.

## Methods

### 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`
- `enabled: boolean = true`
- `get cameraExposureScale(): number`
- `get chunkName(): string`
- `get debugViews(): string[]`
- `get defineName(): string`
- `get entryPoint(): string`
- `get glsl(): string | null`
- `get id(): string`
- `get slot(): string | null`
- `get wgsl(): string | null`
- `destroy(): void`
- `frameUpdate(frame: CameraFrameEffectContext): 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`
