ImprovedNoise 5.46.0
One octave of 3D gradient ("Perlin") noise with a random permutation and offset (ported from misode/deepslate GradientNoise/PerlinNoise, MIT).
The permutation table is stored pre-multiplied into gradient tables so that sampling only needs flat int/float array reads: $p is the permutation (values 0-255), $gx/$gy/$gz the gradient vector selected by p[i] & 15.
Constants
GRADIENT_X
public const GRADIENT_X = [1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 1, 0, -1, 0]Vanilla gradient table (16 entries, the last four repeat earlier ones).
GRADIENT_Y
public const GRADIENT_Y = [1, 1, -1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1]GRADIENT_Z
public const GRADIENT_Z = [0, 0, 0, 0, 1, 1, -1, -1, 1, 1, -1, -1, 0, 1, 0, -1]Properties
$gx
public array $gx$gy
public array $gy$gz
public array $gz$p
public array $p$xo
public float $xo$yo
public float $yo$zo
public float $zoMethods
__construct()
public function __construct(\pocketmine\world\generator\vanilla\random\RandomSource $random)sample()
public function sample(float $x, float $y, float $z) : floatSamples the octave. x/y/z must already be scaled by the octave frequency; wrapping and offsets are applied here.
sampleRaw()
public static function sampleRaw(array $p, array $gx, array $gy, array $gz, float $x, float $y, float $z) : floatsampleSmearedRaw()
public static function sampleSmearedRaw(array $p, array $gx, array $gy, array $gz, float $x, float $y, float $z, float $originalY, float $fudgeScale) : floatY-smeared variant used by the blended noise: the gradient y offset is snapped to multiples of $fudgeScale (computed from the unwrapped scaled coordinate $originalY) while the interpolation uses the real offset. Coordinates must already be wrapped and offset.
wrap()
public static function wrap(float $x) : floatCoordinates are wrapped to avoid precision loss far from the origin.
