Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Xcode_t · Mar 07, 2017 at 03:40 PM · texturegraphicsimageasset

32 bit color in texture file

I need to store 32-bit color in a texture map. I know Unity can support such textures, but I can't seem to find a Unity-supported file type that can hold 32-bit color with a lossless compression. I've been using TIFF for everything, but if I save a 32-bit TIFF I get a complaint from Unity saying it can't be read. Anyone know a file type that I can use?

EDIT: I should clarify a bit. I'm not using PNG or TGA because I lose data when saving from Blender and loading in Unity. For example, if my image has a very low alpha, the original color value is replaced by pure white for unknown reasons. I have verified that it's not fixed by changing import settings.

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image _dns_ · Mar 07, 2017 at 06:08 PM 1
Share

Strange, i've seen no data loss when using PNG or TGA with 8 bits per channel = 32bits in total. If you need more precision, I think you can use the EXR file format that supports more bit depth per channel or floating point format (Unity uses this for some lightmaps it computes)

avatar image Bunny83 · Mar 07, 2017 at 07:47 PM 0
Share

The plain white issue has nothing to do with a limitation of the file format but the behaviour of the exporter. $$anonymous$$ost exporter replace the colors of completely transparent pixels by a solid color (usually white or black) to improve compression quality. From a pure picture point of view it makes sense since those pixels can't be seen at all as they are transparent. However from a general purpose point of view it's an annoying problem. Though changing to a different file format usually won't fix it if the exporter does the same "optimisation". There are only a few programs which actually preserve the color information of transparent pixels. Even Photoshop "suffers" from that "feature".

edit
just to get this straight: By 32bit color you mean "bits per pixel" and not bits per channel, right?

avatar image Xcode_t · Mar 07, 2017 at 08:51 PM 0
Share

Well, I did mean "bits per pixel", but it would be awesome if I could have more. I'm not trying to use this data for rendering, but for a compute shader, and I could use all the data I can get. If I could somehow manage something closer to 64 bits per pixel (16 bits per channel) that would be ideal.

As things stand, I think I am stuck making my own file format, a custom exporter for Blender, and using some kind of post-build script to use the data at runtime. Image files just don't hold enough.

Edit: If I could hold a full float per pixel, which I believe are 4 full bytes, I could simplify my entire system to the point where I only need one single channel. So a 32-bit single-channel texture would solve it all.

avatar image _dns_ Xcode_t · Mar 07, 2017 at 09:30 PM 0
Share

I see that blender can save to EXR with 16 bits per channel half-floats (http://blender-manual-i18n.readthedocs.io/ja/latest/data_system/files/formats/openexr.html) but i'm less sure Unity can read them as 16bit/channel texture (didn't try, just some quick search). So it might be quicker to use your own format if you can export it from Blender. Unity-side, you can read the file and saves it as a Texture2D Asset (Texture2D supports more formats than it can import + save using AssetDatabase). You can even automate this using EditorApplication.projectWindowChanged (did this to generate custom 3D textures assets)

avatar image Xcode_t _dns_ · Mar 07, 2017 at 09:35 PM 0
Share

I tried that since posting the question, but it doesn't integrate very well. It ends up having to read the file from a .asset file based on my own file format, but I can't seem to make that .asset hold a two-dimensional float array. That's why I figured I should just have a script run after the build that can copy my custom file into the build directory, read it at runtime, and go from there. That does cause problems with the editor though because I can't just assign this texture to any of the texture fields.

I was really hoping for a clean solution, and without Unity adding support for custom file formats or Blender fixing the export problem, it just isn't going to happen.

Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

WWW.texture provides a :"?" texture... 1 Answer

Blit into Texture2DArray slice not working in WebGL 0 Answers

build file doesn't show image with GUI parts 0 Answers

Find texture by name? Or other types? 2 Answers

How to load image 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges