我正在尝试使用OpenSimplex 噪声生成随机的星星场,但我注意到出现了重复的模式,现在我已经注意到了它,我无法停止注意到它。我想我已经找到了解决方法,但我仍然想知道为什么会发生这种情况。
目前,我的代码使用 OpenSimplex 噪声生成 2D 灰度图像,然后将低于阈值的每个像素设置为 0,因此只留下一小部分所谓随机的“星星”。
我目前正在使用这个包来实现噪声:https://github.com/ojrac/opensimplex-go
package main
import (
"flag"
"fmt"
"image"
"image/color"
"image/png"
"math/rand"
"os"
"time"
"github.com/ojrac/opensimplex-go"
)
const (
startupMessage = "starfieldtest"
)
var (
flgSize int
flgSeed int64
flgCullThreshold float64
)
func init() {
rand.Seed(time.Now().UnixNano())
seed := rand.Int63()
flag.IntVar(&flgSize, "size", 2048, "size of the starfield")
flag.Int64Var(&flgSeed, "seed", seed, "random noise seed value")
flag.Float64Var(&flgCullThreshold, "cull", 0.998, "normalised threshold to cull values below")
}
func main() {
fmt.Println(startupMessage)
flag.Parse()
img := generate(flgSize, …Run Code Online (Sandbox Code Playgroud)