- Home /
Is animating a tile in a tilemap (quad per tile mesh) by changing quads uv position logical and efficient?
I am new to procedural mesh generation and uv mapping from sprite atlas. So I don't know whether a solution that come to my mind is efficient, logical and "best way", or neither of these.
I am currently making a procedural tile map "engine-y" in Unity. I had a question about it here few days ago, (i asked whether to use a mesh or multiple sprite objects) and by the given answers i am now proceeding with the mesh generation way.
I've created the base structure-framework in my mind. I even made some prototypes. I will map each quad's UV, by the corresponding tile in the sprite atlas. (If there is a better way, please don't hesitate to tell ^^)
But i have a problem with animating them. For example, for a "water-type" tile, which is going to be animated ofcourse, there will be different "frames" of water sprites in the sprite-atlas.
So, i am thinking about updating "that quad's" UV positions to shift to the next frame of the water sprite in the atlas. But i am not sure if it's a good way or not. Is it logical to do that in a Update cycle? Even with the slow animation speed, it will be updating lot's of uv points in an Update cycle.
Say if i zooomed-out in game, and there are 100x100 = 10.000 water tiles in screen, (10.000 quads * 4 = 40.0000 uv points to be updated), will there be an impact on performance when i update that much of UV positions?
Or does the graphic card optimizes it so it doesn't even noticible?
If it's not a wise way, which probably isn't, what is most logical and professional way of animating tiles?
Note: There may or may not be a solution by computing it with shaders, but I don't know anything about shader programming, so if the best solution is to use shaders, I am not hesitated to learn it. If so please provide training sources for both shader programming and UV updating. (Unity uses ShaderLab for shaders if it matters)
You seem a little confused, like you were just reading a whole bunch of stuff about how UVs work, and haven't sorted it out in our $$anonymous$$d yet. I like how you told us that Unity uses ShaderLab (it can use something it calls that, plus the better Vert/Frag shaders.)
Look at how $$anonymous$$aterials can slide around UVs using offset. You can look up how to directly change UVs (and decide for yourself how slow/fast that it.) They are part of the $$anonymous$$esh.
Your answer
Follow this Question
Related Questions
Abrupt change of position between animation transition 2 Answers
Animated Overlay Armor Sprite 1 Answer
Animation based on replacing sprites in sprite renderer does not work? 0 Answers
Animation with Transparency Floats Above Ground 1 Answer
Is there a way to abstract sprite from animation clip? 0 Answers