Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-199343

Perlin Surface Noise causes discontinuity issues along chunk borders

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Awaiting Response
    • None
    • 1.16.2, 1.16.3, 1.16.4, 20w45a, 21w03a, 1.16.5
    • None
    • Confirmed
    • Custom Worlds, World generation
    • Important
    • Platform

      The bug

      When creating a custom dimension with the field simplex_surface_noise set to false in the noise settings, the game will use a perlin noise sampler instead of a simplex noise sampler to calculate the surface noise. This perlin noise sampler causes discontinuity issues, as shown in the attached snapshot. These issues become visible in biomes that use surface builders that test the noise based on a threshold to choose the block, such as mountains, shattered savannas, and giant tree taigas. It also happens in the vanilla nether without any datapacks as it sets simplex_surface_noise to false by default, but it is less visible due to the nether's generation.

      Code analysis

      In NoiseBasedChunkGenerator's buildSurfaceAndBedrock method, the following code is used to calculate the noise: 

      double noise = this.surfaceNoise.getSurfaceNoiseValue(x * 0.0625, z * 0.0625, 0.0625, x * 0.0625) * 15.0;
      

      The 4th parameter is scaled along the x axis and passed to the surface noise. When simplex_surface_noise is set to truePerlinSimplexNoise is the class used. Its implementation of getSurfaceNoiseValue ignores the 3rd and 4th parameters, so this issue isn't visible when simplex_surface_noise is set to true. When it's falsePerlinNoise is the class used to the sampling, and it does use the 3rd and 4th values. Because the x value is the local x value (scaled from 0 to 16), this causes discontinuities along chunk borders. Changing the 4th parameter from x * 0.0625 to just 0.0625 like the 3rd parameter fixes this problem, with the results attached in the second screenshot.

        1. vanilla-generation.png
          vanilla-generation.png
          4.37 MB
        2. fixed-generation.png
          fixed-generation.png
          3.61 MB
        3. mc-199343.zip
          0.7 kB

            Unassigned Unassigned
            SuperCoder79 Jasmine Karthikeyan
            Votes:
            20 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: