Is animating a tile in a tilemap (quad per tile) mesh by changing quads uv position logical and efficient?

落爺英雄遲暮 提交于 2019-12-06 16:40:12

Updating the UV positions is a fine way to do this animation. I don't think it will cause you performance problems.

However, here's another approach to consider. Make your water a separate material, only as wide as one tile's texture, but as tall as you want to make it. Build a mesh of quads for just the water textures, with UVs set to just one tile's worth of the texture height. Now, in the material properties, just change the Y offset of the texture on each frame. Leave all the UV's alone; the Y offset will effectively be added to the V values at each vertex. You can even change it in small increments on each frame (less than an entire tile's worth), for butter-smooth animation without having to touch the mesh at all.

The cost, of course, is that it's a separate material, and thus a separate draw call. But people tend to fuss far too much about draw calls anyway.

If you have multiple scrolling materials (e.g. clean water, muddy water, lava, glowy rivers of magical power, whatever), they can all share the same material, with one column each of the texture map. (But this will require them to all scroll at the same rate.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!