Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411486 Posts in 69371 Topics- by 58427 Members - Latest Member: shelton786

April 24, 2024, 08:37:10 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Random World Generation
Pages: [1]
Print
Author Topic: Random World Generation  (Read 1287 times)
mr_rho
Level 0
*


View Profile
« on: September 24, 2015, 01:28:10 AM »

World generation has been a passion of mine for a long time, and especially realistic world generation. I thought I'd share some of my progress on a game that I have been working on lately.

I start with a customised Perlin noise generator to produce a fractal landscape. Eight octaves with another perlin noise (4 octaves) produced layer of soil on top:



Seeing as this looks very noisy, I apply a soil erosion algorithm producing the following image:



Note the rocky outcroppings becoming more accentuated and the basins forming in the flatter areas. Finally I apply contours and the reason for this is that realistic surface water generation is trickier than you would think. I've been through about four algorithms and perhaps I'm just an idiot but some algorithms just fail on certain edge cases and tend to flood the world. With realistic surface water I mean a source in high elevations that create a river. If this flows into a contained basin, a lake must form, if that fills the basin, it needs to overflow into another river and so forth. With contours, this process is simplified and optimised. A contour has a contour above it which can either be open or closed (touches the edge of the map) if the contour is open, you don't need to go higher, as it overflows off the edge of the map. If it is closed however, you can check how many "child contours" it has. If it has more than one, you have to generate a river from the one contour to another as it "overflows" into an adjacent contour. This can continue until either a river flows off the edge of the map or a lake is formed on the edge of the map. The contour map as generated is displayed below. Some of the "squareness" in the basins is due to the soil erosion algorithm based on the grid structure. The contour image is not of the same images as the first two btw.

Time to generate on 2.2GHz Intel Core i7:
Perlin: 2-3s
Erosion: 700ms or so
Contours: 200ms or so
World size: 512 x 512

All of this is written in Java as a proof of concept.. will most likely be a lot faster in C/C++


« Last Edit: September 24, 2015, 01:40:39 AM by mr_rho » Logged
Cheezmeister
Level 3
***



View Profile
« Reply #1 on: September 24, 2015, 01:31:52 PM »

Interesting that all three images have the "mountain" (or is it a basin?) in the lower-right corner. Do you plan to simulate soil erosion caused by running water i.e. forming snaky rivers? Or is that what you're describing?
Logged

෴Me෴ @chzmstr | www.luchenlabs.com ቒMadeቓ RA | Nextris | Chromathud   ᙍMakingᙌCheezus II (Devlog)
mr_rho
Level 0
*


View Profile
« Reply #2 on: September 24, 2015, 06:43:16 PM »

Hey Cheezmeister,

Thanks for the reply. First off, the basin (lighter is higher) in the bottom corner is purely by chance... attached is an image where the basin is in the upper part of the map. The problem with Perlin noise is that you have to define a frequency together with an amplitude. Currently my frequency is the same as my map width which means there will be a single high point and a single low point. If you make the frequency less, like say 128 (of 512 width/height) you will get more mountains/basins. It is still highly random though. Also, with regards to your question on snaky rivers, my "soil erosion" algorithm already caters for that - see the second image. The way I erode soil is to flow everything down the steepest incline and therefore valleys form "naturally".




Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic