GLSL built-in function
unpackUnorm2x16()
Unpacks one uint into two unsigned normalized components.
Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment
Syntax
vec2 unpackUnorm2x16(uint p)Parameters
- p
- Packed unsigned integer
Return value
A vec2 in [0, 1] decoded from the low and high unsigned 16-bit fields of p.
Live example
Edit the code and the preview updates as you type.
What unpackUnorm2x16 does
Unpacks one uint into two unsigned normalized components.
Read the preview
unpackUnorm2x16(packUnorm2x16(uv)).x reconstructs the 0-to-1 horizontal input. Selecting .y instead makes color vary from bottom to top.
Core call
unpackUnorm2x16(packUnorm2x16(uv)).x;
Results lie in [0,1], with sixteen bits per component.
Experiment
Pass vec2(uv.x-0.5,uv.y) into packUnorm2x16. After unpacking, the left half stays at zero because unsigned normalized packing discarded the negative values.