54 lines
815 B
GLSL
54 lines
815 B
GLSL
#ifndef PI
|
|
#define PI 3.1415927
|
|
#endif
|
|
|
|
#include inc_rand.glsl
|
|
|
|
#ifndef INC_TIME
|
|
#define INC_TIME
|
|
|
|
uniform float iTime;
|
|
uniform float iTempo;
|
|
uniform float iBeats;
|
|
|
|
float randTime(float seed, int beats){
|
|
return rand(seed + floor(iBeats / beats));
|
|
}
|
|
|
|
float randTime(float seed){
|
|
return randTime(seed, 4);
|
|
}
|
|
|
|
float divider(float x)
|
|
{
|
|
if (x < .1) return 0.;
|
|
if (x < .2) return .125;
|
|
if (x < .3) return .25;
|
|
if (x < .4) return .5;
|
|
if (x < .6) return 1.;
|
|
if (x < .8) return 2.;
|
|
return 4.;
|
|
}
|
|
|
|
float modTime(float k, float k2)
|
|
{
|
|
return mod(divider(k) * iBeats * k2 * .25, 1.);
|
|
}
|
|
|
|
float modTime(float k)
|
|
{
|
|
return modTime(k, 1.);
|
|
}
|
|
|
|
float sinTime(float k)
|
|
{
|
|
return sin(modTime(k, .5) * 2. * PI);
|
|
}
|
|
|
|
float cosTime(float k)
|
|
{
|
|
return cos(modTime(k, .5) * 2. * PI);
|
|
}
|
|
|
|
#endif
|