Using shader modifiers to animate texture in SceneKit leads to jittery textures over time

怎甘沉沦 提交于 2019-11-28 12:53:02

It's definitely a floating point precision issue. you should probably try to do a modulo on (u_time*30.0) so that it loops within a reasonable range.

if you want to iterate over images your texture coordinate must stay the same for a short period of time (1 second for instance).

u_time is similar to CACurrentMediaTime(), it's a time in seconds.

Now let's say you have N textures. Then mod(u_time, N) will increase every second from 0 to N-1 and then go back to 0. If you divide this by N you've got your texture coordinate, and you don't need SCNWrapModeRepeat.

If you want your image to change every 0.04 second (25 times per second), then use mod(25 * u_time, N) / N.

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