how does the image size power of 2 works?

guillefaceguilleface Member Posts: 1,014
edited November -1 in Working with GS (Mac)
my actor is 60x30 divisible by 2 is =30x15 but i think it should be even numbers? so do my image has to be 60x32 but i also want my image for ipad and iphone 4 and that should be divisible by 4? so will it will be 60x32 =15x8? but again is not even number no more, so what do you recommend my image of 60x30 should be so i can use it for all ipad,iphone 4 and older devices, i am sure this should then apply to the rest of my images?

Comments

  • PhoticsPhotics Member Posts: 4,172
    From the way I understand it... and I've done some testing... a 60x30 actor gets thrown in a 64x32 container. (It uses the same RAM as a 64x32 image.)

    You might want to move those numbers up to the next power of 2. But if you don't, that's still kinda close enough. It's not a huge memory loss. If that's your retina display graphics, 64x32 might be a better size because it would scale down better at 32x16 instead of 30x15.

    In The Unofficial GameSalad Textbook, I wrote about the huge memory difference between two images...

    512x512 and 513x513

    Even though it was just one more pixel row horizontally and vertically, it basically quadrupled the memory requirement. So for large images, something like this is important... but for 60x30... it doesn't seem so significant memory wise.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    The power of 2 thing is a memory only Issue. ie. How Photics explained the memory thing. But really its not that big of a deal on actors that sized. Also the power of 2 thing applies to the size of the image not the actor. So if your actor is 60x30 and your art is 120x64 it will use the memory of the 128x64 container size.

    As long as your actors are even number sized then when you double it for RI artwork you will be fine.
  • guillefaceguilleface Member Posts: 1,014
    i not saying all my actor are that small but it was just are reference, i just dont want my images to look good on one device and in another blurry, the memory usage i understand now, so basically keep my images with even numbers and i'll be fine?
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Keep your actors with even numbers and your images twice that size.
  • guillefaceguilleface Member Posts: 1,014
    oh man more stuffs now, i dint know that, i have some actors like 50x 40.43 something like that i just drag them to the scene and sometimes i rezise them by accident, so what are you saying is for example my actor is 60x60 i should have my image for that actor 120x120?
  • PhoticsPhotics Member Posts: 4,172
    guilleface said:
    oh man more stuffs now, i dint know that, i have some actors like 50x 40.43 something like that i just drag them to the scene and sometimes i rezise them by accident, so what are you saying is for example my actor is 60x60 i should have my image for that actor 120x120?

    I don't know what your game is like. This is what I usually do for my games...

    I tried to keep most actors powers of two. Like TANK in BOT - the actor size is 64x64. For retina display, the image size is 128x128.
  • LuckyLurcherLuckyLurcher Member Posts: 343
    Does rotating an actor cause it to use more ram?
  • guillefaceguilleface Member Posts: 1,014
    hi photics, my game is a horizontal airplane shooting, most of the actors are not big except the background,. so you are saying to add a double size image to my actor,this way will work on iphone 4 too? and if i go by the power of 2, my images dimension should be 64x64,128x128,256x256,512x512 , so there is no problem by dragging a image size of 128x128 to my actor size of 64x64? i thought i had to make the image size same to the actor size
  • allornothingallornothing Member, PRO Posts: 126
    Your measurements in pixels should be:

    2,4,6,8,16,32,64,128,256,512,1024 etc

    It's not 'divisible by 2' it's 'power of 2' as in 2x2x2x2x2 etc...

    More efficient memory usage is the result. I believe GS scales images up as far as memory usage is concerned, so if you import a 400px wide image, it will treat it as if it was 512.

    Bear in mind that both axis' don't have to be the same. 128x64 or 32x512 is fine. As long as each is a power of 2, you're sorted.

    On a side note, try and keep your original art graphics and the actor size as close as possible, as scaling bitmaps will ALWAYS reduce quality, either by pixellating on scale up, or squashing pixels out of existence on scaling down. If i have a 200px wide actor, i'll use a 256px wide image in photoshop, but only use the 200px for my actor as planned, and have some blank space. I can crop that later in GS by changing the tile mode (for collision purposes) and it means i get 1:1 resolution on the artwork, no nasty compression or expansion.
  • guillefaceguilleface Member Posts: 1,014
    allornothing you really got me lost in the last part, anyways can someone just confirm this, my actor was 100x 32 but decide to make 128x32, if i want my game to work for iphone 4 my image for this actor needs to be 256x64? is divisible by 4, so independence resolution means my image needs to be twice the image? thats why my actor size is 128x32 for ipod and iphone but for the iphone 4 gs will use the image of 256x64 and for ipod gs will shirk the image?
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Guys your really making this way to difficult. Make your actors even numbers and your art twice the size. Thats all.

    The powers of two thing is a memory optimizing technique. It has nothing to do with RI. NOTHING!!!!!!!

    Dont even worry about it if you are not having Performance issues with your Game.

    I have only ever had one time where the powers of 2 made a difference in my apps performance and that was on a scene that had 20+ 960x640 images.
  • allornothingallornothing Member, PRO Posts: 126
    I can accept that it has nothing to do with RI, but its good practice and ignoring it will only cause problems in the long run on more complex projects. In my current project, I made the rookie error of having 40x40pixel images being used on 20+ actors on the screen. When I reduced these images to 32x32 and then scaled the actors to the original 40x40 size, I was effectively using half the memory for those images, despite an almost imperceivable difference in visual quality, and clawed back 8-10fps on performance immediately. I think anyone wishing to develop their skills in... development (!), would do well to avoid any bad habits surely?

    Just my 2c
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    allornothing said:
    I can accept that it has nothing to do with RI, but its good practice and ignoring it will only cause problems in the long run on more complex projects. In my current project, I made the rookie error of having 40x40pixel images being used on 20+ actors on the screen. When I reduced these images to 32x32 and then scaled the actors to the original 40x40 size, I was effectively using half the memory for those images, despite an almost imperceivable difference in visual quality, and clawed back 8-10fps on performance immediately. I think anyone wishing to develop their skills in... development (!), would do well to avoid any bad habits surely?

    Just my 2c

    You may have gain some performance but you now no longer have High res art on 4th gens and lower than low res art on older devices. I would be the low res devices look blurry. Have you even tested this on a low res device. Also you certainly should not be advertising retina art in you app if its not truly high res.
  • allornothingallornothing Member, PRO Posts: 126
    -edit- nevermind.

    my comments are about power of 2 more so than RI, and I think some of your comments in that last post are incorrect, and i'll leave it at that. By all means PM me if you want to chat more, but the way you are talking about resolution is very misleading, and you cant make assumptions about visual fidelity without any reference at all.
Sign In or Register to comment.