Skip to main content
GameDev.net gamedev.net
🔒 Locked

Procedural Islands

Started by AdamWebb Oct 15, 2005 at 4:05 PM 15 replies 2.3k views
Original Post
AdamWebb
AdamWebb
For a demo I'm working on, I am trying to procedurally generate and then render an island. I can't find any information on fractal terrain generation beyond the standard 'mountain style' landscapes. None of these techniques will produce heightmaps that can be used to represent islands. Has anyone done any work along these lines or could someone point in the right direction? Thanks.
UltimaX
UltimaX
Why don't you make a hybrid of the fractal generators to handle islands? It does not matter what algorithm you use (Particle deposition, midpoint displacement, fault formation, etc.), as the technique would come after the generated height map is created. The idea I had immediately come to mind was this:

[EDIT]
I did some images real quick to help give you the idea

1) Generate heightmap based off of desired algorithm



2) Rescan the heightmap and cap values below a certain criteria. Kind of like how you do clouds with noise generators. For instance, any pixel below the shade value of 128 you would make black. This will give you nice round looking islands that were formally mountain tops.



3) Apply a brightness filter to darken the image. This will lower the height of the islands (remember they use to be mountain tops) and make it more natural. (You also may need to play with the contrast too)



4) (This is optional and the image is blurred too much, but you get the idea)If needed apply a smooth filter to smooth any rough edges around the islands base where the beach should be.


Then that should be it. I have never tried this technique, but it is the only thing that came to my mind at the moment.

[EDIT#2]
Also, you might want to look into terrain flattening and also terrain normalizing as those might be a better and faster choice than my idea :-)

Best of luck!

[Edited by - UltimaX on October 15, 2005 4:31:45 PM]
AdamWebb
AdamWebb
Thanks UltimaX, that was a great help.

But your method produces relatively flat islands, could a similiar technique be adapted from the standard fractal algorithms to produce more diverse terrain?
UltimaX
UltimaX
Last idea:

I got this using the same technique, but inverting the image first:


It has more detail and not so flat islands. If I didn't have to leave for New Jersey tomorrow for a business trip I would write you a quick demo to produce islands. I just wanted to give you some food for thought and hopes that someone else may be able to extend upon this or give another method.

Best of luck Adam
MumbleFuzz
MumbleFuzz
Have a look at how libnoise works. It's fairly easy to compose noise functions with various filters (as UltimaX did), and it provides a neat framework for doing so. It might give you some ideas.
MumbleFuzz
Sordith
Sordith
This tutorial creates some decent looking islands. Also, the Particle Deposition algorithm is supose to create islands.
Peregrin
Peregrin
If you want a single large island you could constrain the height map to a hemisphere. Here's what I did:
1. Create a fractal map (in this case using mid-point displacement).
Image Hosted by ImageShack.us
2. Constrain to a hemisphere (see code below).
Image Hosted by ImageShack.us
3. Apply textures, shadows etc.
Image Hosted by ImageShack.us

Here is the hemisphere algorithm:
// Change every value depending on its distance from the center of the terrain:for (x = 0 ; x < m_iHighResSize ; x++)	for (z = 0 ; z < m_iHighResSize ; z++)	{		// Calculate the distance from center of the map (D = sqrt(R^2 - dX^2 - dZ^2):		l_fDist = sqrt(pow(l_fRadius, 2) - pow(x - l_fRadius, 2) - pow(z - l_fRadius, 2));		// If the result is negative, the point is outside the sphere:		if (l_fDist < 0.0f)		{			m_fpHighResMap[x * m_iHighResSize + z] = 0.0f;		}		// Otherwise, the point needs to be weighted using its distance from the center:		// (sqrt(R^2 - X^2 - Z^2)) / R, or distance / radius		else		{			m_fpHighResMap[x * m_iHighResSize + z] *= (l_fDist / (l_fRadius));		}


And this is how it looks with an ocean and a skybox:
Free Image Hosting at www.ImageShack.us
Hope this helps.
Jooleem. Get addicted.
deffer
deffer
A bit offtopic, maybe.
Peregrin, how do you calculate new mid-point height? I'm asking because your generated terrain seems to be somewhat "aligned" in y=-x axis.

I may be wrong, but from what I see, it goes:
A--a--B|\    || \   |d  E  b|   \ ||    \|C--d--DE = (A + D) / 2;E.y += random11() * some_coeff *  (A-D).length();


I was using that (or similar) formula a while ago (and for a while). Then I realized that with first line changed to:

E = (A + B + C + D) / 4;

it gives much nicer results.

Is that the case here?
Peregrin
Peregrin
Deffer, I used the diamond-square algorithm described here.
Jooleem. Get addicted.
deffer
deffer
Hm...
If that's how the things are, then I'm confused...

Mind explaining how is it possible, that using a completely symmetrical algorithm gave you very un-symmetrical result?
(It is random, of course. The distortion I'm talking about, however is clearly of non-random nature - the picture has significantly higher frequencies along y=x axis and lower along y=-x axis. Unfortunately I have no idea how I could perform a 2D FFT without writing a routine myself, but I'm sure it would show that instantly.)
Peregrin
Peregrin
Hi Deffer,

I'm confused. I don't really notice any difference between the frequencies of the two diagonals. Could you please highlight them for me?

Also note that the third picture (the textured one) has a simulated directional light, coming from the left. The light causes self-shadowing, so in that image it does appear as if the diagonals are different. Is that what you mean?
Jooleem. Get addicted.
DekuTree64
DekuTree64
Hmm, I think it's just been skewed, not actually generated like that. It looks to me like an off-by-one error, and reading that paper, I think I see what it is.

Peregrin, are you using a 257x257 array in memory when you generate the heightmap, and then saving it out as a 256x256 image? If so, then make sure you multiply y by 257 each line, not 256.

That said, I think it's actually a cool technique :)
Could be interesting in a perlin noise type generator to skew each octave of noise by random amounts in the x and y directions before adding them together.
deffer
deffer
I don't think it's just skewed. Skewing does not just appear along y=-x axis.

I'll try describing it a little better.

Quote:
Original post by Peregrin[/]
Also note that the third picture (the textured one) has a simulated directional light, coming from the left. The light causes self-shadowing, so in that image it does appear as if the diagonals are different. Is that what you mean?


Yes, but not only. The coloring of your last image is showing altitude.
Look at this enlarged part of the image you previously posted:
Image Hosted by ImageShack.us
Aren't all the mountains going from south-west to north-east? And it's just a minimap, so it lacks details.


The original heightmap image you posted is looking like a fog being blown by the wind coming from north-west.


Well, I guess this wasn't the hell of an explanation. I'll try to write a 2D FFT @home tonight, if I find some time. I think it would show something worth looking at.
trippytarka
trippytarka
If the diamond square algorithm fits your needs, then you can simply alter it to set all edge values to zero. That way you get an island like this:



Ignore the awful colouring please. :)
deffer
deffer
Ok, so I managed to produce 2D FFT from Peregrin's original heightmap.
This image shows the interesting part (enlarged).
Free Image Hosting at www.ImageShack.us
Clearly it emphasises one diagonal over another. This always means that orthogonal lines on original image are dominating. That shouldn't be happening on semi-randomly generated image.

As to the original topic, I second trippytarka.
Somehow force the edges of the heightmap to be at 0 altitude, then subdivide the rest (with any method, diamond square should be good).
AdamWebb
AdamWebb
Quote:
Original post by Peregrin
Here is the hemisphere algorithm:
*** Source Snippet Removed ***

And this is how it looks with an ocean and a skybox:
Free Image Hosting at www.ImageShack.us
Hope this helps.


Peregrin = My Saviour

Seriously, that's an awesome result, thank you. If what I produce turns out half as good as what you've done I'll be very happy.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.