Skip to main content

NormalNoise

Struct NormalNoise 

Source
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: PerlinNoise

First Perlin noise sampler

§second: PerlinNoise

Second Perlin noise sampler (coordinates scaled by INPUT_FACTOR)

§value_factor: f64

Factor applied to the sum of both samplers

§max_value: f64

Maximum possible output value

Implementations§

Source§

impl NormalNoise

Source

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:

  1. Create first PerlinNoise (which advances the random state by consuming 262 + forking)
  2. Create second PerlinNoise (which sees the advanced state)

This ensures the two PerlinNoise instances have different seeds.

Source

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.

Source

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().

Source

fn finish(first: PerlinNoise, second: PerlinNoise, amplitudes: &[f64]) -> Self

Finish construction with the two PerlinNoise instances.

Source

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.

Source

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.

Source

pub fn get_value_xz(&self, x: f64, z: f64) -> f64

Sample the noise at (x, 0.0, z).

Source

pub fn get_value_xy(&self, x: f64, y: f64) -> f64

Sample the noise at (x, y, 0.0).

Source

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.

Source

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.

Source

pub const fn max_value(&self) -> f64

Get the maximum possible output value.

Trait Implementations§

Source§

impl Clone for NormalNoise

Source§

fn clone(&self) -> NormalNoise

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NormalNoise

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
§

impl<T> IntoShared for T

§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>>

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more