Texture size of 512*768, is that bad?

Discussion in 'Game Development (Technical)' started by Jamie W, Jun 9, 2009.

  1. Jamie W

    Original Member Indie Author

    Joined:
    Apr 16, 2006
    Messages:
    1,211
    Likes Received:
    0
    Is it important for textures (in video ram) to have heights of 1<<n?

    I realize a width of 1<<n (i.e. 256, 512, 1024 etc) is important, but is it OK to have a height of say, 768?

    I can understand the video hardware needing a width of 1<<n to allow for quick computation of texture addresses (given x and y), but can't see the importance of having the height be a 1<<n.

    I can understand a height requirement of 1<<n, should there be texture wrapping on the Y coordinate, but I'm not doing that.

    So what do you think, is it a bad idea to have texture sizes of say, 512*768px?
     
  2. Reactor

    Moderator Original Member Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    1,637
    Likes Received:
    0
    I believe textures that aren't power of two are less efficient.
     
  3. Nexic

    Indie Author

    Joined:
    Nov 5, 2004
    Messages:
    2,437
    Likes Received:
    0
    Not 100% sure on the technical side of things, but I know that pretty much everybody uses/recommends power of 2 sizes for both x and y. I'd imagine there is a good reason for doing so.
     
  4. ggambett

    Moderator Original Member Indie Author

    Joined:
    Jul 26, 2004
    Messages:
    1,982
    Likes Received:
    6
    It's probably not OK. Non-1<<n sized textures will work on some card and driver combinations, but the standards don't guarantee it, so cards and drivers don't have to make them work - if they do, good for you, but in cards which don't you'll have untextured polygons.

    Stick to 1<<n. Note that both dimensions must be 1<<n for some n, but need not be the same n - that is, you can have a rectangular texture (say 1024x512) as long as both dimensions are some power of 2.
     
  5. Gary Preston

    Original Member

    Joined:
    Aug 5, 2005
    Messages:
    239
    Likes Received:
    0
    Older graphics cards required pow 2 textures and wouldn't work correctly without. I'm not sure if that's still the case with modern graphics cards though. I'll defer that answer to the graphics programmers on here :)
     
  6. cliffski

    Moderator Original Member

    Joined:
    Jul 27, 2004
    Messages:
    3,897
    Likes Received:
    0
    don't do it. I know from experience many intel cards cant handle it.
     
  7. DavidR91

    DavidR91 New Member

    Joined:
    May 23, 2009
    Messages:
    47
    Likes Received:
    0
    I believe older Nvidia cards will also crap out on sizes like that - I'm certain the 5600FX I had from a few years ago failed to load textures at that size.

    If you're doing casual games for very low spec machines, I would be more wary of ratios than actual sizes - some much older cards (~Geforce 2 and earlier) create very bizarre 'noise' effects/load failures when loading textures outside a certain range of width/height ratios (I think the TNTs were infamous for doing this too - they create random patterns of garbage instead of loading the texture)
     
  8. Sybixsus

    Original Member

    Joined:
    Aug 2, 2004
    Messages:
    959
    Likes Received:
    0
    IIRC, even cards which can use non Power-of-two textures cannot do so in all circumstances. There are certain operations or render states which are incompatible with Non-PoT, I believe.

    The key thing here is I can't really see much advantage. If you're worried about VRam just make a texture atlas to fill up the space more efficiently. Adjusting UV coordinates will allow you to still have pixel-perfect drawing if it's for 2d.

    In short, what compelling reason do you have for using textures of Non-PoT dimensions? IMO it needs to be pretty compelling to make up for the downside.
     
  9. JGOware

    Indie Author

    Joined:
    Aug 22, 2007
    Messages:
    1,578
    Likes Received:
    0
    "So what do you think, is it a bad idea to have texture sizes of say, 512*768px?"

    Yes. Just round up to the next 256 and don't worry about it. Store fonts, small sprites, etc, in the extra space. ;)
     
  10. Jamie W

    Original Member Indie Author

    Joined:
    Apr 16, 2006
    Messages:
    1,211
    Likes Received:
    0
    Thanks everyone.

    Some pretty convincing arguments there, and I can always pad any texture up to a 'good' size, with smaller sprites and fonts etc. So, just not worth using non power of 2 texture sizes.

    But non square (as in, 512*256) is OK?

    Also, is there a minimum texture size? Like 64*64 or something?

    Just checking..

    Thanks once again for all your help. :)
     
  11. Jamie W

    Original Member Indie Author

    Joined:
    Apr 16, 2006
    Messages:
    1,211
    Likes Received:
    0
    I don't plan on having any ratio more than 2:1 (or 1:2) of Width:Height. Would that be OK do you think?
     
  12. Sybixsus

    Original Member

    Joined:
    Aug 2, 2004
    Messages:
    959
    Likes Received:
    0
    Yes, I think the Voodoo 3's were the last cards not to be able to use rectangular textures, and they went the way of the buffalo years ago. If memory serves, there is a CAPS function to return the maximum texture ratio ( x/y or y/x ) and I think the lowest on any card you might expect to come across these days is 1:8 or 8:1 so if you keep a ratio of 1:8 between width and height (either way around) then you should be fine.

    I don't know of one, but I don't personally go below 64x64.
     
  13. vjvj

    Indie Author

    Joined:
    Sep 25, 2004
    Messages:
    1,732
    Likes Received:
    0
    Non-square textures are fine, the main thing is to try and stick to powers of 2. Power of 2 textures are just faster due to the way the memory pages are laid out and how they are usually indexed (it's often not in a straightforward fashion). Non-power of 2 textures can also disable certain features on older video cards.

    No minimum texture size. You can make a 1 x 1 texture if you want, and 1 x n textures are actually quite common and have many uses. Most texture problems revolve around large textures, since they tend to cause a lot of problems (more likely to induce minification, which causes cache thrashing and texture aliasing, they take up more space, etc.).
     
  14. Sol_HSA

    Indie Author

    Joined:
    Feb 27, 2005
    Messages:
    470
    Likes Received:
    1
    NPOT-textures have worked for most cards for some time now, but the performance is often abysmal, even for relatively recent cards. In the worst case the driver drops down to software rendering.

    Yes, I know I'm only echoing what others have already said, but here's an example:

    We released a small demo a couple years back, which included a 64x64 sprite. This sprite was drawn a couple thousand times a frame if I remember correctly. An artist replaced my placeholder with a 65x65 image instead, which worked fine for him; when people with ATI cards watched the demo, the framerate crawled.
     
  15. GaiaDreamCreation

    Indie Author

    Joined:
    Jun 8, 2008
    Messages:
    440
    Likes Received:
    26
    I used DirectX and the textures were resized automatically to the closest factor of 2 (going up). For example, a texture of 512x1000 would be resized to 514x1024. I do not know for all cards, but it is true that mathematically speaking it is faster to computer with number based on 2 exp N. The memory is segmented in that way. Yes it might be a bad idea, but not so bad. Just resize your textures to compute properly and copy your original texture insider. There will be a blank and unused space, but it does not matter. If your texture is mapped to a 3D model, then you would need to readjust your texture mapping.
     
  16. PoV

    PoV
    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    2,132
    Likes Received:
    0
    Even some modern chipsets are still bound by the restriction. The PowerVR SGX (iPhone 3G S), while the OpenGL ES 2.0 spec says should be capable of supporting "Non Power of Two" textures, the spec allows them to disregard mipmap support in that condition (which the PowerVR SGX does). So despite all our "advances" in computer graphics over the years, unless you enjoy portability issues, Power of Two textures should still be used. Really, there's no reason to stop using them.
     
  17. oNyx

    Original Member

    Joined:
    Jul 26, 2004
    Messages:
    1,212
    Likes Received:
    0
    >But non square (as in, 512*256) is OK?

    Always has been.

    >Also, is there a minimum texture size? Like 64*64 or something?

    1x1.

    --

    For 3D stuff NPOT is alright if the card can handle it. 2D things look very bad though.
     
  18. Acord

    Acord New Member

    Joined:
    Jul 26, 2008
    Messages:
    1,217
    Likes Received:
    0
    Depends on the engine. Some engines will automatically chop things up and store them to save memory, and some engines will automatically add blank space until you hit a power of two. So 512x769 would become 512x1024 in the latter case, and would become 6 256x256 images in the former.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer