Hello Guest

Author Topic: Mipmapping based on platform  (Read 7282 times)

dakeese

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 50
    • View Profile
Mipmapping based on platform
« on: March 26, 2012, 01:10:24 am »
I'm making an iPhone/Android game that has a static camera.

It's been easy to set up the graphics so they are pixel perfect on iPad, and then still pixel perfect on iPhone4 by cropping a little off the sides (smaller orthographic size on camera).  And the iPhone 3gs is also pixel perfect because I set the camera to the same orthographic size as I do on iPhone4 so the first smaller mipmap is used and is pixel perfect.

But on Android, there are way too many resolutions to support. I don't want to have to allow any more cropping than I do now, or the scenes will have a bunch of unimportant space around the edges because I need to account for them possibly being cropped off. So on devices that do not have resolutions in between iPhone4 and iPad, I just scale to fit and rely on linear scaling to keep the graphics decent. 

This is where the problem is.  On Android devices that are slightly smaller in resolution than iPhone4, it drops to the lower mipmap and scales up, so it looks really blurry.  For these devices, it looks better to turn off mipmapping so it's always working with the higher resolution sprites.  The problem is that for smaller resolution devices, the lack of mipmapping is very apparent, i.e. tearing/aliasing in the sprites.  And this affects the iPhone 3gs also, since it's pixel perfect rendering was relying on mipmapping.

So my questions are:

Is there any way to set whether mipmapping is used based on the platform (iOS vs Android)? Then it would look good on all iDevices plus high-res Androids, which would cover the great majority of users.

Is there a way to get mipmapping to pick the higher resolution mipmap and shrink it if the resolution is close?  Not sure what the cutoff is for deciding whether to display the higher or lower resolution texture.  When I did OpenGL programming myself, you could pick mipmapping independently for maximizing and minimizing filters.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Mipmapping based on platform
« Reply #1 on: March 28, 2012, 09:38:51 pm »
Hi,

First and foremost, I would like to apologise for not replying to this post sooner - I somehow totally missed it.

You can't  set up mipmapping per platform - this would need to be exposed through Unity, and Unity doesn't allow you to do this, I'm afraid. You can, however, disable mipmapping completely, and then use QualitySettings to scale your texture down when you need to. This might work out much better. If you're going to do this, I suggest increasing the amount of padding in the atlas to avoid bleeding across edges.

Its not possible to set cutoffs for mipmap selection, most hardware actually supports this internally to some extent, but this isn't exposed in D3D at least. However, you could increase the Max Anisotropy, which generally improves mipmap filtering somewhat. Its definitely worth a try on your test samples.

Cheers,
unikron

dakeese

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 50
    • View Profile
Re: Mipmapping based on platform
« Reply #2 on: March 30, 2012, 03:17:53 am »
Thanks for your response.  I'll have to try out the Quality Settings....didn't realize you can change them at run time!

I think I found an alternate solution as well. It looks way better if I turn on trilinear filtering, which is supposed to improve the interpolation between mipmap levels. Looks really good and no framerate problem with what I'm doing so far but my scenes are still pretty simple.

However, I think your solution with the Quality Settings switching would be better in terms of keeping memory use and load times lower on devices that don't need the higher resolution textures.  Plus, if my scenes get complicated, I may need to turn off trilinear filtering for performance reasons.

As far as anisotropic filtering goes, I don't think it would help in my case, since my sprites aren't stretched or shrunk oblong.

39thstreet

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 77
    • View Profile
Re: Mipmapping based on platform
« Reply #3 on: August 16, 2012, 08:46:55 pm »
Bumping this old thread.

I would really love a way to disable mipmap by platform.  Since I want them off on iOS and on when on Android.    Failing that, though, it would be great to have the mipmap setting exposed in the SpriteCollection settings. 

Being able to flip on/off mipmaps in the Collection (as opposed to having to separately edit the atlas0.png texture itself) would at least make life easier.

Just a thought.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Mipmapping based on platform
« Reply #4 on: August 16, 2012, 09:24:05 pm »
Enabling / disabling mipmaps per platform is not possible directly on a texture, that is more a limitation of Unity than anything else - however, the next version will have part1 of the multiplatform version - it will let you do some more creative things :)