// ---- 64-bit (16 x 4) ---- private static void Write_16_16_16_16_UNorm(this BinaryDataWriter self, Vector4F value) { self.Write((ushort)(Algebra.Clamp(value.X, 0, 1) * 65535)); self.Write((ushort)(Algebra.Clamp(value.Y, 0, 1) * 65535)); self.Write((ushort)(Algebra.Clamp(value.Z, 0, 1) * 65535)); self.Write((ushort)(Algebra.Clamp(value.W, 0, 1) * 65535)); }
private static void Write_16_16_16_16_SNorm(this BinaryDataWriter self, Vector4F value) { self.Write((short)(Algebra.Clamp(value.X, -1, 1) * 32767)); self.Write((short)(Algebra.Clamp(value.Y, -1, 1) * 32767)); self.Write((short)(Algebra.Clamp(value.Z, -1, 1) * 32767)); self.Write((short)(Algebra.Clamp(value.W, -1, 1) * 32767)); }
private static void Write_8_8_8_8_SNorm(this BinaryDataWriter self, Vector4F value) { self.Write((sbyte)(Algebra.Clamp(value.X, -1, 1) * 127)); self.Write((sbyte)(Algebra.Clamp(value.Y, -1, 1) * 127)); self.Write((sbyte)(Algebra.Clamp(value.Z, -1, 1) * 127)); self.Write((sbyte)(Algebra.Clamp(value.W, -1, 1) * 127)); }
// ---- 32-bit (8 x 4) ---- private static void Write_8_8_8_8_UNorm(this BinaryDataWriter self, Vector4F value) { self.Write((byte)(Algebra.Clamp(value.X, 0, 1) * 255)); self.Write((byte)(Algebra.Clamp(value.Y, 0, 1) * 255)); self.Write((byte)(Algebra.Clamp(value.Z, 0, 1) * 255)); self.Write((byte)(Algebra.Clamp(value.W, 0, 1) * 255)); }
// ---- 8-bit (4 x 2) ---- private static void Write_4_4_UNorm(this BinaryDataWriter self, Vector4F value) { byte x = (byte)(Algebra.Clamp(value.X, 0, 1) * 127); byte y = (byte)(Algebra.Clamp(value.Y, 0, 1) * 127); self.Write((byte)(x | y << 4)); }
private static void Write_10_10_10_2_SNorm(this BinaryDataWriter self, Vector4F value) { int x = SingleToInt10(Algebra.Clamp(value.X, -1, 1) * 511); int y = SingleToInt10(Algebra.Clamp(value.Y, -1, 1) * 511); int z = SingleToInt10(Algebra.Clamp(value.Z, -1, 1) * 511); int w = SingleToInt2(Algebra.Clamp(value.W, 0, 1)); self.Write(x | (y << 10) | (z << 20) | (w << 30)); }
// ---- 32-bit (10 x 3 + 2) ---- private static void Write_10_10_10_2_UNorm(this BinaryDataWriter self, Vector4F value) { uint x = SingleToUInt10(Algebra.Clamp(value.X, 0, 1) * 1023); uint y = SingleToUInt10(Algebra.Clamp(value.Y, 0, 1) * 1023); uint z = SingleToUInt10(Algebra.Clamp(value.Z, 0, 1) * 1023); uint w = SingleToUInt2(Algebra.Clamp(value.W, 0, 1) * 3); self.Write(x | (y << 10) | (z << 20) | (w << 30)); }
private uint SingleToUSingle4x6(float value) { return((uint)(Algebra.Clamp(value, 0, 13) * 64)); }
private uint SingleToSingle5x6(float value) { return((uint)(Algebra.Clamp(value, -32, 31.984375f) * 64)); }