Skip to content
This repository has been archived by the owner on May 7, 2022. It is now read-only.

Tile Transforms #75

Open
chrisburnor opened this issue Dec 29, 2020 · 6 comments
Open

Tile Transforms #75

chrisburnor opened this issue Dec 29, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@chrisburnor
Copy link

chrisburnor commented Dec 29, 2020

Right now TileMaps can have a local and global transform, but it seems to apply to the whole tilesheet. It would be useful, for animations or effects to be able to control the transform of each Tile as well to enable rotations, scaling, and other arbitrary distortions.

@chrisburnor chrisburnor added the enhancement New feature or request label Dec 29, 2020
@inodentry
Copy link
Contributor

I suspect this might be fairly easy to implement, by passing a per-tile transform matrix as another input into the vertex shader. It could multiply that matrix after calculating the coordinates.

IDK how much overhead this would have, and if it might be worth coming up with a way to make it optional, so that people who only want a static grid don't have to pay the price in performance.

@Lythenas
Copy link

Yes please. Rotating would be very useful.

@inodentry
Copy link
Contributor

I just can't help but wonder -- at what point would the functionality of this crate converge with simply using bevy sprites for all the tiles (after bevy implements batching/instancing for sprite rendering to make it efficient). Would this crate eventually become redundant/obsolete? Particularly if its complexity grows due to features like this proposal. It would no longer be simply a crate for efficient rendering of a static grid. So maybe this feature request is out of scope?

IDK, @joshuajbouw is the one to decide / give an opinion on this.

@chrisburnor
Copy link
Author

I was wondering the same thing. My reasoning in putting it here, though, is that, as @jamadazi referenced, it should be simply a transform. Since each tile is already being passed a transform to place it on the screen, it shouldn't be much technical overhead.

I think the open question is more logical overhead in terms of having an API to express matrices and transforms (something the rust ecosystem seems awash in these days without a clear standard lib to do so)

@joshuajbouw
Copy link
Owner

joshuajbouw commented Jan 7, 2021

@chrisburnor Animations will be coming, same with transforms. It wouldn't be like Bevy's transform API, but just flip flags and vector of animation frames with reference to which tiles to render from the spritesheet. It is MUCH cheaper to hold bit flags of the tile's transform, then it's actual transform.

@jamadazi I don't think so. Tile maps are typically part of a core game dev library. I would at that point switch to doing per tile rendering and check if the performance is the same or better. If it isn't, then I would stick with this method here.

It IS part of the transform which is passed to the shader, I think it is just as simple as passing in the transform.

@chrisburnor
Copy link
Author

bit flags

Does that mean the plan is to only allow flip transforms? My hope had been to give a sort of compression/bend effect as sprites move between tiles to make them feel a bit more 'alive'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants