Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411576 Posts in 69386 Topics- by 58444 Members - Latest Member: darkcitien

May 05, 2024, 02:35:36 AM

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


@eigenbom


View Profile WWW
« Reply #100 on: June 02, 2012, 11:43:36 PM »

so the idea was that you want to keep the angle of the point but change its dist from the center so all points are equally distant

yeh i just meant use a vec3 to store the radius,longitude and latitude, so in that case p.r just means p.x .. but the way you did it is clearer, so stick with that..
Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #101 on: June 02, 2012, 11:47:16 PM »

I don't think this looks correct:
Logged

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


...


View Profile
« Reply #102 on: June 02, 2012, 11:51:37 PM »


Code:
    private void Spherise() {
            for (int i = 0; i < vertices.Count; i++) {
                float radius = this.radius;
                float longitude = 0;
                float latitude = 0;

                float sphereRadius = 32;

                Color color = vertices[i].Color;

                ToPolar(vertices[i].Position - centre, out radius, out longitude, out latitude);
                Vector3 position = ToCartesian(sphereRadius, longitude, latitude) + centre;

                Vector3 normal = vertices[i].Position - centre;
                normal.Normalize();

                vertices[i] = new VertexPositionColorNormal(position, color, normal);
            }
        }
« Last Edit: June 03, 2012, 12:06:40 AM by darestium » Logged

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


@eigenbom


View Profile WWW
« Reply #103 on: June 03, 2012, 02:27:45 AM »

make sure the cube is actually centered exactly around the centre point?
Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #104 on: June 03, 2012, 11:27:36 PM »

LOL, that would help :D, still doesn't produce a sphere though:

Logged

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


@eigenbom


View Profile WWW
« Reply #105 on: June 03, 2012, 11:43:38 PM »

i would do a bunch of tests, slowly apply more of the spherify operation on the cube to see whats going wrong, e.g., render an image at lerpAmount=0, another one at lerpAmount=0.1, lerpAmount=.2, ..., etc... you should see a cube slowly turning into a sphere, good luck..

Code:
...
const float lerpAmount = 0;
Vector3 lerp = (position - vertices[i].Position)*lerpAmount + vertices[i].Position;
vertices[i] = new VertexPositionColorNormal(position, color, normal);
Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #106 on: June 05, 2012, 01:42:24 AM »

Well, I'm trying to figure out what the hell is wrong... (O_o)

Lerp 0.2f



Any ideas? If not... I'll just keep playing with the lerpy until I figure what the hell is wrong :D

Code:
        private void Spherise() {
            for (int i = 0; i < vertices.Count; i++) {
                float radius = this.radius;
                float longitude = 0;
                float latitude = 0;

                float sphereRadius = 32;

                Color color = vertices[i].Color;

                ToPolar(vertices[i].Position - centre, out radius, out longitude, out latitude);
                Vector3 position = ToCartesian(sphereRadius, longitude, latitude) + centre;

                Vector3 normal = vertices[i].Position - centre;
                normal.Normalize();

                const float lerpAmount = 0.2f;
                Vector3 lerp = (position - vertices[i].Position) * lerpAmount + vertices[i].Position;
                vertices[i] = new VertexPositionColorNormal(lerp, color, normal);
            }
        }
Logged

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


@eigenbom


View Profile WWW
« Reply #107 on: June 05, 2012, 05:49:07 AM »

Hmm weird, I would check that your polar function is working properly.. An easy way would be to randomly generate a bunch of lats and longs with a constant radius and then draw their x,y,z as points and see if it's a sphere..

Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #108 on: June 12, 2012, 02:45:02 AM »

Yay! It works!!!




I'll have to fix that issue on the front face - it defiantly doesn't have anything to do with the cube to sphere(ing) process - something to do with the way I am defining the front side. Anyhow I'm sure I'll figure it out... So now for generating the terrain on the sphere?
Logged

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


@eigenbom


View Profile WWW
« Reply #109 on: June 12, 2012, 04:37:42 AM »

Cool to see you're still working on this dude!
Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #110 on: June 13, 2012, 11:43:27 PM »

Hmm... Good sir, I was wondering when exactly should I generate the noise and apply it to the vertices? before or after I sphereise the cube? If it is the former, will it look smooth on the edges?

Fixed the weird problem with the front face:

Logged

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


@eigenbom


View Profile WWW
« Reply #111 on: June 13, 2012, 11:54:18 PM »

apply the terrain function to the already spherised verts young padawan

Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #112 on: June 14, 2012, 11:05:17 PM »

Yes master. Okay, done that, here's what I've got... Not too pretty but (I get really weird artifacts from the back faces because of the lighting difference... Sad ), meh:

What would you recommend I do now? Play with the noise function until I get a normal looking terrain? make the planet larger? Texturing? Or something completely different?



Code:
                Vector3 lerp = (position - vertices[i].Position) * lerpAmount + vertices[i].Position;

                float offset = (float)RidgedNoise.RidgedMultifractal((vertices[i].Position.X / dimensions.X) * frequency, (vertices[i].Position.Y / dimensions.Y) * frequency, (vertices[i].Position.Z / dimensions.Z) * frequency, 1, lacunarity, octaves, 1, 2) * amplitude;
                lerp += normal * offset;

                vertices[i] = new VertexPositionColorNormal(lerp, color, normal);

Oh, and I'm going to start reading the book today! I've read the forward, and introduction already and it seems to be exactly what I need to be reading/learning. Thanks for the recommendation!
« Last Edit: June 14, 2012, 11:26:09 PM by darestium » Logged

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


@eigenbom


View Profile WWW
« Reply #113 on: June 14, 2012, 11:23:09 PM »

hey that's starting to look pretty cool, with more detail and texturing and lighting it'll look really solid Smiley

what you do next is up to you, there's a million things to choose from Tongue

Logged

Fallsburg
Level 10
*****


Fear the CircleCat


View Profile
« Reply #114 on: June 15, 2012, 05:19:16 AM »

I'm just going to go ahead and post this again:

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.

Your terrain is way too intense for that sphere (unless you are going for something way smaller than a planet, like something Phobos or Deimos sized). 
Logged
rivon
Level 10
*****



View Profile
« Reply #115 on: June 15, 2012, 05:56:54 AM »

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.
He's already done that.
Logged
fentlewoodlewix
Level 1
*


View Profile WWW
« Reply #116 on: June 15, 2012, 06:16:59 AM »

What would you recommend I do now? Play with the noise function until I get a normal looking terrain? make the planet larger? Texturing? Or something completely different?



Oh, and I'm going to start reading the book today! I've read the forward, and introduction already and it seems to be exactly what I need to be reading/learning. Thanks for the recommendation!

well, this looks really awesome! you have done a lot of great work.

perhaps you could scale back the height of the mountains a bit? though even "realistic" games it is often worth exaggerating some features for entertainment purposes so maybe the mountains could be extra high but not 1000s of km high?

questions you might ask yourself are...
 * how realistic are you planning to go? 
 * what is the target hardware?

working out the answers for these wil allow you to cut a lot of corners later on.

finally, for en experiment i'd add in a blue spere at sea level then some mountains would be above water and this dryland others below would be seabed.

keep up the good work, this looks amazing! are you planning of doing open source?
Logged
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile
« Reply #117 on: June 15, 2012, 06:19:51 AM »

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.
He's already done that.
Right, sorry, copy-pasted without looking too deeply at what I copy pasted.  Although I still stand by it, sort of.  Mountains are only going to be very large at a very fine level of detail, i.e. very close to a flat plane.  If I were going about this, I would worry more about getting the level of detail stuff working and less about mapping the noise to a sphere.
Logged
eigenbom
Level 10
*****


@eigenbom


View Profile WWW
« Reply #118 on: June 15, 2012, 03:19:43 PM »

Yeh it all depends on if you wanted to do a mario galaxy or spore style planet, as opposed to one of those more realistic planets they have in flight sims and the like, or something in between ..

So maybe having a goal game in mind will help drive those decisions. Personally I'd go for something dramatic and surreal rather than realistic. Although I do agree that your current amplitude is probably too much, but its early stages. Smiley
Logged

Hedgehodg
Level 1
*


...


View Profile
« Reply #119 on: June 17, 2012, 12:32:45 AM »

Thanks guys Smiley um, well, I was really not planning to have the terrain too realistic, since, I think the amount of work involved would be gigantic. So I think I'll go for something on the more realistic side, with a touch of "Mario Galaxy" (65%, 35%). In regards to the Open Source question - I really don't know... Never thought of it :D. And yeah... I really do think the amplitude is *way* too high. Oh, and I also stuffed up something somewhere (I gave each side a unique colour to help me debug the problem I have created... The hole in the  centre front and back faces...)

And yes... I guess my main priority should be getting the terrain looking realistic and nice. I would really love to finish with the main parts of the sphere first: Get it "sphereing" correctly, then writing level of detail algorithm. I'll properly spend a lot of my time working on the terrain generation and texturing the terrain after that...

« Last Edit: June 17, 2012, 02:58:49 AM by darestium » Logged

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

Theme orange-lt created by panic