Home | History | Annotate | Download | only in Debug
      1 uniform float t;
      2 varying vec4 vTexCoord;
      3 
      4 const float BLOWUP=66.0; /* 86.0 */
      5 const float MAXSTEPSHIFT=8.0; /* 6.0 */
      6 const int MAXITERS=34; /* 26 */
      7 
      8 const float pi=3.1415926535;
      9 
     10 float sum(vec3 v) { return v.x+v.y+v.z; }
     11 
     12 int func(vec3 pos,float stepshift)
     13 {
     14 	vec3 v2=abs(fract(pos)-vec3(0.5,0.5,0.5))/2.0;
     15 	float r=0.0769*sin(t*-0.0708);
     16 	float blowup=BLOWUP/pow(2.0,stepshift+8.0);
     17     
     18 	if(sum(v2)-0.1445+r<blowup) return 1;
     19 	v2=vec3(0.25,0.25,0.25)-v2;
     20 	if(sum(v2)-0.1445-r<blowup) return 2;
     21     
     22 	int hue;
     23 	float width;
     24 	if(abs(sum(v2)-3.0*r-0.375)<0.03846)
     25 	{
     26 		width=0.1445;
     27 		hue=4;
     28 	}
     29 	else
     30 	{
     31 		width=0.0676;
     32 		hue=3;
     33 	}
     34     
     35 	if(sum(abs(v2.zxy-v2.xyz))-width<blowup) return hue;
     36     
     37 	return 0;
     38 }
     39 
     40 void main()
     41 {
     42 	float x=vTexCoord.x*0.5;
     43 	float y=vTexCoord.y*0.5;
     44     
     45 	float sin_a=sin(t*0.00564);
     46 	float cos_a=cos(t*0.00564);
     47     
     48 	vec3 dir=vec3(x,-y,0.33594-x*x-y*y);
     49 	dir=vec3(dir.y,dir.z*cos_a-dir.x*sin_a,dir.x*cos_a+dir.z*sin_a);
     50 	dir=vec3(dir.y,dir.z*cos_a-dir.x*sin_a,dir.x*cos_a+dir.z*sin_a);
     51 	dir=vec3(dir.y,dir.z*cos_a-dir.x*sin_a,dir.x*cos_a+dir.z*sin_a);
     52     
     53 	vec3 pos=vec3(0.5,1.1875,0.875)+vec3(1.0,1.0,1.0)*0.0134*t;
     54     
     55 	float stepshift=MAXSTEPSHIFT;
     56     
     57 	if(fract(pow(x,y)*t*1000.0)>0.5) pos+=dir/pow(2.0,stepshift);
     58 	else pos-=dir/pow(2.0,stepshift);
     59     
     60 	int i=0;
     61 	int c;
     62 	do
     63 	{
     64 		c=func(pos,stepshift);
     65 		if(c>0)
     66 		{
     67 			stepshift+=1.0;
     68 			pos-=dir/pow(2.0,stepshift);
     69 		}
     70 		else
     71 		{
     72 			if(stepshift>0.0) stepshift-=1.0;
     73 			pos+=dir/pow(2.0,stepshift);
     74 			i++;
     75 		}
     76 	}
     77 	while(stepshift<MAXSTEPSHIFT&&i<MAXITERS);
     78     
     79     
     80 	vec3 col;
     81 	if(c==0) col=vec3(0.0,0.0,0.0);
     82 	else if(c==1) col=vec3(1.0,0.5,0.0);
     83 	else if(c==2) col=vec3(0.0,1.0,0.0);
     84 	else if(c==3) col=vec3(1.0,1.0,1.0);
     85 	else if(c==4) col=vec3(0.5,0.5,0.5);
     86     
     87 	gl_FragColor=vec4(col*(1.0-(float(i)-stepshift)/32.0),1.0);
     88 }
     89