GLSL built-in function
packSnorm2x16()
Packs two signed normalized components into one uint.
Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment
Syntax
uint packSnorm2x16(vec2 v)Parameters
- v
- Components to pack
Return value
One uint containing two signed 16-bit normalized encodings after clamping v to [-1, 1], with x in the low bits.
Live example
Edit the code and the preview updates as you type.
What packSnorm2x16 does
Packs two signed normalized components into one uint.
Read the preview
The pack/unpack expression reads back x from two signed normalized channels. Change vec2(x,y) to vec2(x*2.0,y) to reveal flat ends where packing clamps x to [-1, 1].
Core call
unpackSnorm2x16(packSnorm2x16(vec2(x,y))).x;
Inputs are clamped to [-1,1]; packing is lossy quantization.
Experiment
Use vec2(-0.5,y) as the packSnorm2x16 input. The first decoded channel becomes a horizontal line near -0.5 instead of the diagonal ramp.