monstercho
Topic Author
Posts: 20
Joined: 26 Jan 2016, 19:54

Noesis 2 png transparency

03 Mar 2017, 09:45

After moving to Noesis v2 I have problem with pngs. Tried to play with the png import settings without success.

Screenshots:
Noesis 2.0.0f1: https://drive.google.com/file/d/0B1zHz_ ... sp=sharing
Noesis 1.2.6f5: https://drive.google.com/file/d/0B1zHz_ ... sp=sharing

Test projects:
Noesis 2.0.0f1: https://drive.google.com/file/d/0B1zHz_ ... sp=sharing
Noesis 1.2.6f5: https://drive.google.com/file/d/0B1zHz_ ... sp=sharing

I don't see such issue with NoesisGUI ControlGallery - for example the "folder.png" there is shown correctly.
 
User avatar
jsantos
Site Admin
Posts: 1917
Joined: 20 Jan 2012, 17:18
Contact:

Re: Noesis 2 png transparency

07 Mar 2017, 06:25

You need to use premultiplied alpha in your images to work correctly with Noesis. This should be ideally done by Unity when the image is converter to texture (using a flag in the importer) but for now it is not implemented. So for now, you need to manually premultiply each color channel by its alpha (making transparent areas black).

We did it with photoshop and a custom script, we should probably publish this (and document this issue).
 
nokola
Posts: 134
Joined: 10 Mar 2015, 05:29

Re: Noesis 2 png transparency

07 Mar 2017, 16:34

Note that a lot of the PNGs come from websites e.g. https://icons8.com/, all of those would have to be premultiplied before being usable. Assuming Noesis 2 changes for performance reasons.
Is there a way to add a custom importer in Unity that premultiplies all files that contain ".pm" in the name e.g. file.pm.png? That would help alleviate the problem.
 
monstercho
Topic Author
Posts: 20
Joined: 26 Jan 2016, 19:54

Re: Noesis 2 png transparency

07 Mar 2017, 21:21

Installed ImageMagick and tested converting png. From command line:
 > magick convert in.png ( +clone -alpha Extract ) -channel RGB -compose Multiply -compose Copy_Opacity -composite out.png
and in Unity import settings uncheck "Alpha is Transparency".
Looks good in Noesis 2.

EDIT: This doesn't work with semi-transparent image like the one in the example project.
I though it's ok, but I was testing another image where opacity is just 0 or 255.
 
monstercho
Topic Author
Posts: 20
Joined: 26 Jan 2016, 19:54

Re: Noesis 2 png transparency

07 Mar 2017, 22:22

Is it sure that Noesis 2 works with semi-transparent images?
Like the one from my 1st post.

I confirmed It is ok with images with 0/255 opacity after alpha premultiply (transparent => black), but I cannot make it work for semi-transparent.
 
User avatar
jsantos
Site Admin
Posts: 1917
Joined: 20 Jan 2012, 17:18
Contact:

Re: Noesis 2 png transparency

07 Mar 2017, 22:40

Yes, we support semi-transparent images. In fact, this is not a real change from the 1.3 version, we were already using premultiplied alpha in that version (as you can read here)

Alpha premultiplication is the only correct way to use alpha without any artifacts. That's the reason we use it in Noesis.

The change is in the Unity integration layer. In v1.3 we were creating our own textures, this was very inconvenient because we didn't support all Unity formats and flags (like compression in iOS or Android for example). Right now, we use directly the texture created by Unity. We think this approach is a lot better although we will probably need to provide a script for our users if Unity doesn't want to include that flag.
 
monstercho
Topic Author
Posts: 20
Joined: 26 Jan 2016, 19:54

Re: Noesis 2 png transparency

07 Mar 2017, 23:15

Yes, confirmed it works after manually doing alpha premultiply from C# - multiplied the colors, then EncodeToPNG() and saved to file.

My ImageMagick experiment above is wrong.
 
monstercho
Topic Author
Posts: 20
Joined: 26 Jan 2016, 19:54

Re: Noesis 2 png transparency

08 Mar 2017, 00:15

Working ImageMagick calls (from here):
> magick convert in.png -background black -alpha Remove in.png -compose Copy_Opacity -composite out.png
or
> magick convert in.png -write mpr:temp -background black -alpha Remove mpr:temp -compose Copy_Opacity -composite out.png
 
User avatar
jsantos
Site Admin
Posts: 1917
Joined: 20 Jan 2012, 17:18
Contact:

Re: Noesis 2 png transparency

08 Mar 2017, 02:05

Thanks for this!
 
User avatar
sfernandez
Site Admin
Posts: 1187
Joined: 22 Dec 2011, 19:20

Re: Noesis 2 png transparency

08 Mar 2017, 10:38

Another tool that can be used to convert png files to premultiplied alpha: https://github.com/maxme/PNG-Alpha-Premultiplier

Who is online

Users browsing this forum: No registered users and 3 guests