Home / Software Engineering / Shader Programming
New comment
// Started here
// Spent about two hours tinkering around and produced the following.
// Enjoy 😊
#ifdef GL_ES precision mediump float; #endif uniform float time; uniform vec2 resolution; uniform sampler2D backbuffer; #define PI 3.14159 void main(){ vec2 p = (gl_FragCoord.xy - 0.5 * resolution) / min(resolution.x, resolution.y); vec2 t = vec2(gl_FragCoord.xy / resolution); vec3 c = vec3(0); for(int i = -6; i <= 6; i++) { if (i == 0) continue; float t = float(i) * time / 6.; float x = cos(t*1.618033989) * 4.; float y = sin(t*PI*.25) * 3.; vec2 o = .1 * vec2(x, y); vec2 o2 = .1 * vec2(y * 1.5, x * 1.); vec2 om = -o; vec2 o2m = -o2; float r = (fract(x)) * .45; float g = (1.0 - r) * .3; c += 0.005 / (length(p-o)) * vec3(r, g, .5); c += 0.005 / (length(p-om)) * vec3(r, g, .5); c += 0.002 / (length(p-o2) * .4) * vec3(g,.25, r); c += 0.002 / (length(p-o2m) * .4) * vec3(g,.25, r); } gl_FragColor = vec4(c, 1); }
Visualize the math
// Started here
// Spent about two hours tinkering around and produced the following.
// Enjoy 😊