# GSplatVaryings

Class · category: Graphics

Source: https://github.com/playcanvas/engine/blob/970d89f6d3bc6667f4e1f88153abd6e7e82ed52c/src/scene/gsplat-unified/gsplat-varyings.js#L89

Manages custom varying streams for the gsplat render customization. Streams added here generate
set functions available to the `gsplatModifyVS` shader chunk, where they run once per splat,
and matching get functions available to the `gsplatModifyPS` shader chunk, where the per-splat
value can be read for each rendered fragment.

Access the instance via [GSplatParams#varyings](https://api.playcanvas.com/engine/classes/GSplatParams.md#varyings).

## Accessors

### streams

```ts
get streams(): GSplatVaryingDescriptor[]
```

Gets the varying stream descriptors. Do not modify the returned array.

## Methods

### add

```ts
add(streams: GSplatVaryingDescriptor[]): void
```

Adds varying streams. For each stream, a set function (`set<Name>`) is generated and made
available to the `gsplatModifyVS` shader chunk, where it runs once per splat, and a
matching get function (`get<Name>`) is made available to the `gsplatModifyPS` shader
chunk, where the per-splat value can be read for each rendered fragment.

Supported types are [TYPE_FLOAT32](https://api.playcanvas.com/engine/variables/TYPE_FLOAT32.md), [TYPE_INT32](https://api.playcanvas.com/engine/variables/TYPE_INT32.md) and [TYPE_UINT32](https://api.playcanvas.com/engine/variables/TYPE_UINT32.md), with
1 to 4 components. Adding or removing streams rebuilds the gsplat shaders.

Note: on some platforms each component is stored in per-splat video memory, so its size
scales with the number of rendered splats. Keep the data as compact as possible - prefer
fewer components, and consider bit-packing multiple small values into a single uint
component instead of using separate streams.

**Parameters**

- `streams` ([`GSplatVaryingDescriptor`](https://api.playcanvas.com/engine/interfaces/GSplatVaryingDescriptor.md)`[]`): The streams to add.

**Example**

```ts
// Add a per-splat flag, written once per splat in gsplatModifyVS using setFlag(value),
// and read per fragment in gsplatModifyPS using getFlag()
app.scene.gsplat.varyings.add([{
    name: 'flag',
    type: TYPE_UINT32,
    components: 1
}]);
```

### remove

```ts
remove(names: string[]): void
```

Removes varying streams previously added by [GSplatVaryings#add](https://api.playcanvas.com/engine/classes/GSplatVaryings.md#add).

**Parameters**

- `names` (`string[]`): The names of the streams to remove.
