Author Topic: Odd behavior with transparency in the atlas maker (has workaround though)  (Read 8080 times)

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
I'm seeing some pretty strange behavior with the atlas maker. I can manually tweak/fix the generated atlas afterward using photoshop and it fixes the problem, but it's still a bit odd and problematic.

I have a window that I'm drawing using 9 sprites (upper/mid/lower multiplied by left/center/right) with linear filtering turned off. All sprites have a semi transparent shadow in their "outer" facing pixels. The shadows look fine with the corner sections, but the shadows in the edge sections (which get stretched), always get baked in to the atlas with their transparency modified (they're about 2x more transparent).

It's definitely a problem with the atlas itself (rather than how it's displayed), since the pixels in the atlas image itself can be easily manually verified as being too transparent in an image editor. I've attached a screenshot that shows what the sections look like and red rectangles around the shadows that get effected. The shadows in the corner sections are not effected at all though. I don't think the source textures are the issue either, since they're what I use to manually fix the issue afterward...  Unless it's a format incompatibility caused by photoshop saving those skinny sections differently.

I've also attached a screenshot of an atlas as generated by NGUI (before being manually fixed, but i did add red arrows to show where the issue occurs).

And I've attached a zoomed in example of the effect (top half is post-NGUI, bottom half is the source)

« Last Edit: April 29, 2014, 06:32:50 PM by Wisteso »

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
I had this problem recently as well. The generated atlas would add about 20% transparency to everything. I managed to make it not do this by manually setting all the derived textures to true color, then recreating the atlas. Im not sure if this was coincidental, but it fixed it for me.

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
I would try the same idea, except I have everything set to true color already. Though I have noticed that the atlas maker likes to change a lot of the settings of the images which it uses (E.G. sets it to ARGB, turns off "alpha is transparency", etc), since it doesn't change them back to what they were before. It may have something to do with that?

However, the fact that this happens with only skinny sprites suggests to me that it could also be some math error going on somewhere. Though it could easily also be something like an incompatibility with an optimization that photoshop applies to small images...

Fortunately there's a workaround, but it's a bit tedious to do all the time. Right now I'm just leaving the atlases broken until I need to publish a build.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
That second image seems to suggest that the border is flipped differently than the center.

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Sorry Nicki, but I dont know what you mean. As far as I can tell, the orientation is good for everything in the atlas.

The only issue is the transparency being too strong in the edge segments (even though they're all from the same verified-to-be-correct source image)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Why are you using 9 sprites? Creating a window using 9 sliced is just that -- 9-slicing. Sliced sprite.

Try this. Create a circle in Photoshop. Just a pain circle, 64 pixels in diameter. Save it as a texture. Now create a sprite out of it, and specify a border of 32 pixels all around. ALT+SHIFT+S to add a sprite to the scene, make sure you are using this sprite you just added and that it's set to "Sliced".

Note how it behaves when you resize it.

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Aren, the spliced sprite is great, and I can probably use it for this case - so thank you for pointing that out! =)

However, I was in the habit of building them out of 9 sprites since I needed the edges to be tiled for other cases, rather than stretched, and sliced sprites do not yet support tiling rather than stretching.

I'll give it a try though and it will probably fix this particular case, but I do think that there still may be a bug here with transparency.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Sure they do. Change the sprite type to be Advanced and you can specify exactly what will happen with each side/corner -- including making them tile.

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Oh, awesome! I'll check that out then. Thanks!

I'm trying to remember what I saw that made me think you could not do it...  it must have been an old post.