The code is bugged for certain colors, use this code instead: Packing the color: uint32 PackedColor = Color.ToPackedRGBA(); float PackedFloat = *reinterpret_cast(&PackedColor); return PackedFloat; Unpacking the color (HLSL): uint PackedInt = asuint(PackedValue); // Convert the float back to a uint float R = ((PackedInt >> 24) & 0xFF) / 255.0; // Extract R (top byte) float G = ((PackedInt >> 16) & 0xFF) / 255.0; // Extract G float B = ((PackedInt >> 8) & 0xFF) / 255.0; // Extract B float A = (PackedInt & 0xFF) / 255.0; // Extract A (lowest byte) return float4(R, G, B, A);