text: #version 330 core
  in vec4 v;out vec4 f;uniform float e;uniform vec4 d[160];const int k=80;const vec3 i=normalize(vec3(1.,1.1,1.));const float z=99999.;float t(float z,vec3 v,vec3 e,vec3 i,float f,int d,out vec3 x,out vec3 o,out int y){vec3 w=i-e;float k=dot(w,v);if(k<0.)return z;else{float p=length(w),s=p*p-k*k;if(s>f)return z;else{float t=sqrt(f-s),c=k-t;if(c<z)return x=e+c*v,o=normalize(x-i),y=d,c;else return z;}}}bool t(vec3 v,vec3 e,vec3 z,float f){vec3 i=z-e;float k=dot(i,v);if(k<0.)return false;else{float p=length(i),o=p*p-k*k;if(o>f)return false;else return true;}}float t(vec3 i,vec3 v,float f,out vec3 e,out vec3 x){if(i.y>=0.)return z;float k=(f-v.y)/i.y;x=vec3(0.,1.f,0.f);e=v+i*k;return k;}float t(float i,vec3 v,vec3 f){float e=(1.-i)/(1.+i);e*=e;float z=-dot(v,f),k=1.-z,o=e+(1.-e)*k*k*k*k*k;return o;}const vec3 x=vec3(5e-06,1.5e-05,.00027)*15.,o=vec3(.00015,.00015,.00027)*15.;vec3 t(float e){return exp(-e*(x+o));}vec3 t(float i,float v){vec3 k=4.*vec3(27.,4.,1.)/pow(i,4.);return k;}vec3 p(float i,float v){float k=.0003/16.*3.14159*(1.+v*v);vec3 f=vec3(1./(x.x+o.x)*(1.-exp(-i*o.x)),1./(x.y+o.y)*(1.-exp(-i*o.y)),1./(x.z+o.z)*(1.-exp(-i*o.z)));float e=.476;vec3 z=vec3(.002,.0008,.0002)*(1.-e)*(1.-e)/(12.5664*pow(1.+e*e-2.*e*v,1.5));float p=20./(x.x+o.x)*(1.-exp(-i*o.x));return k*f+z*p;}void main(){vec2 x=vec2(.5,.5);float o=e*2.,c=(30.*o-45.*cos(o)+cos(3.*o)-9.*sin(2.*o))/96.;c+=e*.1;vec2 w=v.xy/1200.,s=2.*(w-x);vec3 r=vec3(s,-39.);float y=c/3.+e*.2;mat3 n=mat3(cos(y),0,-sin(y),0,1,0,sin(y),0,cos(y));vec3 u=n*vec3(0,0,-40.),b=normalize(n*r-u);float m=1.;vec3 l=vec3(0,0,0);for(int a=2;a>0;a--){vec3 h,g,q,Z;float Y,X=0.;int W=-1;float V=z,U=0.;V=t(b,u,-18.,q,g);if(V<=z){Y=1.77;Z=vec3(.05,.05,.05);if((int(q.x/5.)+int(q.z/5.)&1)==1){float T=q.x*q.x+q.z*q.z;Z=mix(Z,vec3(.59,.6,.5),smoothstep(8000.,4000.,T));}}else Z=vec3(1.,1.,0.);for(int T=0;T<k;T++){vec3 S=vec3(0.,0.,0.)*float(T);V=t(V,b,u,d[T*2].xyz,d[T*2].w,T,q,g,W);}if(W>=0)Z=d[W*2+1].xyz,Y=d[W*2+1].w,X=t(Y,g,b),h=reflect(b,g);vec3 T=vec3(0,0,0);if(V>=z){T+=p(V,dot(i,b));l+=T*m;break;}for(int S=0;S<1;S++){bool R=false;for(int Q=0;Q<k;Q++){if(t(i,q,d[Q*2].xyz,d[Q*2].w)){R=true;break;}}if(!R){vec3 Q=reflect(-i,g),P=-b;float O=dot(i,g);vec3 N=normalize(P+i);float M=pow(dot(g,N),121.);M=clamp(M,0.,1.);vec3 L=Z*O;T+=vec3(M,M,M)+L;}else T+=Z*.02;}T*=t(V);if(W!=0)T+=t(V,dot(i,b));T+=p(V,dot(i,b));l+=T*m*(1.-X);m=m*X;b=h;u=q;if(W==-1){break;}}vec3 V=pow(l,vec3(1./2.2));f=vec4(V,1.);}