I'd like to persist an ARGBFloat texture somewhere but EncodePNG/EncodeJPG don't seem to be the right choice. What are my options?
Why is EncodePNG/EncodeJPG not a good choice for you? Without knowing this it is hard to answer.
Answer by Bunny83
Jul 09, 2016 at 03:38 PM
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:
With this file in your project you can simply do this:
To load an image you can use
Texture2D tex = new Texture2D(1,1);
I've also implemented a smaller 16 bit format that only works for color values in the range of 0.0 to 1.0
This format is smaller (half the size) but with a bit less precision.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
6 People are following this question.
Where are all my assets and textures?
How do I apply Multiple textures to a surface?
C4D R11.5 -Unity iPhone - Can I Use the animate Textures feature in Unity?
Textures look horrible.
Textures weird transparency problem -- black lines on edges --