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, 09:12:32 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Procedural Planetary Generation
Pages: 1 2 [3] 4 5 ... 8
Print
Author Topic: Procedural Planetary Generation  (Read 25345 times)
motorherp
Level 3
***



View Profile
« Reply #40 on: May 08, 2012, 08:19:05 AM »

Heya sean and darestium, just for clarification, the method you describe where you normalise the vertices of the cube to get a sphere and the one you linked to on 'Maths Proof' aren't quite the same. 

Using a normalisation approach like you describe is the simplest way to map from a cube to a sphere but also results in a fair amount of warping.  What you'll find is that there will be a regions with a high density of verts on the resulting sphere which correspond to where the cube corners used to be, and regions with a low dnesity of verts which correspond to the faces.  The un-even distribution of vertices will result in a stretching of your textures when you then texture map the sphere.

The mapping equation given on 'Maths Proof' is slightly different. Its more like 'bending' the faces of the cube around a sphere and stretching the surface more evenly.  This results in a more even distribution of vertices on the resulting sphere and hence less texture warping.


@darestium - I've been working a bit here and there on some procedural space stuff myself in my spare time.  I'm not tackling the issue of generating planet terrain meshes like you are but you might find some of it useful or helpful anyway.  Take a look at the link in my sig if you're interested.
Logged
Hedgehodg
Level 1
*


...


View Profile
« Reply #41 on: May 09, 2012, 11:16:46 PM »

@motorherp Wow... You beast Tongue I just hope what I make looks as good as yours!

@eigenbom Okay, I've got this thus far (I've just started on it now been studying for tests and doing assignments Sad damn school getting in the way of my coding :D and just come back to this today...)



with the following code:

Code:
        private void ConstructHeightmap() {
            float[,] data = new float[100, 100];
            float frequency = 1;
            float amplitude = 8;

            PerlinNoise.Initialize();

            for (int x = 0; x < data.GetLength(0); x++) {
                for (int y = 0; y < data.GetLength(1); y++) {
                    data[x, y] = (float)PerlinNoise.Noise(x * 0.1f * frequency, y * 0.1f * frequency, 0) * amplitude;
                }
            }

            map = new Heightmap(data);
            mesh.ApplyHeightmap(map);
        }

oh, and I blew $60 AU on the book Smiley so I hope it arrives soon (I ordered it 4 days ago and it's coming from the UK). And by the way was does lacunarity mean exactly? FYI, I subscribed to the moonman feed Smiley looks like an awesome game, I will be sure to purchase it when you release it!
« Last Edit: May 09, 2012, 11:46:38 PM by darestium » Logged

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


@eigenbom


View Profile WWW
« Reply #42 on: May 10, 2012, 12:19:14 AM »

And you're on your way! I think lacunarity is similar to fractal dimension.. but i could be wrong. it'll be in the book anyway. Tongue

and thx for following moonman. it'll be released .. one day... O_O
Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #43 on: May 10, 2012, 03:12:52 AM »

So right now you recommend that I just experiment with the noise functions (all of them together?) but how would I go about creating higher terrain in one place then the other? For example in the following screen shot everything is pretty much at the same height (used perlin + ridged):



But in the following image there are both slopes and "hills" and things based on different "levels":



How do I achieve with the terrain like the one directly above? Is it with the accumulation of ridged noise, e.g: you build the terrain with a mid amplitude low frequency noise, then you apply all the bumps with a high frequency very low amplitude noise? Any other advice would be much appreciated Wink
Logged

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



View Profile
« Reply #44 on: May 10, 2012, 06:39:46 AM »

Do a few passes with various scales? Example: generate terrain in 1024x1024 resolution, then subdivide it so that you have 4 smaller parts, then apply 1024x1024 terrain to each of the smaller parts. Then do it again for smaller parts. Something like that. Experiment with different scales etc.
Logged
eigenbom
Level 10
*****


@eigenbom


View Profile WWW
« Reply #45 on: May 10, 2012, 02:20:23 PM »

i seem to recall that ridge multifractal made the terrain rough on mountains and smooth on plains (as shown in the second pic) ...

but here's some tips:
- Why don't you first update your rendering code to render the terrain solid and smooth. I can't really see what's going on (have wireframe, solid, smooth, and smooth+wireframe modes).
- then just try as rivon suggests. you should see big hills with smaller scale detail. the trick is to scale the amplitude too. See e.g., the NOISE(x) function here.

Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #46 on: May 11, 2012, 01:05:42 AM »

When you say "subdivide it" do you mean I do it on my tessellating quad? Or can I do this straight on a height-map? So for each iteration of the quad I apply it's parent's height-map to itself? O_o And I added the functionality to swap between wire-frame and solid, the problem is you can't really see the different in height (no lighting) so I guess I'll have to implement very basic lighting in order to be able to differentiate between different heights...
Logged

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



View Profile
« Reply #47 on: May 11, 2012, 04:11:44 AM »

I would do something like generate the first big terrain, subdivide it. Generate another 4 heightmaps and add them with some scale modifier (height(x, y) * 0.4) to the four smaller parts. Repeat... If you know what I mean.
Logged
nikki
Level 10
*****


View Profile
« Reply #48 on: May 11, 2012, 02:56:43 PM »

Maybe slightly off topic but what are good methods to look into for creating rivers in a world thats created with noise(x,y,z)?

can't really find anything particular about it
Logged
eigenbom
Level 10
*****


@eigenbom


View Profile WWW
« Reply #49 on: May 11, 2012, 03:18:21 PM »

yeh you'll need to turn lighting on, and also the vertex normals so they shaded properly. just try to do it slowly and methodically. Smiley

Maybe slightly off topic but what are good methods to look into for creating rivers in a world thats created with noise(x,y,z)?

can't really find anything particular about it

i'm not sure, but my guess is that there isn't really a nice explicit function for believable rivers. i guess if i were to do it, i'd just write a 'river' generator that drops a point in the map and then travels down stream "carving" out the river along the way...
Logged

nikki
Level 10
*****


View Profile
« Reply #50 on: May 11, 2012, 03:26:52 PM »

but when 'chunks' are generated dynamically -on request it could just as be be an upstream location that's generated later then the downstream place,   so there is no carving along the way ?
Logged
Hedgehodg
Level 1
*


...


View Profile
« Reply #51 on: May 11, 2012, 08:45:21 PM »

Okay, my attempt at lighting (top view). So now just play with the noise functions and continue to wait for the book to arrive?



Now, back to Super meat boy :D
Logged

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


@eigenbom


View Profile WWW
« Reply #52 on: May 11, 2012, 09:31:36 PM »

but when 'chunks' are generated dynamically -on request it could just as be be an upstream location that's generated later then the downstream place,   so there is no carving along the way ?

ha hah, yes, you're right. it's a tricky problem. i'm sure you could hack a local noise(x,y,z)-like solution to generating channels that look like rivers. But I think a more realistic solution like the one i proposed means that chunks are no longer independent. in this case you could do a rough pass of lower res terrain to get the global structure of the river network.

Okay, my attempt at lighting (top view). So now just play with the noise functions and continue to wait for the book to arrive?

great work! But let's have an isometric view. Yes, keep playing around with it. Try to get a feel for what noise is actually doing. Do some summed fractal noise .. it should be like noise, but "rougher" ...

Code:
function summed_fractal_noise(x,y)
  val = 0
  for i=0 to 3 do
    scale = pow(2,i)
    val += noise(x*scale,y*scale)/scale
  end
  return val
end
Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #53 on: May 12, 2012, 01:03:08 AM »

Wow! That function is awesome - super rough (using summed perlin noise):



Code:
        public static float NoiseSummed(double x, double y) {
            float val = 0;
            double scale = 0;

            for (int i = 0; i < 3; i++) {
                scale = Math.Pow(2, i);

                val += (float)Noise(x * scale, y * scale, 0) / 2;
            }

            return val;
        }

By isometric do you simply mean rotated 45 degrees? or with a isometric projection?
Logged

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


@eigenbom


View Profile WWW
« Reply #54 on: May 12, 2012, 03:48:02 PM »

That code is wrong in an important way...

val += (float)Noise(x * scale, y * scale, 0) / 2;

should be

val += (float)Noise(x * scale, y * scale, 0) / scale;

because you want to make each new term in the sum contribute less to the shape of the terrain.

In English ... you make big hills with i=0, then smaller hills on those hills with i=1, then even smaller hills on those hills, etc..

And yeh, i just meant a view-point that is looking down at an angle. It's hard to see what's going on looking straight down. something like that:
Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #55 on: May 12, 2012, 04:53:30 PM »

Okay, I fixed the code up and moved the camera and it's target...



Yup, I think that makes sense; the larger the scale the smaller the hill.
Logged

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


@eigenbom


View Profile WWW
« Reply #56 on: May 12, 2012, 05:01:16 PM »

looks good, but it still doesn't look correct ...

turn the for loop into the following..
Code:
const int LEVELS = 3;
for (int i = 0; i < LEVELS; i++) {
...
}
then render (and post) images for different LEVELS values, e.g., LEVELS = 1, LEVELS = 2, LEVELS = 3, ...

at levels=1 you want just a couple of hills in your terrain
Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #57 on: May 12, 2012, 05:46:07 PM »

The screenshot in the previous post had a height-map with a sized of 600x600

Level 1 (100x100 sized height-map):



Level 2 (100x100 sized height-map):



Level 3 (100x100 sized height-map):

Logged

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


@eigenbom


View Profile WWW
« Reply #58 on: May 12, 2012, 09:09:17 PM »

Yeh that looks correct, so the scale and everything looks alright. Now increase the terrain resolution and the number of LEVELS, maybe 1000x1000 verts and 8 LEVELS?

After that the next step is either to implement ridged multifractal noise, which should give you much more 'realistic' terrain..
Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #59 on: May 12, 2012, 09:54:29 PM »

There is one problem according to this runtime error: XNA Framework HiDef profile supports a maximum of 1048575 primitives per draw call, so I'll have to split the terrain into sections and render then individually if I want to get more then 1048575 primitives... The maximum I could get to (rounded to the nearest 100) is 700x700.

700x700, 8 Levels:



Logged

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

Theme orange-lt created by panic