00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 uniform sampler2D texture;
00015 varying vec4 texc;
00016 uniform int width;
00017 uniform int height;
00018 uniform float zoom;
00019 uniform float posx;
00020 uniform float posy;
00021 uniform int max_iter;
00022 uniform float real;
00023 uniform float imag;
00024 uniform int smoothcolors;
00025 uniform float dilatation;
00026
00027 void main(void)
00028 {
00029 float ratio = float(width)/height;
00030 float newWidth = ratio*512.0;
00031 float newHeight = 512.0;
00032 float x0b;
00033 float y0b;
00034
00035 float x0 = texc.x;
00036 float y0 = texc.y;
00037 x0b = ratio*512.0*x0/width;
00038 y0b = 512.0*y0/height;
00039 int iter = 0;
00040 float x = (x0b-newWidth/2.0)*zoom+posx;
00041 float y = (y0b-newHeight/2.0)*zoom+posy;
00042 float xtemp;
00043 while (x*x + y*y <= (2*2) && iter < max_iter)
00044 {
00045 xtemp = x*x - y*y + real;
00046 y = 2*x*y + imag;
00047 x = xtemp;
00048 iter++;
00049 }
00050
00051 if ( iter == max_iter )
00052 {
00053 gl_FragColor = vec4(0,0,0,1);
00054 }else{
00055 float val = iter;
00056 if (smoothcolors==1)
00057 {
00058 val = val-log2(log2(sqrt(x*x+y*y)));
00059 }
00060 val = (sin(val/dilatation)+1.0)*0.5;
00061 gl_FragColor = texture2D(texture,vec2(val,val));
00062 }
00063 }