Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 14 May 2013
Offline Last Active Jun 25 2013 04:04 AM

#5062556 Procedural Terrain and Biomes

Posted by on 17 May 2013 - 05:21 AM

Hello all,


I'm working on a terrain generator. Through multiple noise functions, I'm able to create many kinds of terrain I like, but I'm having a bit of difficulty joining them together in a seamless fashion. 


My first thought was to use a single low level noise call (calling it the mask) and then I could simply say things like:

if (returnVal < .1) GenerateBiome1();

if (returnVal < .2) GenerateBiome2();

if (returnVal < .3) GenerateBiome3();

and so on...


The issue here is that the height of the terrain doesn't blend together very well. If biome 1 was more mountainous and biome 2 was flat land, it's a drastic switch from one to the other and it looks atrocious.


My next thought was to attempt blending by giving a 'strength' to each biome based on what my mask noise returns. In C# code, it looks something like this at the moment:

tatic public float GetHeight(float X, float Z)
    float fRollingHills_Location = .25f, fRollingHills_Impact = .5f, fRollingHills = 0;
    float fMountains_Location = .75f, fMountains_Impact = .5f, fMountains = 0;

    float fMask = Game1.GetNoise2(0, X, Z, .01f);
    float fRollingHills_Strength = (fRollingHills_Impact - Math.Abs(fMask - fRollingHills_Location)) / fRollingHills_Impact;
    float fMountains_Strength = (fMountains_Impact - Math.Abs(fMask - fMountains_Location)) / fMountains_Impact;

    if (fRollingHills_Strength > 0) fRollingHills = fRollingHills_Strength * (Game1.GetNoise2(0, X, Z, .02f) * 10f + 10f);
    if (fMountains_Strength > 0) fMountains = fMountains_Strength * (Game1.GetNoise2(0, X, Z, .05f) * 25f + 10f);

    return fRollingHills + fMountains;


The issue I have here is that even for only two biomes, it's pretty important for me to manually choose the "location" and "impact" values to ensure I'm getting some combination of strengths to total 100% by the time it returns a value (if not, I get things like giant cliffs making the borders from one biome another ugly and obvious). I'm also not entirely sure I understand it just yet, but the way in which I multiply the noise for a height looks like it needs to change to handle multiple biomes blending smoothly.
Does anyone have any experience in this and can either help correct me, explain it better, explain a whole new method to do this that might be easier, or just point me to some good resources on the subject? While I've managed a few good looking maps, if I try to go up to 10 or more biomes, without having more automation in my code which I think might be just beyond me with this method, I don't think I'll be able to succeed.