The sequel you've been clamoring for! Welcome to:

ROBOTS DREAM OF MANDELBROT 2: ELECTRIC BOOGALOO

Controls

WASD / ZQSD / IJKLPan Camera
Up / Down Arrow KeysIncrease / Decrease Iterations
Left / Right Arrow KeysIncrease / Decrease C
Mouse Scroll WheelZoom In / Out
RRestart Game
F11Toggle Fullscreen (Windows only)
EscapeClose Game (Windows)

While still slower the higher the iterations count, depending on your hardware, and while still an HTML5 made in GameMaker, this Mandelbrot Set program is astronomically faster than my previous Mandelbrot Set program. Why? Because this program uses shaders! Well, one single shader, but still. While it may look nearly identical, this program works entirely differently than my previous program, which manually calculated the color of each pixel in normal processor code as a simple first attempt. This does the exact same math but in a GLSL shader, with some optimizations.

I could likely optimize the shader further, especially if I removed the variable iteration count control, but I'm very happy with this. It's instantaneous no matter how many iterations there are on my machine (under 10,000), though it may be slower if you have slower hardware. It is still made in GMS2 and running in HTML5 / JavaScript, so it's inherently going to be somewhat slow.

The HTML5 build is limited to 10,000 in its max iteration count due to how JS compiles GLSL shaders (for-loop needed a constant comparison), but the Windows version is unlimited in the iteration count, however it does slow down after 10,000 anyway as when you start to get up to the 20, 40, 80K+ range it really slows down for minimal improvements.

DOWNLOAD WINDOWS VERSION FOR MAX SPEED! (obviously...)

I also made the zooming work properly, automatically adjusting the pan position so that whatever was in the center of the screen remains in the center of the screen when you zoom in and out, infinitely. This was VERY difficult and annoying (hence why it wasn't in the first version), but I'm very proud that I got it working.

About

This was made in GameMaker Studio 2 in a few hours as a quick follow-up to my first Mandelbrot Set program that I made for Trijam 78. It uses GLSL shaders as stated above.

The sound effects are from the free UI sound Kenney sound pack.

Download

Download NowName your own price

Click download now to get access to the following files:

RobotsDreamOfMandelbrot2_Windows_v100.zip 1 MB

Comments

Log in with itch.io to leave a comment.

(+1)

real good implementation! 

(+1)

Thank you so much!

It does work well even on a cruddy intel chip, however you can't go very deep before it just shows pixels.
BTW. Androids do indeed dream of 3D fractal flames https://electricsheep.org

Yeah there's a hard limit to how much a shader can render there due to the inherent limits of a floating-point number. When you start to see the pixels / how the more you zoom in the less detail you get, that's because the float is approaching 0. The code to get the pixel coordinates in the shader is:

float xx = (gl_FragCoord.x / u_fZoom) + u_fPan.x;

float yy = (gl_FragCoord.y / u_fZoom) + u_fPan.y;

So the bigger zoom is, the closer the float is reduced to 0 and eventually you lose information as the variable can only hold so many bytes.

All equivalent fractal shaders do this. See here how this Mandelbrot Set shader on Shadertoy (which houses much better / smarter shader programmers than I) zooms in, and you can start to see the set become pixelated, so instead of zooming in all the way they turn around and zoom back out.

https://www.shadertoy.com/view/4df3Rn

I just give you full control to zoom in-or-out as much as you like. But also check out the zoom number, as you have to zoom-in a LOT to get to the pixels, I just made the scroll wheel double the zoom value every scroll tick, so you get to really big numbers really fast like Sissa ibn Dahir.

(+1)

this is amazing

Thank you!

(+1)

Wow, this is really fast! I can zoom in all the way down to pixel size.

Indubitably

I actually don't really know why it eventually stops at the pixel-level. That is a ridiculously close zoom, but I thought it would continue forever at the same quality / detail no matter how far you zoomed-in. I'm going to ask some friendly shader gurus if they know why...

My educated guess was correct and the shader gurus confirmed that there's no way to fix it, it's just the hard limit of float-values haha...