blob: 6c20aba528f373879e326aef99281782dce186cb [file] [log] [blame]
Skyler Grey3eef73c2022-05-25 10:41:04 +01001#extension GL_OES_standard_derivatives : enable
2
3precision highp float;
4
5uniform float time;
6uniform vec2 mouse;
7uniform vec2 resolution;
8
9vec3 white = vec3(1, 1, 1);
10vec3 amaranth_pink = vec3(0.945, 0.612, 0.733);
11vec3 maya_blue = vec3(0.298, 0.624, 0.886);
12
Skyler Grey397535e2022-05-25 11:47:09 +010013vec3 color_for_position (vec2 position) {
Skyler Grey3eef73c2022-05-25 10:41:04 +010014 vec3 color = white;
15
Skyler Grey397535e2022-05-25 11:47:09 +010016 if (sin(position.x + time / 30.0) / 2.0 - position.y + 0.4 < 0.0) {
Skyler Grey3eef73c2022-05-25 10:41:04 +010017 color = amaranth_pink;
Skyler Grey397535e2022-05-25 11:47:09 +010018 } else if (sin(position.x / 5.0 + time / 21.0 + 20.0) / 2.0 - position.y + 0.5 < 0.0) {
Skyler Grey3eef73c2022-05-25 10:41:04 +010019 color = maya_blue;
20 }
21
Skyler Grey397535e2022-05-25 11:47:09 +010022 return color;
23}
Skyler Grey3eef73c2022-05-25 10:41:04 +010024
Skyler Grey397535e2022-05-25 11:47:09 +010025void main( void ) {
26 vec2 position = ( gl_FragCoord.xy / resolution.xy );
27
Skyler Grey69974aa2022-05-25 12:06:19 +010028 float r = 0.0;
Skyler Grey397535e2022-05-25 11:47:09 +010029 float g = 0.0;
30 float b = 0.0;
31
Skyler Grey5d50f262022-05-25 20:40:34 +010032 float sampleSqrt = 3.0;
Skyler Grey69974aa2022-05-25 12:06:19 +010033
Skyler Grey5d50f262022-05-25 20:40:34 +010034 for (float x = 0.0; x < sampleSqrt; x++) {
Skyler Grey69974aa2022-05-25 12:06:19 +010035 for (float y = 0.0; y <= sampleSqrt; y++) {
Skyler Grey397535e2022-05-25 11:47:09 +010036 vec3 color = color_for_position(
37 vec2(
Skyler Grey69974aa2022-05-25 12:06:19 +010038 (x / (resolution.x * sampleSqrt)) + position.x,
39 (y / (resolution.y * sampleSqrt)) + position.y
Skyler Grey397535e2022-05-25 11:47:09 +010040 )
41 );
42 r += color.x;
43 g += color.y;
44 b += color.z;
45 }
46 }
47
Skyler Grey69974aa2022-05-25 12:06:19 +010048 r /= sampleSqrt * sampleSqrt;
49 g /= sampleSqrt * sampleSqrt;
50 b /= sampleSqrt * sampleSqrt;
Skyler Grey397535e2022-05-25 11:47:09 +010051
52 gl_FragColor = vec4(vec3(r, g, b), 1.0);
Skyler Grey3eef73c2022-05-25 10:41:04 +010053}