Repository: godot
Issue: Odd-sized sprites do not rotate correctly
Labels: discussion,topic:rendering,topic:2d

### Godot version

v3.4.4.stable.official [419e713a2]

### System information

Windows 10 GLES2

### Issue description

Apologies for writing another pixel rotation question, I hope this is relevant. I know from the discussion in https://github.com/godotengine/godot/issues/57221 that there used to be some rotation changes recently that had to be reverted, so there might not be a lot of focus on pushing these issues, but I would still like to discuss whether this is worth addressing.

Currently, pixel perfect 2D games have problems with rotating odd-sized sprites.

To my understanding, pixel perfect games in Godot still live in float space, only that the pixels are forced to the pixel grid when they are drawn. 

Mathematically, it is a matter of definition whether a pixel's origin in the float grid should be aligned to the pixel's center or the top left corner. Currently in Godot, as far as I understand, pixels are aligned at the top left corner.

![sprite_0](https://user-images.githubusercontent.com/16470072/162586902-f1e9ce5f-2cb7-4fab-b349-dd411eedb56f.png)

This definition plays a role once we try to rotate a sprite. For even-sized sprites, the rotation behaves correctly if the origin is the top-left. For odd sprites the rotation is correct if the origin is centered.

This is what happens when a sprite is rotated in 90° increments if the pixel origin does not fit. 

* top: centered alignment
* bottom: edge alignment:

![sprite_02](https://user-images.githubusercontent.com/16470072/162587805-49b410e4-90a1-4865-819f-ad52bf70a0df.gif)

Currently this means that an artist is recommended to only draw even sprite sizes in Godot if any type of precise rotation is needed. For me, this became apparent when I made my Ludum Dare 50 Game [Eternal Crisis](https://ldjam.com/events/ludum-dare/50/endless-crisis). In the game, spaceship is made out of parts that connect at specific points, around which the parts rotate. If I had made the connectors odd-sized (which they were in the initial version), then I would have gotten rotation artifacts similar to the ones in the gif above.

A solution could be to add a sprite setting to define the pixel grid origin of each sprite to be either centered or edge-aligned. This has to be done for x and y separately, since we can have pixels that are even in x and odd in y. This setting would not mean that there is a visible half-pixel offset between the centered and edge-aligned sprites, because every pixel would still obey the grid. But it would mean that certain operations that work in float coordinates before rounding to match the grid would be more precise. 

An alternative to a manual setting would be to consider this issue automatically depending on the sprite size, but this would be an incomplete solution that would not deal properly with offset rotation and could cause problems if the sprites have transparent backgrounds that e.g. make them appear even although the actual pixels are odd in size.

This is potentially related to https://github.com/godotengine/godot/issues/7015, which asks for a half-pixel offset in case the sprite is set to be centered. I believe that the solution suggested here would address that issue as well.

### Steps to reproduce

* Set Godot to pixel-perfect mode (pixel snap)
* Add a square, odd sized sprite
* Rotate it by increments of 90°
* note how it does not fit in its original footprint as it rotates (like the gifs above)

### Minimal reproduction project

[game.zip](https://github.com/godotengine/godot/files/8457667/game.zip)