Hello Guest

Author Topic: Optimize space for 960x640 BG's and multiresolution question  (Read 9945 times)

mamamia

  • Guest
Optimize space for 960x640 BG's and multiresolution question
« on: October 30, 2012, 04:03:40 pm »
Hi,

I'm targeting 960x640 resolution on iphone. It downscales to 480x320 and upscales to all the others resolutions from this one. I don't mind much about aspect ratio differences between ipad/iphone (I have to think about iphone 5). My main concern is that my textures must be 1024x1024 because I support >=3gs devices. I have noticed a lot of texture space is wasted because 2 bgs do not fit 1 texture atlas. Is there anything I could do to improve this? Could sliced sprites help?

On the other hand, Is there any document, etc... I could read to know how to face the multiresolution/aspec ration/pixel density on android?.

Thanks a lot for this great piece of software.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Optimize space for 960x640 BG's and multiresolution question
« Reply #1 on: October 30, 2012, 07:31:02 pm »
Hi,

You could try storing the texture as non power of two, not putting it in a sprite collection, and use tk2dSprite.CreateFromTexture(...) to create it. I'm not sure if older iPhones support non-po2 textures though - you'll have to check that. If you're doing that, you'll have to manage resolution switching manually (using resources.load) but that shouldn't be too bad.
As far as I know, 3GS does 2048x2048 textures, so you could do that to support iPhone5.

For full screen textures, explicitly loading textures is probably the easiest way to handle this. You can then load specific images for whatever resolution you're dealing with.

Sprite dicing could help, but you'd need empty space in your textures for it to be of any help. It will massively help if your images aren't fully solid.

I suggest using tk2dCamera so you automatically get everything scaling properly - even on android. You can then use overrides to manage different related (scaled) resolutions if you need to.


mamamia

  • Guest
Re: Optimize space for 960x640 BG's and multiresolution question
« Reply #2 on: October 31, 2012, 01:44:12 pm »
Thanks a lot for the insights unikron.

Just some thoughts: My game is a puzzle game were I have pieces built of blocks placed on a grid. This is important because glitches between blocks composing the piece are shown when resolution changes.

Some idea I have come across is let my backgroudns just scale to fill the screen and scale my piece blocks to keep aspect ratio. So they will be smaller/bigger depending on the target resolution but keeping aspect ratio. What do you think about it? Is this possible with 2dtoolkit? Should I use 2 diferent cameras with masks for this (to apply diferent ratios)? Keeping aspect ratio will make me get rid of the glitches betwen the blocks?

Thanks in advance.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Optimize space for 960x640 BG's and multiresolution question
« Reply #3 on: October 31, 2012, 01:57:36 pm »
Scaling by multiples of 2 will always reduce glitches. Filtering will be predictable then.

Also what kind of glitches? Do you have mips turned on?

mamamia

  • Guest
Re: Optimize space for 960x640 BG's and multiresolution question
« Reply #4 on: October 31, 2012, 04:20:26 pm »
Hi again!,

Well, I'm moving from another platform to unity3d. My game is a port from the code I had on the other platform (gamemaker). There when I loaded my game on an ipad (ipad was rescaling) I got some times cracks between the piece blocks. This is why I asked you about this glitches, because I want to take care of them as soon as possible.

On the other hand, about the block rescaling I exposed in my previous question, scaling by 2x is too much. An example, I have a resolution of 800x600 and another of 1000x700. Obviuosly they are different aspect ratios. 800x600 is 1.333 and 1000x700 is 1.428.  As I exposed before, the only way I think I could go when passing from 800x600 to 1000x700 is:

1) rescale the background to fit the new screen size (or have a texture that could adapt best to this aspect ratio).
2) rescale my pieces by a percentage that could fill screen vertically but not horizontally retaining aspect ratio.

With this setup I am a bit concerned about the cracks that 2 can produce where piece blocks meet. Don't know how to achieve this 2 different rescaling either , this is why I threw in the idea about having 2 2dtoolkit cameras targeting diferent aspect ratios/resolutions (Update: It seems 2dtoolkit does not support more than one 2tkCamera. When one is on the other doesn't render its view).

Could you comment on all this? I know it is not 100% 2dtoolkit related but would really apreciate the help.

Thanks in advance for your time and support.
« Last Edit: October 31, 2012, 11:59:03 pm by mamamia »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Optimize space for 960x640 BG's and multiresolution question
« Reply #5 on: November 01, 2012, 12:00:00 am »
Cracks between blocks really depends on what the platform is doing. You are far less likely to get cracks if you design for the lowest resolution and only ever upscale, as opposed to designing at a high resolution and downscaling. Say you position a sprite at 101, 100 and then downscale to 50% - the coordinate then will be 50.5, 50 - which is no longer a pixel position. Authoring at low res works around this completely.

tk2dCamera can adapt to different aspects and resolutions - it has an anchor system and also a scale and offset which you can override specifically for every resolution should you want to. In most cases it won't be necessary. For example #2 is one of the things the tk2dCamera can do for you if you tell it to. Also, scale to fill horizontally if you prefer that. Or find the best fit. Its really flexible in that regard.


mamamia

  • Guest
Re: Optimize space for 960x640 BG's and multiresolution question
« Reply #6 on: November 01, 2012, 03:22:06 pm »
Again, thanks a lot for the insights.

I have been doing some tests, etc... and there's something I would like to do that I don't know if it is possilbe.

I have been able in the editor to fit all screen without keeping original aspect ratio checking "Force Editor Resolution" with any resolution override. This allows the view to resscale to whatever resolution unity is set. I really need this option and don't understand why it is not provided. From the other thread that a pal was requesting it too I understand the problems with the aspect ratio change, but some times and depending on the game it could be a really good option.

Is there any possibility to achieve this?.

Thanks in advance.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Optimize space for 960x640 BG's and multiresolution question
« Reply #7 on: November 01, 2012, 03:38:41 pm »
That will just work like that.
Force Editor Resolution is just to force the editor resolution, working around a "bug" in unity where if you resize your window so its smaller than the resolution specified, it will incorrectly report size. That tickbox only affects behaviour in the editor.

mamamia

  • Guest
Re: Optimize space for 960x640 BG's and multiresolution question
« Reply #8 on: November 01, 2012, 04:45:43 pm »
I see. Anyway I commented the #define letting it just work on editor and now it scales all screen. For my game, stretching is the best option. I hope you don't mind we modify your code. Is there any possibility to have this as a official feature in the next version? I mean, another option besides the width fit,height, visible. Something like fit visible without aspect ratio.

Thanks in advance.
« Last Edit: November 01, 2012, 04:47:16 pm by mamamia »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Optimize space for 960x640 BG's and multiresolution question
« Reply #9 on: November 02, 2012, 12:24:59 am »
There will be something like that in the next version. Drop me an email (support@unikronsoftware.com) and I'll send you the latest tk2dCamera. That mode is "unsupported" as in it can look bad with non-uniform scales, etc.

mamamia

  • Guest
Re: Optimize space for 960x640 BG's and multiresolution question
« Reply #10 on: November 02, 2012, 12:07:55 pm »
Thanks a lot for the offering. I know it could sound odd, but right now I prefer to wait for next official release, I have been hacking around the t2dcamera and I don't think I will be back to the current one. It exactly does now what I need.

On the other hand, is there any possibility to easily switch sprite collections depending on the resolution I detect without obects loosing refrences, etc...? I have really bad experiences with unity when changing resources it looses references.

Thanks a lot for you time and effort, one of the things that made me buy 2dtoolkit was its support. Now I can really confirm it is amazing.

Cheers!.
« Last Edit: November 02, 2012, 12:19:08 pm by mamamia »