Archived

This topic is now archived and is closed to further replies.

Vulcan

Advanced Random Terrain Generation

Recommended Posts

Got the heightmap all done working fine. What I need to know is, is there any good ways to go about placing other random features on the terrain, eg. roads + rivers? I was thinking of generating a spline through the terrain then lowering the vertices/heightmap to accompany for the rivers, for roads I was going to do the similar spline, but only modify the terrain if the slope was to high (otherwise flatten it in the area for the road) Any other ideas? places I can go to find more info maybe? -Vulcan

Share this post


Link to post
Share on other sites
I have been thinking about this stuff also, as I need to create random maps for my 3D RTS...

I plan on using perlin noise for EVERY aspect of my map... not sure how you are creating your terrain, but I really like this method.

I was thinking that you could position trees/bushes/rocks by using a product in the perlin noise function possibly, and then testing if the height is above/below a certain threshold. Basically, you would end up with a realistic looking tree/bush pattern... you could even make it so that grass is found at a very ''low'' height, trees at ''high'' height, and shrubs in-between. This would produce a fairly realistic looking spread. There would be groups of trees which would fade into shrubs and then finally grass...

To make rivers, you can do the same sort of thing. The only problem is that to be realistic, it would need to follow some general rules... For example, rivers tend to be in ravienes not on peaks of mountains... Also, lakes tend not to be at high altitudes, though sometimes are. The easiest way to make the lakes is to just make any of your original land that is below a certain point, water... I''ll have to think about the rivers...

for rocks and things, you could just use say the first part of you terrain height perlin function and then add layer of fairly random, low amplitude noise. Again, you would place rocks at points above a scpefic threshold.

If you havn''t read up on perlin noise, I suggest you do, as it is a very very versitle algorithm and, I think, applies itself very well to this situation.

I would also, love to hear everyone else''s oppinions on this, as I am going to need to do this stuff pretty soon too as I stated above...

Hope I could help.

Dwiel

Share this post


Link to post
Share on other sites
usually mine are generated like so:

firstly weather patterns. if you make the WHOLE map the same weather style it doesn;t matter

for the roads, just tell it where to start and where to end. this can be city''s warves, or edges of the map. you can make this bit random.


for the roads, just let some simple ai plot a course between the two points. don''t let the gradient (the slope of the road get to high) and in the end you shuold get a fairly decent road.


for the rivers, for each block on the map (or position, you get teh drift) their is an amount of rain fall.
Each bit of rain fall will add to its neighbour with the greatest negative slope (ie sloping downwards).
After a while this will generate a river.
Lakes will form when there are no lower neighbours.

If you set a level which the water will have to be above to be visible, this will let your dry bits, and the puddelly bits.

Share this post


Link to post
Share on other sites
Dredge-Master:

I really really, like your idea about rainfall causing the rivers and such...

I think that it could be very interesting, dependin on the type of game, for all of this to be real time... have storms move in, rain falls, increasing size of creaks/rivers/lakes/etc... Adds for interesting effects if, in an RTS game, you can alter the ground''s shape... ie re-route water, etc... you could kinda make a natural moat around you city...

I wonder though, if there would be a good way to generate results of say, t amount of time of rain/the elements... without actually going through and simulating the weather... I guess you could just have a completely dry terrain... and have a ''great flood'' or just rain everywhere... I think this would still work...

I think it could be very interesting if the terrain changed as you played... commonly traversed places errode, weather patterns create dry spots, etc... You could also place trees this way... say, let some grow, with a leaniancy to grow near water...

Sounds very interesting...

I think real time rain in an RTS could be interesting... if say a huge storm moves in, a cloud oscures the units somewhat... water levels raise, etc

any more ideas?

Dwiel

Share this post


Link to post
Share on other sites
I once had a craving for oldschool, totally useless but still fun coding in QBasic and wrote a really quick and dirty terrain generator (traced in pseudo-3D! :D). Of course, this was rather dumb though it was mostly a matter of getting that 90''s bit of code-craving calmed down and settled properly. But once that was done I felt like adding a little something extra, on a whim.

I had a nice little heightmap with heights ranging from 0-100. Since I was working in mode 13h, I had to limit myself (just putting things into context). I created a palette from 101-200 that contained water and started making it rain. I made every droplet "slide" down my hills by selecting the pixel with the lowest color value around it (ie, the lowest pixel on the map) and moving it in that direction. I''d keep doing that until I reached a point where no other pixel around the drop was lower (water already accumulated counts as land for the purpose of determining height). I let water accumulate like that, nice quick and dirty little bit of code...

What I ended up with was actually pertty surprising. I had bassins of water that filled up VERY realistically. After adding a little erosion (by "digging" into the ground as droplets flowed over them) I had very interesting rivers and lakes.

Ported to a more modern and more performant language, I''m pretty sure it could have nice results. I might try that at home tonight. But yeah, that technique turned out looking very nice.

Share this post


Link to post
Share on other sites
funny
ive been thinking about the exact same weather system thing myself the past weeks. i doubt you could make it realtime though. just imagine this: you have a huge mountain lake, and someone digs a canal: how do you imagine you engine handling millions of cubic meters of water spilling over you map in realtime?

quote:

What I ended up with was actually pertty surprising. I had bassins of water that filled up VERY realistically. After adding a little erosion (by "digging" into the ground as droplets flowed over them) I had very interesting rivers and lakes.



i also think that wouldbe cricial to realism: the more water flows over a spot, the more ground is eroded. you could also make the water carry the sediment, and deposit it where the flowspeed decreases, in order to generate nice river deltas and meandering rivers and such. but once again: i think youll be forced to pregenerate this. on the other hand, that would rule out the possibility of deformable terrain... hmm..

maybe realtime would be possible, but you would have to come up with quite a clever system for that i think..

Share this post


Link to post
Share on other sites

Some interesting links:



Modeling of ecosystems as a data source for real-time terrain by Johannes Hammes



A basic explanation of hydraulic erosion on a heightmap



John Beale''s homepage (screenshots of landscapes and some source code)



A while back, bishop_pass posted an interesting thread about terrain erosion, but unfortunately due to gamedev''s lack of adequate search function/archival methods, I''ve been unable to track it down. Hopefully this stuff can get you going in the right direction though.

Share this post


Link to post
Share on other sites
ok cool. I have the perlin noise working all nice and pretty already. About these roads, what pathing algorithm do you suggest?

Also, for forests/trees etc, I was thinking of generating another perlin noise ''tree map'' and then using it to place trees on the terrain (granted the slope at the location was sufficient) Any other ways of doing this?

and about the rainfall/water deal. Once I do a calculation such as that (which sounds really cool, btw) how do you suggest you go about generating the renderable part? just a simple ''tile'' in the tiles that have enough water? it seems like it''d work, just want to see what you think.

also, thanks for the help, its greatly appreciated.

regards,
-Eric

Share this post


Link to post
Share on other sites
quote:
and about the rainfall/water deal. Once I do a calculation such as that (which sounds really cool, btw) how do you suggest you go about generating the renderable part? just a simple ''tile'' in the tiles that have enough water? it seems like it''d work, just want to see what you think.


It depends on how you are drawing your terrain, but I would think that you water is going to look very very ugly unless the x and y coords of the water (at the banks) are the same as x and y coords of the land. Basically, if you are using a grid basic system for your terrain, make sure that the water is on the SAME grid. If the grids do not line up, you will end up with water that interescts the land unpredictably... there will be holes in your water...

Hope that makes sence... if it doesn''t I might try coding it up into my engine so I can show you...

of course it all depends on the way your verticies are created from the perlin noise...

hope I helped...

Dwiel

Share this post


Link to post
Share on other sites
roads could be done with a sort of A*-like algorithm. Basically when the road builders build a road from town A to town B they want to make the road as straight and flat as possible, so when going from one map square to the next , it would evaluate the raw distance (manhattan) to the target, the angle from the previous road square, and the slope of the current one.

The less the angle from the previous square the currwent has, the lower the score. so:
__ will have lower score than:

_/ Would have, since there is a bend.

And slope, the steeper it gets, the higher the score.

Finally Manhattan distance. the closer the less score a square gets.

Then by adding up the total scores of each square, from these three, you get a rough aproximisation of how a real road would be built.
The shortest possible route, going around steep hills, and as straight as possible.
If you want to make it a bit wonky (depending on your world this would potentially create perfectly straight lines)
You could simply add a drunkards walk element to this, and make it possible for the road workers to choose a non perfect square to build on, make an un necessary turn, and so on.

Hope this has given you some ideas.

The more I think, the more confused I get.

Share this post


Link to post
Share on other sites
My choice for the rendering now is everything is in opengl. place a gulley on the tile, then stick a translucent and textured surface over it at the desired position and height for the water on that tile.

before now it would have just been ALOT of different textured tiles to stick on (which is also alot faster).

Share this post


Link to post
Share on other sites
I was thinking, the perlin noise idea for all of the trees, etc is probobly faster, but I think you might get more pleasing results if you start with say, a topology, which I would still use perlin noise to generate, and 20ft of dirt on top, trees placed randomly. Then I would simulate time, and let rain fall, creating rivers, wetlands, ponds, deserts... I''d let wind come through... create rocky, mountainous areas, etc...

Not sure yet if weathering a completely uniform piece of land into a very dynamic one would be easy to simulate or even better, than using our knowledge of how the land should look, and creating perlin noise functions to simulate it... I guess you have more control with perlin functions, but maybe won''t be as nice. The ecosystem method also seems like it would be very rewarding... not very efficient way though...

Ok, just thought it seemed like a good idea. Probobly best to use as a seperate demo or something... A lot of work for just instantiating a world that a player will play on..

Dwiel

Share this post


Link to post
Share on other sites