Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Planet sized terrain method

Author
Message
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 3rd May 2014 01:28 Edited at: 3rd May 2014 01:29
I am wanting to generate a planet's terrain. I want the detail to increase as the viewer approaches the surface. Here is a video showing it in action: (this is not mine, it's just an example)
http://youtu.be/0bQz5ugtfLY

The rough idea is to have 6 surfaces (cube faces) that will be "spherefied" once the detail level and the height map is applied. This will make a planet-shaped mesh with a rough surface. Each of the face of the cube is a separate quadtree object that uses the "distance" from the center (camera) to determine what detail level each chunk of the quadtree is at.

This works fine on approach, but I have a maximum level of detail that I can't get past. I'm using Perlin noise to generate the surface features, but it seems very plain until I get around 10 levels of detail. At 10 and higher, the noise starts to become lines like rows of plants in a garden. Here is an image:


I'm really not sure where to start to correct this. I think there is a limitation to Perlin noise that is causing this. It may be the use of floats causing this or it could be the sample size..... Don't know.

If this limitation exists, I think I might have to come up with a way to generate greater detail using a trick I've been thinking about.....

I don't want to waste too much time on this because I want to get back to the meat of my game. I put this part of it off as long as I can...

The fastest code is the code never written.

Attachments

Login to view attachments
Barry Pythagoras
10
Years of Service
User Offline
Joined: 14th Mar 2014
Location:
Posted: 3rd May 2014 02:13 Edited at: 3rd May 2014 02:16
It looks a bit different in each zone, so it looks like you just have to multiply the perlin noise by about 3 or something. But it's in rows so that's probably not going to help much.
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 3rd May 2014 03:53 Edited at: 3rd May 2014 03:54
Perlin noise is not appropriate for tiled/wrapped images. Try Simplex noise.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd May 2014 13:23
Quote: "Perlin noise is not appropriate for tiled/wrapped images"


Why not?

There are several seamless Perlin noise demos around on this site if that's what you're referring to.

The problem looks more like a simple coding error to me.



Powered by Free Banners
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 3rd May 2014 16:47
I'm not tiling/wrapping the noise. I'm using 3D noise and each 3D point on the "sphere" is taken as an input to get the noise output which is then used as a height value.

The fastest code is the code never written.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd May 2014 18:22
That should work fine so perhaps a coding or logic error is at fault in the noise calculation.



Powered by Free Banners
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 3rd May 2014 18:39
Because you can get results like what's in the picture. Whether that's the case in this case is open for discussion.

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 3rd May 2014 21:10
Here is the noise files: (not my creation)
perlin.h

perlin.cpp

I was thinking perhaps I should convert all the floats into doubles or some other mathematical data structure (a hybrid) to get better accuracy......

GG, bitJericho may have a point about using simplex noise.... I don't know--I've never used it. Is there a difference? What advantages/disadvantages are there?

The fastest code is the code never written.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd May 2014 22:57 Edited at: 4th May 2014 12:37
Quote: "Is there a difference?"


I believe they are essentially the same idea - the main difference if I recall correctly is that simplex noise uses a simplex for the corners of the basic shape whereas standard Perlin noise uses a box. The use of a simplex reduces calculation load in higher dimensions I believe.

In 2D a simplex is a triangle and a "box" is just a rectangle, in 3D a simplex is a tetrahedron and a "box" is in fact a box. Hence in 2d there is a 3:4 ratio but in 3D the ratio is 4:8 and gets better in 4D and higher.

Final results should be similar though. Someone posted a simplex noise plug-in or code which included spheres (plus more informed discussion of the basic idea ) if I remember correctly. I'll try to find the link and edit this post. Edit2 Here's the link:

Simplex noise plug-in

Edit3 Sorry . That's not quite the right link - but it should point you in the right direction.

Edit4 Here's the correct link hopefully.

http://forum.thegamecreators.com/?m=forum_view&t=189861&b=18

Edit Just had a quick peek at the code and the 3D version looks wrong to me: in 1D the code has constants b0 and b1, in 2D it has b00, b01, b10 and b11. I expected the 3D code to have b000, b001, etc, up to b111 (i.e. 8 combinations in all). Something ain't right.

Edit5 Corrected stupid typo.



Powered by Free Banners
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 4th May 2014 04:52
I was hoping for some c++ code.....

I think I have a method that might work: I generate a 1024x1024 heightmap using 3 samplings of Perlin noise. Each elevation point on the mesh is lerp'd so that points that fall between the elements of the array will have the correct value. This produces smooth slopes no matter how detailed the mesh. The sloped values are then perturbed by another sample of noise that is repeated, but varies with elevation so that low elevation areas have a small amount of perturbation while higher elevations have more. This produces a decent look, but it's not exactly what I'm looking for..... I would like to be able to procedurally generate terrain with (nearly) sheer cliffs at almost any elevation. An example of this would be a cliff near the ocean.

I also have another problem. The repeated noise map isn't seamless. This produces sharp edges at a regular interval. I would like to be able to generate a noise map that is seamless.

The fastest code is the code never written.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th May 2014 13:28
Quote: "I would like to be able to generate a noise map that is seamless."


If you want a seamless 2D heightmap there are several suitable code snippets around in the DBPro forums. Search for Perlin noise. If you're still stuck post back.

Quote: "I would like to be able to procedurally generate terrain with (nearly) sheer cliffs"


You would need to modify the Perlin noise function quite a bit to achieve that.

Quote: "I was hoping for some c++ code....."


Have you tried Googling Ken Perlin? When I last looked I found some detailed descriptions of his algorithms by the man himself. For example, a rather non-technical description of his basic algorithm can be found here:

http://www.noisemachine.com/talk1/

Where did you get the 3D code from? Each extra dimension adds more lines of code, bigger arrays, etc, but nothing new in principle. I'm sure I've seen an example of 3D code for this somewhere.



Powered by Free Banners
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 4th May 2014 15:41 Edited at: 4th May 2014 15:42
Quote: "Where did you get the 3D code from?"

I honestly don't remember. It was a while ago, so it could have been on this forum (or linked from this forum).
Here is a short video of what I have so far:

The texture quality is lame, but I'm more worried about geometry right now. I'm having a problem with the ocean z-fighting with the land and the overall geometry "popping".....

The fastest code is the code never written.

Login to post a reply

Server time is: 2024-04-27 21:01:53
Your offset time is: 2024-04-27 21:01:53