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
aReadonlyNode<K>bNoInfer<ArithArg<K>>tReadonlyNode<'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
| Target | Support | Notes |
|---|---|---|
| WGSL (WebGPU) | Supported |
|
| GLSL ES 3.00 (WebGL2) | Supported |
|
| 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