# What kind of projection is used here?

Tibia is a 2d game, but it's sprites are drawn using certain kind of orthographic projection that is not the same I'm used to:

I'm trying to figure out what projection is used here. I've guessed the following:

``````project(x,y,z) = (x-z/sqrt(2), y-z/sqrt(2))
``````

It produces a circle very similar to that wheel, and alright cubes, but the spheres are not projected as perfect circles like the globe and the crystal ball on the picture above.

So which is the actual projection that game is using?

-

You guessed properly. The orthographic projection you came up with is the one used for most of the objects. You can tell because parallel lines in the X, Y or Z directions all become parallel lines, indicating that there is no perspective projection. Also, horizontal lines remain horizontal, meaning that X' does not depend on Y. Similarly, Y' does not depend on X. You empirically found the remaining values of the projection matrix.

As for the spheres, it's probably an artist's decision to render them as spheres instead of ellipsoids because they would otherwise look weird. The waterwheel aspect ratio is much more correct in that sense.

-
Thanks, but how do you know? Also, any clue on the projection used for the globe? – Dokkat Dec 23 '12 at 14:42
Oh, I see. All good, though I'm still particularly curious as to why z/sqrt(2) worked so well. – Dokkat Dec 23 '12 at 14:58
@Dokkat `sqrt(2)` is not a coincidence and was probably chosen because it lets object boundaries fall on grid boundaries. Elevating an object one unit up in the 3D world will move it one grid cell left and one grid cell up in 2D. – sam hocevar Dec 23 '12 at 15:02
@SamHocevar Do the maths again, `sqrt(2)` makes a unit in either axial direction have the same length on screen, but it doesn't fit any exact pixel boundaries. If you look at the rendered cube in the question this should be fairly obvious. – aaaaaaaaaaaa Dec 24 '12 at 14:09

I'd say that is mixed projection, indeed a lot of the items seem to follow the formula you describe, but with pre-rendered sprites one is not bound to follow one specific formula. I guess the creators simply thought that a non-round sphere looked stupid. Lots of 2D games is made with some mixed projection where stuff that looks stupid in the base projection is rendered in a different fashion.

Edit:
Actually, looking a bit further it seems that the projection varies from item to item, if you assume that the box to the right is as tall as it is wide, then it is around `(x-1/3*z, y-1/3*z)`, but the water wheel and the house seems to be close to your suggestion.

-
Thanks, but, how do you know? Also, any clue on the projection used for the globe? (same comment as above) – Dokkat Dec 23 '12 at 14:42