Hi gang;
I too, like Ker2X, am trying to learn how to generate the Mandelbulb, through studying and learning source code (I understand that much better than algorithms).
I have been working with the previously posted code and understanding how it works, as well as adapting it for my own purposes.
I would love any help and suggestions on how to continue developing this further. Building a raytracer would be an amazing experience but that is far beyond my capabilities (I'm primarily an artist and only secondarily a programmer - the two don't mix!).
The first thing I did was take ker2X's great code and try to optimize it by removing the random sampling part and instead convert it to a pixel by pixel ray marcher.
for(y = 0; y < Y; y++)
for(x = 0; x < X; x++) {
xx = 2.0* ((float)x/(float)X) -1.0;
yy = 2.0* ((float)y/(float)Y) -1.0;
zz = -4.0;
In other words, march a ray from every screen pixel and draw the fractal that way. Although it is far faster (you don't end up using duplicate rays), it presents some problems which I can't figure out:
This is a render of the MB using 2 iterations only and it shows these black speckles. They are present in any iteration count but this one is the clearest to see. I think this is because those points are not being rendered but I don't understand why since a ray is being marched from every pixel. In theory, it shouldn't miss any points.
I had a hunch it was something to do with the bounding box:
xx = 2.0* ((float)x/(float)X) -1.0;
yy = 2.0* ((float)y/(float)Y) -1.0;
So I started experimenting with a larger one to see if that was the problem. For the next image, I tried:
xx = 4.0* ((float)x/(float)X) -2.0;
yy = 4.0* ((float)y/(float)Y) -2.0;
And then:
xx = 8.0* ((float)x/(float)X) -4.0;
yy = 8.0* ((float)y/(float)Y) -4.0;
So it looks like those are spaces in between the pixels that I'm tracing? Is this the cause of the speckling I'm getting in the first image? I tried the opposite and minimized the bounding box to a smaller than usual value and the black speckles became fewer.
Anyway, I suppose my first question is: Am I doing this the right way? If I want to trace a ray from each pixel to draw a clean MB? If so, why am I getting these artifacts?
Thanks in advance for any suggestions and help. I am really looking forward to learning how to do this with some of your much appreciated help!
-Rich