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 Playground

The 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

ParameterTypeDescription
packeduintPacked 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