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