tweak world generation
This commit is contained in:
parent
08e08000a6
commit
aa8c3128db
@ -27,6 +27,18 @@ func init() {
|
||||
perlins = make(map[int64]*perlin.Perlin)
|
||||
}
|
||||
|
||||
func fractal(p *perlin.Perlin, x, y float64, levels int) float64 {
|
||||
ans := 0.0
|
||||
amp := 1.0
|
||||
for i := 0; i < levels; i++ {
|
||||
ans += amp * p.Noise2D(x, y)
|
||||
amp /= 3
|
||||
x *= 2
|
||||
y *= 2
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
// Chunk generates the chunk (must with chunkID set!!) with seed.
|
||||
func Chunk(chunk *packworld.Chunk, world *packworld.World, seed int64) {
|
||||
|
||||
@ -50,9 +62,10 @@ func Chunk(chunk *packworld.Chunk, world *packworld.World, seed int64) {
|
||||
for x := 0; x < packworld.ChunkSizeX; x++ {
|
||||
for z := 0; z < packworld.ChunkSizeZ; z++ {
|
||||
|
||||
height := Lowest + int(float64(Highest-Lowest)*(p.Noise2D(
|
||||
height := Lowest + int(float64(Highest-Lowest)*(fractal(
|
||||
p,
|
||||
float64(offX+x)/AltitudeDensity,
|
||||
float64(offZ+z)/AltitudeDensity)/2+0.5))
|
||||
float64(offZ+z)/AltitudeDensity, 6)/2+0.5))
|
||||
//log.Printf("height = %d (noise=%.5f)", height, p.Noise2D(float64(offX+x)/AltitudeDensity, float64(offZ+z)/AltitudeDensity)/2+0.5)
|
||||
|
||||
// water
|
||||
|
Loading…
Reference in New Issue
Block a user