Solved Perlin noise smooth transitions

Discussion in 'Spigot Plugin Development' started by xTimPugz, May 17, 2017.

  1. Hello

    I am using Perlin noise to generate a smooth terrain, but I want to make a transition go smoothly between area x = (x, y, z) and area y = (x, y + 10, z).
    My goal is to generate 4 islands in the world, only 4. Any ideas?

    Code (Text):
    ChunkData data = createChunkData(world);
            PerlinNoiseGenerator perl = new PerlinNoiseGenerator(world.getSeed());
            for(int x = 0; x < 16; x++){
                for(int z = 0; z < 16; z++){
                    int realX = xChunk * 16 + x;
                    int realZ = zChunk * 16 + z;
                    int heightAddition = 1;
                    if((realX > 2300 && realX < 2700 & realZ > 2300 && realZ < 2700) || (realX < -2300 && realX > -2700 & realZ < -2300 && realZ > -2700)) heightAddition = 10;
                    double noise = Math.abs(perl.noise(realX * (0.005), realZ * (0.005)));
                   
                    double height =  noise * 64 + baseLevel + heightAddition;
                    for(int y = 0; y < height; y++){
                        data.setBlock(x, y, z, Material.STONE);
                    }
                }
            }
    This is an image of the code in action so you don't have to run it:
    [​IMG]
    http://prntscr.com/f90fuo

    Thanks!
     
  2. You could check how close your current coordinate is to the "edge" of the +10 area and adjust the heightAddition according to it. If it's right next to it set it to 1. If it's 1 block away from it set it to 2, all the way up to 10.
     
  3. Hmhhh that seems like a good idea. It's my current approach but I had to use a logarithm. Thanks, will marked as solved.