Author Topic: Pixel perfect pixels that don't bleed  (Read 17775 times)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Pixel perfect pixels that don't bleed
« on: May 23, 2012, 02:59:57 AM »
Is Pixel perfect aspect ratio even possible using sprites in NGUI? I almost certain this is a Unity problem and not a NGUI one.

For example, Sprites I make in NGUI end up coming out slightly blurry, no matter what texture size or device. I made an 8x8 image and even that came out blurry, I drew diagonal lines across the image, now when I zoom in, all the pixels are blended together and instead of seeing squares I get melted looking diamond effects. I'd hoped that by having your sprites positioned in exactly the correct position away from the camera would allow the pixels to look normal but it doesn't make much difference.

I can achieve pixel perfect only by creating a sprite per square and then positioning them next to each other, but I mean come on, who would be stupid enough to have 64 seperate sprites to display a single 8x8 sprite :)

I tried clicking on every single shader Unity has to offer and I couldn't find anything to make my texture pixel perfect.

loopyllama

  • Guest
Re: Pixel perfect pixels that don't bleed
« Reply #1 on: May 23, 2012, 03:45:44 AM »
click on your atlas texture and in the inspector make sure mipmaps are disabled and filtering is set to point. be warned, ngui will clobber these settings every time you update an atlas. To remove this feature, search the forums for posts I made containing mipmapenabled and trilinear.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #2 on: May 23, 2012, 04:35:45 AM »
Look up bilinear and trilinear filtering. If you want really pixel perfect, you need to set your atlas to point filtering and never ever scale it out of pixel perfect. ;)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #3 on: May 23, 2012, 05:12:44 AM »
Thanks guys! :) The mip map I can't find in the atlas, or do you mean, setting mip map to null in the image before I add it to an atlas. Ironically I have all my images with mip map set to zero, and point. Except in the atlas itself!

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #4 on: May 23, 2012, 06:11:21 AM »
Hmm, that didn't seem to work out too well, all my sprites now look incredibly blocky instead of being blurred being pixel perfect. I thought pixel perfect sprites were supposed to be 1 unit in Unity to 1 pixel on the screen?

loopyllama

  • Guest
Re: Pixel perfect pixels that don't bleed
« Reply #5 on: May 23, 2012, 06:45:35 AM »
if the gameobject scale is 1 1 1 and mip maps are disabled with filtering set to point, then pixels are 1:1.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #6 on: May 23, 2012, 07:20:23 AM »
Everything looks really quite blocky. It looks especially pad on the ipad.

I am certain that my pixel perfect sprites are ok. Is there anyway to check whether the scale in Unity is the same as your sprites?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #7 on: May 23, 2012, 08:29:01 AM »
That's how filtering works. If you zoom in on a small texture, you're obviously going to get either blockiness, or bilinearly interpolated version of the same blockiness. It's only pixel-perfect if you leave it pixel-perfect. Zooming in != pixel perfectness.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #8 on: May 23, 2012, 09:28:51 PM »
Thanks for the post :) I know all about the bleeding and how pixels work and stuff, it is just getting the texture to align up with the camera that is my problem.

I have attached a screen dump. In it I have several basic images (all with their own separate atlases)
As you can, two of them have their atlases selected to have no bleeding, but despite clicking on pixel perfect, they aren't, most are 2x2 pixels and some are 2x3 or 3x2 at random. After messing around with the camera settings, zooming in out etc, there doesn't seem to be any setting where the pixels are all at 1x1.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #9 on: May 23, 2012, 09:31:22 PM »
What I am hoping for is something like this. Which is simply an attachment of the image itself. Having them at any size 8x8, 16x16... 256x256 etc there is no difference in texture size.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #10 on: May 23, 2012, 09:37:12 PM »
The fact that there is blurriness tells you that they aren't pixel perfect. Perhaps "half-pixel offset" is off, or perhaps your UI hierarchy isn't using integer numbers. Try selecting your UI Root and hitting Alt+Shift+P (makes the whole thing pixel-perfect).

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #11 on: May 23, 2012, 09:50:43 PM »
Well I just tried opening up one of your examples and adding a sprite in there and now it is working fine!
Arenmook, and everybody else, you have given me hope! :)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #12 on: May 23, 2012, 10:18:15 PM »
Well, I think I am getting close, things are working as expected on the PC and Mac now but when I compile to ipad, the aspect ratio is not correct, the 8x8 texture seem to have become squashed into 3.5x3.5 or similiar. And the other textures look like they have been automatically resized, it is as if the point set texture settings has just been ignored.

This is the Example 1 I compiled with using the default settings, ie "Top Left", "Top" etc 8 button example, but still things are not how I expected.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #13 on: May 23, 2012, 10:24:21 PM »
Make sure the atlas doesn't get compressed on the iPad. iOS/Android targets often override texture import settings, and not for the better.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Pixel perfect pixels that don't bleed
« Reply #14 on: May 23, 2012, 10:34:12 PM »
I think that is what could be happening. How do I check? There doesn't seem to be any option in the build window in Unity.