Skyler Grey | 3eef73c | 2022-05-25 10:41:04 +0100 | [diff] [blame] | 1 | #extension GL_OES_standard_derivatives : enable |
| 2 | |
| 3 | precision highp float; |
| 4 | |
| 5 | uniform float time; |
| 6 | uniform vec2 mouse; |
| 7 | uniform vec2 resolution; |
| 8 | |
| 9 | vec3 white = vec3(1, 1, 1); |
| 10 | vec3 amaranth_pink = vec3(0.945, 0.612, 0.733); |
| 11 | vec3 maya_blue = vec3(0.298, 0.624, 0.886); |
| 12 | |
Skyler Grey | 397535e | 2022-05-25 11:47:09 +0100 | [diff] [blame] | 13 | vec3 color_for_position (vec2 position) { |
Skyler Grey | 3eef73c | 2022-05-25 10:41:04 +0100 | [diff] [blame] | 14 | vec3 color = white; |
| 15 | |
Skyler Grey | 397535e | 2022-05-25 11:47:09 +0100 | [diff] [blame] | 16 | if (sin(position.x + time / 30.0) / 2.0 - position.y + 0.4 < 0.0) { |
Skyler Grey | 3eef73c | 2022-05-25 10:41:04 +0100 | [diff] [blame] | 17 | color = amaranth_pink; |
Skyler Grey | 397535e | 2022-05-25 11:47:09 +0100 | [diff] [blame] | 18 | } else if (sin(position.x / 5.0 + time / 21.0 + 20.0) / 2.0 - position.y + 0.5 < 0.0) { |
Skyler Grey | 3eef73c | 2022-05-25 10:41:04 +0100 | [diff] [blame] | 19 | color = maya_blue; |
| 20 | } |
| 21 | |
Skyler Grey | 397535e | 2022-05-25 11:47:09 +0100 | [diff] [blame] | 22 | return color; |
| 23 | } |
Skyler Grey | 3eef73c | 2022-05-25 10:41:04 +0100 | [diff] [blame] | 24 | |
Skyler Grey | 397535e | 2022-05-25 11:47:09 +0100 | [diff] [blame] | 25 | void main( void ) { |
| 26 | vec2 position = ( gl_FragCoord.xy / resolution.xy ); |
| 27 | |
Skyler Grey | 69974aa | 2022-05-25 12:06:19 +0100 | [diff] [blame] | 28 | float r = 0.0; |
Skyler Grey | 397535e | 2022-05-25 11:47:09 +0100 | [diff] [blame] | 29 | float g = 0.0; |
| 30 | float b = 0.0; |
| 31 | |
Skyler Grey | 5d50f26 | 2022-05-25 20:40:34 +0100 | [diff] [blame] | 32 | float sampleSqrt = 3.0; |
Skyler Grey | 69974aa | 2022-05-25 12:06:19 +0100 | [diff] [blame] | 33 | |
Skyler Grey | 5d50f26 | 2022-05-25 20:40:34 +0100 | [diff] [blame] | 34 | for (float x = 0.0; x < sampleSqrt; x++) { |
Skyler Grey | 69974aa | 2022-05-25 12:06:19 +0100 | [diff] [blame] | 35 | for (float y = 0.0; y <= sampleSqrt; y++) { |
Skyler Grey | 397535e | 2022-05-25 11:47:09 +0100 | [diff] [blame] | 36 | vec3 color = color_for_position( |
| 37 | vec2( |
Skyler Grey | 69974aa | 2022-05-25 12:06:19 +0100 | [diff] [blame] | 38 | (x / (resolution.x * sampleSqrt)) + position.x, |
| 39 | (y / (resolution.y * sampleSqrt)) + position.y |
Skyler Grey | 397535e | 2022-05-25 11:47:09 +0100 | [diff] [blame] | 40 | ) |
| 41 | ); |
| 42 | r += color.x; |
| 43 | g += color.y; |
| 44 | b += color.z; |
| 45 | } |
| 46 | } |
| 47 | |
Skyler Grey | 69974aa | 2022-05-25 12:06:19 +0100 | [diff] [blame] | 48 | r /= sampleSqrt * sampleSqrt; |
| 49 | g /= sampleSqrt * sampleSqrt; |
| 50 | b /= sampleSqrt * sampleSqrt; |
Skyler Grey | 397535e | 2022-05-25 11:47:09 +0100 | [diff] [blame] | 51 | |
| 52 | gl_FragColor = vec4(vec3(r, g, b), 1.0); |
Skyler Grey | 3eef73c | 2022-05-25 10:41:04 +0100 | [diff] [blame] | 53 | } |