GLSL Mandelbrot

Show off your games, demos and other (playable) creations.
Post Reply
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

GLSL Mandelbrot

Post 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
Attachments
Mandelbrot GLSL.love
V.4
(3.15 KiB) Downloaded 220 times
1485728623.png
1485728623.png (13.74 MiB) Viewed 6984 times
Last edited by GijsB on Thu Feb 02, 2017 1:24 pm, edited 6 times in total.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: GLSL Mandelbrot

Post by raidho36 »

Amazingly enough it runs pretty deep before it breaks down.
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: GLSL Mandelbrot

Post 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?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: GLSL Mandelbrot

Post 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.
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: GLSL Mandelbrot

Post 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 :
Attachments
Mandelbrot GLSL.love
(1.36 KiB) Downloaded 186 times
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: GLSL Mandelbrot

Post by zorg »

viewtopic.php?f=14&t=83267
Just gonna leave this here as well, to compare and whatnot :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: GLSL Mandelbrot

Post 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)
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: GLSL Mandelbrot

Post 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! :)
Attachments
Mandelbrot GLSL.love
(1.89 KiB) Downloaded 174 times
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: GLSL Mandelbrot

Post by GijsB »

Added my GUI library, you can now change the render resolution for screenshots
Attachments
Mandelbrot GLSL.love
V.4
(3.15 KiB) Downloaded 170 times
1486041183.png
1486041183.png (12.71 MiB) Viewed 6985 times
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 7 guests