biome depth stuff
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package gen
|
package gen
|
||||||
|
|
||||||
|
import "math"
|
||||||
|
|
||||||
type NoiseParam int
|
type NoiseParam int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -54,6 +56,10 @@ func BiomeNoiseFromXoroshiro(x Xoroshiro, large bool) (v BiomeNoise) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func peaksAndValleys(weirdness float64) float64 {
|
||||||
|
return -(math.Abs(math.Abs(weirdness)-0.6666667) - 0.33333334) * 3.0
|
||||||
|
}
|
||||||
|
|
||||||
func (b BiomeNoise) Sample(x, y, z int) (t, h, c, e, d, w float64, combinedData [6]int64, id int) {
|
func (b BiomeNoise) Sample(x, y, z int) (t, h, c, e, d, w float64, combinedData [6]int64, id int) {
|
||||||
px := float64(x)
|
px := float64(x)
|
||||||
pz := float64(z)
|
pz := float64(z)
|
||||||
@@ -66,6 +72,9 @@ func (b BiomeNoise) Sample(x, y, z int) (t, h, c, e, d, w float64, combinedData
|
|||||||
t = b.Temperature.Sample(px, 0, pz)
|
t = b.Temperature.Sample(px, 0, pz)
|
||||||
h = b.Humidity.Sample(px, 0, pz)
|
h = b.Humidity.Sample(px, 0, pz)
|
||||||
|
|
||||||
|
off := float64(BiomeDepthSpline.Sample([]float32{float32(c), float32(e), float32(peaksAndValleys(w)), float32(w)})) + 0.015
|
||||||
|
d = 1.0 - (float64(y)*4)/128.0 - 83.0/160.0 + off
|
||||||
|
|
||||||
combinedData = [6]int64{
|
combinedData = [6]int64{
|
||||||
int64(float32(t) * 10000.0),
|
int64(float32(t) * 10000.0),
|
||||||
int64(float32(h) * 10000.0),
|
int64(float32(h) * 10000.0),
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func TestBiome(t *testing.T) {
|
|||||||
b := BiomeNoiseFromXoroshiro(x, false)
|
b := BiomeNoiseFromXoroshiro(x, false)
|
||||||
_, _, _, _, _, _, combinedData, _ := b.Sample(-1, -16, 0)
|
_, _, _, _, _, _, combinedData, _ := b.Sample(-1, -16, 0)
|
||||||
|
|
||||||
expected := [6]int64{3238, 3521, 2364, 1396, 0, 2202}
|
expected := [6]int64{3238, 3521, 2364, 1396, 10062, 2202}
|
||||||
if combinedData != expected {
|
if combinedData != expected {
|
||||||
t.Errorf("combinedData = %v, want %v", combinedData, expected)
|
t.Errorf("combinedData = %v, want %v", combinedData, expected)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user