Unity ques: Hi res sprite sheet swapping for retina devices?

Hey, does anybody have experience using multiple resolution sprite sheets for mobile devices using unity's built-in 2D/new GUI stuff?

I know things like NGUI had (shitty) strategies for this, but ideally I'm looking for a native solution. So far the best I can find is that we have to do this manually, which seems not great for many reasons which I listed in this thread:
http://forum.unity3d.com/threads/working-multi-resolution-sprite-sheets.274683/

Any body has experience it would be appreciated ;)

Comments

  • So, weird idea, but it might work: Can you manually load different textures at the different mip levels and then move your camera back and forth (or change your mip bias) according to the resolution reported by the device? Unity should only load the textures at the correct mip resolution and voila, bob's your uncle.
  • My guess is that changing the camera Z wont make any difference on mipmap sampling as with an Orthographic projection, the Z doesn't affect the size of viewport, and hence the scale of the textures being rendered.

    Unfortunately, Unity always has the entire mipmap chain in memory (that's how textures work), and the GPU will decide what mip level(s) will be chosen for sampling based on "things".

    You can also only control the mipmap bias through shaders in Unity unless you happen to be running the FFP, which I guess Peter *could* be doing, but not if he's targeting mobile at all?

    But yeah, having the bias set as a global shader values based on resolution at startup, and writing all of your own custom shaders for textures that you wish to dynamically change the resolution of could be a pretty neat trick in and of itself, but you'll still be sucking up all of that massive extra RAM on low-end devices just to store the 'retina' sized image data that isn't necessary, not to mention having to write and maintain a bunch of your own custom shaders
  • Ah. I'm mostly suggesting it because we had some really weird shit going on with mipmaps in DD (which is orthographic) based on camera distance to objects and specific build settings on different machines. Very annoying to diagnose... It probably wouldn't be an effective solution though :(
  • edited
    So for those interested I seem to have arrived at the most official solution, which is to load assets from the Resources folder using string references. It's not perfect but it works. Thanks to all the guys that helped out with suggestions both online and offline. If you want more detail I updated the Unity thread: http://forum.unity3d.com/threads/working-multi-resolution-sprite-sheets.274683/#post-1816605

    Also this video was linked by one the Unity devs. It's super useful if ever you've argued with 2D issues in Unity like how to do HD/SD texture swapping, Setting the size of the camera, getting pixel perfect sprites etc...
    Thanked by 2AngryMoose Fengol
Sign In or Register to comment.