uniform sampler2D tex;
uniform float cellSize;
void main(void)
{
	
	vec2 thisTCoord=vec2(gl_TexCoord[0]);

        float cellSizeR = (cellSize-100.0)*0.5;
        if(cellSize==0.0)
         cellSizeR=300.0;
        thisTCoord *= (cellSizeR);
        thisTCoord.x += sin(thisTCoord.x -12.0)*cellSize/30.0;
        thisTCoord.y += cos(thisTCoord.y -12.0)*cellSize/30.0;

        thisTCoord = ceil (thisTCoord);
                thisTCoord /=(cellSizeR);	
        vec4 value = texture2D(tex,thisTCoord);
	gl_FragColor = value;
}

