Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: ENAY 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.
-
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.
-
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. ;)
-
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!
-
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?
-
if the gameobject scale is 1 1 1 and mip maps are disabled with filtering set to point, then pixels are 1:1.
-
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?
-
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.
-
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.
-
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.
-
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).
-
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! :)
-
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.
-
Make sure the atlas doesn't get compressed on the iPad. iOS/Android targets often override texture import settings, and not for the better.
-
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.
-
Select the texture used by the atlas, choose "Override for iOS/Android", and make sure it's set to truecolor there.
-
Ok I did that for both the atlases and it didn't make any difference. Whilst Unity is compiling I can see the Game window temporarily go all low detail (exactly the same view from the ipad) before it goes into XCode.
I also check the scene settings and made sure everything was high and Full size textures were on.
-
If the game window goes into low detail, it suggests that the quality setting is actually set to fastest or something else that downgrades the texture resolution for mobile devices. But you say you checked it... Just make sure it's also the case for mobile targets.
Bed time for me though, so good luck!
-
Many MANY thanks for all the help man, I will keep looking :)
-
Finally cracked it! A fault of Unity maybe but the settings were always set to fastest, even though it was highlighted as best quality. In the end what I did was simply delete all the other settings except the highest quality and now it works perfectly. Pretty much every issue I had with gfx has now gone as if by magic. Again thanks for the help guys :) ;D