logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

packUnorm - pack floating-point values into an unsigned integer

Declaration

uintpackUnorm2x16(vec2v);uintpackSnorm2x16(vec2v);uintpackUnorm4x8(vec4v);uintpackSnorm4x8(vec4v);

Description

packUnorm2x16, packSnorm2x16, packUnorm4x8 and packSnorm4x8 convert each component of the normalized
       floating-ponit value v into 8- or 16-bit integer values and then packs the results into a 32-bit unsigned
       intgeter.

       The conversion for component c of v to fixed-point is performed as follows:

       •   packUnorm2x16: round(clamp(c, 0.0, 1.0) * 65535.0)

       •   packSnorm2x16: round(clamp(c, -1.0, 1.0) * 32767.0)

       •   packUnorm4x8: round(clamp(c, 0.0, 1.0) * 255.0)

       •   packSnorm4x8: round(clamp(c, -1.0, 1.0) * 127.0)

       The first component of the vector will be written to the least significant bits of the output; the last
       component will be written to the most significant bits.

Name

       packUnorm - pack floating-point values into an unsigned integer

Parameters

v
           Specifies a vector of values to be packed into an unsigned integer.

See Also

unpackUnorm2x16,

       unpackSnorm2x16,

       unpackUnorm4x8,

       unpackSnorm4x8

Version Support

       ┌───────────────┬───────────────────────────────────────────────────────────────────────────────────┐
       │               │        OpenGLShadingLanguageVersion                                            │
       ├───────────────┼──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┤
       │ Function1.101.201.301.401.503.304.004.104.204.304.404.50 │
       │ Name          │      │      │      │      │      │      │      │      │      │      │      │      │
       ├───────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
       │ packUnorm2x16 │  -   │  -   │  -   │  -   │  -   │  -   │  -   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │
       ├───────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
       │ packSnorm2x16 │  -   │  -   │  -   │  -   │  -   │  -   │  -   │  -   │  ✔   │  ✔   │  ✔   │  ✔   │
       ├───────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
       │ packUnorm4x8  │  -   │  -   │  -   │  -   │  -   │  -   │  -   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │
       ├───────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
       │ packSnorm4x8  │  -   │  -   │  -   │  -   │  -   │  -   │  -   │  ✔   │  ✔   │  ✔   │  ✔   │  ✔   │
       └───────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┘

See Also