Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Fractal Brownian Motion

This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
Fractal Brownian Motion
Billybob
Member #3,136
January 2003

I played with Fractal Brownian Motion for procedural terrain generation for a little while and got a rather nice picture :)

{"name":"601802","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/1\/a1bca34f37902e76499144418cfd363c.png","w":816,"h":638,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/1\/a1bca34f37902e76499144418cfd363c"}601802

8-)

It actually produced a pleasant result for just 20 or so minutes of coding and tweaking. Here is a code snippet:

#SelectExpand
1PerlinNoise terrainNoise = new PerlinNoise(); 2 PerlinNoise roughnessNoise = new PerlinNoise(); 3 4 for(int y = 0; y < 1024; ++y) 5 for (int x = 0; x < 1024; ++x) 6 { 7 float noise = 0.0f; 8 float k = 1.0f; 9 float scale = 128.0f; 10 float roughness = (roughnessNoise.Noise(x / 256.0f, y / 256.0f, 0, 0) + 1.0f) * 0.5f; 11 roughness = MathHelper.Clamp(roughness, 0.1f, 0.9f); 12 13 for (int lvl = 0; lvl < 4; ++lvl) 14 { 15 noise += terrainNoise.Noise(x / scale, y / scale, 0, 0) * k; 16 k *= roughness; 17 scale *= 0.5f; 18 19 } 20 21 noise = MathHelper.Clamp(noise, 0.0f, 1.0f); 22 data[y * 1024 + x] = (byte)(noise * 255); 23 }

I use a second Perlin Noise generator to create a random roughness map. That's what gives the map areas of smooth terrain and areas of mountain terrain. It should probably be tweaked to favor smooth terrain over mountains. Also, one article recommended using an exponent on the final value to make it smooth near coast lines. Anyway, lots can be tweaked, but I wanted to show how easy it was to get cool results in very little time.

Arthur Kalliokoski
Second in Command
February 2005
avatar

Give us a 3d terrain view :).

They all watch too much MSNBC... they get ideas.

Billybob
Member #3,136
January 2003

Well here it is as a colored diffuse map applied to a sphere:

{"name":"601804","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/8\/18f0e9f338fa81070fdf08b414d44b49.png","w":816,"h":638,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/8\/18f0e9f338fa81070fdf08b414d44b49"}601804

I'll plug in a new shader next and see if I can get a normal map to go along with this.

EDIT:
And now with normal+height mapping. Also, two different planets at the same time! :o

{"name":"601805","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/6\/761b469d4e4d360d49ade596fdbdcdfb.png","w":816,"h":638,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/6\/761b469d4e4d360d49ade596fdbdcdfb"}601805

Now I need to generate different color patterns for them.

EDIT2:
Colors! And random amounts of water and snow! 8-)

{"name":"601806","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/1\/71af987d8d76685a7e140cb09d823c31.png","w":816,"h":638,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/1\/71af987d8d76685a7e140cb09d823c31"}601806

I really need to speed up the noise function, but I'd also like to add a vegetation layer and then get these puppies in orbit. Plus stars!

blargmob
Member #8,356
February 2007
avatar

Oh boy this would be great to shove into my 3d galaxy simulations 8-)

---
"No amount of prayer would have produced the computers you use to spread your nonsense." Arthur Kalliokoski

Trent Gamblin
Member #261
April 2000
avatar

The second picture -- with the two planets, looks quite good.

Billybob
Member #3,136
January 2003

The second picture -- with the two planets, looks quite good.

Thank you :D I like those better as well. The color algorithm is just a quick hack. I'd like to tweak it more later to get better parameter distributions, as well as picking sane colors :P Plus vegetation patterns would look nice.

Star field!
{"name":"601807","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/e\/ce26c9f182bd15e4248511aea033f28f.png","w":1296,"h":1062,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/e\/ce26c9f182bd15e4248511aea033f28f"}601807

Made of about 100,000 points, brightness chosen with more Fractal Brownian Motion, and the shader for them automatically makes them flicker in both brightness and red/blue bursts.

Now I'd like a sun+orbits, better camera controls :-/ and perhaps some nebula-like formations in the distance.

blargmob
Member #8,356
February 2007
avatar

Billybob said:

nebula-like formations in the distance.

I can throw you some data/visualization techniques from my simulations to take good care of that if you'd like.

---
"No amount of prayer would have produced the computers you use to spread your nonsense." Arthur Kalliokoski

ImLeftFooted
Member #3,935
October 2003
avatar

Ooo, purdy...

Billybob
Member #3,136
January 2003

Ooo, purdy...

;D

Space ship!
{"name":"601812","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/b\/0b59a5effd3f56ae2fe1147975261060.png","w":1040,"h":806,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/b\/0b59a5effd3f56ae2fe1147975261060"}601812

Controls are still odd but I'll put up with it for now. Next up, I'm gonna put the planet generator in a separate thread so it loads in the background. Then it's time for a little sun and solar system action.

I can throw you some data/visualization techniques from my simulations to take good care of that if you'd like.

I'm using procedural only methods. Got anything for that? Nebula are awesome looking, so it'll probably take me awhile to figure out a good way to generate them procedurally.

EDIT:
Solar system!
{"name":"601813","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/0\/20366a75f2bc22cec34ec5ff2dd80894.png","w":1296,"h":1062,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/0\/20366a75f2bc22cec34ec5ff2dd80894"}601813

Johan Halmén
Member #1,550
September 2001

{"name":"1523ef0fa16a3394c3811c0d21aa8bca.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/5\/1523ef0fa16a3394c3811c0d21aa8bca.jpg","w":340,"h":354,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/5\/1523ef0fa16a3394c3811c0d21aa8bca"}1523ef0fa16a3394c3811c0d21aa8bca.jpg

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Billybob
Member #3,136
January 2003

Some basic nebula like stuff...
{"name":"601814","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/8\/887468d63343805c0828d2ec7c4f9288.png","w":1296,"h":1062,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/8\/887468d63343805c0828d2ec7c4f9288"}601814
Not amazing, but it breaks up the sky and makes it more interesting.

The planets now load in background threads, yay!

I'd like to work on the sun. It's just a sphere right now. I also want to generate locations for other solar systems and display them in the sky as brighter stars. Then I'll hack in a way to select and travel to one :)

EDIT: Yay I've got 256 different solar systems available for exploration now. 8-) I can even travel to a few of them. Next up, map them onto the sky and allow myself to select and travel to them that way.

LennyLen
Member #5,313
December 2004
avatar

Billybob said:

Not amazing, but it breaks up the sky and makes it more interesting.

I really like it just as it is. I'm sure you can do some great things with that with as a starting point.

Jakub Wasilewski
Member #3,653
June 2003
avatar

{"name":"601816","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/6\/a66e744f9cab41aeec50b9f620812001.png","w":700,"h":500,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/6\/a66e744f9cab41aeec50b9f620812001"}601816

Seems like a lot of us have been working on planet generators at one point or another ;).

---------------------------
[ ChristmasHack! | My games ] :::: One CSS to style them all, One Javascript to script them, / One HTML to bring them all and in the browser bind them / In the Land of Fantasy where Standards mean something.

Trent Gamblin
Member #261
April 2000
avatar

Johan's, although unrealistically exaggerated, looks cool. I used that terrain generator of yours, Johan, for a game I made btw... though I didn't use the default colors.

Billybob
Member #3,136
January 2003

LennyLen said:

I really like it just as it is. I'm sure you can do some great things with that with as a starting point.

Thank you for the kind feedback :) It makes me happy to hear other people like it.

Seems like a lot of us have been working on planet generators at one point or another .

Is that image from one of your games? If so, it looks really nice 8-) Kind of has a feel that I'm going for. Not quite sure what my gameplay is going to be, but at least one part will be going to planets and checking out their resources.

Finally got nearby solar systems to show up as brighter stars:
{"name":"601817","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/f\/7fa864b80ff2386a84ddab7c99c8a088.png","w":1296,"h":1062,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/f\/7fa864b80ff2386a84ddab7c99c8a088"}601817
New sprite:
{"name":"601818","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/5\/556c874b96900884ff91157e2916665b.png","w":1296,"h":1062,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/5\/556c874b96900884ff91157e2916665b"}601818
I like the sprite in the second image better, but it's a bit harder to see. Needs more work.

Next up, selecting and travelling to those systems, and then sun texture+glow.

EDIT:
YAY! I added a gui system (Neoforce Controls). Using that, I was able to get the cursor to change when hovering over a nearby solar system, and double clicking prompts me to travel there. I was even able to bounce back and forth between two known solar systems using a little navigation skill. 8-)

EDIT2:
Naming system and highlighting ;D
{"name":"601819","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/6\/664076a3bf8d1bb3c53dc03e6719b85e.png","w":1040,"h":806,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/6\/664076a3bf8d1bb3c53dc03e6719b85e"}601819

Jakub Wasilewski
Member #3,653
June 2003
avatar

Billybob said:

Is that image from one of your games?

Yup, it's from a Flash remake of Starship Survivor that I'm currently working on. It's not going so well lately, though.

Good luck with your project ;).

---------------------------
[ ChristmasHack! | My games ] :::: One CSS to style them all, One Javascript to script them, / One HTML to bring them all and in the browser bind them / In the Land of Fantasy where Standards mean something.

Billybob
Member #3,136
January 2003

A little video that I thought was cool.

video

Quite peaceful I think.

I'm adding the beginnings of game play now. Still no idea what exactly I wanna do, but ... I shall proceed blindly and keep adding fun things 8-)

Yup, it's from a Flash remake of Starship Survivor that I'm currently working on. It's not going so well lately, though.

That's a shame. I'd love to give it a play. I tried your original Starship Survivor. The game play sounded quite fun, although I had the hardest time controlling my ship :'( I'll probably try it again later and do my best to actually collect something ...

OICW
Member #4,069
November 2003
avatar

Oh crap. And I've been meddling with this semestral project for quite a while:
{"name":"normal-mapping.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/8\/a86352556b93381f92111cfc7704bbe9.png","w":802,"h":628,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/8\/a86352556b93381f92111cfc7704bbe9"}normal-mapping.png

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Slartibartfast
Member #8,789
June 2007
avatar

Billybob said:

Quite peaceful I think.

The lighting on the planet seems weird, it is as if every place on the planet is lit from the side (so the sun is rising over the entire planet)

Arthur Kalliokoski
Second in Command
February 2005
avatar

The lighting on the planet seems weird, it is as if every place on the planet is lit from the side (so the sun is rising over the entire planet)

He's probably forgetting to add the correct normals per vertex.

They all watch too much MSNBC... they get ideas.

Billybob
Member #3,136
January 2003

OICW: Looks very nice. 8-) Better than my cartoony planets :( I'll have to go back and tweak a lot to make mine look nicer.

In the meantime, I'm plunging into game-play! I added a crazy, experimental idea I had. Inspired by Minecraft and Manufactoria, I wanted to have a crafting system in my game with a twist: programmability. The player creates blueprints for machines by combining various components that act kind of like a graphical Finite Automata.

video

In the screenshot you can see the debug window for an automated mining machine. The 3x3 grid is the graphical FSM. The orange grid on the right is a material density map of the planet. The machine moves to the area with the highest local material density and mines there until it needs to move to the next highest area. On the 3x3 grid a green background indicates that "instruction" is going to be executed next. There is a mine instruction, a switch, and a move north and move south instruction.

After implementing this, as crude as it may be, I'm actually quite happy with the possibilities. The player will create blueprints, and then can make and install the machines on planets and such. The bigger and more complicated the blueprint, the more expensive the machine will be. The machine above would be cheap, but it's slow (spends most of its time looking for local maxima). A faster machine would cost more to make, but would hopefully extract materials faster.

What do you guys think? I'm sure it will need lots of tweaking, but I'm curious to hear feedback.

OICW
Member #4,069
November 2003
avatar

Billybob said:

Looks very nice. 8-) Better than my cartoony planets :( I'll have to go back and tweak a lot to make mine look nicer.

Thanks. Right now I'm trying to get rid of visible seams on the normal map that is cube mapped onto the surface. I must say that it added a lot more details to the planet although it's really a low poly model.

Last thing I need is better zoning and improved generator.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Billybob
Member #3,136
January 2003

I've made a bit more progress on inventory and machines. There is a window for designing blueprints, and the player can craft machines from blueprints within the inventory screen. There's also a way to view the machines currently on a planet, and install new ones. 8-) And of course you can open the storage containers on each machine to grab the raw materials its collected thus far.

{"name":"601849","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/6\/f63cd016d3a414b11448dc8eeae5e484.png","w":1040,"h":806,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/6\/f63cd016d3a414b11448dc8eeae5e484"}601849

phew Now I need to have it require raw materials for the production of machines, and probably a time delay. Then I guess I'll start implementing some markets where materials can be bought and sold.

Bruce Perry
Member #270
April 2000

{"name":"fire.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/6\/665af8e0cdd61e1752ac62c467f7fbc1.jpg","w":646,"h":507,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/6\/665af8e0cdd61e1752ac62c467f7fbc1"}fire.jpg

{"name":"9465-1","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/e\/1e8e114ecfb8cfe900e80d8d443d2cc9.gif","w":320,"h":200,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/1\/e\/1e8e114ecfb8cfe900e80d8d443d2cc9"}9465-1

From TINS and SpeedHack entries respectively :)

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

blargmob
Member #8,356
February 2007
avatar

Billybob said:

I'm using procedural only methods. Got anything for that?

No :-[

But you're system is looking fucking great so far. If you haven't seen this already, give this a look

http://www.infinity-universe.com/Infinity/index.php

It's this enormous procedural project being coded by the Admin with content coming from the vast community. In the end, it'll be this gigantic sci-fi, space, open-world/open-ended game where you can essentially do anything you want.

Aside from the assets, everything is procedural and they estimated (IIRC) over 70 billion EXPLORABLE star systems. It's looks pretty fucking promising so far; I very much encourage you to watch the April Tech Demo video.

I await the release of this game very eagerly 8-)

---
"No amount of prayer would have produced the computers you use to spread your nonsense." Arthur Kalliokoski

 1   2   3 


Go to: