- Home /
A PNG appears differently from its PSD
Before you ask, I don't think this is the alpha edge problem as it is not occuring on just the edge pixels.
This is an image of two versions of the same file. The left is from the PNG exported by Photoshop and the right is from the actual PSD imported to unity. The design is supposed to be a small black dropshadow and is looking correct on the left PNG version. It is imported as an uncompressed, true colour, bilinear GUI image and applied to a plane on an orthographic camera.
So why is there a difference between these? It isn't the colour of the dropshadow pixels as this must be set to black in Photoshop to define it as a black dropshadow. My only conclusion is that the PSD import in Unity has a bug. If it happened over one pixel I would suspect it as the alpha bleeding problem but its too wide to be that.
Unity is all about easy of use. The ability to drop in a texture or other asset is a key feature and I'm a little surprised that it falls down so easily.
"Save your multi-layer Photoshop files normally and let Unity automatically compress your images with high quality compression. It's all automatic without a single required click. " - Unity promotional material :)
Answer by wlad_s · Sep 13, 2012 at 05:46 PM
Do you have a white background when you turn off the alpha channel in photoshop?
PNG makes pixel bleeding automatically so that's why it looks ok when PNG.
I mean, if you want to have a feathered green circle in unity, and if you want to use PSD, the best way would be to have your whole image painted green and only alpha channel to be a feathered circle.
Converted to answer, because I think it has enough info there to possibly resolve this issue.
O$$anonymous$$, I made it a comment initially because it contained a question :) I can go into more detail if I wasn't clear enough.
By the way, the same principle as PSD, applies to tga and tiff as far as I know.
The problem doesn't occur because of any residual colour on a fully transparent pixel as it occurs over the entire fading dropshadow.
Assu$$anonymous$$g what you say it true though, surely the issue here then is why doesn't Unity have this "automatic pixel bleeding" mechanism in its importer? I don't believe this should be a necessary process for the user.
Being able to just use a dropshadow layer style in Photoshop and have it work in Unity is surely not an unreasonable request?
Ok we've done some more testing and I think I now understand the reason, and why it's not the transparent coloured pixel problem. Uberwleiss you are right for your solution. It still means though there is still a bug in the way Unity flattens the layers and it should be an easy fix too.
All it has to do is not take a default white colour when it would otherwise get the Photoshop's checkerboard backing. Ins$$anonymous$$d it should not change the calculated RGB which came from all the other layers that contributed to the colour before this back layer. I guess this is what Photoshop does and is why it gets right results. You don't need to do any "bleeding" trick, just don't default the backing to white and then apply the alpha over it.
Please comment if you agree with this.
For what it's worth ... as of early 2012 this was working just fine for me, and I used it the exact same way you did to create black drop shadows around all sorts of images. Within Unity, when I look at the preview of the .psd it show on a black background, which makes it impossible to see the blurred black drop shadow, but once rendered in game it is definitely working as designed.
However, sometime in August/October 2012 unity started displaying my newly created .psd files with a white background, and now every since image I use fades in alpha using white ins$$anonymous$$d of the black that is in the source .psd file. Interestingly, .png still does the same thing for me ... but .tiff yields the correct results.
I am using Pixelmator on OSX to author the .psd, .png, and .tiff ... and I talked to the developers and they say there has been no changes on the .psd export process on their end and that I should ask Unity.
Answer by wlad_s · Sep 14, 2012 at 08:48 AM
I've made a couple of printscreens in order to explain what's happening:
first, see this image of a red circle just drawn in photoshop It doesn't add any alpha channel in photoshop and when read in unity you get an automatic alpha but the white background is added (I think it's in PSD not in unity) so the red colour fades to white and you get the red-to-white antialias:
But if you save the same file in PNG, the png automatically makes colour bleeding where antialias from red to transparent is present as seen here:
Answer by wlad_s · Sep 14, 2012 at 08:55 AM
[I will continue my previous answer here since this system doesn't allow more than two images attached, so read my previous answer first]
What you need to do is make color bleeding yourself and add an alpha channel like this:
Then you can save it as psd, tga or tiff.
I don't know why is this happening but I think that "adding white background automatically" thing is related to photoshop, not Unity. Just as "adding bleeding" is the thing related to PNG.
I remember that I've encountered similar problems when importing transparent images from max to photoshop. It just started happening since one particular version of photoshop (I think it was year 2003). Since then, I'm using pngs.
Maybe there's an easier method but this is the only one I know of.
Hope I helped, I agree its frustrating but so are many other things :)
Blimey, its been problematic since 2003?!?! Is amazing what people have to put up with sometimes!
If Unity's conversion to a flat image differs from what Photoshop can do then in my book that is a bug with Unity. If they are supplied with a converter by Adobe then its theirs (and that would be yet another reason to boycott them). But either way I don't think Unity should be touting themselves as an easy importing solution until it is resolved.
no its a problem with Photoshop. all image formats use same basic principle of RGBA, photshop added its own "transparency" for use in photoshop years ago, but you can also add Alpha channel... that A from RGBA.
Soo adobe created this problem in that things can look different in photoshop from actual RGBA formats... all RGBA formats do not have to support photoshop... PS should support the look of those RGBA formats. So you have to understand both PS, and the format you are saving to. Does the format you are saving to support full alpha channel, or just 1 bit alpha (on.off). or no alpha support at all... e.g. jpeg. But meanwhile inside PS... it still uses transparency, and also a background color. Saved image formats don't have a background color ( another reason why things sometimes look different in PS )
Well, yeah, when I think about it, many other software don't have a problem importing PSDs correctly. I've only remember noticing some changes in the way Photoshop handles alpha since about 2003/2004. When importing tga or tiff render from 3DS$$anonymous$$ax to Photoshop. But when using PNG, it works as before that. I don't know if it's related to this problem but I've got used to using PNGs since then.