What's the best way to save an ARGBFloat texture without any loss?

I’d like to persist an ARGBFloat texture somewhere but EncodePNG/EncodeJPG don’t seem to be the right choice. What are my options?

Use
Texture2D.EncodeToEXR()

It can store floats.

Well, if the texture only contains colors in the range of 0.0 to 1.0, EncodePNG should work fine as long as each color component actually stores a color and not some more dense packed data. The graphics hardware can only represent 256 different levels for each component. That’s why almost all image formats store each channel as byte or even less.

A single pixel would be represented by 4 bytes. If you store each component as float you have 4 times the data.

Example for an uncompressed float image would be:

//  size     |       float format          |       byte format
// ----------|-----------------------------|-------------------------
// 1024x1024 | 1024 * 1024 * 4 * 4 = 16 MB | 1024 * 1024 * 4 =  4 MB
// 2048x2048 | 2048 * 2048 * 4 * 4 = 64 MB | 2048 * 2048 * 4 = 16 MB

If you don’t care about the file size you can simply store a float images with an extension like this:

Texture2DExtension

With this file in your project you can simply do this:

someTexture.SaveUncompressed("SomeFilename", Texture2DExtension.DataFormat.ARGBFloat);

To load an image you can use

    Texture2D tex = new Texture2D(1,1);
    tex.ReadUncompressed("SomeFilename");

I’ve also implemented a smaller 16 bit format that only works for color values in the range of 0.0 to 1.0

someTexture.SaveUncompressed("SomeFilename", Texture2DExtension.DataFormat.ARGBUShort);

This format is smaller (half the size) but with a bit less precision.