User Tag List

Page 1 of 5 1 2 3 ... LastLast
Results 1 to 10 of 41

Thread: how to work out if an image is to the power of 2

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Simflare's Avatar
    Join Date
    Oct 2013
    Location
    Australia
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to work out if an image is to the power of 2

    This might seem obvious to some of you, but how do I know if an image is to the power of 2? What's the easiest method of working out the maths? I know that 2^2 is 2x2 which is 4, but I don't know how to work it out backwards for my images...

    Would I divide the number in question by 4, and if the answer is even (with no floating decimals) would that be then to the power of 2? I need to work this out for all of my images so that I can make the game run smoother and scale correctly, and I'm not big on maths.

    example: 1080 x 1920

    1920 / 4 = 480
    1080 / 4 = 270

    Therefore 1080 x 1920 is to the power of 2? Is that correct?

    Thanks in advance
    Simflare

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Faithtoken's Avatar
    Join Date
    Jan 2014
    Location
    Sveg, Harjedalen, Sweden
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not exactly, 24 is dividable by 4, but is not in the power of two.
    I guess it's just something you learn from working with computers for some time.

    2,4,8,16,32,64,128,256,512,1024,2048,4096 and so on.

    As you can see 1080 and 1920 is not to the power of 2 eather, unless I have misunderstood EVERYTHING. :P

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Simflare's Avatar
    Join Date
    Oct 2013
    Location
    Australia
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks to both of you, that is extremely helpful information. I'm at a bit of a loss about how to make that work for my games images though, now that I've already designed the entire game. For example, my ground tiles are 28x34, and floating tiles are 28 x 17, so that's not to the power of 2, but they are evenly divisible by 4. If I put that in fusion 2.5 and auto scaled it 4x, would it distort?

    Essentially I'm designing a game for Android at 480 x 270 and setting it to auto scale up with 'fit outside'. I'm not actually totally clear on why images need to be to the power of 2, perhaps you could explain that to me also?

    Recap:

    Would a ground tile image that's 28x34 distort if it auto scaled for an Android game?
    Why do images need to be to the power of 2?

    Thanks!

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,272
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Images doesn't need to be a power of 2. The only reason you would like them to be is to use as less memory as possible. For Direct3D, iOS and Android, Fusion will create an imagebox for each of your images. This imagebox will be a power of 2. This I think has to do with how the graphicscard works. The closer the image width or height is to a power of 2, the more of the imagebox will be filled by the actual image.

    Take your image that is 28x34 for instance. For this Fusion will make an imagebox that is 32 * 64, as 32 is the closest power of 2 that the width will fit inside, and 64 is the closest power of 2 that the height will fit inside. You see that the width is fine, but the height is just 2 pixels high to be a power of 2. Your image is 28 * 34 = 952 pixels, but Fusion will generate an image that is 32 * 64 = 2048 pixels. By redusing the height from 34 to 32 you will half the memory usage of this image as it will now only be 32 * 32 = 1024 pixels.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Simflare's Avatar
    Join Date
    Oct 2013
    Location
    Australia
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is incredibly helpful. Thank you popcorn!

  6. #6
    Clickteam Clickteam
    Danny's Avatar
    Join Date
    Aug 2007
    Location
    United Kingdom
    Posts
    2,904
    Mentioned
    12 Post(s)
    Tagged
    2 Thread(s)
    Optimising for NPOT (Power of Two) is essential across the exporters or any runtime that is Hardware Accelerated. The slightest pixel above NPOT will force the GPU to allocate a shedload of extra blocks to accommodate the next size up. There are plenty of threads on the forum if you search:

    http://community.clickteam.com/threads/82322-Power-of-2-graphics-Should-I-be-concerned

    Also to boot, anything below 8x8 will still be rendered at a minimum of 8x8. So, 2x2,2x4,4x2,4x4 etc. will be allocated as 8x8.

    There used to be an NPOT restriction on older GPU's to enable the pipeline to render faster using the "Power of Two", however, more modern graphics cards don't tend to deal with that anymore with the increase in speed and memory.

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Simflare's Avatar
    Join Date
    Oct 2013
    Location
    Australia
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that extra clarification Danny. That will be useful to know about 8x8 being the minimum. I will make sure to optimize my graphics for NPOT. I'm glad I found all of this out now and not further down the track with my project. I'll read that other post you linked.

    Thanks for your help!

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,525
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'd say for exe HWA builds it's really a non-issue though. Unless you are running the game on a 10 year old machine.

    It's definitely important for mobile games though.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Simflare's Avatar
    Join Date
    Oct 2013
    Location
    Australia
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay cheers. What is HWA? I just looked up and it says it means Hardware Acceleration? What exactly does that mean?

    Also, this power of 2 thing for optimisation: strictly speaking, although you might not notice it on a PC, do PC's still work to the power of 2 rule? So if I did an image that wasn't to the power of 2, would a PC, or any gaming console for that matter, still apply an invisible box that is to the power of 2?

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,272
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    In Fusion HWA is the nickname for hardware accelerated runtime on PC. That is the default Windows Display Option in Fusion 2.5. You can select Standard Display Mode from the Runtime Options tab in your app's properties if you don't want to use HWA. Doing this I don't think the Power of 2 is any longer a matter, as graphics are drawn in an entirely different way.
    Earlier HWA was its own product, but was then merged into MMF2 and is now an integrated part of Fusion 2.5. HWA is the recommended Display Option, however in some cases you might like to go for standard, for instance if you're making a retro game with old school graphics and uses no special effects at all. It is a known fact that large scrolling levels may in fact be faster using the standard Display Option.

Page 1 of 5 1 2 3 ... LastLast

Similar Threads

  1. To the power of?
    By ChrisBurrows in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 29th April 2012, 01:29 PM
  2. use power of two size of image
    By ASD in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 26th March 2012, 10:55 AM
  3. Effect image loading doesn't work?
    By brawltaunts22 in forum Hardware Accelerated Runtime
    Replies: 9
    Last Post: 8th March 2012, 01:34 PM
  4. Power/score bar
    By MdNelson in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 7th February 2012, 01:58 AM
  5. How do I do something to another power?
    By Karl in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 8th November 2009, 09:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •