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