PDA

View Full Version : Mandelbrot zoom makes screen black after 0.1f zoom, how to fix it?



kamhagh
01-06-2015, 08:42 AM
first this is my Fragment shader, i assume its the only code needed:

#version 330 core

out vec4 pixelColor;
in vec2 coord;

uniform sampler1D Pallet;

uniform float Zoom;
uniform vec2 Move;

uniform int MaxIterations;

void main()
{
float real = (coord.x + Move.x) * Zoom; // adding Zoom
float imag = (coord.y + Move.y) * Zoom;

float Creal = real;
float Cimag = imag;

float r2 = 0.0;

float iter;

for (iter = 0.0; iter < MaxIterations && r2 < 4.0; ++iter)
{
float tempreal = real;

real = (tempreal * tempreal) - (imag * imag) + Creal;
imag = 2.0 * tempreal * imag + Cimag;
r2 = (real * real) + (imag * imag);
}

vec4 color;

highp int iterint = int(iter);

//color.y = (iter == MaxIterations ? 0.0 : iter) / 100.0;
//color.xz = vec2(0.0f);
color = texture1D(Pallet, (iter == MaxIterations ? 0.0 : iter) / 100.0);

pixelColor = vec4(color.xyz, 1.0);
}

when zoom uniform reaches 0.1f my screen goes completely black ! And not my main problem but image moves towards middle when i zoom, and i don't want it to, how can i fix that too?