Trying to fully understand Unity's Sprite Editor

,

Hello new to GemeDev.tv and I have a noob question about Unity 2.5D Turn-Based RPG course. So the png image from the resources was 128 * 128 the instructor set pixels per unit = 16 in Sprite mode, and later it sliced the image Grid of Cell Size using 32 * 32 for pixel size, why those numbers used? Why, for example didn’t he set pixel per unit to 32 and then slide it 32 * 32 pixel size i think it has the same result Also, the reference image must be exactly 128 * 128 or can we achieve the same result with other resolution aswel?

It’s not as noob of a question as one may think. In a normal 2D game, I would very likely do exactly as you suggest, set the PPU to 32 and cut into 32x32 segments so that our characters take up exactly one unit. In 2D coordinates, this makes sense.

In our case, however, we’re thinking in 3d terms. Consider our starting point, the Capsule, which we’re using for our shadows, along with it’s Capsule Collider. Both of these are actually 2 units tall. Since 2.5D graphics are essentially putting 2d billboarded objects into 3d space (the terrain, for example, is 3d), it’s simply going to look better if it’s treated as 2 units instead of 1.

That’s where the math comes in… For the John image, one unit = 16px, so a 32x32 frame actually consists of 4 (2x2) units. Now when you overlay this with the Capsule Collider and shadow, things line up like they are supposed to.

As a rule of thumb, the most efficient resolutions for any texture are powers of 2. This is because the highly optimized video cards on our computers (even the junky built in graphics if you don’t have a GTX or Radeon) are built to think in powers of 2. You can have textures of any resolution, but if they’re not a power of 2, Unity is going to have to pad that texture to get it to a power of 2 to upload it to the video card and that chews up CPU and transfer time.

This doesn’t mean that the texture has to be square, however, it could also be 128x256 for example, as long as both sides are powers of 2…

For handy reference, these are the powers of 2 (effectively doubling as we go)

2^1 = 2 
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
2^6 = 64
2^7 = 128
2^8 =  256
2^9 = 512
2^10 = 1028
2^11 = 2048
2^12 = 4096
2^13 = 8192

So John is a 128x128 sprite sheet with 16 cells of 32x32 each. Each cell represents 2x2 Unity units. Now suppose John’s spritesheet was drawn at a higher resolution, like 512x512, with 16 cells of 128x128 each. We would then set the cell size to 64. You would wind up with a clearer character, but with the blocky images being more in vogue these days, our current John sprite fits in quite well in the retro 2.5D JRPG model.

1 Like

Privacy & Terms