unpack4x8unorm
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:
unpackUnorm4x8
Compare examples
Compare the components, hexadecimal word, and recovered values. Notice which component occupies the low field.
Example 1unpack4x8unorm(0xff00ff00)
0101 - Result
[0, 1, 0, 1]
4278255360Example 2unpack4x8unorm(0x00000000)
0000 - Result
[0, 0, 0, 0]
0Example 3unpack4x8unorm(0x40404040)
0.25098040.25098040.25098040.2509804 - Result
[0.2509804, 0.2509804, 0.2509804, 0.2509804]
1077952576The 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
unpack4x8unorm(a)- GLSL ES 3.00
(vec4(uvec4(a, a >> 8, a >> 16, a >> 24) & 0xFFu) / 255.0)
The signature, the sentence and any message are the compiler's own text at commit af54ddad5.
Unpacks the four bytes of a u32 into a vec4 of values in [0, 1], the low byte into component 0.
Syntax
declare function unpack4x8unorm(a0: u32): vec4declare function unpack4x8unorm(e: u32): vec4Parameters
-
eu32
Return value
Description
The inverse of pack4x8unorm.
Targets
- WGSL
-
unpack4x8unorm(a) - GLSL ES 3.00
-
(vec4(uvec4(a, a >> 8, a >> 16, a >> 24) & 0xFFu) / 255.0)