92 lines
1.7 KiB
GLSL
92 lines
1.7 KiB
GLSL
int numRows = 5;
|
|
int numCols = 5;
|
|
|
|
#define period (2.0)
|
|
#define halfperiod (period * 0.5)
|
|
#define dt (mod(iTime, period))
|
|
#define dth (mod(iTime, halfperiod))
|
|
|
|
#define moveFlip (int(mod(iTime, period * 2.0) > period))
|
|
#define moveRows (int(mod(iTime, period) > halfperiod))
|
|
#define moveEvens (int(mod(iTime, period) > halfperiod))
|
|
|
|
|
|
|
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
|
{
|
|
int move_evens = moveEvens;
|
|
if (moveFlip > 0)
|
|
{
|
|
move_evens = 1 - moveEvens;
|
|
}
|
|
|
|
float dx = iResolution.x / float(numRows);
|
|
float dy = iResolution.y / float(numCols);
|
|
|
|
float x = fragCoord.x;
|
|
float y = fragCoord.y;
|
|
|
|
x *= iResolution.x/iResolution.y;
|
|
|
|
|
|
int rowx = int(x / dx);
|
|
int rowy = int(y / dy);
|
|
|
|
int xeven = int(mod(float(rowx), 2.0));
|
|
int yeven = int(mod(float(rowy), 2.0));
|
|
|
|
float t = dth / halfperiod;
|
|
|
|
float dtx = dx * t * 2.0;
|
|
float dty = dy * t * 2.0;
|
|
|
|
if (moveEvens == 1)
|
|
{
|
|
if (moveRows == 1 && xeven == 1)
|
|
{
|
|
y = y + dty;
|
|
rowy = int(y / dy);
|
|
}
|
|
else if (moveRows == 0 && yeven == 0)
|
|
{
|
|
x = x + dtx;
|
|
rowx = int(x / dx);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (moveRows == 1 && xeven == 0)
|
|
{
|
|
y = y + dty;
|
|
rowy = int(y / dy);
|
|
}
|
|
else if (moveRows == 0 && yeven == 1)
|
|
{
|
|
x = x + dtx;
|
|
rowx = int(x / dx);
|
|
}
|
|
}
|
|
|
|
xeven = int(mod(float(rowx), 2.0));
|
|
yeven = int(mod(float(rowy), 2.0));
|
|
|
|
if (xeven == yeven)
|
|
{
|
|
// vec4 c = texture(iChannel0, fragCoord.xy / iResolution.xy);
|
|
//
|
|
// if (c.x == 0.0 && c.y == 0.0 && c.z == 0.0)
|
|
// {
|
|
// c = vec4(1.0, 1.0, 1.0, 1.0);
|
|
// }
|
|
//
|
|
// fragColor = c;
|
|
fragColor = vec4(1.0, 1.0, 1.0, 1.0);
|
|
}
|
|
else
|
|
{
|
|
// vec4 c = texture(iChannel1, fragCoord.xy / iResolution.xy);
|
|
// fragColor = c;
|
|
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
}
|
|
}
|