diff --git a/glm/core/func_packing.hpp b/glm/core/func_packing.hpp
index 6281c15c..5ff94ad9 100644
--- a/glm/core/func_packing.hpp
+++ b/glm/core/func_packing.hpp
@@ -37,7 +37,7 @@
#define GLM_CORE_func_packing GLM_VERSION
namespace glm
-{
+{
/// @addtogroup core_func_packing
/// @{
@@ -53,7 +53,20 @@ namespace glm
/// @see - GLSL packUnorm2x16 man page
/// @see - GLSL 4.20.8 specification, section 8.4
detail::uint32 packUnorm2x16(detail::tvec2 const & v);
-
+
+ //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
+ //! Then, the results are packed into the returned 32-bit unsigned integer.
+ //!
+ //! The conversion for component c of v to fixed point is done as follows:
+ //! packSnorm2x16: round(clamp(c, 0, +1) * 65535.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.
+ //!
+ /// @see - GLSL packSnorm2x16 man page
+ /// @see - GLSL 4.20.8 specification, section 8.4
+ detail::uint32 packSnorm2x16(detail::tvec2 const & v);
+
//! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
//! Then, the results are packed into the returned 32-bit unsigned integer.
//!
diff --git a/glm/core/func_packing.inl b/glm/core/func_packing.inl
index 9c04dcb1..c6b8a2cb 100644
--- a/glm/core/func_packing.inl
+++ b/glm/core/func_packing.inl
@@ -35,6 +35,13 @@ GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2 c
return detail::uint32((B << 16) | A);
}
+GLM_FUNC_QUALIFIER detail::uint32 packSnorm2x16(detail::tvec2 const & v)
+{
+ detail::uint16 A((detail::uint16)round(clamp(v.x,-1.0f, 1.0f) * 32767.0f));
+ detail::uint16 B((detail::uint16)round(clamp(v.y,-1.0f, 1.0f) * 32767.0f));
+ return detail::uint32((B << 16) | A);
+}
+
GLM_FUNC_QUALIFIER detail::uint32 packUnorm4x8(detail::tvec4 const & v)
{
detail::uint8 A((detail::uint8)round(clamp(v.x, 0.0f, 1.0f) * 255.0f));
@@ -62,6 +69,15 @@ GLM_FUNC_QUALIFIER detail::tvec2 unpackUnorm2x16(detail::uint32
B * 1.0f / 65535.0f);
}
+GLM_FUNC_QUALIFIER detail::tvec2 unpackSnorm2x16(detail::uint32 const & p)
+{
+ detail::uint16 A(detail::uint16(p >> 0));
+ detail::uint16 B(detail::uint16(p >> 16));
+ return clamp(detail::tvec2(
+ A * 1.0f / 32767.0f,
+ B * 1.0f / 32767.0f));
+}
+
GLM_FUNC_QUALIFIER detail::tvec4 unpackUnorm4x8(detail::uint32 const & p)
{
detail::uint8 A(detail::uint8(p >> 0));