Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Ben 2 · Jun 18, 2010 at 10:20 PM · texturecoloralphapng

Problems With Alpha Channels When Loading DXT5 Texture2D From PNG

I'm having a strange problem when loading pngs from disk as Texture2Ds in Unity. I want to load the images using DXT5 like so:

Texture2D texture = new Texture2D(2,2, TextureFormat.DXT5, false);
...
texture.LoadImage(buffer); 

When I do this, some of the images appear as they normally do, meaning, the look like they look when I load them in an image editor. But other images appear red and washed out. It seems like there may be some channel mangling going on with the images but I comparing and image that works next to one that doesn't in any graphics editor yields no clue as to why some of the images are red.

If I load the images as ARGB32 then they all work fine but I see a performance degradation.

What could be causing the images to take on a red hue? Is this a problem that should be solved in my code or is it a problem saving the image files? The image files came from a number of different users who created them using whatever tools they had available but the images look perfectly fine in every editor I've tried. Any clues what's going on and how to fix it in my script?

Comment
Add comment · Show 2
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 qJake · Jun 18, 2010 at 11:00 PM 0
Share

This may not be the issue, but your "performance degradation" you're talking about could be $$anonymous$$ipmapping... if you want your textures to always be top quality no matter what, consider disabling $$anonymous$$ipmapping.

avatar image Ben 2 · Jun 21, 2010 at 05:06 PM 0
Share

$$anonymous$$ipmapping was disabled for these images in the construction of the Texture2Ds.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by fherbst · Jun 18, 2010 at 11:31 PM

Maybe use a Photoshop action (or FastStone or whatever) and overwrite all images with resaved ones? That could get rid of possible faults in whatever editors were used. Maybe the alpha is written differently by the external tools, interpreted in the correct way by image viewers, but not by Unity (things like premultiplied/non-premultiplied alphas in compositing).

Comment
Add comment · Show 3 · Share
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 Ben 2 · Jun 21, 2010 at 05:07 PM 0
Share

The red-hued images themselves were lacking alpha channels so as part of our build process I added a script that adds the alpha channel and overwrites the original.

avatar image Kragh · Dec 04, 2013 at 03:20 PM 0
Share

This is to Ben 2: Thank you very much for providing me with the answer. I have been having troubles with this all day, and for some reason I didn't stumble on your solution before now. It works perfectly. Have you ever reported a bug in this regard? I mean, compressing a .png texture should just work, no matter how it's saved... At the very least if it is created using the Texture2D.EncodeToPng function, provided by the API.

Anyways, thanks again!!!!!

avatar image ThiagoSCF · May 20, 2015 at 07:09 PM 0
Share

I was facing the exact same problem here for three days now! Adding the alpha channel on Photoshop solved the problem, but I need to make sure that the application does this by itself.

Could you tell me how you did it via script?

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

1 Person is following this question.

avatar image

Related Questions

How to Make a Character Flicker? 1 Answer

Need Help adding Main Color Property to a complicated Shader 1 Answer

unity png color bleeding 1 Answer

Vegetation Texture Error 1 Answer

Texture with alpha upon a color 0 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