DevMaster.net Forums
[[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]]

Go Back   DevMaster.net Forums > General > DevMaster Lounge
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
Old 11-08-2008, 09:25 PM   #1
TheNut
Senior Member
 
TheNut's Avatar
 
Join Date: Aug 2004
Location: Thornhill, TO
Posts: 849
Default Fun with fractals

Just thought I'd bring up the interesting subject of fractals and procedurally generated content. Over the past two weeks I've been doing some work on various fractals and iterated function systems. I didn't know what to expect at first, but having gotten my feet wet I'm surprised at how simple these systems are. In some ways, I've always been interested in fractals since I heard about fractal landscapes and procedural generation of textures (see Terragen). I suppose too that since I've played Spore my interest in the subject has been vastly rejuvenated. Proof that there is a strong future for those systems. And with the ever-expanding multi-core computers, it's a blast just watching how fast these things can be produced now.

So far I've dabbled around with mandelbrot, fractal flames, and the use of perlin noise and plasma clouds. The most difficult challenge actually is colouring the output. So many ways, but finding the nicest requires a bit of trial and error. This leads to my next goal, which is to improve on my colouring scheme. To make better use of noise and colours for textures. As a test, I'm aiming to produce something like Tarragen. See how far I can get with high quality textures and bring my GPU down to its knees

A couple shots of my system so far.

As a fun side project, I've been rendering a couple 1080p mandelbrot videos too. Aside from being nauseous, it's quite a trip.

Anyone else have experiences to share?
___________________________________________
http://www.nutty.ca - Being a nut has its advantages.
TheNut is offline   Reply With Quote
Old 11-10-2008, 04:04 PM   #2
geon
Senior Member
 
geon's Avatar
 
Join Date: Sep 2005
Location: Jönköping, Sweden
Posts: 546
Default Re: Fun with fractals

Not really my own experience, but you can't talk about procedurally generated terrain without mentioning Infinity:

http://www.infinity-universe.com/Inf...mid=90&catid=4
___________________________________________
Topmost webbyrå i Jönköping - webbutveckling & design
geon is offline   Reply With Quote
Old 11-10-2008, 09:05 PM   #3
TheNut
Senior Member
 
TheNut's Avatar
 
Join Date: Aug 2004
Location: Thornhill, TO
Posts: 849
Default Re: Fun with fractals

Whoa, impressive. I'm totally inspired. Just the fact that you see a Saturn like planet from the ground, knowing full well that if you left the planet's orbit you could fly over to that planet. Jesus, and one man too. This guy is an animal. The graphics are just tack sharp.

Alright, no sleep for the next week
___________________________________________
http://www.nutty.ca - Being a nut has its advantages.
TheNut is offline   Reply With Quote
Old 11-11-2008, 02:35 AM   #4
roel
Senior Member
 
roel's Avatar
 
Join Date: Sep 2005
Location: .nl
Posts: 504
Default Re: Fun with fractals

And it is real-time (where terragen isn't). You might want to take a look on his journal too.

Regarding "classic" fractals: the buddhabrot is one of my favourites: http://www.steckles.com/buddha/ or here: http://www.superliminal.com/fractals/bbrot/bbrot.htm . And the 4d Julia's are cool too
roel is offline   Reply With Quote
Old 11-11-2008, 11:47 AM   #5
geon
Senior Member
 
geon's Avatar
 
Join Date: Sep 2005
Location: Jönköping, Sweden
Posts: 546
Default Re: Fun with fractals

Quote:
Originally Posted by TheNut
Anyone else have experiences to share?

I wrote a few fracta renderers. The first one was written in VB, and rendered a Dragon or Koch kurve.

The second one was also VB, but drew a mandelbrot. I did it mostly because I got bored in a VB class in school.

The third one I wrote in C with OpenGL for rendering large "empty" areas as simple interpolated gradients. (I think I just checked if each corner of the quad differed from the others more than some low threshold, and recursively split the quad.) It was slow, even with all that OpenGL "acceleration".

The fourth was plain C, pixel, by pixel. Worked well, but not very quickly.

There should be immense possibilities to optimize something like this. Some SSE and threaded rendering so our dual quadcores have some work to do for once?


How about yourself? Can you tell us anything on the technical side? rendering high-res fractal videos sounds time consuming...
___________________________________________
Topmost webbyrå i Jönköping - webbutveckling & design
geon is offline   Reply With Quote
Old 11-11-2008, 02:03 PM   #6
.oisyn
DevMaster Staff
 
.oisyn's Avatar
 
Join Date: Sep 2005
Location: The Netherlands
Posts: 1,442
Default Re: Fun with fractals

Quote:
Originally Posted by roel
And the 4d Julia's are cool too
As the nerd that I am, I have a 4d julia on my ATM card

(Here in the Netherlands a certain bank provides the service that you can put your own picture on the card)
___________________________________________
C++ addict
-
Currently working on: the 3D engine for Tomb Raider: Underworld and Deus Ex 3.
.oisyn is offline   Reply With Quote
Old 11-11-2008, 04:34 PM   #7
TheNut
Senior Member
 
TheNut's Avatar
 
Join Date: Aug 2004
Location: Thornhill, TO
Posts: 849
Default Re: Fun with fractals

I looked over his journal the other day and it was quite informative. I'm surprised how things are really that easy. He also got me thinking about Voronoi diagrams, which I completely forgot about. Very cool stuff that I'm working on implementing.

The buddhabrot is interesting. The nebulabrot (lol, who comes up with these names) makes me think of space invaders. I've seen some YouTube videos where they've animated the colours, but if it's possible to slightly animate the shape (slight rotations and what not), it would make for an interesting addition to my video.

The video itself is quite time consuming. I'm rendering it on a dual core 1.8GHz. Some scenes take 2-3 days of processing to film the full zoom on one section at roughly 2048 max iterations (though it varies on what I'm targeting). And if I make a mistake, I smash myself into the wall head first.. To make things worse, I'm producing the videos at 60fps and downsampling the output images from 3840x2160 to 1920x1080. It's really worth it though. I wrote the thing in C++ so there's no fancy assembly going on (see QuickMAN), but I am taking advantage of multithreading. I'm even contemplating adding a network renderer to get my other PCs to join in. Hmm, I should also get the GPU to help out too. Heh, the funny thing is my PC can't even playback the final video. 60fps HD is to much for my crummy PC to handle.

The fractal flame algorithm is a lot worse too since it requires tons of iterations to converge the result. I'd love to do videos with that because it's so fluidic and beautiful, but it would take a month just to do a 1 minute video.

Quote:
I have a 4d julia on my ATM card
Better to have julia than starfleet's logo on there
___________________________________________
http://www.nutty.ca - Being a nut has its advantages.
TheNut is offline   Reply With Quote
Old 11-12-2008, 02:11 PM   #8
vrnunes
Valued Member
 
Join Date: Aug 2004
Location: Brasil
Posts: 192
Default Re: Fun with fractals

very nice!
vrnunes is offline   Reply With Quote
Old 11-13-2008, 10:08 PM   #9
TheNut
Senior Member
 
TheNut's Avatar
 
Join Date: Aug 2004
Location: Thornhill, TO
Posts: 849
Default Re: Fun with fractals

So I decided to port my Mandelbrot renderer over into a fragment shader and... WHOA! Talk about insane speed. It doesn't have the precision or quality I get on the CPU, but just to navigate around is incredible. Because it's the week of the Mandelbrot, I'll post my shader code if anyone is interested in trying it out themselves or wants to improve their overall shader knowledge. I'll also post my fractal test app I've been working on soon. It generates some pretty nice desktop wallpaper. Every day is a new image



CPU quality is obviously better, but GPU kicks my Intel's butt in speed.

Feel free to use the shader code below however you see fit. You could trim it down some more given that your application would be different than mine.
Code:
/* Author: Nathaniel Meyer E-Mail: nate@nutty.ca Website: http://www.nutty.ca Desc: Fragment program for calculating and drawing the mandelbrot on a shape's surface. */ // Textures // tex0 is used to render to texture by the CPU // if shaders are disabled. tex1 identifies the // gradient texture used to colour the mandelbrot. uniform sampler2D tex0; uniform sampler2D tex1; // Variables to be provided by application // maxIteration - A finite "infinity" number to prevent the // calculation loop from going on forever. // real - Starting x-coordinate in mandelbrot. // imaginary - Starting y-coordinate in mandelbrot. // scaleX - Maintain aspect ratio: 3.0 / window_width. // scaleY - Maintain aspect ratio: 2.0 / window_height. uniform int maxIteration; uniform float real; uniform float imaginary; uniform float scaleX; uniform float scaleY; // Keep track of complex number system. float z; float cfX; float cfY; float fX; float fY; /* Calculate mandelbrot */ int mandelbrot (int numIteration) { int iteration = 0; float temp; // Zn+1 = Zn^2 + c while ( ((z = ((cfX*cfX + cfY*cfY))) <= (4.0)) && (iteration < numIteration) ) { temp = cfX*cfX - cfY*cfY + fX; cfY = 2.0*cfX*cfY + fY; cfX = temp; ++iteration; } return iteration; } /* Main fragment shader function */ void main () { // Start location fX = real + ((gl_TexCoord[0].s - 0.5) * scaleX); fY = imaginary + ((gl_TexCoord[0].t - 0.5) * scaleY); // Calculate mandelbrot int iteration = mandelbrot(maxIteration); // Process result if ( iteration == maxIteration ) { // Not part of the mandelbrot solution gl_FragColor.xyz = 0; } else { float intensity; // Faster, but subject to colour banding //intensity = float(iteration) / float(maxIteration); // Normalized Iteration Count. // Slower, but reduces colour banding // Smoothing. Add a few extra counts to reduce error iteration += mandelbrot(1); z = (cfX*cfX + cfY*cfY); intensity = (float(iteration) - (log(log(sqrt(z))) / log(2.0))) / float(maxIteration); // If a texture gradient is not provided, this formula // will render a standard greyscale mandelbrot. //gl_FragColor.xyz = intensity; // Provide a 1D gradient for the mandelbrot to render // colours. It should be of sufficient width (1024 pixels) // to render smooth gradients. gl_FragColor.xyz = texture2D(tex1, vec2(intensity, 0)).xyz * 2.0; } // Set final output gl_FragColor.w = 1.0; }
___________________________________________
http://www.nutty.ca - Being a nut has its advantages.
TheNut is offline   Reply With Quote
Old 11-14-2008, 03:06 PM   #10
roel
Senior Member
 
roel's Avatar
 
Join Date: Sep 2005
Location: .nl
Posts: 504
Default Re: Fun with fractals

I'm looking forward for your app!
roel is offline   Reply With Quote
Old 11-14-2008, 10:51 PM   #11
TheNut
Senior Member
 
TheNut's Avatar
 
Join Date: Aug 2004
Location: Thornhill, TO
Posts: 849
Default Re: Fun with fractals


Here you go. I included links to download the program for either Windows or Linux. I had to spend some time brushing up the interface, but it should be good enough to get around. Instructions are included in the readme.txt file. You'll find all the mouse and keyboard controls in there, as well as how to add your own gradients. One thing I didn't mention is that you can edit resources/gui.xml and add your own resolutions and max iterations (if you really want to go psycho on your computer). Also, you can't take screenshots while in Shader mode. I was to lazy to get the frame buffer and setup all that jazz
___________________________________________
http://www.nutty.ca - Being a nut has its advantages.
TheNut is offline   Reply With Quote
Old 11-15-2008, 04:19 AM   #12
roel
Senior Member
 
roel's Avatar
 
Join Date: Sep 2005
Location: .nl
Posts: 504
Default Re: Fun with fractals

I had (Fractal) Fun indeed Too bad that my videocard doesn't do GLSL though.
roel is offline   Reply With Quote
Old 11-15-2008, 09:02 AM   #13
TheNut
Senior Member
 
TheNut's Avatar
 
Join Date: Aug 2004
Location: Thornhill, TO
Posts: 849
Default Re: Fun with fractals

What video card do you have? My netbook has an Intel 945GME that supports shader model 2.0, but not GLSL. I'm thinking about returning back to Cg to get that added support. I'm sure even on that Intel chip rendering via the GPU would show a great deal of added performance.
___________________________________________
http://www.nutty.ca - Being a nut has its advantages.
TheNut is offline   Reply With Quote
Old 11-16-2008, 02:54 PM   #14
roel
Senior Member
 
roel's Avatar
 
Join Date: Sep 2005
Location: .nl
Posts: 504
Default Re: Fun with fractals

I have a Radeon 9600 All In Wonder And yes, it also supports sm 2.0.
roel is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Forum Jump


All times are GMT -7. The time now is 04:44 PM.


Powered by vBulletin
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.