#version 330 #pragma optionNV (unroll 1) #define show_vec #define SEG 32 #define R .8 #define I .5 #define n 100. #define PI 3.1415 in vec2 UVo; uniform float time; uniform int OPTIONS; out vec4 fragColor; vec3 tuljava (vec3 pz) { float dr = 2. * PI / float(SEG); vec3 sum = vec3(0); for (int i = 0; i < SEG; i++){ float theta = dr * float(i); // jebi se, zakaj neza? pisat ?ita linearno >:( 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 () { vec2 uv = UVo; vec3 poz = vec3(uv*2.,sin(time/10.)*R); vec3 offset = vec3(R/2.,0,0); vec3 rez = tuljava(poz+offset)*n*I + tuljava(poz-offset)*n*I; rez *= 1000.; #ifdef show_vec fragColor = vec4(rez, 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.); } */