# Kernel

Class · category: Math

Source: https://github.com/playcanvas/engine/blob/970d89f6d3bc6667f4e1f88153abd6e7e82ed52c/src/core/math/kernel.js#L14

Sampling kernels: sets of 2D offsets, generated on demand, used to take several samples around a
point, as blur, soft shadow and ambient occlusion effects do.

[concentric](https://api.playcanvas.com/engine/classes/Kernel.md#concentric) produces a center point followed by points arranged in evenly spaced rings out
to a radius of one, returned as a flat `[x, y, x, y, ...]` array ready to upload as a shader
uniform.

**Example**

```ts
// A kernel with 3 rings and 8 points in the innermost ring
const offsets = Kernel.concentric(3, 8);   // [0, 0, x1, y1, x2, y2, ...]
```

## Methods

### concentric

```ts
static concentric(numRings: number, numPoints: number): number[]
```

Generate a set of points distributed in a series of concentric rings around the origin. The
spacing between points is determined by the number of points in the first ring, and subsequent
rings maintain this spacing by adjusting their number of points accordingly.

**Parameters**

- `numRings` (`number`): The number of concentric rings to generate.
- `numPoints` (`number`): The number of points in the first ring.

**Returns** `number[]`: An array where each point is represented by two consecutive numbers (x, y).

**Example**

```ts
// Generate a kernel with 3 rings and 8 points in the first ring
const kernel = Kernel.concentric(3, 8);
// kernel is a flat array: [x0, y0, x1, y1, x2, y2, ...]
```
