Intrinsics1 min read
unpack_unorm2x16
Unpacks two unsigned normalized channels from a 32-bit integer.
Reading Time
1 min
Word Count
85
Sections
7
Try It Live
Test unpack_unorm2x16 in a live shader
Open the playground, start from a visual preset, and wire unpack_unorm2x16 into the fragment stage to see how it behaves with real values.
Open PlaygroundThe unpack_unorm2x16 function decodes a uint containing two 16-bit unsigned normalized channels into a float2 in [0, 1].
Live Demo
Signature
bwsl
unpack_unorm2x16 :: (uint packed) -> float2
Parameters
| Parameter | Type | Description |
|---|---|---|
packed | uint | Packed 2x16-bit UNorm value |
Return Value
Returns a float2 with components in [0, 1].
Example
bwsl
uint packedVelocity = resources.velocityBuffer[index];
float2 velocity = unpack_unorm2x16(packedVelocity);Compiled Output
When compiled to GLSL:
glsl
unpackUnorm2x16(packed)
When compiled to HLSL:
hlsl
// lowered to shifts, masks, and division by 65535
When compiled to Metal:
metal
unpack_unorm2x16(packed)
See Also
- pack_unorm2x16 - Pack UNorm16 channels
- unpack_snorm2x16 - Decode signed normalized channels
- unpack_unorm4x8 - Decode four 8-bit UNorm channels