Author Topic: A few atlas/texture things...  (Read 6585 times)

schuberbia

  • Guest
A few atlas/texture things...
« on: April 23, 2012, 03:30:09 PM »
I've run into a few things I thought I'd mention in working with the Atlases/Fonts...

If you have an existing atlas and you try to add a new texture to it while the packed texture PNG is read only, your atlas will get messed up.  I believe it goes ahead and modifies the atlas' coordinates to account for the addition, but since it doesn't write the PNG the new coordinates are incorrect.  It'd be great if the process would either do absolutely nothing if it can't complete successfully, or to handle this particular problem, switch the PNG to writable so Unity can update it.

It'd be nice if items in the atlas remembered their original source texture.  I've name my assets things like "Button_HiRes" and "Button_LowRes" and pull them into an Atlas and rename them to just "Button" so I can swap the atlases out.  Problem is, I can't update the assets as easily this way because nothing connects the filename "Button"HiRes" to the sprite name "Button".

Somewhat relatedly, if a widget is using a texture that doesn't exist because I've deleted it (so I can replace it with another, I'd rather it wasn't automatically reassigned another texture in the atlas.  If I accidentally delete a texture, I don't want to have to dig up all the old references and fix 'em back up.

When I pull in fonts from BMFont it seems to fill the background with black around character blocks which causes the edges of the letters to pull some black from the background when filtering.  It'd be nice if there was a way to tell the atlas/font builders what color to fill the background transparency with, or maybe even an option to copy the neighboring colored pixels in.

Really, any graphic does the above - I can see a solid case for not supplying a fix for fonts (really the issue is with BMFont).  But, for example, if I have a 8x8 white square in my atlas the outer pixels all end up being grey after filtering.  I tried fixing this by moving the Dimensions of the sprite in by one, but then when I updated the atlas later they'd be wrong again.  I assume the texture packer throws out the pixels that I clipped out by modifying the dimensions since nothing seemed to need 'em anymore.

Anyway, just a few things I've run into I thought I'd note...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: A few atlas/texture things...
« Reply #1 on: April 23, 2012, 03:36:41 PM »
The not keeping references to textures is intentional, it allows you to safely remove the source textures, keeping your project clean. Ideally source textures will be somewhere outside the "Assets" folder -- Art folder for example. When you need to update something, copy a texture from the art folder, update it in the atlas, then delete the copy. This way Unity isn't loading megs of extra textures it doesn't need.

BMFont exporting black around characters is trivial to fix. Open it in Photoshop, and replace RGB with pure white. Ideally you will also add something more in photoshop -- outline, drop shadow, bevel -- something to make your fonts look a bit fancier. Simply clearing the font's RGB channel with white by default when creating the UIFont simply isn't feasible. Maybe if it was an optional feature...

schuberbia

  • Guest
Re: A few atlas/texture things...
« Reply #2 on: April 23, 2012, 03:55:03 PM »
I understand why you don't keep references around, but maybe you could keep the filename reference as a hint for the importer.  Really though, if you're designing decent reusable UI graphics, it won't add up to that much data and (IMO) you're better off just keeping it tucked away in your project since they'll get built out of the finished product.  Also, if you're using asset server, you'll need the source in your project anyway for version control.

The bigger issue I've had is the read only flag, though.  We're using Perforce, so its pretty easy to have this accidentally happen which can really jack up the interface.

Any thoughts on my "white square" example?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: A few atlas/texture things...
« Reply #3 on: April 23, 2012, 04:01:34 PM »
Generally you only see parts of another sprite filtered through if you zoom in on your sprite, meaning you aren't working in pixel-perfect coordinates. In pixel-perfect coordinates it's generally not noticeable. That said, I will keep an eye out. If I can add an option to extend the border by 1 pixel without breaking things, I will do it.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: A few atlas/texture things...
« Reply #4 on: April 23, 2012, 05:29:34 PM »
Use Glyph Designer to export. BMFont sucks donkey nuts, especially with lower sizes.

If you switch between low res and high res atlases, you should name your original files the same, but place them in lowRes and high res folders instead, makes it a lot easier.