---
url: /api/passes/pingPongFBO/functions/pingPongFBO.md
---
# pingPongFBO()

```ts
function pingPongFBO<U extends UniformSources<UniformContext>>(params: {
  gl: WebGL2RenderingContext;
  uniforms?: U;
  fragment: string;
  dataTexture: {
    name?: string;
    initialData: number[] | Float32Array<ArrayBufferLike>;
  };
}): PingPongFBOPass<U>;
```

Creates a ping-pong Framebuffer Object (FBO) pass for GPGPU calculations.

This pattern uses two textures (read and write) that are swapped at each render call.
It is commonly used for particle simulations, fluid dynamics, or any iterative process.

* [Example: Particles](/examples/gpgpu/particles/)
* [Example: Boids](/examples/gpgpu/boids/)
* [Example: Game of Life](/examples/gpgpu/game-of-life/)

## Type Parameters

### U

`U` *extends* [`UniformSources`](../../../types/types/type-aliases/UniformSources.md)<[`UniformContext`](../../../types/types/interfaces/UniformContext.md)>

## Parameters

### params

Configuration for the ping-pong pass.

#### gl

`WebGL2RenderingContext`

WebGL2 context.

#### uniforms?

`U` = `...`

Uniform sources for the simulation pass.

#### fragment

`string`

Fragment shader source. Should read from `dataTexture.name`.

#### dataTexture

{
`name?`: `string`;
`initialData`: `number`\[] | `Float32Array`<`ArrayBufferLike`>;
}

Initial data and uniform name for the double-buffered texture.

#### dataTexture.name?

`string`

The name of the sampler2D uniform in the fragment shader. Defaults to "tData".

#### dataTexture.initialData

`number`\[] | `Float32Array`<`ArrayBufferLike`>

The raw numerical data to seed the initial texture state.

## Returns

[`PingPongFBOPass`](../type-aliases/PingPongFBOPass.md)<`U`>

A [RenderPass](../../renderPass/type-aliases/RenderPass.md) object specialized for double-buffering.
