saturate()
함수, 내장 함수 분류
saturate(x): clamp(x, 0, 1), component-wise, the standard normalized-range clamp for colour channels, interpolation factors and coverage.
import { saturate } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
const saturate: <K extends FloatKey>(x: ReadonlyNode<K>) => Node<K>매개변수
xReadonlyNode<K>
반환값
Node<K>
설명
WGSL has a saturate builtin; GLSL ES
3.00 has none, so the GLSL output is clamp(x, 0.0, 1.0), with the same semantics.
예제
예제
import { fn, saturate, f32T } from 'typeshade'
const alpha = fn('alpha', { fade: f32T }, ({ fade }) => saturate(fade))대상별 지원
| 대상 | 지원 | 비고 |
|---|---|---|
| WGSL (WebGPU) | 지원 |
|
| GLSL ES 3.00 (WebGL2) | 지원 |
|
| CPU 오라클 | 지원 | Evaluated in f64 by the oracle. |
소스
src/core/ir/node.ts, 1596행, 커밋 c66579bf 기준