7 const float cOneOverSqrt2 = 0.70710678f;
8 const uint cNumBits = 14;
9 const uint cMask = (1u << cNumBits) - 1;
10 const uint cMaxValue = cMask - 1;
11 const int cHalfMaxValue = int(cMaxValue >> 1);
12 const float cScale = 2.0f * cOneOverSqrt2 / float(cMaxValue);
15 float2 v2 = float2(
float(
int(inValue & cMask) - cHalfMaxValue),
float(
int((inValue >> cNumBits) & cMask) - cHalfMaxValue)) * cScale;
18 float3 v = float3(v2, sqrt(max(1.0f - dot(v2, v2), 0.0f)));
21 if ((inValue & 0x80000000u) != 0)
25 uint max_element = (inValue >> 29) & 3;
26 v = max_element == 0? v.zxy : (max_element == 1? v.xzy : v);