mix()
함수, 내장 함수 분류
mix(a, b, t): linear interpolation a + t·(b − a), component-wise, keyed by a.
import { mix } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
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'>;매개변수
aReadonlyNode<K>bNoInfer<ArithArg<K>>tReadonlyNode<'f32'> | number
반환값
Node<K>
설명
A t
outside [0, 1] extrapolates; pass t through clamp or smoothstep when the
result must stay within the a..b range.
예제
예제
import { fn, mix, vec3, f32T } from 'typeshade'
const blend = fn('blend', { t: f32T }, ({ t }) => mix(vec3(0, 0, 0), vec3(1, 1, 1), t))대상별 지원
| 대상 | 지원 | 비고 |
|---|---|---|
| WGSL (WebGPU) | 지원 |
|
| GLSL ES 3.00 (WebGL2) | 지원 |
|
| CPU 오라클 | 지원 | Evaluated in f64 by the oracle. |
관련 가이드
함께 보기
소스
src/core/ir/node.ts, 1740행, 커밋 c66579bf 기준