UNPACKUNORM(3G)

πŸ“¦
version 1.0~svn33624 Β· 4 versions
, in ubuntu jammy, ubuntu noble

πŸ‘‘ 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.0
  • packSnorm2x16: clamp(f / 32727.0, -1.0, 1.0)
  • packUnorm4x8: f / 255.0
  • packSnorm4x8: clamp(f / 127.0, -1.0, 1.0)
ngl, notice it's 32727.0 up there and not 32767.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 β€” - in 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00; βœ” in 4.10, 4.20, 4.30, 4.40, 4.50 πŸ‘‘
  • unpackSnorm2x16 β€” - in 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00, 4.10; βœ” in 4.20, 4.30, 4.40, 4.50 🐒 (late bloomer, we love her)
  • unpackUnorm4x8 β€” - in 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00; βœ” in 4.10, 4.20, 4.30, 4.40, 4.50 πŸ”₯
  • unpackSnorm4x8 β€” - in 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00; βœ” in 4.10, 4.20, 4.30, 4.40, 4.50 πŸ”₯

πŸ’œ SEE ALSO πŸ’œ

the other side of the coin, the packers, iykyk:

  • packUnorm2x16
  • packUnorm4x8
  • packSnorm4x8

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