title: Repeating patterns in OpenSimplex noise?
body: <p>I'm trying to generate a random field of stars using <a href="https://en.wikipedia.org/wiki/OpenSimplex_noise" rel="nofollow noreferrer">OpenSimplex noise</a>, but I'm noticing repeating patterns appearing and now that I've noticed it, I can't stop noticing it. I think I've found a workaround but I still like to know why this is happening.</p>
  <p>At the moment my code generates a 2D greyscale image using OpenSimplex noise, then sets every pixel below a threshold value to 0, so only a small, supposedly random set of &quot;stars&quot; are left.</p>
  <p>Here is the generated image with a repeated pattern circled.
  <a href="https://i.stack.imgur.com/8bEK0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8bEK0.png" alt="Starfield with repeated pattern circled" /></a></p>
  <p>I'm currently using this package for the noise implementation: <a href="https://github.com/ojrac/opensimplex-go" rel="nofollow noreferrer">https://github.com/ojrac/opensimplex-go</a></p>
  <pre><code>package main
  
  import (
      &quot;flag&quot;
      &quot;fmt&quot;
      &quot;image&quot;
      &quot;image/color&quot;
      &quot;image/png&quot;
      &quot;math/rand&quot;
      &quot;os&quot;
      &quot;time&quot;
  
      &quot;github.com/ojrac/opensimplex-go&quot;
  )
  
  const (
      startupMessage = &quot;starfieldtest&quot;
  )
  
  var (
      flgSize          int
      flgSeed          int64
      flgCullThreshold float64
  )
  
  func init() {
      rand.Seed(time.Now().UnixNano())
      seed := rand.Int63()
  
      flag.IntVar(&amp;flgSize, &quot;size&quot;, 2048, &quot;size of the starfield&quot;)
      flag.Int64Var(&amp;flgSeed, &quot;seed&quot;, seed, &quot;random noise seed value&quot;)
      flag.Float64Var(&amp;flgCullThreshold, &quot;cull&quot;, 0.998, &quot;normalised threshold to cull values below&quot;)
  }
  
  func main() {
      fmt.Println(startupMessage)
      flag.Parse()
  
      img := generate(flgSize, flgSeed, float32(flgCullThreshold))
  
      outName := fmt.Sprintf(&quot;generated_%s.png&quot;, time.Now().Format(&quot;20060102150405&quot;))
      pngFile, err := os.OpenFile(outName, os.O_CREATE|os.O_WRONLY, 0644)
      if err != nil {
          panic(err)
      }
      defer pngFile.Close()
  
      if err = png.Encode(pngFile, img); err != nil {
          panic(err)
      }
  
      fmt.Printf(&quot;Done!\n&quot;)
  }
  
  func generate(size int, seed int64, threshold float32) *image.Gray {
  
      noise := opensimplex.NewNormalized32(seed)
  
      pix := image.NewGray(image.Rect(0, 0, size, size))
      for y := 0; y &lt; size; y++ {
          for x := 0; x &lt; size; x++ {
              v := noise.Eval2(float32(x), float32(y))
  
              if v &lt; threshold {
                  v = 0
              }
  
              pix.SetGray(x, y, color.Gray{Y: uint8(v * 255.0)})
          }
      }
  
      return pix
  }
  </code></pre>
  <p>I think I can get around it by using the <code>Eval3</code> function and changing depth after a certain number of pixels, but is this expected behaviour because it's only really pseudo-random, or is OpenSimplex noise not supposed to do this? I can't really find any statement by anyone knowledgeable one way or the other as to whether this is just a limitation of pseudo-random noise or a problem with the implementation.</p>
  <p><strong>EDIT:</strong> this still happens when I vary the depth, it seems like repeating patterns exist across all dimensions of the noise. This line however, does work (when I get rid of the dimensionality and treat it as a one long wrapped line of pixels):</p>
  <pre><code>v := noise.Eval2((float32(size)*float32(y))+float32(x), 0)
  </code></pre>