AuthorTopic: Sprite tile sizes, what should I know?  (Read 4499 times)

Offline Favorlock

  • 0001
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile

Sprite tile sizes, what should I know?

on: March 06, 2016, 03:28:55 am
Hello folks,

I've started working on a new project, but I'm pretty much just getting started with developing my own games from scratch. I've delved around in the modding community of some games for quite a while, but I am finally taking that first step to making something I can call my own. Now, onto the question at hand.

At this time I am currently working on design specifications and need to select a standard set of tile sizes. I was talking with my friend (whom plans to help with pixel art) about the tile sizes for the assets he will be making for me. He and I have a fundamentally different way of thinking about working with graphics I suppose, but basically he was suggesting that it's common place for sprites to be centered and that tiles would need to have dimensions that are odd in length such that there would be a single center pixel for centering, however, from what I've seen in a short search across tutorials people tend to use tile sprites with dimensions of 32 x 32 or some other dimensions of even length.

Now, I'd like some recommendations as to what direction I should take. Would it be best to use my friends logic as the basis for selecting sprite dimensions or should I use tile sprites with dimensions even in length and center based off a point?

Thanks,
Favorlock

Offline Ai

  • 0100
  • ***
  • Posts: 1057
  • Karma: +2/-0
  • finti
    • http://pixeljoint.com/pixels/profile.asp?id=1996
    • finticemo
    • View Profile

Re: Sprite tile sizes, what should I know?

Reply #1 on: March 06, 2016, 03:44:38 am
Hello folks,
Quote
He and I have a fundamentally different way of thinking about working with graphics I suppose, but basically he was suggesting that it's common place for sprites to be centered and that tiles would need to have dimensions that are odd in length such that there would be a single center pixel for centering,
This logic is wrong. In practice, hitting exact centre should not matter, as your tiles should disguise their exact borders in any case.

Typically, tile sizes are chosen based on speed -- powers of two like 16x16, 32x32.. Rarely, the width will be different from the height -- eg 32x16. Using a tile size that is NOT a power of two is extremely rare IME.
If you insist on being pessimistic about your own abilities, consider also being pessimistic about the accuracy of that pessimistic judgement.

Offline lachrymose

  • 0010
  • *
  • Posts: 345
  • Karma: +0/-0
    • View Profile

Re: Sprite tile sizes, what should I know?

Reply #2 on: March 06, 2016, 03:57:36 am
I would think centering would be much difficult using the method your friend described.
It is not a coincident that your typical screen resolutions and sprites are powers of two and multiples of 8.

Offline Favorlock

  • 0001
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile

Re: Sprite tile sizes, what should I know?

Reply #3 on: March 06, 2016, 04:01:45 am
Thank you for the feedback Ai and lachrymose! I agree with you. I was iffy on his logic behind his reasoning and I'm glad that I came here to ask. I will relay your feedback to him.

Offline Glak

  • 0010
  • *
  • Posts: 114
  • Karma: +0/-0
    • View Profile

Re: Sprite tile sizes, what should I know?

Reply #4 on: March 06, 2016, 05:35:54 pm
There is absolutely no technical reason to restrict yourself to powers of 2 unless you are using ancient hardware.  Odd dimensions, even dimensions, etc.... all work just as well.  I think that his argument about centering is good for handling collision with round sprites (such as bullets/fireballs), so if the programmer wants to go with odd sprites I don't see why not.  If the programmer doesn't care, then let the artist decide which dimensions to use.

Offline 0xDB

  • 0011
  • **
  • Posts: 873
  • Karma: +0/-0
  • Dennis inter-is.
    • dennisbusch_de
    • http://pixeljoint.com/p/1287.htm
    • 0xdb
    • View Profile
    • 0xDB

Re: Sprite tile sizes, what should I know?

Reply #5 on: March 06, 2016, 05:56:51 pm
It does not matter much either way. The underlying collision/movement model should work with floating point geometry/math for higher accuracy and be mostly independent from visuals and whole pixels. The vertices of the collision polygons or any 2D point like a "center" pixel could be expressed as values on two axes, each going from 0.0 to <1.0 to be interpreted as a point relative to the upper left corner of the sprites dimensions. With that, you can define the center accurately in any case, even if it does not happen to align with the center of an actual pixel.

Also, "odd + odd = even", so even if an odd tile side length may give you the possibility to place a whole pixel at the center instead of the center being between pixels (as it is the case with even side lengths), as soon as you are drawing an object which needs 2 odd-sized tiles side by side in size, you are back to not having a center pixel column along the horizontal span because the center falls between the two odd tiles then.

Offline Ai

  • 0100
  • ***
  • Posts: 1057
  • Karma: +2/-0
  • finti
    • http://pixeljoint.com/pixels/profile.asp?id=1996
    • finticemo
    • View Profile

Re: Sprite tile sizes, what should I know?

Reply #6 on: March 07, 2016, 01:49:53 am
It does not matter much either way. The underlying collision/movement model should work with floating point geometry/math for higher accuracy and be mostly independent from visuals and whole pixels.
True, but you have to be careful here. Some OpenGL games have occasional subpixel gaps between tiles, and AFAICS this is because the texture mapping is fractionally off.

Good point about the centring problem.

Quote
There is absolutely no technical reason to restrict yourself to powers of 2 unless you are using ancient hardware.
I don't know if it's a 'technical' reason, more of a 'design' reason, but screen resolutions, and texture resolutions, tend to be divisible by 8 (and also often by 16, 32, and 64). This means that choosing one of those values can guarantee a whole number of tiles fits onscreen. Picking a non-power-of-two makes it very difficult to make such a guarantee.  According to the type of gameplay or if you are pushed for texture space, that may matter.

I would agree that picking powers of two for purely 'it goes fast' reasons is specious. Picking a 'unified global sprite size' (as opposed to tile size) in general is specious. Sprites tend to be of all sorts of sizes which is fine, you don't need to make them match tile sizes exactly; But the tiles are sort of like the 'grid' that you are working with to design the entire game, so it -does- warrant careful consideration.
Involving both artist and programmer discussing -actual situations that are planned to come up in game-, not hypothetical 'circles work better' or 'X game uses NxN tiles'. I guess that was a problem I had with the OP.. all design decisions need to have a concrete basis or things get silly.
If you insist on being pessimistic about your own abilities, consider also being pessimistic about the accuracy of that pessimistic judgement.

Offline Gil

  • 0100
  • ***
  • Posts: 1543
  • Karma: +1/-0
  • Too square to be hip
    • http://pixeljoint.com/p/475.htm
    • View Profile
    • My Portfolio

Re: Sprite tile sizes, what should I know?

Reply #7 on: March 07, 2016, 07:37:45 am
There is absolutely no technical reason to restrict yourself to powers of 2 unless you are using ancient hardware.
This is patently untrue btw. OpenGL ES and WebGL allow ONLY power of 2. If you ever plan to port your game to mobile (which is probably the largest game market right now), you HAVE to use power of 2.


There is extensions and states to allow for them, but you have to give up certain features to do it.

Offline questseeker

  • 0010
  • *
  • Posts: 112
  • Karma: +0/-0
    • View Profile

Re: Sprite tile sizes, what should I know?

Reply #8 on: March 07, 2016, 08:15:37 am
Some OpenGL games have occasional subpixel gaps between tiles, and AFAICS this is because the texture mapping is fractionally off.
If there is a subpixel gap, there is a bug, and it could happen with any tile size. Correct drawing is possible, and expecting it is a minimal test of programmer competence.