mix
On this page

mix()

Function in Builtins

mix(a, b, t): linear interpolation a + t·(b − a), component-wise, keyed by a.

import { mix } from 'typeshade'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

function mix<K extends FloatKey | Float64Key>(
a: ReadonlyNode<K>,
b: NoInfer<ArithArg<K>>,
t: ReadonlyNode<'f32'> | number,
): Node<K>;
function mix(
a: number,
b: ReadonlyNode<'f32'> | number,
t: ReadonlyNode<'f32'> | number,
): Node<'f32'>;

Parameters

a ReadonlyNode<K>
b NoInfer<ArithArg<K>>
t ReadonlyNode<'f32'> | number

Return value

Node<K>

Description

A t outside [0, 1] extrapolates; pass t through clamp or smoothstep when the result must stay within the a..b range.

Examples

Example

import { fn, mix, vec3, f32T } from 'typeshade'
const blend = fn('blend', { t: f32T }, ({ t }) => mix(vec3(0, 0, 0), vec3(1, 1, 1), t))

Targets

TargetSupportNotes
WGSL (WebGPU) Supported

mix(a, b, t). Over f64 operands the fp64 pass rewrites it into its df64 helper.

GLSL ES 3.00 (WebGL2) Supported

mix(a, b, t). Over f64 operands the fp64 pass rewrites it into its df64 helper.

CPU oracle Supported

Evaluated in f64 by the oracle.

In the guide

See also

Source

src/core/ir/node.ts, line 1740, at commit 26de7be8

Edit this page Report a problem