Pixel Perfect Calculator for Orthographic Camera : Unity3D
It’s pretty easy to setup an Orthographic Camera in Unity, but without paying attention the settings can cause us numerous problems when it comes to sprites, textures and the quest for pixel perfect graphics in our games.
When wanting pixel perfect graphics it is important that we set the camera size to give us a 1:1 pixel/texture ration between Photoshop (or your alternative) and Unity.
For example, if our game resolution is set to width = 960px height = 640px and our camera size is set to 5 a Unity cube (scaled at 1,1,1) will be the equivalent of a 64px by 64px square in Photoshop. This means that our game screen will have space for ten 64px sprites stacked on top of each other.
Many game devs will prefer to work with a set size in Photoshop and then adjust their camera setup in Unity accordingly. Depending on the resolution and the target Photoshop size this can require some complicated trial and error. However an untraceable contributor in the comments section of Rocket 5’s wonderful tutorial series on 2D in Unity , provided a formula thus avoiding the trial and error.
Camera Size = x / ((( x / y ) * 2 ) * s )
Where:
x = Screen Width (px)
y = Screen Height (px)
s = Desired Height of Photoshop Square (px)
x = Screen Width (px)
y = Screen Height (px)
s = Desired Height of Photoshop Square (px)
It’s a formula that works perfectly and I have setup a calculator to make the calculation process even easier via my Pixel Perfect Camera Size Calculator – Google Doc. Feel free to share, use and download as you wish.
No comments:
Post a Comment