Simple planet generator

Community Forums/Showcase/Simple planet generator

Damien Sturdy(Posted 2007) [#1]
Hey all,

I was helping a mate of mine earlier in the week- the result was a planet-like generator. I called it PlanetGen (well thought out eh?).

It's really simple but quite fun.
you can set ground colour, land mass, water colour, cloud colour, density, set it as a "star", turn on/off a basic flare, and turn on/off a day>night style effect. You can also set the scale.
Also, you can save and load your presets or export as PNG with alpha.

Sadly I cannot get it to work with OpenGL for some silly reason so it's not cross platform.



download: http://cygnus.servegame.com/planetgen10a.zip

Also, this marks the end of a holiday for me, so I'll not have much time to work on it often (Back to Flow now!), though there's quite a bit i'd like to do in the future.

Who knows, maybe someone else will find it of use too?


Grey Alien(Posted 2007) [#2]
Hey cool! Nice little project. Is there a way to blend those polygons in or show more detail?


Damien Sturdy(Posted 2007) [#3]
Polies? What polies? :-P

you can change the detail/resolution- though I didn't think to enable/disable the "poly" look- they are actually shadows but since I dont curve the texture they shouldn't be there anyway. My bad :)


Grey Alien(Posted 2007) [#4]
The line is just too obvious that's all.


Damien Sturdy(Posted 2007) [#5]
Ah :-) Easy to fix. See what I can do next weekend. :-D


Who was John Galt?(Posted 2007) [#6]
Looks good. How does your land mass drawing work, in broad terms?


Damien Sturdy(Posted 2007) [#7]
In broad terms, it uses a heightmap array populated using plasma-esque code.


*In depth here- can't help it ;-)*
Simple- say 20 points are selected, these are given a radius, and a heightmap array is populated based on the distance between the current coord and each point. Levels below 128 are "underwater" and above that is land. I add a little "noise" by adding a slight value to this using RND

the clouds are similar, only the result of the distance check is modified using rand to give a higher noise ratio.
There's also a secondary cloud step which is placed and then smoothed right around the edge of the planet.

After populating the landmass and clouds, the heightmaps for both are smoothed using the average of the surrounding cells.

because of the higher noise ratio on the clouds, the smoothing creates whisps.



The shadows too are simple. if heightmap(x,y)>heightmap(x-1,y) then heightmap(x,y)=heightmap(x,y)/2 (or -1)

They seem cool but don't fit because I'm not drawing the land mass curved. at lower resolution there are no shadows, just shades.

Rendering:

colours are mixed using the resulting cloud map- if levels in the cloudmap are <0 then the resulting colour is 100% ground/water. cloudmap levels>0 give cloud.

and alpha is worked out using a) distance from edge and b) cloud depth. (nice bloom effects are possible.)


slenkar(Posted 2007) [#8]
looks very good, just needs a blur to make the different land colors blend together


Who was John Galt?(Posted 2007) [#9]
Cheers Cygnus - the 'in depth' explanation was indeed more useful.


Damien Sturdy(Posted 2007) [#10]
[edit] due to the rather large amount of emails, I spent 25 seconds removing the edge. ;-) Archive and image updated.


MGE(Posted 2007) [#11]
Can you show examples of a more realistic Earth or Moon? If it can do those, it can probably do anything. Thanks!


Grey Alien(Posted 2007) [#12]
Looks better now. Still you could do MORE :-) A planet generator would be way cool for making game backgrounds etc.


Rob Farley(Posted 2007) [#13]
I think it looks a little cartoon like, might have a go at writing one of these tonight... looks like fun!


Damien Sturdy(Posted 2007) [#14]
Fun indeed! That's what started it, A mate showed me some graphics and I thought this up! I don't doubt some more tallented progers than myself can come up with better. Looking forward to it there Rob!

As for the style, well, it's meant to be cartoony, It never entered my mind to make it do anything but cartoony graphics, so the chances of it making a realistic earth are pretty slim.

Though with some extra bits of code I guess I could make it do crators etc :-)

if you do have suggestions, feel free to let me know. i'm sure to get 5 mins now and then to add stuff, and it seems this is more popular than I thought it would be lol. (Quit it with yer emails people! :S)


Aymes(Posted 2007) [#15]
Yay! Thanks for that matey!


Damien Sturdy(Posted 2007) [#16]
No problemo!


GaryV(Posted 2008) [#17]
Any chance somebody could repost this?