Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autotiling does not work in combination with half offsets. #17065

Closed
michalove opened this issue Feb 26, 2018 · 7 comments
Closed

Autotiling does not work in combination with half offsets. #17065

michalove opened this issue Feb 26, 2018 · 7 comments

Comments

@michalove
Copy link

Godot version:
3.0

Issue description:
Autotiling determines the tile to be drawn by looking at the neighbor cells. These are defined by having an x- or y-index that differs by at most 1. With an activated half-offset, this neighborhood-logic breaks.

What is the upper-right neighbor in a regular grid, can become two different things in a half-offset grid: Either a cell that does not touch the original cell anymore, or a cell that shares half an edge with the cell.
This are diagonal neighbors on the regular grid:
regular_grid
And here are two pairs of diagonal neighbors on the half offset grid
half_offset_grid
That means the concept of a neighbor depends on what cell you are looking at.
Therefore it does not make sense to look at the neighboring cells to determine the tile to draw.

I have a suggestion for fixing that. Maybe you find it helpful:
I suggest the following change in the half-offset functionality: Instead of making the cells go zig-zag, when turning on half offset, make them go skewed (Each row is shifted by one half cell more than the previous one, instead of going back and forth). With that arrangement, autotiling would work for half offset grid, without any other changes.

@SpechtMagnus
Copy link
Contributor

SpechtMagnus commented Mar 31, 2019

I like your suggestion but I think it would mess with the quadrants used for tilemap optimisation. Another possibility would be to use the central bit of the autotile bitmask to determine whether the tile is on a odd or even row. What do you think about that?
For obvious reasons this is only a solution using the wildcard functionallity I just introduced. #27565

@SpechtMagnus
Copy link
Contributor

@MarianoGnu What would you suggest to solve this problem. I could implement it but I would really like to hear a second opinion on this.

@michalove
Copy link
Author

Here is an opinion from me, a random guy from the internet:
Yes, the suggestion with the central bit would work. It would be a solution that requires only a minimum of changes in the code.
From a user perspective, however, this solution does not seem optimal to me. The central-bit solution would again lead to redundancies in the bitmasks (for each tile-configuration, the user has to input two bitmasks, one for even and one for odd rows/columns). Furthermore, this solution is quiet unintuitive (why should autotiling lead to different results depending on the absolute position of the tile? For the user and for the tiling-logic, the odd and even columns are irrelevant), so it would required proper documentation.

A very intuitive solution would be to add two more types of bitmasks (besides the 2x2 and 3x3 one), namely for the two possible half offset grids. These would consist of 7 bits (center bit plus 6 neighbor bits), three in the middle, two on the left and two on the right (of top and bottom for the other half offset mode). Here is how I imagine this to look like:
bitmask

To sum up, I suggest: Add two new types of bitmasks (vertical half offset and horizontal half offset), Then adapt the tilemap code, so the bitmask is assigned correctly (when the user turns on one of the half offsets, the the bitmask computation needs to adapt).

I believe, this is the way, the user thinks. Fiddling around with the center bit unnecessary work for the user and can easily be done automatically (once it is implemented). Of course, I know, this solution is more difficult to implement. I hope my ideas are helpful for your discussion.

@SpechtMagnus
Copy link
Contributor

I actually like this idea quite a lot as it would probably be the most intuitive way to implement this without breaking backwards campatibility. I think I could implement this very quickly but I would really like to here the opinion of someone who knows a little bit more about the plans for this engine as I'm just a developer.
MarianoGnu, @akien-mga or @reduz possibly

@KoBeWi
Copy link
Member

KoBeWi commented Aug 3, 2020

Can anyone still reproduce this bug in Godot 3.2.3 rc3 or any later release?

If yes, please ensure that an up-to-date Minimal Reproduction Project (MRP) is included in this report (a MRP is a zipped Godot project with the minimal elements necessary to reliably trigger the bug). You can upload ZIP files in an issue comment with a drag and drop.

@akien-mga
Copy link
Member

No answer, so closing.

Please comment if you can still reproduce it, and this issue can be reopened. Or open a new issue with a MRP if this would be better suited.

@Merlin1846
Copy link

It's less of a bug and more of just the way the tile set auto tile works, so until one of the suggested fixes are implemented it will always be reproducible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants