Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411613 Posts in 69390 Topics- by 58447 Members - Latest Member: sinsofsven

May 10, 2024, 02:08:25 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Real time mandelbulb / fractal rendering thread
Pages: [1]
Print
Author Topic: Real time mandelbulb / fractal rendering thread  (Read 6669 times)
Zaphos
Guest
« on: December 04, 2009, 07:07:56 PM »

I just saw this awesome thing: http://www.icare3d.org/blog_techno/gpu/gigabroccoli_the_mandelbulb_into_gigavoxels.html

Also go to the site he links: http://www.skytopia.com/project/fractal/mandelbulb.html
And maybe also here: http://www.bugman123.com/Hypercomplex/index.html

Fact: These are really cool!  I want to fly around mandelbulbs interactively so much ... I want to fly around a galaxy of them ...

Anyone played with cuda and/or rendering voxel octree type structures?  Any thoughts on implementing this sort of thing?

(edit: I admit, mostly I am posting because they look cool.  So, I should put a picture ...
- this one's from http://www.skytopia.com/project/fractal/mandelbulb.html ... also, feel free to post about other awesome fractals Smiley)
« Last Edit: December 04, 2009, 07:27:15 PM by Zaphos » Logged
PGGB
Level 8
***



View Profile
« Reply #1 on: December 05, 2009, 05:48:18 AM »

I'm pretty sure that computers are still not fast enough to render this in realtime.
Logged
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #2 on: December 05, 2009, 06:24:08 AM »

Fractals are very difficult to render, as there's little you can do to approximate them.

I believe a few fractals are very amenable to efficient raytracing, though, like the menger sponge.
Logged
increpare
Guest
« Reply #3 on: December 05, 2009, 06:45:14 AM »

Fractals are very difficult to render, as there's little you can do to approximate them.
In what sense might there be approximation difficulties?  They are defined by recursion, with the renderers usually stopping after (at most) n steps for each volume element.

(To render an arbitrary portion is more difficult, for sure; I'm pretty sure you always have to start at the topmost portion)
Logged
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #4 on: December 05, 2009, 07:48:16 AM »

Mandelbrot (and presumeably mandelbulb) is not defined by recursion. It's defined by a function which tells you if it is solid at a given point or not. Fortunately, this function also has a "cutoff" parameter (the number of iterations before giving up), but that still gives you a function of solidity, which needs to be approximated (e.g. marching cubes). As interesting fractals have a high level of detail, this is hard to do well.

You generally can evaluate just a portion though - that's why you can get programs to easily zoom in indefinitely on a mandelbrot.

Edit: Wikipedia disagrees with me on recursion (as side-effect free iteration is a form of recursion). So let me clarify that the mandelblot is not based on spatial recursion - you don't calculate it by approximating it, and then shrinking multiple approximations and adding them. So you don't have a canonical sequence of increasingly good approximations.
« Last Edit: December 05, 2009, 07:51:32 AM by BorisTheBrave » Logged
increpare
Guest
« Reply #5 on: December 05, 2009, 08:00:21 AM »

So you don't have a canonical sequence of increasingly good approximations.
If I give you a particular approximation, can't you use at least some of that data when building the next part? (admittedly maybe not much : P )

Quote
You generally can evaluate just a portion though - that's why you can get programs to easily zoom in indefinitely on a mandelbrot.
Most mandlebrot zoomers I've seen just break once you get to a certain magnification.  I haven't looked into the math too much, but I'm guessing it's very difficult to keep very large or very small numbers from appearing.
Logged
brog
Level 7
**



View Profile WWW
« Reply #6 on: December 05, 2009, 08:04:54 AM »

Most mandlebrot zoomers I've seen just break once you get to a certain magnification.  I haven't looked into the math too much, but I'm guessing it's very difficult to keep very large or very small numbers from appearing.

Generally they just use floats, and at some zoom that becomes relevant.  The alternative is to be slow, I guess.
Logged
increpare
Guest
« Reply #7 on: December 05, 2009, 08:07:51 AM »

Generally they just use floats, and at some zoom that becomes relevant.  The alternative is to be slow, I guess.
Oh maybe that's not the issue at all actually.  I guess generally when you're zooming in, you're zooming i on more detailed areas: more detail=more iterations, so it'll take longer to calculate.  I don't know of any zoomerrrs that take fractal symmetries (which are invariably non-trivial and fractal-specific) into account to achieve a bound on the number of iterations.
« Last Edit: December 05, 2009, 08:10:59 AM by increpare » Logged
brog
Level 7
**



View Profile WWW
« Reply #8 on: December 05, 2009, 08:10:52 AM »

This is a point; any fixed number of iterations is going to miss out a lot of detail when you zoom in enough.
Logged
LemonScented
Level 7
**



View Profile
« Reply #9 on: December 05, 2009, 08:17:40 AM »

You can do some fractals in realtime on the GPU now: NVidia's CUDA (http://www.nvidia.com/object/cuda_home.html) comes with an example of a realtime Mandelbrot explorer:

- as people have been discussing, the detail breaks down at the limit of floating point accuracy. The demo can switch up to double precision but that's much slower. Hopefully before too long, OpenMP should become a more widely adopted and available standard, which means that you'll be able to program stuff in such a way that it's not specific to some particular graphics card manufacturer.

Those 3D Mandelbulbs, as I understand them, are drawn with custom-built renderers which I presume involve raytracing in some respect. Whilst I don't know for sure, I'd imagine that that would be something you could parallelise on a GPU, but it'd be quite tricky to write and I'm still not sure that you could guarantee realtime results on current hardware.
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #10 on: December 05, 2009, 08:20:04 AM »

For the mandelbrot, there are no easy hacks. It doesn't repeat on any level (it just looks similar). This is why it's so fascinating in the first place (and the simplicity of the formula).

Zoomers do stop eventually, it's a performance issue. As you zoom in on details, you need a higher and higher cutoff value in order to see the detail properly. You also need higher precision calculations, which probably means you need to re-do your old low precision calculations from scratch. That's if you are using arbitrary precision floats. If you just have double accuracy, there's obviously a limit on how much you can zoom.

Either way, they can zoom much more than would be feasible if they were calculating the whole set.

I would strongly recommend writing a 2d fractal rendering program. It's an excellent beginners programming exercise, and somewhat a rite of passage.
Logged
increpare
Guest
« Reply #11 on: December 05, 2009, 08:44:39 AM »

It doesn't repeat on any level (it just looks similar).
I'm not talking about straight-forward scalings (which obv. don't apply), but allowing for other sorts of contraction mappings (even if only partial functions).  Not sure what sort of work has been done on this on the maths side (A quick internet search brings me to a couple of springerlink lockouts): I've certainly seen stuff about automorphism groups of fractals of various sorts, so.

edit: but I'm bordering on bullshitting here.  I can see lots of reasons why the above mightn't work either.  Blech.
« Last Edit: December 05, 2009, 08:50:38 AM by increpare » Logged
powly
Level 4
****



View Profile WWW
« Reply #12 on: December 05, 2009, 08:59:36 AM »

I actually once wrote a semi-realtime mandelbrot but never started tweaking it... Feel free to hassle with the shader programs.

I'm more interested in IFSs than any other kind of fractal because they can be randomly generated and look rather bad-ass.
Logged
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #13 on: December 05, 2009, 09:04:55 AM »

Yes, seems there are portions of the set that can be mapped onto one another, at least approximately. So I stand corrected, you could use this information to cut down on calculations required. It still doesn't seem likely that you could cover all areas of detail of the mandlebrot this way.

But this was pretty much my original point - some fractals can be done efficiently, but without some specialized knowledge, they are hard.
Logged
increpare
Guest
« Reply #14 on: December 05, 2009, 10:04:01 AM »

Ah cool; thanks for linking those : )
Logged
Zaphos
Guest
« Reply #15 on: December 05, 2009, 12:48:23 PM »

I'm pretty sure that computers are still not fast enough to render this in realtime.

^ That's a real time renderer of mandelbulbs.

edit:
Hopefully before too long, OpenMP should become a more widely adopted and available standard, which means that you'll be able to program stuff in such a way that it's not specific to some particular graphics card manufacturer.
Do you mean OpenCL?
« Last Edit: December 05, 2009, 12:53:11 PM by Zaphos » Logged
LemonScented
Level 7
**



View Profile
« Reply #16 on: December 05, 2009, 01:02:06 PM »

Quote
Do you mean OpenCL?

Doh! Yes, yes I do. OpenMP is the multithreading library (which I suppose can be useful for calculating fractals on a multicore CPU), but yeah, I was thinking of OpenCL. I've done some work with CUDA, and it's a nice enough system (once you've wrapped your head around the fact that GPUs work in a completely different way to CPUs), but I'm looking forward to something where you can write a GPU program once and know that it'll run on any supported card by any manufacturer. Sorry if I confused anyone.
Logged

Zaphos
Guest
« Reply #17 on: December 05, 2009, 01:13:18 PM »

No worries, LemonScented Smiley  I do really want to try out OpenCL ... maybe fractal rendering would be a good excuse!  edit: It looks like nvidia and apple and amd have all released some amount of support for it -- I guess it's not 'widespread' support yet though?  Will it in practice only work on snow leopard probably?

Fractals are very difficult to render, as there's little you can do to approximate them.

I believe a few fractals are very amenable to efficient raytracing, though, like the menger sponge.
Holy crap, the javascript version is inspiring: http://www.p01.org/releases/512b_jspongy/
Quote from: that page
Menger Sponge raymarching in about 300 bytes of HTML5 with a very scarce design, the release version fits in the 512b category and retain some of the style and complexity of the original.
And the source is apparently:
Code:
<body onload=setInterval("t++;for(i=-1;i<B*q;I.data[i+=4]=h)for(x=i/128%2-1,y=i/8192-1,m=C=$(a=t/86),S=$(a+8),u=x*C+S,X=q+9*C,Y=q+9*S,Z=t,h=B;--h&&m<q;N[h]=h/86&1,X+=u*S+y*C,Y+=y*S-u*C,Z+=C-x*S)for(m=2;N[X*m&B]+N[Y*m&B]+N[Z*m&B]<2&&m<q;m*=3);K.putImageData(I,0,0)",N=[K=R.getContext('2d'),I=K.getImageData(t=0,0,q=64,q),$=Math.cos,B=255])><canvas id=R style=width:900;height:450>
A game set in a menger sponge might be interesting ...
« Last Edit: December 05, 2009, 01:17:39 PM by Zaphos » Logged
CatStack
Level 0
***


View Profile
« Reply #18 on: December 05, 2009, 01:27:49 PM »


A game set in a menger sponge might be interesting ...

I always thought a game set on a 4D julia fractal might be interesting. You could hide stuff in all kinds of crazy places because the 3-dimensional geometry changes completely depending on the angle of view in 4 dimensional space.





Logged

LemonScented
Level 7
**



View Profile
« Reply #19 on: December 05, 2009, 05:57:02 PM »

No worries, LemonScented Smiley  I do really want to try out OpenCL ... maybe fractal rendering would be a good excuse!  edit: It looks like nvidia and apple and amd have all released some amount of support for it -- I guess it's not 'widespread' support yet though?  Will it in practice only work on snow leopard probably?

For now it's only Snow Leopard, I think. OpenCL is available to "registered developers", or something, and has been since earlier this year. I'm hoping they roll out version 1.0 to anyone and everyone to play with next year. I don't see why it shouldn't run on all operating systems, although I'm not sure what the deal is going to be with drivers - obviously they'll roll them out for any new or future cards, but my uneducated brain can see no technical reason why the drivers for all cards in the last few years couldn't be updated to add support. Of course, they probably won't do that, in order to sell newer and shinier graphics hardware to people, which means it'll be a while yet before games featuring OpenCL become commonplace if they want to sell to anyone except hardcore PC gamers.

Realistically, though, NVidia, AMD and Apple all seem pretty serious about it, and I see no reason why Microsoft won't follow suit if they haven't done already, so I do think we will see this as standard eventually. Having a standard like this for GPGPU processing is definitely overdue.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic