mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Merge pull request #552 from amc522/packing_fixes
Packing/unpacking function fixed for 5_6_5 and 5_5_5_1 #552
This commit is contained in:
commit
f32e64e634
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user