pub struct NormalNoise {
first: PerlinNoise,
second: PerlinNoise,
value_factor: f64,
max_value: f64,
}Expand description
Normal (Double Perlin) noise generator.
Combines two PerlinNoise samplers with different coordinate scales to create
smoother noise. The result is scaled by a value factor based on the octave span.
Fields§
§first: PerlinNoiseFirst Perlin noise sampler
second: PerlinNoiseSecond Perlin noise sampler (coordinates scaled by INPUT_FACTOR)
value_factor: f64Factor applied to the sum of both samplers
max_value: f64Maximum possible output value
Implementations§
Source§impl NormalNoise
impl NormalNoise
Sourcepub fn create_from_random(
random: &mut RandomSource,
first_octave: i32,
amplitudes: &[f64],
) -> Self
pub fn create_from_random( random: &mut RandomSource, first_octave: i32, amplitudes: &[f64], ) -> Self
Create a new NormalNoise from a mutable sequential random source.
This matches vanilla’s NormalNoise constructor:
- Create first
PerlinNoise(which advances the random state by consuming 262 + forking) - Create second
PerlinNoise(which sees the advanced state)
This ensures the two PerlinNoise instances have different seeds.
Sourcepub fn create(
splitter: &RandomSplitter,
noise_id: &str,
first_octave: i32,
amplitudes: &[f64],
) -> Self
pub fn create( splitter: &RandomSplitter, noise_id: &str, first_octave: i32, amplitudes: &[f64], ) -> Self
Create a new NormalNoise from a positional random splitter.
Note: This creates a sequential random source from the splitter’s noise ID,
then delegates to create_from_random for vanilla-matching behavior.
Sourcepub fn create_legacy_nether_biome(
random: &mut RandomSource,
first_octave: i32,
amplitudes: &[f64],
) -> Self
pub fn create_legacy_nether_biome( random: &mut RandomSource, first_octave: i32, amplitudes: &[f64], ) -> Self
Create a NormalNoise using the legacy nether biome initialization path.
This uses PerlinNoise::create_legacy_for_nether instead of the hash-based
positional seeding. The ImprovedNoise instances are created directly from
a sequential LegacyRandomSource. Matches vanilla’s
NormalNoise.createLegacyNetherBiome().
Sourcefn finish(first: PerlinNoise, second: PerlinNoise, amplitudes: &[f64]) -> Self
fn finish(first: PerlinNoise, second: PerlinNoise, amplitudes: &[f64]) -> Self
Finish construction with the two PerlinNoise instances.
Sourcepub fn get_value(&self, x: f64, y: f64, z: f64) -> f64
pub fn get_value(&self, x: f64, y: f64, z: f64) -> f64
Sample the noise at the given coordinates.
The result combines two Perlin noise samples:
- First sampler at (x, y, z)
- Second sampler at (x *
INPUT_FACTOR, y *INPUT_FACTOR, z *INPUT_FACTOR)
The sum is then scaled by the value factor.
Sourcepub fn get_value_simd<F, const N: usize>(
&self,
x: Simd<F, N>,
y: Simd<F, N>,
z: Simd<F, N>,
) -> Simd<F, N>where
F: SimdElement + SimdCast,
Simd<F, N>: SimdFloat<Cast<i32> = Simd<i32, N>> + SimdPartialOrd + SimdPartialEq<Mask = Mask<<F as SimdElement>::Mask, N>> + Add<Output = Simd<F, N>> + Sub<Output = Simd<F, N>> + Mul<Output = Simd<F, N>> + Div<Output = Simd<F, N>> + Neg<Output = Simd<F, N>> + StdFloat,
pub fn get_value_simd<F, const N: usize>(
&self,
x: Simd<F, N>,
y: Simd<F, N>,
z: Simd<F, N>,
) -> Simd<F, N>where
F: SimdElement + SimdCast,
Simd<F, N>: SimdFloat<Cast<i32> = Simd<i32, N>> + SimdPartialOrd + SimdPartialEq<Mask = Mask<<F as SimdElement>::Mask, N>> + Add<Output = Simd<F, N>> + Sub<Output = Simd<F, N>> + Mul<Output = Simd<F, N>> + Div<Output = Simd<F, N>> + Neg<Output = Simd<F, N>> + StdFloat,
Calculate normal noise value using SIMD vectors.
Sourcepub fn get_value_xz(&self, x: f64, z: f64) -> f64
pub fn get_value_xz(&self, x: f64, z: f64) -> f64
Sample the noise at (x, 0.0, z).
Sourcepub fn get_value_xy(&self, x: f64, y: f64) -> f64
pub fn get_value_xy(&self, x: f64, y: f64) -> f64
Sample the noise at (x, y, 0.0).
Sourcepub fn get_value_y_4x(&self, x: f64, ys: f64x4, z: f64) -> f64x4
pub fn get_value_y_4x(&self, x: f64, ys: f64x4, z: f64) -> f64x4
Sample 4 Y values at fixed (x, z) in one call.
Sourcepub fn get_value_y_simd<const N: usize>(
&self,
x: f64,
ys: Simd<f64, N>,
z: f64,
) -> Simd<f64, N>
pub fn get_value_y_simd<const N: usize>( &self, x: f64, ys: Simd<f64, N>, z: f64, ) -> Simd<f64, N>
Sample N Y values at fixed (x, z) in one call.
SIMD form of Self::get_value for transpiled density-function trees
that batch N cell-corner Ys together. Per-lane math is identical to
the scalar path, so get_value_y_simd(x, splat(y), z)[i] == get_value(x, y, z)
for any finite y.
Trait Implementations§
Source§impl Clone for NormalNoise
impl Clone for NormalNoise
Source§fn clone(&self) -> NormalNoise
fn clone(&self) -> NormalNoise
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for NormalNoise
impl RefUnwindSafe for NormalNoise
impl Send for NormalNoise
impl Sync for NormalNoise
impl Unpin for NormalNoise
impl UnsafeUnpin for NormalNoise
impl UnwindSafe for NormalNoise
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>