#version 330
// #pragma optionNV (unroll 1)
#define show_vec
#define SEG 32
#define n 100.
#define PI 3.1415
in vec2 UVo;
uniform float time;
uniform int OPTIONS;
out vec4 fragColor;
vec3 tuljava (vec3 pz, float R) {
float dr = 2. * PI / float(SEG);
vec3 sum = vec3(0);
for (int i = 0; i < SEG; i++){
float theta = dr * float(i);
vec3 dl = vec3(0,cos(theta),-sin(theta))*dr*R;
vec3 r = vec3(0,sin(theta),cos(theta))*R;
r+=pz;
sum+=cross(dl,r)/(length(r)*length(r)*length(r));
}
sum *= 1e-6;
return sum;
}
void main () {
float I = -.5;
float R = 0.8;
float R2 = (abs(sin((time+8.2)/.6))+0.5)*0+R;
vec2 uv = UVo;
vec2 poz = vec2(uv*2.); // zavrteti moramo tako točke same, kot tudi
vec2 offset = vec2(R/2.,0); // njihove komponente
float kot = time/.4;
float multi = n*I/**abs(sin(time/.2)+0.2)*/;
vec2 dodatek = vec2(sin(time/.6)*.5, cos(time/.4)*.6)*0;
vec3 rez = tuljava(
vec3(poz+offset, 1/2*R), R
)*n*I +
tuljava(
vec3(
vec2(poz-offset+dodatek)*
mat2( cos(kot),
sin(kot), -sin(kot),
cos(kot)
),
1/2*R
),
R2
)*multi*mat3( cos(kot),
sin(kot),
0,
-sin(kot),
cos(kot),
0,
0,
0,
1);
rez *= 1000.;
#ifdef show_vec
fragColor = vec4(rez+0.5, 1);
#else
fragColor = vec4(vec3(length(rez)), 1);
#endif
}
/*
uniform float time;
uform int OPTIONS;
//uniform mat2 bounds;
out vec4 frag_colour;
void main() {
vec2 UV = UVo;
float scale = 1.1;
vec2 complex=UV*scale;
vec2 ot=vec2(0);
int tmpy=OPTIONS;
for (int x = 0; x < 16; x++){
ot=vec2(complex.x*ot.x-complex.y*ot.y,complex.x*ot.y+complex.y*ot.x);
int swch = tmpy & 1;
ot+=complex * (swch*2-1);
tmpy>>=1;
}
frag_colour = vec4(vec3(smoothstep(.05,0,length(ot))), 1.);
}
*/