#version 330 core
in vec4 fcolor;
in vec2 fTexCoord;
in vec2 fCoord;
uniform int maxIterations;
uniform sampler1D mandiTexture;
uniform vec2 center;
uniform float scale;
out vec4 color;
void main()
{
float ONE_OVER_LOG_TWO = 1.0f/0.69314718055f;
vec2 c, z;
vec4 colora, colorb;
c.x = (fCoord.x * scale) + center.x;
c.y = (fCoord.y * scale) + center.y;
int i;
z = vec2(0.0f, 0.0f);
float size, smoothed, colorI;
for(i=0; i< maxIterations; i++) {
float x = (z.x * z.x - z.y * z.y) + c.x;
float y = (z.y * z.x + z.x * z.y) + c.y;
if((x * x + y * y) > (1 << 30))
{
break;
}
z.x = x;
z.y = y;
}
vec4 tcolor;
if (i == maxIterations)
{
tcolor = vec4(0.0f, 0.0f, 0.0f, 1.0f);
}
else
{
float tr, tg, tb;
float t = float(i)/float(maxIterations);
tr = (9*(1-t)*t*t*t);
tg = (15*(1-t)*(1-t)*t*t);
tb = (8.5*(1-t)*(1-t)*(1-t)*t);
tcolor = vec4(tr, tg, tb, 1.0f);
}
color = tcolor;
}