---
title: "select"
description: "`ifTrue` when the condition holds, otherwise `ifFalse`."
group: "space"
groupTitle: "Shapes, frames & warps"
categoryId: "math"
categorySlug: "math"
categoryTitle: "Math"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/math.ts#L486"
---

# select

`ifTrue` when the condition holds, otherwise `ifFalse`.

```ts
select(cond: Expr, ifTrue: Val, ifFalse: Val): Expr
```

Import `math` from `shaders/std` and use `math.select`.

Both values are computed at every pixel, so this picks rather than skips work. For a soft transition use `mix` or `smoothstep` instead.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `cond` | `Expr` |  |
| `ifTrue` | `Val` |  |
| `ifFalse` | `Val` |  |

## Example

```ts
const rgb = select(lt(dist, radius), params.uniforms.fill.member('rgb'), params.uniforms.background.member('rgb'))
```

## See also

- [`lt`](/docs/primitives/math/lt) — True when `a` is less than `b`.
- [`gt`](/docs/primitives/math/gt) — True when `a` is greater than `b`.
- [`mix`](/docs/primitives/math/mix) — A blend from `a` to `b` by `t`, where 0 gives `a` and 1 gives `b`.

## Used by

[CarbonFiber](/docs/components/carbonfiber), [Crystal](/docs/components/crystal), [ReactionDiffusion](/docs/components/reactiondiffusion)