Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

878827 Posts in 32939 Topics- by 24349 Members - Latest Member: Ozymandias

May 22, 2013, 06:24:26 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Procedural Planetary Generation
Pages: 1 [2] 3 4 ... 10
Print
Author Topic: Procedural Planetary Generation  (Read 7760 times)
eigenbom
Level 10
*****



View Profile WWW
« Reply #15 on: May 01, 2012, 02:23:33 AM »

I'd start with the noise functions. first perlin noise, then a fractal version (fbm), then some more advanced method like ridged multifractals.
Logged

sean
Level 1
*



View Profile WWW Email
« Reply #16 on: May 02, 2012, 03:23:31 AM »

or start applying the quad to a sphere (somehow) or something else entirely?

As stated elsewhere, start applying the noise functions first.
I wanted to shed some light on the world sphere issue because it may be simpler than you are imagining.

If you take a subdivided cube (like a wireframe rubics cube but it works for any levels of subdivision) and assuming the vectors representing the vertices are from the centre, normalise them, you will get a sphere.



I know this is a very lightweight reply to a big challenge. Let me know if you want more specifics.

sean

p.s. Depending on details can be simple or difficult to apply your noise function to each quad. Remember that the noise functions applied to a quad on a flat plane will assume a direction perpendicualt to the plane (y-axis) if you are applying noise to a quad on a sphere you may need to take into account the normal of the quad (or rotate the whole thing).



Logged

rivon
Level 10
*****



View Profile
« Reply #17 on: May 02, 2012, 03:34:42 AM »

If you take a subdivided cube (like a wireframe rubics cube but it works for any levels of subdivision) and assuming the vectors representing the vertices are from the centre, normalise them, you will get a sphere.
Oh god, so simple? :D
Logged
sean
Level 1
*



View Profile WWW Email
« Reply #18 on: May 02, 2012, 03:39:18 AM »

Yay! I got the tessellating quads working correctly Smiley what would you recommend I work on now? The terrain generation (with noise functions) or start applying the quad to a sphere (somehow) or something else entirely?

Congrats! You sounds like you are well on your way.

There is an alternative approach that could be considered.

Follow this link here to the opengl book (yes opengl, i know) and scroll down to the title. An Example: Building an Icosahedron

This image perhaps explains it all in a flash.



There is a example code for recursive subdivision of spheres made from triangles. Clearly the example is just an algorithm and it needs o be engineered into a solution somewhat, but....if we use a variant of the normalise function that has pseudo-random noise added then you can get a unique world very quickly.

(i like this one because it looks all retro, with flat shaded wireframes etc)

hope this helps, if you need more, let me know if i can help...
sean

(edit: oops, fixed broken link)
« Last Edit: May 02, 2012, 07:36:36 AM by sean » Logged

Geeze
Level 5
*****


Totally.


View Profile
« Reply #19 on: May 02, 2012, 06:15:17 AM »

On a sidenote, have you considered using three dimensional noise instead of 2D, it's easy to apply to a. sphere, and is probably less distorted than plain 2D applied to sphere. You could basically loop through all vertices in sphere, calculate noise for that position and apply that as a heightmap.
Logged

sean
Level 1
*



View Profile WWW Email
« Reply #20 on: May 02, 2012, 06:26:16 AM »

If you take a subdivided cube (like a wireframe rubics cube but it works for any levels of subdivision) and assuming the vectors representing the vertices are from the centre, normalise them, you will get a sphere.
Oh god, so simple? :D

yup works with any shape, (try it on a teapot!)
the shape you choose varies the distribution of points over the sphere, so if you do choose a teapot, you may get more verts in some places than others.

normalise basically makes all points the same distance from the centre, i.e. spherical.
Logged

rivon
Level 10
*****



View Profile
« Reply #21 on: May 02, 2012, 09:58:17 AM »

Yeah, I understand how it works. It's just that it's so simple. I would never have thought there is so easy way to do this.
Logged
Hedgehodg
Level 1
*


...


View Profile Email
« Reply #22 on: May 03, 2012, 02:03:07 AM »

Wow, Thanks for all the posts!

Sean, are you saying that I should create a tessellating triangle rather then a tessellating quad in the case that I go with "An Example: Building an Icosahedron" since applying a quad to a triangle seems like quite an impossible task. However, from what I have read, most seem to use a cube to sphere algorithm of sorts, the planet noise is initially generated on a 6 sided cube (assumption), then when the user gets further away from the cube, it slowly morphs into a sphere. But if you recommend your away I would gladly implement it. And what do you mean with your initial post? :3

Eigenbom, would you recommend that I implement fbm, perlin and ridged multi-fractal noise (RMN)? Or just one of them, I've got a Java version of the RMN and pasted it into my C# project, and tested it against a basic mesh supporting a height-map. It seems to produce similar results to Perlin noise - what is the difference? Here is what I used: http://www.hayles.demon.co.uk/perlin/ridgedmf.html. In addition, how would I apply the RMN to the tessellating quad? It is easy enough with a height-map-mesh-thing since there are always the same amount of vertices, but I don't see how I can do it with the quad.

Logged

Previously known as "darestium"...
sean
Level 1
*



View Profile WWW Email
« Reply #23 on: May 03, 2012, 03:16:59 AM »


Sean, are you saying that I should create a tessellating triangle rather then a tessellating quad in the case that I go with "An Example: Building an Icosahedron" since applying a quad to a triangle seems like quite an impossible task.

i wouldnt attempt to take your quad noise mesh and apply it to a triangle. The example is meant to show there is more than one approach.

A triangle can be subdivided by adding a new vert at the middle of each edge and joining the old and new verts edges to  make 4 new smaller ones.



(from) http://www.rhythm.com/~ivan/dispMap.html

Now those triangles can be the triangles that make up the surface of a sphere.



(from) http://www.skofnunggames.com/?p=4

If you add an additional pseudo-random offset to the length of the vector representing each new each time you subdivide then you end up with a landscape.

With the spherical approach you can add  the pseudo-random (perlin or whatever you like) noise to the length of the vectors that represent these new verts.

Hey, i just found this... http://www.unifycommunity.com/wiki/index.php?title=MeshSubdivision

However, from what I have read, most seem to use a cube to sphere algorithm of sorts, the planet noise is initially generated on a 6 sided cube (assumption), then when the user gets further away from the cube, it slowly morphs into a sphere.

I dont think they generally morph between cube and sphere as you approach, but that the sphere/cube issue is one of the steps to get your quad patches onto the surface of a sphere.

But if you recommend your away I would gladly implement it.

I recommend finding an open source project that has already implemented it and using the code. ;-)
I used this approach for an elite space trading thing i was working on a few years back worked for me as i wasnt going to do any texturing and wanted all wireframe & flat triangles for that retro look.

And what do you mean with your initial post? :3

I'm not sure how low level to take it but basically if you have a mesh described by vectors measured from the centre. Or in other words a mesh at/around the origin. Then you apply the Normalise function (divide each vector by its length) to each of the vectors describing the verts. Now each of these vectors has a length of 1.0. Try it.



(from) http://mathproofs.blogspot.co.uk/2005/07/mapping-cube-to-sphere.html
Logged

eigenbom
Level 10
*****



View Profile WWW
« Reply #24 on: May 03, 2012, 03:47:30 PM »

I personally wouldn't just copy/paste, except for the perlin_noise() function. I only suggest noise -> fbm -> ridged multifractal because you can incrementally build up one after the other. Terrain functions (as are most procedural methods) are very difficult to tune to get what you want, so I'd take my time with this step.

Ridged multi-fractal noise has a lot of fine detail, so if you're applying it to a coarse meh, then it will probably look like any other method. Try applying it to a really fine mesh. You will have to tweak the various parameters until you get something worthwhile..

Oh btw, I dug up some procedural stuff I did 6 years ago, pretty crappy texturing, but I was just learning computer graphics at that stage! Tongue

Logged

Hedgehodg
Level 1
*


...


View Profile Email
« Reply #25 on: May 03, 2012, 11:41:47 PM »

Wow! That looks completely awesome! Smiley So, I would prefer to go with the method using tessellating quads rather then triangles for no other reason then I think it makes more sense in my head that way. But how would I apply the noise to the quad and how do I apply the quad to the sphere? Any suggestions? Also, when you say "I only suggest noise -> fbm -> ridged multifractal because you can incrementally build up one after the other." does that mean I can mix them together?  Undecided
Logged

Previously known as "darestium"...
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile WWW
« Reply #26 on: May 04, 2012, 05:02:57 AM »

Well, I'd recommend not worrying about the sphere, for now.

For instance,
The highest mountain on Earth is 8.8 km and the Earth's radius is ~6371 km.
A billiard ball's radius is 2.25 in and by regulation can't have any marring of more than 0.005 in.

This means that the maximum perturbation on Earth is 0.1381% of the radius and on a billiard ball is 0.2222%. So the Earth is ~63% as bumpy as a billiard ball.

So, I'd suggest getting a heightmap working with perlin (or some other noise) on a flat plane.  Only when you have that would I worry about mapping that on to a sphere.

To do that, I'd recommend looking into geodesy.  There are quite a few wikipedia articles on geodesy that might help you out, but basically, you are going to want to have work in a couple of coordinate systems for convenience.
I'd recommend thinking of your height maps as Lon/Lat/Alt and then converting them to ECEF (Earth-Centered, Earth-Fixed) or ECI (Earth-Centered Inertial).
Logged

Hedgehodg
Level 1
*


...


View Profile Email
« Reply #27 on: May 04, 2012, 03:37:27 PM »

Sean, regarding your initial post, are you saying if I make a cube out of the quads and I just normalise each vertex I get a sphere? and could you please explain the following: "assuming the vectors representing the vertices are from the centre, normalise them, you will get a sphere." but I don't see how that works...
Logged

Previously known as "darestium"...
eigenbom
Level 10
*****



View Profile WWW
« Reply #28 on: May 04, 2012, 03:43:29 PM »

But how would I apply the noise to the quad and how do I apply the quad to the sphere? Any suggestions?

The terrain function just perturbs the vertices of the quad. To do this (in general) you need (a) the "coordinates" of the vertex, and (b) the normal of the vertex. In a 2-d plane, the coordinates can just be the absolute coordinates of the vertex, and the normal is "up".

So in that case (assuming Y is up), your perturb function would be something like...
Code:
function perturb(v)
  v.pos += vec3(0,1,0) * terrain(v.x,v.z)
end

And your "terrain" function might be...
Code:
function terrain(x,y)
  return abs(noise(x,y))
end

When mapped to a sphere, the coordinates could be either the absolute 3D coordinates or planet local coordinates e.g., (latitude,longitude). Probably the absolute coords would be easiest, but then you need a terrain function that acts on 3d coords. The normal of the vertex on a sphere is the vector pointing attaching the center of the sphere to the vertex. But again, I'd leave this until you show us some awesome terrain acting on a 2d plane..

Quote
Also, when you say "I only suggest noise -> fbm -> ridged multifractal because you can incrementally build up one after the other." does that mean I can mix them together?  Undecided

well noise is the basic building block. fbm justs sums a bunch of noise functions. and ridge multifractal also sums a bunch of noises, but in a more complex way.

If you want to really investigate this area, I'd start with a noise function, then trying different ways to use it, e.g.,

Code:
function my_terrain_1(x,y,z)
  return abs(noise(x,y,z))
end

function my_terrain_2(x,y,z)
  return noise(2*x,y+sin(x),z)
end

function my_terrain_3(x,y,z)
  float val = 0
  for(int i=0;i<4;i++)
    val = noise(x,y,z) * pow(2,-i)
  return val
end

Each of these should have "different" characteristics.

And definitely you can combine functions. A good trick is to have a bunch of different terrain functions, e.g., RockyMountain, Desert, and Plains, and combine them in different ways, so you have a desert region in one part of the map that morphs into mountains in another part, and so on...

Logged

Hedgehodg
Level 1
*


...


View Profile Email
« Reply #29 on: May 04, 2012, 06:58:48 PM »

Ok, sounds like a good idea. I'll take your advice and play with some noise functions Wink. Could you recommend and good implementations of Perlin/Simplex Noise? I've read the following http://freespace.virgin.net/hugo.elias/models/m_perlin.htm and found I quite interesting :)But there appears to be little C# examples of a perlin noise module. And so I guess I'll start out with 2D noise?

So, like you said I'll just have to play with it until I get the type of functions that I want i.e if I want a function makes the terrain more like the moon (craters), or one that is more mountainous, etc?
« Last Edit: May 04, 2012, 07:46:11 PM by Darestium » Logged

Previously known as "darestium"...
Pages: 1 [2] 3 4 ... 10
Print
Jump to:  

Theme orange-lt created by panic