pack2x16unorm
Function
Normalized packing maps a bounded floating-point interval onto integer fields.
Related names in other languages
These related operations can differ in arguments, support, and semantics. The foreign names are not accepted TypeShade aliases. Check the target forms and restrictions.
- GLSL:
packUnorm2x16
Compare examples
Compare the components, hexadecimal word, and recovered values. Notice which component occupies the low field.
Example 1pack2x16unorm(vec2(0, 1))
01 - Result
0xffff0000
4294901760Example 2pack2x16unorm(vec2(0, 0))
00 - Result
0x00000000
0Example 3pack2x16unorm(vec2(0.25, 0.25))
0.250.25 - Result
0x40004000
1073758208The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.
When to use it
Use it to reduce storage or bandwidth when the reduced precision is acceptable.
Inputs and limits
Packing clamps to the normalized interval and quantizes values. Unpacking approximates the original value; the low field belongs to the first component.
For shader input rules and precision, consult WGSL and GLSL ES 3.00.
Related functions
- WGSL
pack2x16unorm(a)- GLSL ES 3.00
packUnorm2x16(a)
The signature, the sentence and any message are the compiler's own text at commit af54ddad5.
Packs a vec2 of values in [0, 1] into two 16-bit halves of a u32, component 0 in the low 16 bits.
Syntax
declare function pack2x16unorm(a0: vec2): u32declare function pack2x16unorm(e: vec2): u32Parameters
-
evec2
Return value
Description
packUnorm2x16 on GLSL ES 3.00.
Targets
- WGSL
-
pack2x16unorm(a) - GLSL ES 3.00
-
packUnorm2x16(a)