uniform float minReal; uniform float maxReal; uniform float minImag; uniform float maxImag; uniform int iterations; // Utilities // Lerping float lerp(float a, float b, float ratio) { return a * (1.0-ratio) + b * ratio; } vec2 lerp2(vec2 a, vec2 b, float ratio) { return a * (1.0-ratio) + b * ratio; } void main() { // The complex constant c vec2 c = vec2(lerp(minReal, maxReal, gl_TexCoord[0].x), lerp(minImag, maxImag, gl_TexCoord[0].y)); // declaration of the iterative obj Z vec2 z; // funciton of a mandelbrot set is as such: // Zn+1 = Zn^2 + c // We determine if Zn approaches infinity to // determine whether or not the ucrrent point/pixel // is in the set or not. bool isInside = true; int iIterations = 0; for (int i=0; i 4.0) { // We're approaching infinity! // This is not in the set iIterations = i; isInside = false; break; } } if (isInside) { // In the set gl_FragColor = vec4(0,0,0,1); } else { // out of the set gl_FragColor = vec4(float(iIterations)/float(iterations),0,0,1); } }