Fixed scaling factors for packing and unpacking unorm555 and unorm565

This commit is contained in:
Aaron 2016-09-11 22:49:15 -07:00
parent ec5e34e04f
commit 47abea7dba

View File

@ -725,7 +725,7 @@ namespace detail
GLM_FUNC_QUALIFIER uint16 packUnorm1x5_1x6_1x5(vec3 const & v)
{
u32vec3 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec3(15.f, 31.f, 15.f)));
u32vec3 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec3(31.f, 63.f, 31.f)));
detail::u5u6u5 Result;
Result.data.x = Unpack.x;
Result.data.y = Unpack.y;
@ -735,7 +735,7 @@ namespace detail
GLM_FUNC_QUALIFIER vec3 unpackUnorm1x5_1x6_1x5(uint16 v)
{
vec3 const ScaleFactor(1.f / 15.f, 1.f / 31.f, 1.f / 15.f);
vec3 const ScaleFactor(1.f / 31.f, 1.f / 63.f, 1.f / 31.f);
detail::u5u6u5 Unpack;
Unpack.pack = v;
return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * ScaleFactor;
@ -743,7 +743,7 @@ namespace detail
GLM_FUNC_QUALIFIER uint16 packUnorm3x5_1x1(vec4 const & v)
{
u32vec4 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec4(15.f, 15.f, 15.f, 1.f)));
u32vec4 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec4(31.f, 31.f, 31.f, 1.f)));
detail::u5u5u5u1 Result;
Result.data.x = Unpack.x;
Result.data.y = Unpack.y;
@ -754,7 +754,7 @@ namespace detail
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x5_1x1(uint16 v)
{
vec4 const ScaleFactor(1.f / 15.f, 1.f / 15.f, 1.f / 15.f, 1.f);
vec4 const ScaleFactor(1.f / 31.f, 1.f / 31.f, 1.f / 31.f, 1.f);
detail::u5u5u5u1 Unpack;
Unpack.pack = v;
return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactor;