UI coordinate system

(Joonatan Saarhelo) #1

While discussing https://github.com/amethyst/amethyst/pull/2118 it came up that the UI coordinate system is different from the screen coordinate system because someone was annoyed that the UI coordinates were not in sync with world coordinates in a 2d game.

Currently if you want to position some UI element on top of some world thing in 3d, you have to invert the y-axis of the output of world_to_screen. I find that very ugly.

If the UI coordinates were reverted, 2d would work just fine using world_to_screen.

But there is a solution that pleases all parties! The default orthographic camera currently mirrors y-axis. If we remove that mirroring, x and y point in the same direction in screen coordinates and the default 2d camera.

(Azriel Hoh) #2

Heya, adding my opinion: I have a slight preference to having 2d world coordinates, UI coordinates, and screen coordinates all being 0, 0 on the top left, mainly because I work in pixel land in all those systems. But can also imagine 2d world coordinates starting from the bottom left for different kinds of games.

That said, I’m happy to go with what works for the majority – simply would like us to settle on something :v: (changing back and forth is also a cost).

(Marco Alka) #3

Being a webdev by day, I can not imagine a UI (or 2D) system which has its origin in the bottom left corner. What would be the use for that? Is there any relevant example, or any major reason for doing that? I could imagine 2D games using it because they don’t really have all the document-baggage, hence don’t care, however if that’s all, then I’d love to see a unified 2D origin in the upper left corner :slight_smile:

(Joonatan Saarhelo) #4

The OpenGL coordinate has a y-axis that goes up. That is also typical in math.

I don’t really care about the specific choice but it would be nice if Amethyst was consistent. x going right and y going down is very common for screen coordinates, so I think it is a good choice.

1 Like