https://www.shadertoy.com/
我想在我的android studio项目中实现shadertoy
itime
,我想在我的项目中实现itime
var,
这是我的代码:
long last_time = System.nanoTime();
while(running) {
long time = System.nanoTime();
int delta_time = (int) ((time - last_time) / 1000000);
last_time = time;
}
但这不起作用,还有其他方法在android中实现itime
吗?
最佳答案
iTime 是一个耗时值。last_time = time
只会告诉您每个循环之间的时间。 iTime
是自程序开始以来的时间或定义的时间段。
因此,只需删除 last_time = time
并将您的 delta_time
变量设置为 long
或 double
并确保将其重命名或以后你会很困惑的!
如果您决定将 delta_time
设为 :double
,请务必除以 1 000 000 000 而不是 1 000 000,您将在左侧看到第二个,而右侧部分为毫秒,就像在 Shaderoy 中一样。
在shadertoy中可以定义时间变量:
- uniform float iTime:如前所述告知时间
- uniform float iTimeDelta:告诉每帧之间的时间
如果您想了解更多信息,请查看how to在那儿的网站上!
关于android - 如何实现shaderoy itime?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58707219/