- Home /
Procedural Mountain Generation
I would like to be able to generate mountains out of my terrain, but a problem I am having is that the only was I can make the mountains look like actual mountains is doing this:
if (height > 175) {
height *= height/175;
}
Which include a threshold to check if the height is over, then it will generate a nice looking mountain, but I would like it to match my biome system. So if the biome is "Mountain" it will generate a mountain there even if its not over 175. I want to be able to have flat terrain someplaces while I have bumpy terrains other places.
Full generation code: http://pastebin.com/vvdDNCgK
Would I be able to do something like this?
var terrainHeight = 250;
if (Biome == "Mountain") {
height += height / terrainHeight;
}
It would work fine if the terrain wasn't so rough, and high someplaces.
EDIT: I played a little with the perlin noise generation variables and got some fine results, now my question is how can I make the heigher spots (Mountains) more rough while the rest of the terrain is just normal :)
Result:
sorry the question wasnt entirely clear to me. there's many maths options to do the kind of thing you say, however i couldnt be more precise at this stage. i dont know the biome system is. you can have some kinds of extra variable to govern zones, you can for example use perlin noise, say
if 2dnoise >0 terrainheight*= 1-2dnoise
(or 1-sqrt(2dnoise) for diff. gradient)
would make half the map gently flatter mountains.
for the 2d noise you can use mathf.perlinnoise(worldspaceX,worldspaceZ)
Do you mean something like this?¨
if (Biome != "$$anonymous$$ountain") {
noise = $$anonymous$$athf.Sqrt(noise);
}
Because that gives weird looking mountains like the rest of the things I tried.
Hey, sqrt only increases values towards 1 from zero, thus turning a sinewave more into a square wave. I have done alot of mountain maths but i don't actually understand your question, i dont know what a biome is, and what equations govern zones that are a biome and a mountain. Have a play at my mountains code if you like. you can see i made flat zones corresponding to perlin.noise(x,z)<0... press space to fly forwards: the code is on sale incidentally. it mixes 100 mountain zone formulas potentially, here is abotu 15 of them. https://dl.dropboxusercontent.com/u/114667999/landscape%20flying%20hd/landscape%20flying%20hd.html
I biome is a zone, which have some specific values. I want my mountain biome to be an actual mountain like in the webplayer you link is refering to. To have the basic flat land world and then if the biome is mountain a mountain would pop up. :)
mountain generation is of 2 kinds... one equation like sine cosine perlin, or loop many mountains and add them. we all use perlin and sometimes loop it. it's fast but it loses control of what you need, placing things at specific places. normally we make the biomes a result of the perlin and not the other way round... to make mountains in a particular zone here is a solution:
this will make round zones filled with mountain:
take a centre of the biome, tell the map...
go through all map points, if map point distance < than biome centre + biome edge distance, then multiply map height by (perlin noise) * (map point distance from biome centre ) that will give round biome zones. you can use 2-3 circles to avoid them being round.
i make my flat zones by using a second noise function, multiply it and clamp it by 2 so it roughly is like /''''\...../''''\....
waveshape ... and then i multiply the mountains size by this waveshape, so that there are flat areas, and high areas, and in between it lerped by slopes, from the perlin fct. i will have the infinite terrain on the asset store soon hopefully, im abit slow! cheers
Answer by Cherno · Sep 28, 2014 at 04:03 PM
Take a look at the After Playing Minecraft thread, there are several duscussion spread throughout that deal with terrain map generation, one is here:
http://forum.unity3d.com/threads/after-playing-minecraft.63149/page-50#post-1732501
That didn't work, because I know how to create the biomes I just don't know how to make the mountains.
Answer by revolute · Oct 02, 2014 at 06:36 AM
Try perlin noise. Unity has this in Mathf. This makes a soft and gradually changing values.
I use this to create the terrain heights:
for (var oc = 0; oc < Octaves; oc++) {
noise += $$anonymous$$athf.PerlinNoise((Seed + (startPosX + WorldPnt.x))*gain/(terrainSize * scale), (Seed + (startPosZ + WorldPnt.z))*gain/(terrainSize * scale)) / gain;
gain *= 5;
}
But that gives me some fine terrain, I just want to be able to have more control over the mountain generation. So some biomes are flat and others are bumpy
It is not hard to do so. You can combine 2 different perlin noises and make mountains twice as high.
I tried something like
if (Biome == "$$anonymous$$ountain") {
gain *= 8;
} else {
gain *= 4;
}
But that just elevates the mountains
Your answer
Follow this Question
Related Questions
Discrete divisions on terrain? 0 Answers
Looking for Grass asset that can procedurally generate grass on a mesh at runtime 0 Answers
How to generate a grid for procedurally generated platforms 1 Answer
Strange shading on procedural mesh 0 Answers
How do I go about texturing a flat-shaded generated mesh? 1 Answer