示例#1
0
        public static uint PackSNorm(uint bitmask, float value)
        {
            float max = (float)(bitmask >> 1);

            value *= max;
            return((uint)(int)PackUtils.ClampAndRound(value, -max, max) & bitmask);
        }
示例#2
0
        public static uint PackSigned(uint bitmask, float value)
        {
            float max = (float)(bitmask >> 1);
            float min = (float)(-(double)max - 1.0);

            return((uint)(int)PackUtils.ClampAndRound(value, min, max) & bitmask);
        }
示例#3
0
        /// <summary>
        /// Expands the packed representation into a Vector4.
        /// </summary>
        public Vector4 ToVector4()
        {
            Vector4 vector4;

            vector4.X = PackUtils.UnpackSNorm((uint)byte.MaxValue, this.packedValue);
            vector4.Y = PackUtils.UnpackSNorm((uint)byte.MaxValue, this.packedValue >> 8);
            vector4.Z = PackUtils.UnpackSNorm((uint)byte.MaxValue, this.packedValue >> 16);
            vector4.W = PackUtils.UnpackSNorm((uint)byte.MaxValue, this.packedValue >> 24);
            return(vector4);
        }
示例#4
0
 public static uint PackUNorm(float bitmask, float value)
 {
     value *= bitmask;
     return((uint)PackUtils.ClampAndRound(value, 0.0f, bitmask));
 }
示例#5
0
 public static uint PackUnsigned(float bitmask, float value)
 {
     return((uint)PackUtils.ClampAndRound(value, 0.0f, bitmask));
 }
示例#6
0
 private static uint PackHelper(float vectorX, float vectorY, float vectorZ, float vectorW)
 {
     return(PackUtils.PackSNorm((uint)byte.MaxValue, vectorX) | PackUtils.PackSNorm((uint)byte.MaxValue, vectorY) << 8 | PackUtils.PackSNorm((uint)byte.MaxValue, vectorZ) << 16 | PackUtils.PackSNorm((uint)byte.MaxValue, vectorW) << 24);
 }