Unity完美像素Sprite:怎么让图片变得清晰(转载) Unity Pixel Perfect Sprite: How To Achieve Crispy And Sharp Images
https://gamedevelopertips.com/unity-pixel-perfect-sprite/
So I was making a little prototype for my new game when I just came across a little problem.
The sprite that I was loading into Unity was just looking too pixelated and not sharp at all.
So I spent a few days to understand and address this problem until I found the perfect solution that I’ll share with you in this article.
Let’s start with the beginning.
Create the sprite in photoshop.
In my example, I’ve created a simple semi-circle shape:
The resolution of this circle is 512*512 pixel, but now let’s load it into Unity and let’s see what are the adjustments that we have to do to make the sprite look crispy and sharp.
This is the settings that you should use in your project:
Now here are the things to keep in mind:
- In my case “Generate Mip Maps” is turned off but in case you are planning to zoom in / out a lot then you should tour it on.
- Pixel per units, This setting is good for my project which was using a screen resolution of 750×1334 pixels, but feel free to just this number until will fit perfectly you screen
- Be sure that the max size of the sprite is at least the same resolution of the sprite (in my case was 512 so 2048 is ok), but not lower.
- Make sure your sprite import compression is not set too low (try None to see if it has an effect).
Unity pixel perfect sprite: Other tips to improve the look if your sprite in Unity
Now, if all the above suggestions didn’t make you sprites look good, we have some other adjustment that we can do, so follow me:
Let’s start with the antialiasing settings:
Go to Edit->Project Settings->Quality-> Anti Aliasing and set it to 4x or 8x, but be careful, this will drag your resources down so keep it as low as possible. In my case 4x was enough to help me achieve a slightly better look on my sprites.
Anti-aliasing has the following effect:
With an Anti-aliased tour on, the pixels will result in more smooth and blurry which is something that I really like, but if you want to achieve ultra-sharp images, then you can consider to tour it off.
The second setting to check on the same screen is the following: Edit->Project Settings->Quality->Texture Quality should be Full Res.
Moving forward, make sure your sprite gameObject has a scale of 1 on x, y and z.
Change the camera orthographic size
Now this is another relevant part
remember before when we have set out Pixel Per Unit (PPU)?
Now you need to tell the camera how big we want it to be based on that PPU so that one pixel on screen corresponds with one pixel on our game.
To get that size we just need to do a simple formula:
Camera orthographic size = vertical resolution / PPU *0.5
Once you have that size click in the Main Camera object, and put that value in the Size setting:
In my case for example:
I have a resolution of 750×1334 and a PPU 600 = 1334 / 600 * 0.5 = 1,11
Ok with these little tips you should be able to have nice looking images and build amazing games.
Thanks
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!