diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2024-05-21 01:35:20 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2024-05-21 01:35:20 +0300 |
commit | 7c26dcc4480025b5d11e315273541b3fb2c34a09 (patch) | |
tree | 0fe3f3ff8cdd0d728f15f6cec4cca4d39aa8cb71 /src/shader.frag | |
parent | 9ead62940aecb7793b3d82c9c8eb73bc9eb4f60f (diff) | |
download | cgame-7c26dcc4480025b5d11e315273541b3fb2c34a09.tar.gz cgame-7c26dcc4480025b5d11e315273541b3fb2c34a09.tar.bz2 cgame-7c26dcc4480025b5d11e315273541b3fb2c34a09.zip |
ez going
Diffstat (limited to 'src/shader.frag')
-rw-r--r-- | src/shader.frag | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/shader.frag b/src/shader.frag index 7c5b0e7..cad317c 100644 --- a/src/shader.frag +++ b/src/shader.frag @@ -1,9 +1,34 @@ #version 450 layout(location = 0) in vec3 fragColor; +layout(location = 1) in vec2 fragPos; layout(location = 0) out vec4 outColor; +// void main() { +// outColor = vec4(fragColor, 1.0); +// } +vec3 mandel(vec2 z0) { + float k = 0.0; + vec2 z = vec2(0.0); + for(int i = 0; i < 420; ++i) { + z = vec2(z.x*z.x-z.y*z.y, z.x*z.y*2.0) + z0; + if (length(z) > 20.0) break; + k += 1.0; + } + float mu = k + 1.0 - log2(log(length(z))); + return sin(mu*0.1 + vec3(0.0,0.5,1.0)); +} void main() { - outColor = vec4(fragColor, 1.0); + float ar = fragPos.x / fragPos.y; + vec2 uv = gl_FragCoord.xy / fragPos.yy - vec2(0.66 * ar, 0.5); + //uv = uv * 2.0 + vec2(-0.3, 1.0); + float p = 30.0; + float t = mod(13.0, p); + if (t > p/2.0) t = p - t; + float scale = 0.5 + pow(4.0, t); + vec2 offset = vec2(-1.36799, .01); + uv += offset*scale; + uv /= scale; + outColor = vec4(mandel(uv), 1.0); } |