XNA Creators Club Online
Page 1 of 1 (7 items)
Sort Posts: Previous Next

Texture question: Can you have an "odd" sized texture or does it have to be 256, 512, etc?

Last post 4/19/2009 5:22 AM by moneras s. 6 replies.
  • 4/19/2009 12:44 AM

    Texture question: Can you have an "odd" sized texture or does it have to be 256, 512, etc?

    I'm working on a 2D game for the Xbox 360 and I've spent most of the day getting my grass texture in good working order (no seams or odd clumps to give off the repeat) only to realize that the final size of my square image is 418x418.  Will that work or does the texture size have to be a power of 2?
  • 4/19/2009 2:04 AM In reply to

    Re: Texture question: Can you have an "odd" sized texture or does it have to be 256, 512, etc?

    textures can be any size, the "power of 2"-rule does only mean that a texture that is 200pix will use the same amount of memory as a 256pix.
  • 4/19/2009 2:04 AM In reply to

    Re: Texture question: Can you have an "odd" sized texture or does it have to be 256, 512, etc?

    For a 2D game it doesn't matter.  However, assuming you would want to tile the texture, having standardized sizes makes a lot of sense.
  • 4/19/2009 3:33 AM In reply to

    Re: Texture question: Can you have an "odd" sized texture or does it have to be 256, 512, etc?

    moneras s:
    For a 2D game it doesn't matter.  However, assuming you would want to tile the texture, having standardized sizes makes a lot of sense.


    That does worry me.  The intention is to tile the texture such that it is a solid field of grass.  I don't mind if my 418x418 takes up as much memory as a 512x512, but I do need it to repeat without any gaps.  Would the extra 94 pixels be filled with empty space?
  • 4/19/2009 4:01 AM In reply to

    Re: Texture question: Can you have an "odd" sized texture or does it have to be 256, 512, etc?

    Naughty Puppy:
    moneras s:
    For a 2D game it doesn't matter.  However, assuming you would want to tile the texture, having standardized sizes makes a lot of sense.


    That does worry me.  The intention is to tile the texture such that it is a solid field of grass.  I don't mind if my 418x418 takes up as much memory as a 512x512, but I do need it to repeat without any gaps.  Would the extra 94 pixels be filled with empty space?


    You have complete control to scale the image to whatever size you want, as well as tile the image however you want.  All you would do is draw the image every 418x418 pixels, or you could scale it up to 512x512 at runtime by changing the size of the rectangle that you render it in.

    I think the key thing is to plan before you implement.  Many 2D games work on some type of tile based system.  The Starcraft level editor comes to mind.  Every tile is maybe 32x32 pixels.  A space marine is small and takes up one tile.  A bunker takes up 4 tiles total, and is 64x64 pixels, etc. The point of this system is to make sure that all the pieces fit together nicely, large and small.

    And to be clear, you could make it 50x50 pixels per tile, or whatever you want, and images can have non-square dimensions.
  • 4/19/2009 4:29 AM In reply to

    Re: Texture question: Can you have an "odd" sized texture or does it have to be 256, 512, etc?

    That makes me feel quite a bit better.  Most of my experience is in 3D for video (and even then, mostly animation and not texturing/modeling) and in most of those cases, it's simply a matter of doing whatever it takes to look good.  The texture was scaled down to 418x418 from a larger image in order to scale correctly with the player character so going to 512x512 would most likely mean redoing all of my tile work from the original image.

    The second part of your reply is interesting though, as my mentality had been to simply create elements and layer them on top of each other.  The theory so far is that my player character and enemies need to follow very specific size relationships but as far as the background for the area the player can walk on goes, anything that looks good flies as it's just decoration.  When I get to blocking elements, I'll probably start thinking about size more carefully again (buildings, walls, etc).  Am I overlooking something?
  • 4/19/2009 5:22 AM In reply to

    Re: Texture question: Can you have an "odd" sized texture or does it have to be 256, 512, etc?

    Naughty Puppy:
    Am I overlooking something?


    Who knows.  A lot of this is trial and error anyways; after a while you will figure out a way of doing things that makes sense for your game.
Page 1 of 1 (7 items) Previous Next