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

Reimplement ability to flip/rotate/modulate individual tiles in a TileMap (as opposed to creating flipped/rotated/modulated tiles in the TileSet) #3967

Closed
seocwen opened this issue Feb 14, 2022 · 27 comments · Fixed by godotengine/godot#80144

Comments

@seocwen
Copy link

seocwen commented Feb 14, 2022

Describe the project you are working on

A top-down procedurally generated rogue-like.

Describe the problem or limitation you are having in your project

Godot 4.0 Tilemaps no longer support the flipping and transposition of individual tiles. This feature is useful for reusing assets, preventing resource bloat, and synchronizing symmetrical features. The project I'm attempting to test-port from 3.0 to 4.0 relies heavily on this functionality. Because there's no support for this feature, and my maps are built for it, 4.0 isn't currently a viable option for my existing projects.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The way Godot 3.0 handled flipping and rotation was excellent. I suggest adding that part back into 4.0, which is otherwise superior.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I recommend reinstituting the previously existing buttons back on the icon bar of the tilemap editor. The icons for rotate left, rotate right, flip horizontally, flip vertically, and clear transforms would appear next to the other buttons, or become accessible after clicking on a "transform" button.

If this enhancement will not be used often, can it be worked around with a few lines of script?

This is an editor issue, not a coding issue.

As for work-arounds, not everyone will need this, but for those of us who do, the alternatives are rather painful. It is possible to make an "alternate tile" with these transforms set. This should theoretically work alright for a small number of individual tiles.

Attempting this for an entire tileset, the result is an unusable mess, especially as there is no way to cleanly match an alternate to its corresponding primary tile. It is far less painful being able to make these transformations as needed on the fly in tilemaps rather than in tilesets. You can't necessarily plan in advance what might need to be flipped, it's impractical to flip everything, and in general, the current layout of the alternatives panel leads to bad organization even if you were to try planning this out. Likewise, with the current alternative tiles panel, you lose the functionality to paint "patches" of tiles because they appear out of their intended ordering.

The thought also occurred to me of making a separate layer and using costum dummy tiles to mark where I'd like transformations, but these changes would be non-obvious in the editor, which is required for design best practices.

Is there a reason why this should be core and not an add-on in the asset library?

Mostly, because this is re-implementing a 3.0 feature that got lost in the shuffle. In my opinion, an add-on should not be necessary for porting projects to 4.0.

@groud
Copy link
Member

groud commented Feb 14, 2022

I don't think bringing them back is worth the trouble.
Most of the time, if you want flipped tiles, tile alternatives are fine for objects (as you place them once and you are done).
The remaining difficult part is likely about painting ground, but 99% of the cases, this can be handled using the terrain system (there are still some issues there but I hope they will eventually be fixed).

Also, remember that this feature only works for square tilemaps, and that the new TileMap features a lot more different shapes now. So I am not in favor of implementing a workaround specific to this situation.

Edit: BTW, that does not mean that the alternative system is perfect right now. I agree on the fact it's hard to be organized with them. I am not against some changes there that would simplify the workflow for flipped or rotated tiles.

@Calinou Calinou added this to the 4.0 milestone Feb 14, 2022
@seocwen
Copy link
Author

seocwen commented Feb 14, 2022

Most of the time, if you want flipped tiles, tile alternatives are fine for objects (as you place them once and you are done).

I don't think "most of the time" is a fair characterization. There are diverse workflows for working with art assets. If your tileset only contains right-facing walls and corners, and you flip them to get the the rest, you've just halved your total texture count. And if you do make two corners, you can flip both versions to get that diversity on either side.

What works for objects does not work for walls, and it's certainly not a "place once" fix. The tileset I've been working with is "all wall," because my objects are composed of tiles smaller than themselves so that they can be mixed and matched. This is more like how many SNES games like Chrono Trigger handle tesselation (trees in particular)--which is quite different from the Link's Awakening style tiles I noticed from most of the demos.

Flips would be useful at least for all rectangular sets. Horizontal flips at least would be useful for isometric sets. I don't think it make sense to deny functionality simply because not every use case will require it. Besides, other users of more exotic tiles might surprise you with their creative uses of this feature if it's available.

If there's something I'm missing in terms of the functionality that will be offered through patterns, please do explain.

It's not inconceivable that the alternatives system could work for the use case I'm describing. The best case I can imagine is selecting my entire tilemap, hitting "make alternative," selecting h-flip, and getting an identically laid out copy of the entire tilemap, flipped. This would work, but it would be extremely inelegant for half the tiles used for related objects to appear on opposite sides of the tile palette. And then, if I needed v-flip on top of that, I'd be doubling everything again.

Now that I think about it, the same could hold true for modulate, too, but my actual plan there is to use palette swapping by drawing custom values on a separate layer, which I don't ever expect editor support for. Regardless, IMHO, most of what appears in the alternatives system belongs in the TileMaps, not TileSets.

@Mickeon
Copy link

Mickeon commented Feb 17, 2022

I'm not sure about implementing them exactly as they were, but I do have to agree that these features are pretty standard for a tile-based... well, anything, and that they will be missed by users making use of them, forcing them to spend plenty of time implementing an alternative that can be considered a mere downgrade for this purpose.

Perhaps, there could a way to set them up in the TileSet without wasting texture space, unlike autotiles, and have them easily accessible through similar shortcuts as the 3.x's existing buttons on the TileMap editor.

@KingBrainlord
Copy link

Its nice the new system integrates tilesets and tilemaps closely, but it confuses their roles. Tilesets represent the semantics of what a tile is while tilemaps control where and how they're placed and rendered. Flips, transposition, modulation, and z-index concern the latter. Moving the alternatives properties to tilemaps will give the user finer control without needlessly creating new objects.

I've been thinking I'd like to have very gradual, subtle, color shifts in all my tilemaps using modulate, for instance. That would require hundreds, even thousands of tilemap alternatives - or it could just be painting onto the tilemap.

I strongly recommend that this be fixed before the 4.0 release. The new tilemaps are an important breaking change so its important that their design be good.

@PoisonousGame
Copy link

PoisonousGame commented Sep 10, 2022

How to flip the pattern? My pattern consists of multiple tiles, I can't flip my pattern by alternative tile. I don't want to combine several tiles into one tile, and then create an alternative tile and flip it.

@Mickeon
Copy link

Mickeon commented Sep 10, 2022

You cannot, in Godot 4.0 as of yet. This is in the milestone, so it will have to be added at some point down the line.

@jonSP12
Copy link

jonSP12 commented Nov 29, 2022

I was going to post about this issue, but then saw one was already open.
The flip horizontal and flip vertical, was always been present in all tileEditors. Iam constantly being blocked for not being able to use it.

The FLIP TILE may not be usefull, for when someone is working with tiles downloaded from the internet. But when making your own, saving the image with both sides LEFT and RIGHT will take 2x the space in view. This also requires to edit and remake all the tilesets images, and saving them with 2x the memory.

Here's an example of tiles stack togheter, the left side is always diferent from the right
tileFace

another tile using shadows, ( a layer that goes on top of any tile texture )
tileFaceShadow

Its not very good, to make all of this stuff facing left and right in the same image...

@feendrache
Copy link

Are there any updates for this topic?
I think this feature is really needed

@Calinou
Copy link
Member

Calinou commented Dec 9, 2022

Are there any updates for this topic? I think this feature is really needed

There is no ETA for features being completed, as contributors are working on a best-effort basis.

@jonSP12
Copy link

jonSP12 commented Dec 11, 2022

It would be important to have this feature ON, even if it wanst working 100%.
People would be able to go on with their 2D projects in gd4, and the bugs report would flow normally without any worries...
This way all of the time is spent waiting, and gd4 is not being used.
( waiting or going somewere else, were things are normal )

@Calinou Calinou changed the title Bring Back Tilemap Flip and Transpose Reimplement ability to flip/rotate individual tiles in a TileMap (as opposed to creating flipped/rotated tiles in the TileSet) Dec 12, 2022
@zurasuta
Copy link

I'm curious, is this feature going to be implemented? Cause I'd love to have it too.

@Mickeon
Copy link

Mickeon commented Feb 22, 2023

Judging by the overwhelmingly positive feedback, yes, and absolutely it should. Not now, perhaps a later 4.x version. No one that I've seen came up with an actual implementation yet, so it may only be 4.1 is we're being cautiously optimistic, or if it's deemed to be a quite urgent feature to have.

@Calinou Calinou modified the milestones: 4.0, 4.x Feb 22, 2023
@groud
Copy link
Member

groud commented Feb 24, 2023

Alright, I guess I need to write a follow up to my previous message. Sorry if it sounded dismissive of the problem, but that was not my intention. It is indeed clear now, considering on my message downvotes, that a lot of people relied on that feature and that it should be brought back one way or another ASAP.

Sadly it's now a bit late for 4.0, but I think it should be easy to bring it back for 4.1.

@Gnumaru
Copy link

Gnumaru commented Feb 24, 2023

The workflow for flipping and rotating tiles could perhaps be implemented by automatically selecting or creating alternative tiles.

Consider the following workflow:

  1. The user selects a tile to paint
  2. The user press 'X' on the keyboard
  3. The editor searches among the alternative tiles one that is identical to the current except for flip_h property which will have the opposite value of the current alternative
  4. If such alternative is not found, it is created.
  5. Then, it is selected by the editor.

The same would be done with the other keyboard shortcuts, Z, A and S. This way the users would paint flipped and rotated tiles the same way they did in 3.X, but behind the curtains alternative tiles would be used as it is currently designed.

The same logic would also work for patterns. Suppose the user selects a pattern, whatever it's shape. If the user tries to flip the entire pattern, then the editor flips each tile of the pattern and rearrange the tiles inside the pattern. For example, while flipping horizontally, every tile would be flipped horizontally and each tile in the row would be reversed: the first in the row would become the last, the second would become the second last, and so on and so forth.

@securas
Copy link

securas commented Feb 25, 2023

I would like to add to the proposal the possibility of flipping tiles via code. This is pretty important for procgen. However, it is unclear to me if it should be discussed here or on an issue.

@feendrache
Copy link

i recreated the functionality with my Tiled Importer Plugin for Godot 4 with creating alternative tiles for each tile in the tileset and using the alternatives in the imported maps.
But this is only really useable when you import maps from tiled, to use flipped tiles in godot mapmaking this is no alternative

@jonSP12
Copy link

jonSP12 commented Feb 26, 2023

I would remove the 1000x tiles on screen, and alternate tiles, and let user deal with the problem. Iam sure a solution will came up, something like a viewPort that only draws the size of the camera, or something else.

There is a possibility that duplicating the entire tile sheet into 3 or 4 will make things worse. I have a 1 sec delay when changing between levels ( I think its a for loop somewere, might need to pre-load the level scenes )

Or even simplier solution make 2 tile map editors, 1 with alternate tiles, and another 1 without alternated tiles.

@thelordofscrubs
Copy link

As someone who really only writes code, I am very much struggling with importing my project to godot 4 because of this. I relied on tile rotating and flipping for my tilemap, and now that that is no longer available I need to figure out how to flip selections in paint.net, which apparently isnt really possible :/

@Gnumaru
Copy link

Gnumaru commented Mar 8, 2023

Tiled 1.10 RC

https://github.com/mapeditor/tiled/releases/tag/v1.9.91

Added a godot 4 export plugin

mapeditor/tiled#3550

It handles flipped and rotated tiles by creating 7 variants for each tile in the tileset (3 rotations for the default non flipped tile + 1 horizontally flipped tile + 3 rotations for the horizontally flipped tile).

@Skrapion
Copy link

I'm the author of the Tiled exporter.

Note that you need to turn on exportAlternates to get the flipping/rotating feature, because I wasn't comfortable with octupling the tileset size by default. I imagine it doesn't have much impact on performance, but actually using the generated TileSet in Godot is very unwieldy with so many alternates.

If there was a way to flip/rotate tiles in the TileMap instead of the TileSet, I would definitely have used that option instead. Or perhaps a way to make an alternate class, which applies the same transformation to the whole sheet, and shows the whole sheet transformed.

@Calinou Calinou changed the title Reimplement ability to flip/rotate individual tiles in a TileMap (as opposed to creating flipped/rotated tiles in the TileSet) Reimplement ability to flip/rotate/modulate individual tiles in a TileMap (as opposed to creating flipped/rotated/modulated tiles in the TileSet) May 26, 2023
@KoBeWi
Copy link
Member

KoBeWi commented Aug 10, 2023

There's PR that implements this feature: godotengine/godot#80144
You can test it using this build: https://github.com/godotengine/godot/suites/15001107777/artifacts/856191715

Note that not all default shortcuts will work until godotengine/godot#80221 is fixed, so you need to rebind them.
Also the PR does not implement per-tile modulate and will not implement it. It's impossible to add given how the tile data is stored.

@jonSP12
Copy link

jonSP12 commented Aug 11, 2023

  • shortcut key (V) doesnt seem to work
  • Select a single tile, rotate it / flip it (Z) (X) (C) paint it on canvas, then select multiple tiles blocks and they are all scrambled ( they appear pre rotated/flipped and rotate or flip using shortcut keys )
  • the editor keeps crasing multiple times, always after creating ( new node ). I was using MSI afterBurner along with Riva Tuner with max fps set to 60, closed MSI afterBurner Ran the editor again and it seems to be better now.
  • I dont know how to turn visibility on for the editor console, but manage to snatch a photo right before it colses when opening a project
    everything else looks fine

gdERROR

maybe in the future, add an option for viewing the flipped/rotated duplicates... people using radom generated levels might want to access their ID
tile

@KoBeWi
Copy link
Member

KoBeWi commented Aug 11, 2023

Thanks for testing @jonSP12!

shortcut key (V) doesnt seem to work

I already mentioned that this shortcut won't work. It conflicts with another shortcut in 2D editor; for now you need to bind another key as a workaround.

Select a single tile, rotate it / flip it (Z) (X) (C) paint it on canvas, then select multiple tiles blocks and they are all scrambled ( they appear pre rotated/flipped and rotate or flip using shortcut keys )

Fixed. Also improved how patterns are transformed in general, so every case should be supported now.

godot.windows.editor.dev.x86_64_Sd06YCEusO.mp4

maybe in the future, add an option for viewing the flipped/rotated duplicates... people using radom generated levels might want to access their ID

I exposed the transform bits in TileSetAtlasSource and documented some example how they can be used. Is that enough?

Other points are unrelated. I'll link an updated build once it's finished.

EDIT:
https://github.com/godotengine/godot/suites/15030259946/artifacts/858334101

@securas
Copy link

securas commented Aug 11, 2023

Is it possible to flip tiles via gdscript?

@KoBeWi
Copy link
Member

KoBeWi commented Aug 11, 2023

Yes. You can achieve that by manipulating their alternative tile ID, as described in the example I linked.

@securas
Copy link

securas commented Aug 11, 2023

Thanks! I'll check it out very soon.

@jonSP12
Copy link

jonSP12 commented Aug 12, 2023

[edit ] - pattern in select ctrl + c , ctrl + v is missing flip/rotate tools

I tested the animation with flip/rotation and it works.

Problem was... The Tile animation doesnt make much sense, the person cant use the tiles it wants..?! If i want to animate a tile i have to delete the other tiles to use them has frames. ( This way i cant use them anymore )

Cant an array be used in the editor, and loop that array to animated ?
Ive made this in code,
The user just puts the tiles it wants in an array, then just sets a speed on it, and go...

tilePost.mp4

animCode

*******Label

extends Label
@onready var myTile = get_node_or_null("../TileMap");

var font;
var fontSize = 20;

func _ready():
	font = FontFile.new();

func _process(delta):
	queue_redraw();

func _draw() -> void:
	draw_rect( Rect2( Vector2(10, 10), Vector2(250, 50)),  Color.BLACK);
	draw_string(font, Vector2(30, 40), "CURRENT FRAME: " + str( round( myTile.frame1 ) ) , HORIZONTAL_ALIGNMENT_LEFT, -1, fontSize );


*TileMap

extends TileMap

var arrayTile = [ Vector2(6,1), Vector2(7,1), Vector2(8,1) ];

var frame1 = 0;
var speed = 0.5;


func _ready():
	pass # Replace with function body.

func _process(delta):
	if ( frame1 < 3 ):
		frame1 += 1.5 * delta;
		if ( frame1 > 3 ):
			frame1 = 0;
	
	set_cell(0, Vector2(11,6), 0, arrayTile[ frame1 ] );
	#the layer nr ,level coords, tileMap Source, tileMap coords

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

Successfully merging a pull request may close this issue.