UNPACKUNORM(3G)
π UNPACKUNORM β the 3G manual page π
okay bestie, pull up a chair, because today we're unpacking integers into pretty little floats and it's giving main character energy β¨
πΈ NAME πΈ
unpackUnorm2x16, _unpackUnorm4x8, _unpackSnorm4x8 β unpack floating-point values from an unsigned integer π«Ά
π DECLARATION π
here's the lineup, literally copy-paste ready:
vec2 unpackUnorm2x16(uint p);
vec2 unpackSnorm2x16(uint p);
vec4 unpackUnorm4x8(uint p);
vec4 unpackSnorm4x8(uint p);
π¦ PARAMETERS π¦
pβ an unsigned integer that's holding your packed floating-point values, like a lil suitcase full of numbers πΌ
β¨ DESCRIPTION β¨
so unpackUnorm2x16, unpackSnorm2x16, unpackUnorm4x8 and unpackSnorm4x8 take one single 32-bit unsigned integer β that's the p you passed in, hi bestie β and unpack it into either a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. then every component gets converted to a normalized floating-point value so it can generate that returned two- or four-component vector. yes, it's a glow-up. no, we don't gatekeep π
the conversion from the unpacked fixed point value f to floating-point goes like this, periodt:
packUnorm2x16:f / 65535.0packSnorm2x16:clamp(f / 32727.0, -1.0, 1.0)packUnorm4x8:f / 255.0packSnorm4x8:clamp(f / 127.0, -1.0, 1.0)
ngl, notice it's32727.0up there and not32767.0β that's exactly what the page says, so we keep it, no cap π₯
and the ordering? the first component of the returned vector gets extracted from the least significant bits of the input, and the last component gets extracted from the most significant bits. little-endian girlies rise π
β VERSION SUPPORT β
vibe check on which OpenGL Shading Language Versions each one showed up in. the columns were 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50 β so here's who ate and who was still in the group chat but silent:
unpackUnorm2x16β-in1.10,1.20,1.30,1.40,1.50,3.30,4.00; β in4.10,4.20,4.30,4.40,4.50πunpackSnorm2x16β-in1.10,1.20,1.30,1.40,1.50,3.30,4.00,4.10; β in4.20,4.30,4.40,4.50π’ (late bloomer, we love her)unpackUnorm4x8β-in1.10,1.20,1.30,1.40,1.50,3.30,4.00; β in4.10,4.20,4.30,4.40,4.50π₯unpackSnorm4x8β-in1.10,1.20,1.30,1.40,1.50,3.30,4.00; β in4.10,4.20,4.30,4.40,4.50π₯
π SEE ALSO π
the other side of the coin, the packers, iykyk:
packUnorm2x16packUnorm4x8packSnorm4x8
π COPYRIGHT π
Copyright Β© 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.
Copyright Β© 2011-2014 Khronos Group
k byeee π this one came from [FIXME: source], dated 01/03/2018, and lives under the manual name UNPACKUNORM(3G) β go unpack something cute, bestie πβ¨
π¦ where this page comes from
- ubuntu jammy: opengl-4-man-doc 1.0~svn33624-1 Β· SGI-Free-Software-B-License-2
- ubuntu noble: opengl-4-man-doc 1.0~svn33624-1 Β· SGI-Free-Software-B-License-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms