Explain Power of 2 Please :)

DreamWorldDreamWorld Member Posts: 43
edited November -1 in Working with GS (Mac)
Can you please explain me what is the power of 2 and how it works and what is the affect to the engine or the game.

Thanks,
DW

Comments

  • butterbeanbutterbean Member Posts: 4,315
    You should always make all your images to the power of 2, or as close to that as possible.

    So they should be 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024

    This helps optimize memory.

    So if you have an image that is 68X68, round it down to the nearest power of 2 to preserve memory.

    hope this helps!
  • DreamWorldDreamWorld Member Posts: 43
    So I have a tank image which is 220x354 what resolution should it be?
  • DhondonDhondon Member Posts: 717
    256x512
  • butterbeanbutterbean Member Posts: 4,315
    @DreamWorld: Use it as a rule of thumb, and try to get your images as close as possible to the power of 2, but so long as you've optimized your game in other areas, you don't always have to follow it.
  • synthesissynthesis Member Posts: 1,693
    @Dreamworld.

    Your image that is 220x354 will run in the game memory as if it were 256x512. You don't have to use a 256x512...but your game is using that much memory regardless. Its a matter of getting the most "bang for your buck" rather than a rule. So if your image were 258x258...it would actually use 4 times as much memory because it exceeds 256. So it would be using memory for a 512x512 image (4 - 256px tiles). In this case...it would be wise to cut the 2 pixels off of the size and take back some of that memory.

    An example of a hard fast rule would be to always size your images as an even number. This way you won't have the image land on a half pixel (there will always be an equal amount of image on both sides of center). Landing on a half pixel in the layout can cause the image to blur.
  • patm1982patm1982 Member Posts: 50
    Does this apply to game objects too? So like if your image is 64x64 but then on the scene it is enlarged to 70x70. Will that use 128x128 worth of memory still?

    Or what about the opposite, if the image resolution is not power of 2, but in the scene it's scaled so that it is.
  • bluebyu25bluebyu25 Member Posts: 500
    By the way, if I am not mistaken you apply this rule IN YOUR IMAGE EDITING SOFTWARE.

    i.e. make your image 256 x 256 in photoshop.....then you can resize in GS without sacrificing memory.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    DreamWorld said:
    So I have a tank image which is 220x354 what resolution should it be?

    That will use the same memory as an image 256x512 you do not have to increase it to that. The only way to save any memory will be to reduce the image to 128x256 which likely isint worth it since you would be drastically reducing your actors size.
    patm1982 said:
    Does this apply to game objects too? So like if your image is 64x64 but then on the scene it is enlarged to 70x70. Will that use 128x128 worth of memory still?

    Or what about the opposite, if the image resolution is not power of 2, but in the scene it's scaled so that it is.

    No that will use the memory of a 64x64 image however your image will be stretched and probably blurred slightly.

    Dont worry about the power of 2 thing two much. Its just something you can fall back on to help improve performance if you end with memory issues.

    You should however have all even sized actors and then double sized art work for those actors if you are going to use resolution independence.
  • LumpAppsLumpApps Member Posts: 2,881
    As a follow up on this question.
    Does GS take need more memory if I have for example a PNG with 320X64px with a lot of transparency in it and an actual image of 64x64px then when I use a PNG that is just 64x64. In other words, does transparency use memory?
    I ask this because it is sometimes easier to line up images.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    yes transparency uses memory. if you place an image it will use the memory allotted for any color image that matches the full dimensions of the image file.
  • LumpAppsLumpApps Member Posts: 2,881
    Thanks!
Sign In or Register to comment.