Search Unity

2D Game Graphics for different resolutions

Discussion in '2D' started by mmarab, Aug 30, 2014.

  1. mmarab

    mmarab

    Joined:
    Aug 30, 2014
    Posts:
    3
    I found severely forum posts regarding different screens resolutions, but none of them really answered my questions.

    An artists is designing the 2D sprites and asked what resolution I want. I realised i didn't actually know. The idea is that I would ideally like to release the game on multiple platforms which have different resolutions.

    for example:

    IPhone 5 : 1136 x 640
    Galaxy S5: 1080x1920
    IPad: 2,048 x 1,536

    Also this raised another question regarding how I actually handle different resolutions to scale the graphics properly, is this usually a code based solution or does unity have something to help?

    Also in terms of the graphics being designed should I go for the highest resolution and scale down?
     
  2. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,038
    You basically want HD graphics (Retina screens etc.) and non-HD graphics (half the width and height on the assets). With certain types of art it's better if the artist exports the lower resolutions, but generally non-HD can be made by just resizing the source art.

    Unity doesn't currently have much help for different resolutions, but they're planning something for HD/SD graphics switching in the uGUI, and since it's based on sprites it'll most likely carry over. But for now you just have to look at other solutions. Kits like 2D Toolkit have their own solutions to help with this.
     
    mmarab likes this.
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,448
    Ox_ and mmarab like this.
  4. mmarab

    mmarab

    Joined:
    Aug 30, 2014
    Posts:
    3
    Thanks for the information Orb and Mgear much appreciated.
     
  5. Ox_

    Ox_

    Joined:
    Jun 9, 2013
    Posts:
    93
    Unfortunately both of the methods discussed in video (manually loading HD sprites from Resources or AssetBundles and replacing scene sprites) are not effective compared to 2d Toolkit's platform-dependent sprite collections.

    I highly recommend to use 2d Toolkit if you are making a mobile 2d game. It has amazing platform-dependent collections and great 2d camera. Unity's 2d is not that powerful yet. (But I hope it will catch up this year.)

    (And please include retina bundles in your mobile games – it's really annoying to wait when some game is downloading 100mb of resources from its slow US server.)
     
    Last edited: Jul 19, 2015
  6. ColossalPaul

    ColossalPaul

    Unity Technologies

    Joined:
    May 1, 2013
    Posts:
    174
    Oh yes we do. Depending on your resolution you could easily switch out the sprites to the ones suitable for your device.

    See: http://forum.unity3d.com/threads/working-multi-resolution-sprite-sheets.274683/ and look for my posts for an example project. There's no manual relinking or anything. All automated.

    (And we should really pool all these multi-resolution + atlas + pixel perfectness into 1 unified consistent blog posts). Coming soon i guess.

    I would love to hear why you think 2dtk is more powerful or why we are not as powerful. As the 2D Lead, I could nudge the team along in the right direction when given the right feedbacks.
     
  7. Ox_

    Ox_

    Joined:
    Jun 9, 2013
    Posts:
    93
    Thank you for the reply, I really appreciate it.

    It's possible for me to have some incorrect ideas about some Unity 2d features since I haven't had serious projects in it (though I tried its workflow multiple times because I'd like to move to the "native" 2d one day).

    But I'm an advanced user of 2d Toolkit. Here's my previous project with a complex and adaptive UI created fully with 2d Toolkit sprite/UI components:


    Atlas Management
    The main magic of 2d Toolkit is in transparent resolution-dependent atlas use. Its mechanism is also similar to other 2d engines like Cocos2d and Corona.

    My current workflow is incredibly simple:
    • pick @2x sprites from an artist
    • batch resize them to @1x
    • drop @1x- and @2x-suffixed sprites in the same folder
    • drag @1x sprites to a Sprite Collection window
    • set 1x/2x support for the collection
    • commit the collection

    2d Toolkit picks @2x (@3x, @4x, etc.) sprites automatically and creates correct atlases for them. Then I'm checking screen resolution on a game start and setting the right suffix for the current device. From now on 2d Toolkit will always pick correct sprites and atlases.

    Additionally I can:
    • use custom diced mesh for a single sprite to save the atlas space by including repeating parts of the sprite only once (it's very useful for big images like backgrounds where you can find many similar flat-colored parts)
    • see atlas wastage % (so I can rearrange my sprites to use the POT texture space efficiently)
    • remove duplicates from collection
    • set maximum atlas size (I set 1024 on @1x, to prevent accidental creation of 4096 textures for @2x)
    • make the atlas loadable (from Resources), so I can do some manual memory management (this problem is still present on older iOS devices)
    • set compression mode for the whole collection (helpful for reducing quality or moving bunch of rectangle sprites from RGBA32 to RGB24)
    • preview @2x in the editor without running the game

    For the Unity's 2d I'm cool with sprite tags but it's easy to miss a tag completely or make a typo in its name.
    It would be very handy to have a dropdown menu with pre-created tags (like we have for sorting layers) and to get a list of sprites without a packing tag.

    So I watched the video of Veli Pekka Kokkonen explaining the current SD/HD workflow.

    Setting up Resource-based sprite management can't be a solution for big projects (FindObjectsOfType!) until you'd like to put some sprite swapping script on every sprite containing GO. And these GOs have @1x sprite by default, so it will be an unnecessary memory overhead.

    But the Asset Bundle solution is even more uncomfortable to work with. As I understood it from video, it requires to:

    1. Set empty sprites on scenes that really breaks the whole Unity Editor workflow - I want to see things without running the game every time.

    2. Put SD/HD sprites to different folders and use the same names. But 2d games sometimes have thousands of sprites and with the suggested workflow developers can mix up SD/HD or forget to drag HD to its folder or make other small asset management mistakes. @1x/@2x should use suffixes in their names and ideally – be in one place (or maybe Unity can notify me if I'm missing @2x like sprite collections do).

    3. Use renderer names. It could be ok for a very small game but I can't rely on this solution for a big project since it's a fragile linking. Also I can't name different GOs differently if they're using the same sprite.

    And I'd like to note that it's a very rare case for HD to be downloaded separately on mobile. Especially nowadays when 2d games rarely can go over the increased 100mb data downloading limit. HD asset bundles could be used for some additional content but it's not a wise decision to make mobile players wait while the game is downloading huge HD textures.

    I suppose these issues make asset bundles not so important for Unity 2d games at this moment.

    tk2dCamera
    I probably can continue to use this camera even with Unity 2d but it would be a huge thing to have its features natively (because there're other developers who don't own tk2d).

    The camera has a Native Resolution and a list of overrides that can match by wildcard, aspect ratio and a specific resolution. After matching the override, the camera will scale, fit width / height / visible part, stretch or stay pixel perfect.

    It is super flexible and I can easily adapt my 2d game background to any set of aspect ratios and resolutions.
    For example, I will match 4:3, 3:2 and 16:9 aspect ratios of iPads, old short iPhones and modern HD devices. Then I will “cut” the right rectangle from my game backgrounds (and also attach UIs to screen borders with tk2dCamera UI anchors but uGUI does it too):


    Also I saw some statements on this forum that Unity 2d has problems with pixel-perfect rendering but it's not an issue for 2d Toolkit.

    ----------------

    I hope my explanation will help the 2d team. I do not demand a copy of 2d Toolkit workflow and it's easy for me to re-learn and adapt to your solutions.

    But I'd like to have a bit more control of how I'm packing sprites and a bit more magic in how Unity is picking sprites.

    Thanks!
     
    Last edited: Jul 21, 2015
  8. ColossalPaul

    ColossalPaul

    Unity Technologies

    Joined:
    May 1, 2013
    Posts:
    174
    That's deprecated. We should take that off. Ignore everything.

    Thanks for sharing. These all can be done now. However the workflow is not as easy to understand as it should be. It requires:
    • Put textures in separate HD and SD folders, with exact same names.
    • Tag the HD and SD folders with asset bundle variant names.
    • Set different packing tags to the HD sprites and SD sprites, so you create 2 atlases.
    • Build the bundles and either have it downloaded at runtime or shipped with your ipa.
    Then at runtime, load the bundles suitable for your device and nothing else needs to know it was swapped.

    We are revamping the packing tag design to give you more control. Right now it's not easy to see what goes where and what is the atlas size/format etc. We are working on this as we speak.

    Have you seen this: http://blogs.unity3d.com/2015/06/19/pixel-perfect-2d/. I guess we could plan to make a component that helps you adjust your camera's orthographicSize.

    Very cool. Added to road map!

    Thanks again. if you could think of more, do PM me. I'd like to hear all about it.
     
    orb and Ox_ like this.