2022-01-02 19:28:16 -05:00
|
|
|
/* vim: set ft=c: */
|
|
|
|
|
2022-01-16 17:47:04 -05:00
|
|
|
# define M_PI (3.141592653589793238462643383279502884) /* pi */
|
|
|
|
# define M_PI_2 (1.570796326794896619231321691639751442) /* pi/2 */
|
|
|
|
# define M_PI_4 (0.785398163397448309615660845819875721) /* pi/4 */
|
|
|
|
|
2022-01-02 19:28:16 -05:00
|
|
|
/* <https://www.shadertoy.com/new> */
|
|
|
|
|
2022-01-13 12:15:07 -05:00
|
|
|
void
|
|
|
|
mainImage (out vec4 fragColor, in vec2 fragCoord)
|
|
|
|
{
|
2022-01-16 17:47:04 -05:00
|
|
|
const float t = iTime;
|
|
|
|
const int T = int (3 * (0.5 + 0.5 * cos (t)));
|
|
|
|
|
2022-01-13 12:15:07 -05:00
|
|
|
// Normalized pixel coordinates (from 0 to 1)
|
2022-01-16 17:47:04 -05:00
|
|
|
// vec2 uv = fragCoord.xy / iResolution.xy;
|
2022-01-02 19:28:16 -05:00
|
|
|
|
2022-01-16 17:47:04 -05:00
|
|
|
// Texture coordinates
|
|
|
|
vec2 uv = TexCoords;
|
2022-01-02 19:28:16 -05:00
|
|
|
|
2022-01-13 12:15:07 -05:00
|
|
|
// float du = 1.0 / iResolution.y;
|
|
|
|
// vec2 uv = du * (fragCoord.xy - (0.5 * iResolution.xy));
|
|
|
|
|
|
|
|
// Time varying pixel color
|
2022-01-16 17:47:04 -05:00
|
|
|
vec3 z1 = vec3 (
|
|
|
|
sin (t) * cos (t)
|
|
|
|
, sin (t / M_PI) * cos (t / M_PI)
|
|
|
|
, sin (t / M_PI / 2) * cos (t / M_PI_2)
|
|
|
|
);
|
|
|
|
vec3 z2 = uv.xyx;
|
|
|
|
switch (T)
|
|
|
|
{
|
|
|
|
case 0: z2 = uv.xxx; break;
|
|
|
|
case 1: z2 = uv.yyy; break;
|
|
|
|
case 2: z2 = uv.xyx; break;
|
|
|
|
}
|
|
|
|
vec3 col = 0.5 + 0.5 * cos (iTime + z1 + z2);
|
2022-01-13 12:15:07 -05:00
|
|
|
|
|
|
|
// Output to screen
|
|
|
|
fragColor = vec4 (col, 1.0);
|
2022-01-02 19:28:16 -05:00
|
|
|
}
|