내장 함수
export 96개
셰이더에서 부르는 수학, 벡터, 텍스처 함수입니다. 이름 하나로 두 대상 모두에 나갑니다.
시그니처, 설명, 예제는 커밋 26de7be8의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
-
abs함수 - abs(x): absolute value, component-wise.
-
acos함수 - acos(x): arccosine of x, returning radians in [0, π], component-wise.
-
acosh함수 - acosh(x): inverse hyperbolic cosine, component-wise.
-
add함수 - a + b as a free function, the spelling for an expression whose left operand is a literal.
-
asin함수 - asin(x): arcsine of x, returning radians in [-π/2, π/2], component-wise.
-
asinh함수 - asinh(x): inverse hyperbolic sine, component-wise; defined over all reals.
-
atan함수 - atan(x): single-argument arctangent, returning radians in (-π/2, π/2), component-wise.
-
atan2함수 - atan2(y, x): two-argument arctangent, resolving the full angle in [-π, π] from a (y, x) pair.
-
atanh함수 - atanh(x): inverse hyperbolic tangent, component-wise.
-
bitcastF32함수 - Reinterpret the bit pattern of a u32 as an f32, the inverse of bitcastU32.
-
bitcastU32함수 - Reinterpret the bit pattern of an f32 as a u32.
-
ceil함수 - ceil(x): round toward +∞, component-wise.
-
clamp함수 - clamp(x, lo, hi): restricts x to [lo, hi], component-wise.
-
cos함수 - cos(x): cosine of x in radians, component-wise.
-
cosh함수 - cosh(x): hyperbolic cosine, component-wise; the even partner of sinh.
-
cross함수 - cross(a, b): 3-D cross product of two vec3<f32> values.
-
degrees함수 - degrees(rad): radians to degrees, component-wise, with the built-in's exact 180/π; the inverse of radians.
-
distance함수 - distance(a, b): |a − b|, vector to scalar; the built-in form of length(a.sub(b)).
-
div함수 - a / b as a free function, for a literal numerator: div(1, x) is the reciprocal, and emits (1.0 / x).
-
dot함수 - dot(a, b): dot product, vector to scalar.
-
dpdx함수 - dpdx(x): the screen-space partial derivative of x along the X axis, component-wise.
-
dpdy함수 - dpdy(x): the screen-space partial derivative of x along the Y axis, component-wise; the partner of dpdx, with the same GPU-only and fragment-only constraints.
-
exp함수 - exp(x): eˣ, component-wise. exp2 is the base-2 form.
-
exp2함수 - exp2(x): 2ˣ, component-wise; the inverse of log2.
-
f64FromParts함수 - Assemble an f64 from its (hi, lo) f32 halves, the shader-side counterpart of splitF64 for a value that arrives as two f32 components.
-
f64GuardOne함수 - The anti-fast-math guard value of the f64 emulation: a 1.0 the GPU compiler cannot see through, emitted per target as a texel fetch from the guard texture that fp64Guard declares.
-
f64Parts함수 - The (hi, lo) pair of an f64 as a plain vec2<f32>, for storing an f64 into a vec2 buffer field or stage output.
-
floor함수 - floor(x): round toward −∞, component-wise.
-
fma함수 - fma(a, b, c): fused multiply-add, a·b + c.
-
fract함수 - fract(x): fractional part, x − floor(x), component-wise.
-
fwidth함수 - fwidth(x): abs(dpdx(x)) + abs(dpdy(x)), the screen-space derivative magnitude, component-wise.
-
insideRange함수 - In-range predicate: x >= lo && x <= hi.
-
inverseSqrt함수 - inverseSqrt(x): 1/√x, component-wise.
-
length함수 - length(v): Euclidean vector magnitude, |v|.
-
log함수 - log(x): natural logarithm, component-wise.
-
log2함수 - log2(x): base-2 logarithm, component-wise; the inverse of exp2.
-
madd함수 - Multiply-add, a*b + c, written as the plain a.mul(b).add(c) chain.
-
mat2f64함수 - An emulated-double mat2x2<f64> constructor, column-major: one vec2<f64> argument per column, the same convention as WGSL's mat2x2.
-
mat3f64함수 - An emulated-double mat3x3<f64> constructor, column-major, the 3×3 sibling of mat2f64; that entry has the column-argument convention and the transform helpers.
-
mat4f64함수 - An emulated-double mat4x4<f64> constructor, column-major, the 4×4 sibling of mat2f64; that entry has the column-argument convention and the transform helpers.
-
max함수 - max(a, b): component-wise maximum, the partner of min(/api/min/).
-
min함수 - min(a, b): component-wise minimum.
-
mix함수 - mix(a, b, t): linear interpolation a + t·(b − a), component-wise, keyed by a.
-
mod함수 - Floor modulo: x - y * floor(x / y), with identical semantics on both targets.
-
mul함수 - a * b as a free function, for a literal left operand: mul(2, x) emits (2.0 * x).
-
mulMat64함수 - matNxN<f64> × matNxN<f64> → matNxN<f64>: the emulated-double matrix product.
-
normalize함수 - normalize(v): v/|v|, keeping the vector key.
-
optBarrier함수 - An optimization barrier on one f32 value, the shader equivalent of C's volatile.
-
outsideRange함수 - Out-of-range predicate: x < lo || x > hi.
-
pack2x16float함수 - Pack a vec2<f32> into a u32 as two IEEE-754 binary16 (half) values, component 0 in the 16 low bits.
-
pack2x16snorm함수 - Pack a vec2<f32> into a u32 as two 16-bit snorm values, ⌊0.5 + 32767·clamp(x, -1, 1)⌋ per component in two's complement, component 0 in the 16 low bits.
-
pack2x16unorm함수 - Pack a vec2<f32> into a u32 as two 16-bit unorm values, ⌊0.5 + 65535·clamp(x, 0, 1)⌋ per component, component 0 in the 16 low bits.
-
pack4x8unorm함수 - Pack a vec4<f32> into a u32 RGBA8.
-
pow함수 - pow(a, b): a raised to the power b, component-wise.
-
radians함수 - radians(deg): degrees to radians, component-wise, with the built-in's exact π/180.
-
round함수 - round(x): nearest integer, ties to even, component-wise, on both targets.
-
saturate함수 - saturate(x): clamp(x, 0, 1), component-wise, the standard normalized-range clamp for colour channels, interpolation factors and coverage.
-
select함수 - select: the free-function form of ReadonlyNode.select.
-
sign함수 - sign(x): -1, 0 or 1 per component, according to the sign of x.
-
sin함수 - sin(x): sine of x in radians, component-wise.
-
sinh함수 - sinh(x): hyperbolic sine, component-wise.
-
smoothstep함수 - smoothstep(e0, e1, x): Hermite interpolation from 0 at x = e0 to 1 at x = e1, component-wise.
-
sqrt함수 - sqrt(x): square root, component-wise.
-
step함수 - step(edge, x): 0 where x < edge, else 1, component-wise.
-
sub함수 - a - b as a free function.
-
tan함수 - tan(x): tangent of x in radians, component-wise.
-
tanh함수 - tanh(x): hyperbolic tangent, component-wise; sinh(x)/cosh(x), saturating to ±1 as x → ±∞.
-
textureDimensions함수 - Texture extent in texels, as a vec2<u32>.
-
textureLoad함수 - Load one texel from a 2D texture at integer coordinates, returning vec4<f32>, vec4<u32> or vec4<i32> to match the texture's element.
-
textureNumLayers함수 - How many layers a 2D array texture has, as a u32.
-
textureSample함수 - Sample a 2D texture, returning vec4<f32>.
-
textureSampleLevel함수 - Sample a 2D texture at an explicit mip level, returning vec4<f32>.
-
toF32함수 - Convert to f32. On an f64 argument this is the explicit, precision-losing narrow, computed as the sum of the hi and lo halves; f64 never narrows implicitly.
-
toF64함수 - Widen f32 to f64, exactly (the result is the pair (x, 0.0)).
-
toI32함수 - Convert to i32: the explicit numeric cast, where i32(/api/i32/) builds a literal from a JS number.
-
toU32함수 - Convert to u32: the explicit numeric cast, where u32(/api/u32/) builds a literal from a JS number.
-
transformMat4함수 - mat4x4<f32> × vec4<f32> → vec4<f32>: the matrix-vector product, as in a model-view-projection transform.
-
transformMat64함수 - matNxN<f64> × vecN<f64> → vecN<f64>: the emulated-double matrix-vector product.
-
transpose64함수 - Transpose of an emulated-double matrix.
-
trunc함수 - trunc(x): round toward zero, component-wise.
-
unpack2x16float함수 - Unpack a u32 into a vec2<f32> of two binary16 (half) values, the exact inverse of pack2x16float.
-
unpack2x16snorm함수 - Unpack a u32 of two 16-bit snorm values into a vec2<f32> in -1,1 (max per component), the inverse of pack2x16snorm.
-
unpack2x16unorm함수 - Unpack a u32 of two 16-bit unorm values into a vec2<f32> in 0,1, the inverse of pack2x16unorm.
-
unpack4x8unorm함수 - Unpack a u32 RGBA8 into a vec4<f32>.
-
vec2함수 - A vec2<f32> constructor, WGSL-style: vec2(x, y).
-
vec2f64함수 - An emulated-double vec2<f64> constructor.
-
vec2i함수 - A vec2<i32> constructor, WGSL-style: vec2i(x, y).
-
vec2u함수 - A vec2<u32> constructor, WGSL-style: vec2u(x, y).
-
vec3함수 - A vec3<f32> constructor, WGSL-style: vec3(x, y, z).
-
vec3f64함수 - An emulated-double vec3<f64> constructor, the three-component sibling of vec2f64; that entry has the splat, split and widen rules every vecNf64 constructor shares.
-
vec3i함수 - A vec3<i32> constructor, WGSL-style: vec3i(x, y, z).
-
vec3u함수 - A vec3<u32> constructor, WGSL-style: vec3u(x, y, z).
-
vec4함수 - A vec4<f32> constructor, WGSL-style: vec4.
-
vec4f64함수 - An emulated-double vec4<f64> constructor, the four-component sibling of vec2f64; that entry has the splat, split and widen rules every vecNf64 constructor shares.
-
vec4i함수 - A vec4<i32> constructor, WGSL-style: vec4i.
-
vec4u함수 - A vec4<u32> constructor, WGSL-style: vec4u.