# GlslShader

interface in `@dioramajs/diorama/glsl`

```ts
import type { GlslShader } from '@dioramajs/diorama/glsl'
```

Default export of a `?shader` import. `build` needs nothing but `three/tsl`.

```ts
interface GlslShader<P extends ParamSpec = ParamSpec>
```

## Members

| Name | Type | Description |
| --- | --- | --- |
| `animate` | `'hover' \| 'input' \| 'visible'` | Frame policy of the effect. |
| `animateFromPragma` | `boolean` | Whether `animate` comes from a pragma rather than the inputs it reads. |
| `bleed` | `number` | Extra space around the box, CSS px. |
| `colorSpace` | `'srgb' \| 'linear'` | Colour space of its output. |
| `dialect` | `'three' \| 'glsl3' \| 'shadertoy'` | GLSL flavour the source was written in. |
| `externals` | `readonly string[]` | Prototypes the caller provides through `functions`. |
| `file` | `string` | Source file. |
| `media` | `boolean` | Whether it reads the element's image. |
| `name` | `string` | Effect name, from the file name or the pragma. |
| `params` | `P` | Params of the effect, from `param:` uniforms. |
| `presence?` | `'fade' \| 'custom'` | `// @diorama presence=fade\|custom`. |
| `reducedMotion?` | `'static' \| 'off'` | `// @diorama reducedMotion=static\|off`. |
| `segments` | `number` | Plane segments per side, for position stages. |
| `stage` | `'uv' \| 'color' \| 'position'` | What the shader changes: the UV, the colour or the vertex position. |
| `textures` | `{ [uniform: string]: string }` | URLs from `// @texture ./file` pragmas, by uniform name. |
| `uniforms` | `{ [name: string]: UniformInfo }` | Uniforms by GLSL name. |
| `varyings` | `{ [name: string]: GlslType }` | Varyings this stage reads (fragment) or writes (vertex), besides uv. |
| `when?` | `When` | `// @diorama when=…`: media query the page must match, `hover` for `(hover: hover)`. |
| `writes` | `readonly string[]` | Varyings a vertex shader writes. |
| `build` | `build(scope: ShaderScope): Node` | Runs on every material build. Returns vec2 for uv, vec4 for color, vec3 for position. |

Also exported from `@dioramajs/glsl`.

Defined in [packages/glsl/src/types.ts](https://github.com/MasterKurosava/diorama/blob/main/packages/glsl/src/types.ts#L134).
