Page 1 of 1

GLSL Mandelbrot

Posted: Thu Jan 05, 2017 10:35 pm
by GijsB
Explore the wonders of floating point precision errors.

All mouse controlled, you can even change the render resolution for screenshots :).

http://www.iquilezles.org/www/articles/ ... smooth.htm

Re: GLSL Mandelbrot

Posted: Thu Jan 05, 2017 11:24 pm
by raidho36
Amazingly enough it runs pretty deep before it breaks down.

Re: GLSL Mandelbrot

Posted: Fri Jan 06, 2017 3:15 am
by pgimeno
Very cool. I take it it's single precision, right? It would be nice if it zoomed towards the mouse instead of using keys, à la Xaos.

Is there any reason why some mini-Mandelbrots are blue instead of black?

Re: GLSL Mandelbrot

Posted: Fri Jan 06, 2017 4:27 am
by raidho36
I take it that has to do with smoothing function edge cases; messing around with maximum number of iterations produces a lot of glitches of this sort.

Re: GLSL Mandelbrot

Posted: Fri Jan 06, 2017 1:20 pm
by GijsB
raidho36 wrote:
pgimeno wrote:Very cool. I take it it's single precision, right? It would be nice if it zoomed towards the mouse instead of using keys, à la Xaos.

Is there any reason why some mini-Mandelbrots are blue instead of black?
I take it that has to do with smoothing function edge cases; messing around with maximum number of iterations produces a lot of glitches of this sort.
This is correct, however I don't understand the actual mechanics myself. If you want to get rid the of blue mini-brots change the iterations to 200, for example :

Re: GLSL Mandelbrot

Posted: Fri Jan 06, 2017 3:46 pm
by zorg
viewtopic.php?f=14&t=83267
Just gonna leave this here as well, to compare and whatnot :3

Re: GLSL Mandelbrot

Posted: Fri Jan 06, 2017 4:43 pm
by pgimeno
Thanks for the clarification on the mini-Mandelbrot colour.

I said:
pgimeno wrote:It would be nice if it zoomed towards the mouse instead of using keys, à la Xaos.
And here's a function to do that:

Code: Select all

local function PanTowardMouse(oldzoom, newzoom)
  local mx, my = love.mouse.getPosition()
  -- Transform mouse coords to unzoomed graphic axes
  mx = (mx * 2 - Width) * 1.5 / Height
  my = (my * 2 - Height) * 1.5 / Height

  -- Calculate new centre so that the mouse remains in the same place
  Pan.x = Pan.x + mx * oldzoom - mx * newzoom
  Pan.y = Pan.y + my * oldzoom - my * newzoom
end
Just insert this before setting the new zoom on click:

Code: Select all

                PanTowardMouse(Zoom, Zoom/ZoomSpeed) -- (before Zoom = Zoom/ZoomSpeed)
                ...
                PanTowardMouse(Zoom, Zoom*ZoomSpeed) -- (before Zoom = Zoom*ZoomSpeed)

Re: GLSL Mandelbrot

Posted: Fri Jan 06, 2017 4:52 pm
by GijsB
pgimeno wrote:Thanks for the clarification on the mini-Mandelbrot colour.

I said:
pgimeno wrote:It would be nice if it zoomed towards the mouse instead of using keys, à la Xaos.
And here's a function to do that:

Code: Select all

local function PanTowardMouse(oldzoom, newzoom)
  local mx, my = love.mouse.getPosition()
  -- Transform mouse coords to unzoomed graphic axes
  mx = (mx * 2 - Width) * 1.5 / Height
  my = (my * 2 - Height) * 1.5 / Height

  -- Calculate new centre so that the mouse remains in the same place
  Pan.x = Pan.x + mx * oldzoom - mx * newzoom
  Pan.y = Pan.y + my * oldzoom - my * newzoom
end
Just insert this before setting the new zoom on click:

Code: Select all

                PanTowardMouse(Zoom, Zoom/ZoomSpeed) -- (before Zoom = Zoom/ZoomSpeed)
                ...
                PanTowardMouse(Zoom, Zoom*ZoomSpeed) -- (before Zoom = Zoom*ZoomSpeed)
Great! Thanks, added it! :)

Re: GLSL Mandelbrot

Posted: Thu Feb 02, 2017 1:19 pm
by GijsB
Added my GUI library, you can now change the render resolution for screenshots