Results 1 to 12 of 12

Thread: Image size

  1. #1

    Question Image size

    Hey all,
    So for a 2d game is it ok to us any image size you want. I ask because I am making my basic soldier about 52x52 pixels, but would it be more efficient to stick with powers of 2, 64x64 for example. I am generally a 3d artist and for that powers of 2 are more efficient for the real time aspect. Thanks for your time.

    Cheers,
    Tyan
    Last edited by Tyan; 08-29-2012 at 06:27 PM.

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    Both 2D and 3D is drawn the same way today (2D is drawn like billboards in 3D by the GPU), so the rules you know from 3D also apply to 2D. Using power-of-two textures is faster.

    However the overhead is generally less important for 2D because the total face count for the scene is very low in comparison (each image box is drawn as two triangles) and any overdraw is easier controlled. So I'd say in general you shouldn't care if your soldier is power-of-two or not.

    The best way to improve performance in 2D is to pack all your images into one texture. There is a texture packer tool included with ClanLib that can do this, if I remember correctly. The basic idea is to create a 256x256 texture with all your images, which reduces texture changes and also gives you a power-of-two texture in the end. It is mainly the avoidance of texture changes that improves the performance. Bit like using only a few materials in a 3D mesh improves performance there.

  3. #3
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    Yes, ClanLib provides a texture packer tool that handles this.

    What it does is that it reads a resources.xml file, finds all images in it, and packs them into a specific texture size which you choose. Normally you'd start with small texture size, and increase the size if the images doesn't fit. Going up to 2048x2048 isn't a problem - that texture size is very safe these days. When its done packing, it saves out the generated texture(s) AND saves a modified resource file for you with replaced references, so the game won't need to be changed at all.

    So its easy to start out without using this tool, and just bake the final texture when you approach a release. Just make sure you use ClanLib resource files, though.


  4. #4

    Default

    Thanks for the replies, but were is this image packer? I went through my install directory and cant find it.

    Thanks,
    Tyan

  5. #5
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    ClanLib-2.3.6/Utilities/TexturePacker

  6. #6

    Default

    I wish it was that easy but that directory does not exist. Do I need to compile the source code to get that or a separate download? I'm sorry I seem like I don't have a clue as to what I am doing but I really am having a problem finding this.

  7. #7

  8. #8

    Default

    In case a beginner (more beginner than me) read this thread and decide to keep non-power of 2 images sizes because performances is usually not an issue in 2D, you should still keep in mind that you should not use odd sizes, do use only even sizes. For example 52x52 pixels are fine, but 53x53 pixels are not. If your computer displays odd sizes correctly, a lot of other computer won't.

  9. #9
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    For example 52x52 pixels are fine, but 53x53 pixels are not. If your computer displays odd sizes correctly, a lot of other computer won't.
    Where did you read this? It sounds more like a bug in an SDK, than the driver.

    Non power of 2 textures have been supported since OpenGL 2.0 was released in 2004

  10. #10

    Default

    Quote Originally Posted by rombust View Post
    Where did you read this? It sounds more like a bug in an SDK, than the driver.

    Non power of 2 textures have been supported since OpenGL 2.0 was released in 2004
    You have not understood my message.

    I'm not talking about "non power of 2" sizes, but "ODD" sizes.

    Please keep in mind that there are a lot of integers that are even but not powers of 2.


    http://en.wiktionary.org/wiki/odd:

    9. (not comparable) Not divisible by two.

    http://en.wiktionary.org/wiki/even:

    4. (not comparable, of an integer) Divisible by two.

  11. #11
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    Have you experienced that ClanLib has problems with odd sized images? That sounds very strange.

    The only situation I can think of where this could trigger a bug is if there is some kind of word or dword alignment requirement on upload is not being followed and odd sized images then is missing some padding bytes.

  12. #12
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Heh, sorry for confusing you

    "Where did you read this? It sounds more like a bug in an SDK, than the driver."
    is relating to "For example 52x52 pixels are fine, but 53x53 pixels are not. If your computer displays odd sizes correctly, a lot of other computer won't."
    i.e. The is no technical difference between 52x52 pixels and 53x53 pixels, therefore the bug is in the source SDK or the driver.

    And...

    "Non power of 2 textures have been supported since OpenGL 2.0 was released in 2004"
    is relating to "decide to keep non-power of 2 images sizes because performances is usually not an issue in 2D"
    i.e. I mean performance should be identical on modern gpu's

    5 years ago, things may have been different.

    I could be wrong of course

Similar Threads

  1. Rendering to textures that has special size
    By Ferrum in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 07-10-2011, 07:23 AM
  2. Size of CL_String
    By xenus in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 10-10-2009, 06:15 PM
  3. changing the size of CL_Font_Sprite
    By xrubio in forum Official ClanLib SDK Forums
    Replies: 8
    Last Post: 07-27-2009, 09:49 AM
  4. default window size...
    By harrio in forum Novashell Game Creation System
    Replies: 6
    Last Post: 02-18-2008, 05:38 PM
  5. Rendering into my custom image and then drawing this image to the display
    By ValkaVALES in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 07-03-2007, 09:53 AM

Bookmarks

Bookmarks

Posting Permissions

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