动画是在tilemap的(每瓦四)瓦改变圣城UV位置合理,高效的网? [英] Is animating a tile in a tilemap (quad per tile) mesh by changing quads uv position logical and efficient?

查看:356
本文介绍了动画是在tilemap的(每瓦四)瓦改变圣城UV位置合理,高效的网?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的程序网格生成和UV贴图从精灵地图集。因此,我不知道,我想起一个解决方案是否有效,符合逻辑和最佳途径,或没有这些。

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.

我目前正在做一个程序平铺图引擎Y的统一。我这里前几天有一个关于它的问题,(我问是否使用网状或多个精灵对象),并给出答案的,我现在用的网格生成方式进行。

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 ^^)

但我有动画他们的问题。例如,对于一个水型瓦,这是将要ofcourse动画,将有不同的精灵-图谱水精灵帧。

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.

所以,我想更新即四的UV位置转移到阿特拉斯水精灵的下一帧。
但我不知道这是否是一个很好的方法还是不行。它是顺理成章的事情,在一个更​​新周期?即使使用慢的动画速度,将更新的紫外线点很多的在一个更新周期。

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.

说如果我在比赛zooomed出,并有屏幕100×100 = 10.000水砖,(10.000四边形* 4 = 40.0000 UV点进行更新),才能有对性能产生的影响时,我更新了很多UV位置?

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?

还是它确实是这样的显卡优化它甚至不是noticible?

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?

注:有可能会或可能不会与着色器计算它的解决方案,但我不知道着色器编程什么,所以如果最好的解决方案是使用着色器,我毫不迟疑地了解它。如果有,请提供两种着色器编程和UV更新培训资源。 (统一使用ShaderLab为着色器,如果它的事项)

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)

推荐答案

更​​新UV位置是一个很好的方法,这样做动画。我不认为这会导致你的性能问题。

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

然而,这里的另一种方法去考虑。让你的水的单独的材料,只能作为广为一体的瓷砖的质地,但你要让它为高。构建四边形网格只是水的纹理,设置为只有一个平铺的价值质地高度的UV。现在,在材料特性,只是改变每个帧的纹理的Y偏移量。保留所有紫外线的孤独;在Y偏移量将有效地在每个顶点被添加到V值。你甚至可以改变它以小的增量每帧(小于整个瓷砖的价值)上,黄油,流畅的动画,而无需触摸网格都没有。

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.)

这篇关于动画是在tilemap的(每瓦四)瓦改变圣城UV位置合理,高效的网?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆