0

Its a common practice to use Atlases / Spritesheets to reduce connection overheads for web-based games and also, I have read about using sprites with a power of 2, which is useful both for memory as well as mipmapping (not sure if this was for web-based games).

However, does the same principle (of mipmapping) applies to Atlases? Basically, Should my Atlas be of size which is a power of 2 or should it (power of 2 rule) be applicable for the individual images it contain?

Ani
  • 1,655
  • 3
  • 23
  • 37

1 Answers1

0

The general answer is that it depends on the engine you are using. Some engines require power-of-two textures for the reasons you stated in your question. And since an atlas is really nothing but a texture, it holds to this rule.

Again, depending on the engine, the various sprites in your atlas may need to also be power-of-two (this is the so-called "grid system" for spritesheets). But I have worked with engines that don't care, as long as the atlas itself is power-of-two.

Web-Based Games

For web-based games in particular, just from personal experience I have never had to worry about power-of-two. I just made my images whatever size they needed to be. This makes sense because:

  1. It's the web :)
  2. Padding images to powers of two increases file size and therefore bandwidth usage (though not by much)

I think (could be wrong though) most JavaScript engines don't care about power-of-two.

William Gaul
  • 3,181
  • 2
  • 15
  • 21
  • Thnx, but my questions was to make sure that there is no additional advantage in using power of 2 for JavaScript. Can you refer to some source I could readup to confirm? – Ani Oct 01 '13 at 15:21
  • Sorry, I misinterpreted the question...I thought you were just asking whether they needed to be power of 2. As such I can't refer you to any sources about additional advantages. Although, I *do* know that if you plan on using WebGL then you **must** use power of 2. See here: http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences#Non-Power_of_Two_Texture_Support – William Gaul Oct 03 '13 at 00:30
  • Thnx for the link! I tried using NPOT atlas sizes for canvas and they are working fine after testing on a few browsers and having friends do on their machines. So I suppose the answer is: Not required for Canvas, but better to have if using WebGL (given the support is very restricted at the moment) – Ani Oct 03 '13 at 10:30