### 3D Noise Helper Macro (Partial) Source: https://docs.rs/simdnoise/latest/src/simdnoise/noise_helpers.rs.html This macro is designed to generate 3D noise values. It initializes variables for SIMD processing, including frequency, starting coordinates, and dimensions. The provided snippet shows the setup for processing depth slices. ```rust macro_rules! get_3d_noise_helper { ($Setting:expr,$f:expr $(,$arg:expr)*) => {{ // Line 132 let dim = $Setting.dim; let freq = S::set1_ps($Setting.freq); let start_x = dim.x; let width = dim.width; let start_y = dim.y; let height = dim.height; let start_z = dim.z; let depth = dim.depth; let mut min_s = S::set1_ps(f32::MAX); let mut max_s = S::set1_ps(f32::MIN); let mut min = f32::MAX; let mut max = f32::MIN; let mut result = Vec::with_capacity(width * height * depth); result.set_len(width * height * depth); let mut i = 0; let vector_width = S::VF32_WIDTH; let remainder = width % vector_width; let mut x_arr = Vec::with_capacity(vector_width); x_arr.set_len(vector_width); for i in (0..vector_width).rev() { x_arr[i] = start_x + i as f32; } let mut z = S::set1_ps(start_z); for _ in 0..depth { // Line 159 ``` -------------------------------- ### Create default FbmSettings Source: https://docs.rs/simdnoise/3.1.6/simdnoise/struct.FbmSettings.html Initializes FbmSettings with default values for a given noise dimension. This is the starting point for configuring FBM noise. ```rust pub fn default(dim: NoiseDimensions) -> FbmSettings ``` -------------------------------- ### FbmSettings Constructor and Configuration Source: https://docs.rs/simdnoise/3.1.6/simdnoise/struct.FbmSettings.html This section details how to create and configure FbmSettings. The `default` function creates a new FbmSettings instance with default values, and methods like `with_seed`, `with_freq`, `with_lacunarity`, `with_gain`, and `with_octaves` allow for customization of noise generation parameters. These methods return a mutable reference to `self`, enabling chained calls. ```APIDOC ## FbmSettings ### Constructor #### `pub fn default(dim: NoiseDimensions) -> FbmSettings` Creates a new `FbmSettings` instance with default values for the specified noise dimensions. ### Configuration Methods These methods allow you to modify the settings for Fbm noise generation. They all return a mutable reference to the `FbmSettings` instance, allowing for method chaining. #### `pub fn with_seed(&mut self, seed: i32) -> &mut FbmSettings` Sets the seed for the noise generator. #### `pub fn with_freq(&mut self, freq: f32) -> &mut FbmSettings` Sets the base frequency for the noise. #### `pub fn with_lacunarity(&mut self, lacunarity: f32) -> &mut FbmSettings` Sets the lacunarity (frequency multiplier between octaves). #### `pub fn with_gain(&mut self, gain: f32) -> &mut FbmSettings` Sets the gain (amplitude multiplier between octaves). #### `pub fn with_octaves(&mut self, octaves: u8) -> &mut FbmSettings` Sets the number of octaves to use in the Fbm calculation. ``` -------------------------------- ### Noise Generation with Runtime SIMD Detection Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/lib.rs.html This example demonstrates how to generate blocks of noise using the `NoiseBuilder` API, which automatically selects the most performant SIMD instruction set available at runtime (SSE2, SSE41, AVX2) or falls back to scalar operations. ```APIDOC ## Noise Generation with Runtime SIMD Detection This example demonstrates how to generate blocks of noise using the `NoiseBuilder` API, which automatically selects the most performant SIMD instruction set available at runtime (SSE2, SSE41, AVX2) or falls back to scalar operations. ### Usage ```rust use simdnoise::*; // Generate a 100x100 block of 2D FBM noise, scaled to the range [0,1] let noise_fbm = NoiseBuilder::fbm_2d(100, 100).generate_scaled(0.0, 1.0); // Generate a 32x32x32x32 block of 4D ridge noise with custom settings let (noise_ridge, min, max) = NoiseBuilder::ridge_4d(32, 32, 32, 32) .with_freq(0.05) .with_octaves(5) .with_gain(2.0) .with_seed(1337) .with_lacunarity(0.5) .generate(); ``` ``` -------------------------------- ### Get 4D Scaled Noise Block Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/scalar.rs.html Gets a block of 4D noise data that is automatically scaled to a specified range. This function first retrieves unscaled noise and then applies scaling. ```APIDOC ## get_4d_scaled_noise ### Description Gets a width X height X depth X time sized block of scaled 4d noise. `start_*` can be used to provide an offset in the coordinates. `scaled_min` and `scaled_max` specify the range you want the noise scaled to. ### Parameters * `noise_type`: A reference to a `NoiseType` struct that defines the dimensions and desired scaling range. ### Returns `Vec`: A vector of scaled noise values. ### Signature `pub unsafe fn get_4d_scaled_noise(noise_type: &NoiseType) -> Vec` ``` -------------------------------- ### Create 3D FBM Settings Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes FbmSettings for a 3D noise generation with specified width, height, and depth. Use this for standard 3D fractal Brownian motion noise. ```rust pub fn fbm_3d(width: usize, height: usize, depth: usize) -> FbmSettings { let mut dim = NoiseDimensions::default(3); dim.width = width; dim.height = height; dim.depth = depth; FbmSettings::default(dim) } ``` -------------------------------- ### Get 3D Scaled Noise Block Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/scalar.rs.html Gets a block of 3D noise data that is automatically scaled to a specified range. This function first retrieves unscaled noise and then applies scaling. ```APIDOC ## get_3d_scaled_noise ### Description Gets a width X height X depth sized block of scaled 3d noise. `start_x`, `start_y`, and `start_z` can be used to provide an offset in the coordinates. `scaled_min` and `scaled_max` specify the range you want the noise scaled to. ### Parameters * `noise_type`: A reference to a `NoiseType` struct that defines the dimensions and desired scaling range. ### Returns `Vec`: A vector of scaled noise values. ### Signature `pub unsafe fn get_3d_scaled_noise(noise_type: &NoiseType) -> Vec` ``` -------------------------------- ### Get Scaled 4D Noise Block (SSE2) Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/sse2.rs.html Fetches a block of 4D noise data and scales it to a specified range using SSE2. The noise is scaled between `scaled_min` and `scaled_max`. ```rust pub unsafe fn get_4d_scaled_noise(noise_type: &NoiseType) -> Vec { let (mut noise, min, max) = get_4d_noise(noise_type); let dim = noise_type.get_dimensions(); scale_noise::(dim.min, dim.max, min, max, &mut noise); noise } ``` -------------------------------- ### Get 4D Noise Block (Unscaled) Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/scalar.rs.html Gets a block of 4D noise data with specified dimensions and offsets. Results are unscaled, and the minimum and maximum noise values within the block are returned for custom scaling. ```APIDOC ## get_4d_noise ### Description Gets a width X height X depth X time sized block of 4d noise, unscaled. `start_*` can be used to provide an offset in the coordinates. Results are unscaled, 'min' and 'max' noise values are returned so you can scale and transform the noise as you see fit in a single pass. ### Parameters * `noise_type`: A reference to a `NoiseType` struct that defines the dimensions and potentially other properties of the noise block. ### Returns A tuple containing: * `Vec`: A vector of noise values. * `f32`: The minimum noise value in the block. * `f32`: The maximum noise value in the block. ### Signature `pub unsafe fn get_4d_noise(noise_type: &NoiseType) -> (Vec, f32, f32)` ``` -------------------------------- ### Create 3D FBM Settings with Offset Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes FbmSettings for a 3D noise generation with specified dimensions and X/Y/Z offsets. Use this to control the starting point for 3D FBM noise sampling. ```rust pub fn fbm_3d_offset( x_offset: f32, width: usize, y_offset: f32, height: usize, z_offset: f32, depth: usize, ) -> FbmSettings { let mut dim = NoiseDimensions::default(3); dim.width = width; dim.height = height; dim.depth = depth; dim.x = x_offset; dim.y = y_offset; dim.z = z_offset; FbmSettings::default(dim) } ``` -------------------------------- ### Get 3D Noise Block (Unscaled) Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/scalar.rs.html Gets a block of 3D noise data with specified dimensions and offsets. Results are unscaled, and the minimum and maximum noise values within the block are returned for custom scaling. ```APIDOC ## get_3d_noise ### Description Gets a width X height X depth sized block of 3d noise, unscaled. `start_x`, `start_y`, and `start_z` can be used to provide an offset in the coordinates. Results are unscaled, 'min' and 'max' noise values are returned so you can scale and transform the noise as you see fit in a single pass. ### Parameters * `noise_type`: A reference to a `NoiseType` struct that defines the dimensions and potentially other properties of the noise block. ### Returns A tuple containing: * `Vec`: A vector of noise values. * `f32`: The minimum noise value in the block. * `f32`: The maximum noise value in the block. ### Signature `pub unsafe fn get_3d_noise(noise_type: &NoiseType) -> (Vec, f32, f32)` ``` -------------------------------- ### Create 4D FBM Settings with Offset Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes FbmSettings for a 4D noise generation with specified dimensions and X/Y/Z/W offsets. Use this to precisely control the starting point for 4D FBM noise sampling, including temporal aspects. ```rust pub fn fbm_4d_offset( x_offset: f32, width: usize, y_offset: f32, height: usize, z_offset: f32, depth: usize, w_offset: f32, time: usize, ) -> FbmSettings { let mut dim = NoiseDimensions::default(3); dim.width = width; dim.height = height; dim.depth = depth; dim.time = time; dim.x = x_offset; dim.y = y_offset; dim.z = z_offset; dim.w = w_offset; FbmSettings::default(dim) } ``` -------------------------------- ### turbulence_1d Source: https://docs.rs/simdnoise/3.1.6/simdnoise/avx2/index.html Get a single value of 1D turbulence. ```APIDOC ## turbulence_1d ### Description Get a single value of 1D turbulence. ### Parameters (No specific parameters documented in source) ``` -------------------------------- ### turbulence_1d Source: https://docs.rs/simdnoise/latest/src/simdnoise/scalar.rs.html Get a single value of 1D turbulence noise. ```APIDOC ## turbulence_1d ### Description Get a single value of 1D turbulence noise. ### Signature ```rust pub unsafe fn turbulence_1d(x: f32, lacunarity: f32, gain: f32, octaves: u8, seed: i32) -> f32 ``` ### Parameters * `x` (f32): The x-coordinate. * `lacunarity` (f32): Controls the frequency of the noise layers. * `gain` (f32): Controls the amplitude of the noise layers. * `octaves` (u8): The number of noise layers to combine. * `seed` (i32): An integer seed for the noise generator. ``` -------------------------------- ### Call noise functions directly Source: https://docs.rs/simdnoise/latest/index.html Illustrates how to call noise functions directly, either by configuring settings with NoiseBuilder and then calling specific SIMD implementations (e.g., sse41::get_3d_noise), or by directly passing SIMD vectors to noise functions. ```APIDOC ## Call noise functions directly Sometimes you need something other than a block, like the points on the surface of a sphere. Sometimes you may want to use SSE41 even with AVX2 is available. ### Example 1: Using NoiseBuilder with specific SIMD implementation ```rust use simdnoise::*; use core::arch::x86_64::*; let noise_setting = NoiseBuilder::cellular2_3d(32,32,32) .with_freq(0.05) .with_return_type(Cell2ReturnType::Distance2Mul) .with_jitter(0.5) .wrap(); // get a block of noise with the sse41 version, using the above settings unsafe { let (noise,min,max) = simdnoise::sse41::get_3d_noise(&noise_setting); } ``` ### Example 2: Direct SIMD vector operations ```rust use simdnoise::*; use core::arch::x86_64::*; // send your own SIMD x,y values to the noise functions directly unsafe { // sse2 simplex noise let x = _mm_set1_ps(5.0); let y = _mm_set1_ps(10.0); let f : __m128 = simdnoise::sse2::simplex_2d(x,y); // avx2 turbulence let x = _mm256_set1_ps(5.0); let y = _mm256_set1_ps(10.0); let lacunarity = _mm256_set1_ps(0.5); let gain = _mm256_set1_ps(2.0); let octaves = 3; let f_turbulence : __m256 = simdnoise::avx2::turbulence_2d(x,y,lacunarity,gain,octaves); } ``` ``` -------------------------------- ### ridge_4d Source: https://docs.rs/simdnoise/3.1.6/simdnoise/avx2/index.html Get a single value of 4D ridge noise. ```APIDOC ## ridge_4d ### Description Get a single value of 4D ridge noise. ### Parameters (No specific parameters documented in source) ``` -------------------------------- ### Create 4D FBM Settings Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes FbmSettings for a 4D noise generation with specified width, height, depth, and time dimensions. Use this for time-varying 4D FBM noise. ```rust pub fn fbm_4d(width: usize, height: usize, depth: usize, time: usize) -> FbmSettings { let mut dim = NoiseDimensions::default(3); dim.width = width; dim.height = height; dim.depth = depth; dim.time = time; FbmSettings::default(dim) } ``` -------------------------------- ### Get a block of noise with runtime SIMD detection Source: https://docs.rs/simdnoise/latest/index.html Demonstrates how to generate blocks of 2D FBM noise or 4D ridge noise using the NoiseBuilder with runtime SIMD detection to pick the fastest available instruction set (SSE2, SSE41, AVX2). ```APIDOC ## Get a block of noise with runtime SIMD detection The library will, at runtime, pick the fastest available options between SSE2, SSE41, and AVX2. ### Example 1: 2D FBM Noise ```rust use simdnoise::*; // Get a block of 2d fbm noise with default settings, 100 x 100, with values scaled to the range [0,1] let noise = NoiseBuilder::fbm_2d(100, 100).generate_scaled(0.0,1.0); ``` ### Example 2: 4D Ridge Noise with Custom Settings ```rust use simdnoise::*; // Get a block of 4d ridge noise, custom settings, 32x32x32x32 unscaled let (noise,min,max) = NoiseBuilder::ridge_4d(32,32,32,32) .with_freq(0.05) .with_octaves(5) .with_gain(2.0) .with_seed(1337) .with_lacunarity(0.5) .generate(); ``` ``` -------------------------------- ### ridge_2d Source: https://docs.rs/simdnoise/3.1.6/simdnoise/avx2/index.html Get a single value of 2D ridge noise. ```APIDOC ## ridge_2d ### Description Get a single value of 2D ridge noise. ### Parameters (No specific parameters documented in source) ``` -------------------------------- ### ridge_1d Source: https://docs.rs/simdnoise/3.1.6/simdnoise/avx2/index.html Get a single value of 1D ridge noise. ```APIDOC ## ridge_1d ### Description Get a single value of 1D ridge noise. ### Parameters (No specific parameters documented in source) ``` -------------------------------- ### Initialize GradientSettings with Dimensions Source: https://docs.rs/simdnoise/3.1.6/simdnoise/struct.GradientSettings.html Creates a new GradientSettings instance with the specified noise dimensions. This is the default constructor. ```rust pub fn default(dim: NoiseDimensions) -> GradientSettings ``` -------------------------------- ### FbmSettings Default Configuration Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/lib.rs.html Creates a new FbmSettings instance with default values for frequency, lacunarity, gain, and octaves. Requires NoiseDimensions to be specified. ```rust pub fn default(dim: NoiseDimensions) -> FbmSettings { FbmSettings { dim, freq: 0.02, lacunarity: 0.5, gain: 2.0, octaves: 3, } } ``` -------------------------------- ### cellular_3d Source: https://docs.rs/simdnoise/3.1.6/simdnoise/avx2/index.html Get a single value of 3D cellular/Voronoi noise. ```APIDOC ## cellular_3d ### Description Get a single value of 3D cellular/Voronoi noise. ### Parameters (No specific parameters documented in source) ``` -------------------------------- ### Clone To Uninit Method (Nightly Experimental) Source: https://docs.rs/simdnoise/3.1.6/simdnoise/struct.NoiseDimensions.html Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API and requires `unsafe`. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### cellular_2d Source: https://docs.rs/simdnoise/3.1.6/simdnoise/avx2/index.html Get a single value of 2D cellular/Voronoi noise. ```APIDOC ## cellular_2d ### Description Get a single value of 2D cellular/Voronoi noise. ### Parameters (No specific parameters documented in source) ``` -------------------------------- ### get_1d_scaled_noise Source: https://docs.rs/simdnoise/3.1.6/simdnoise/sse41 Gets a width sized block of scaled 1d noise. ```APIDOC ## get_1d_scaled_noise ### Description Gets a width-sized block of scaled 1D noise. `start_x` can be used to provide an offset in the coordinates. `scaled_min` and `scaled_max` specify the range you want the noise scaled to. ### Parameters * **width** (usize) - The desired width of the noise block. * **start_x** (f32) - An offset in the x-coordinate. * **scaled_min** (f32) - The minimum value of the desired scaled range. * **scaled_max** (f32) - The maximum value of the desired scaled range. ### Returns A `Vec` of the generated scaled noise. ### Example ```rust // Assuming appropriate setup and imports // let noise_data = simdnoise::sse41::get_1d_scaled_noise(width, start_x, scaled_min, scaled_max); ``` ``` -------------------------------- ### Create 3D Ridge Settings Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes RidgeSettings for a 3D noise generation with specified width, height, and depth. Use this for volumetric ridge noise. ```rust pub fn ridge_3d(width: usize, height: usize, depth: usize) -> RidgeSettings { let mut dim = NoiseDimensions::default(3); dim.width = width; dim.height = height; dim.depth = depth; RidgeSettings::default(dim) } ``` -------------------------------- ### get_1d_noise Source: https://docs.rs/simdnoise/3.1.6/simdnoise/sse41 Gets a width sized block of 1d noise, unscaled. ```APIDOC ## get_1d_noise ### Description Gets a width-sized block of 1D noise, unscaled. `start_x` can be used to provide an offset in the coordinates. Results are unscaled; 'min' and 'max' noise values are returned so you can scale and transform the noise as you see fit in a single pass. ### Parameters * **width** (usize) - The desired width of the noise block. * **start_x** (f32) - An offset in the x-coordinate. ### Returns A tuple containing the minimum noise value, the maximum noise value, and a `Vec` of the generated noise. ### Example ```rust // Assuming appropriate setup and imports // let (min_val, max_val, noise_data) = simdnoise::sse41::get_1d_noise(width, start_x); ``` ``` -------------------------------- ### Gradient Settings Default Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/lib.rs.html Creates default settings for Gradient noise generation. Initializes with a standard frequency. ```rust pub fn default(dim: NoiseDimensions) -> GradientSettings { GradientSettings { dim, freq: 0.02 } } ``` -------------------------------- ### get_1d_noise Source: https://docs.rs/simdnoise/3.1.6/simdnoise/sse41/index.html Gets a width sized block of 1d noise, unscaled. ```APIDOC ## get_1d_noise ### Description Gets a width sized block of 1d noise, unscaled. `start_x` can be used to provide an offset in the coordinates. Results are unscaled, ‘min’ and ‘max’ noise values are returned so you can scale and transform the noise as you see fit in a single pass. ### Parameters #### Query Parameters - **start_x** (integer) - Optional - Offset in the coordinates. - **width** (integer) - Required - The desired width of the noise block. ### Returns - **min** (f32) - The minimum noise value in the generated block. - **max** (f32) - The maximum noise value in the generated block. - **noise** (Vec) - A vector containing the unscaled noise values. ``` -------------------------------- ### Direct SIMD Noise Function Calls Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Illustrates how to directly call specific SIMD noise functions (e.g., SSE41, SSE2, AVX2) for more granular control or when a specific instruction set is desired, even if a more advanced one is available. This requires `unsafe` blocks due to direct SIMD intrinsic usage. ```APIDOC ## Direct SIMD Function Calls ### Get 3D Cellular Noise with SSE41 This example shows how to configure 3D cellular noise with specific settings (frequency, return type, jitter, wrapping) and then explicitly call the `sse41::get_3d_noise` function to generate the noise block. ```rust use simdnoise::*; use core::arch::x86_64::*; let noise_setting = NoiseBuilder::cellular2_3d(32,32,32) .with_freq(0.05) .with_return_type(Cell2ReturnType::Distance2Mul) .with_jitter(0.5) .wrap(); // get a block of noise with the sse41 version, using the above settings unsafe { let (noise,min,max) = simdnoise::sse41::get_3d_noise(&noise_setting); } ``` ### Direct SIMD Vector Operations This example demonstrates sending SIMD vectors directly to noise functions for operations like SSE2 simplex noise and AVX2 turbulence. ```rust use simdnoise::*; use core::arch::x86_64::*; unsafe { // sse2 simplex noise let x = _mm_set1_ps(5.0); let y = _mm_set1_ps(10.0); let f : __m128 = simdnoise::sse2::simplex_2d(x,y); // avx2 turbulence let x = _mm256_set1_ps(5.0); let y = _mm256_set1_ps(10.0); let lacunarity = _mm256_set1_ps(0.5); let gain = _mm256_set1_ps(2.0); let octaves = 3; let f_turbulence : __m256 = simdnoise::avx2::turbulence_2d(x,y,lacunarity,gain,octaves); } ``` ``` -------------------------------- ### Create 1D Turbulence Settings Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes TurbulenceSettings for a 1D noise generation with a specified width. Use this for basic 1D turbulence noise. ```rust pub fn turbulence_1d(width: usize) -> TurbulenceSettings { let mut dim = NoiseDimensions::default(1); dim.width = width; TurbulenceSettings::default(dim) } ``` -------------------------------- ### fbm_4d Source: https://docs.rs/simdnoise/3.1.6/simdnoise/avx2/index.html Get a single value of 4D fractal Brownian motion. ```APIDOC ## fbm_4d ### Description Get a single value of 4D fractal Brownian motion. ### Parameters (No specific parameters documented in source) ``` -------------------------------- ### Call noise functions directly Source: https://docs.rs/simdnoise Illustrates how to call noise functions directly, allowing for specific SIMD instruction set usage (e.g., SSE41, SSE2, AVX2) and direct manipulation of SIMD vectors for advanced use cases. ```APIDOC ## Call noise functions directly Sometimes you need something other than a block, like the points on the surface of a sphere. Sometimes you may want to use SSE41 even with AVX2 is available ```rust use simdnoise::*; use core::arch::x86_64::*; let noise_setting = NoiseBuilder::cellular2_3d(32,32,32) .with_freq(0.05) .with_return_type(Cell2ReturnType::Distance2Mul) .with_jitter(0.5) .wrap(); // get a block of noise with the sse41 version, using the above settings unsafe { let (noise,min,max) = simdnoise::sse41::get_3d_noise(&noise_setting); } // send your own SIMD x,y values to the noise functions directly unsafe { // sse2 simplex noise let x = _mm_set1_ps(5.0); let y = _mm_set1_ps(10.0); let f : __m128 = simdnoise::sse2::simplex_2d(x,y); // avx2 turbulence let x = _mm256_set1_ps(5.0); let y = _mm256_set1_ps(10.0); let lacunarity = _mm256_set1_ps(0.5); let gain = _mm256_set1_ps(2.0); let octaves = 3; let f_turbulence : __m256 = simdnoise::avx2::turbulence_2d(x,y,lacunarity,gain,octaves); } ``` ``` -------------------------------- ### fbm_3d Source: https://docs.rs/simdnoise/3.1.6/simdnoise/avx2/index.html Get a single value of 3D fractal Brownian motion. ```APIDOC ## fbm_3d ### Description Get a single value of 3D fractal Brownian motion. ### Parameters (No specific parameters documented in source) ``` -------------------------------- ### Create 3D Ridge Settings with Offset Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes RidgeSettings for a 3D noise generation with specified dimensions and X/Y/Z offsets. Use this to control the starting point for 3D ridge noise sampling. ```rust pub fn ridge_3d_offset( x_offset: f32, width: usize, y_offset: f32, height: usize, z_offset: f32, depth: usize, ) -> RidgeSettings { let mut dim = NoiseDimensions::default(3); dim.width = width; dim.height = height; dim.depth = depth; dim.x = x_offset; dim.y = y_offset; dim.z = z_offset; RidgeSettings::default(dim) } ``` -------------------------------- ### fbm_2d Source: https://docs.rs/simdnoise/3.1.6/simdnoise/avx2/index.html Get a single value of 2D fractal Brownian motion. ```APIDOC ## fbm_2d ### Description Get a single value of 2D fractal Brownian motion. ### Parameters (No specific parameters documented in source) ``` -------------------------------- ### Gradient Settings Builders (Rust) Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/lib.rs.html Functions to create default gradient settings for 1D, 2D, 3D, and 4D noise, with options for specifying dimensions and offsets. ```rust pub fn gradient_1d(width: usize) -> GradientSettings { let mut dim = NoiseDimensions::default(1); dim.width = width; GradientSettings::default(dim) } ``` ```rust pub fn gradient_1d_offset(x_offset: f32, width: usize) -> GradientSettings { let mut dim = NoiseDimensions::default(1); dim.width = width; dim.x = x_offset; GradientSettings::default(dim) } ``` ```rust pub fn gradient_2d(width: usize, height: usize) -> GradientSettings { let mut dim = NoiseDimensions::default(2); dim.width = width; dim.height = height; GradientSettings::default(dim) } ``` ```rust pub fn gradient_2d_offset( x_offset: f32, width: usize, y_offset: f32, height: usize, ) -> GradientSettings { let mut dim = NoiseDimensions::default(2); dim.width = width; dim.height = height; dim.x = x_offset; dim.y = y_offset; GradientSettings::default(dim) } ``` ```rust pub fn gradient_3d(width: usize, height: usize, depth: usize) -> GradientSettings { let mut dim = NoiseDimensions::default(3); dim.width = width; dim.height = height; dim.depth = depth; GradientSettings::default(dim) } ``` ```rust pub fn gradient_3d_offset( x_offset: f32, width: usize, y_offset: f32, height: usize, z_offset: f32, depth: usize, ) -> GradientSettings { let mut dim = NoiseDimensions::default(3); dim.width = width; dim.height = height; dim.depth = depth; dim.x = x_offset; dim.y = y_offset; dim.z = z_offset; GradientSettings::default(dim) } ``` ```rust pub fn gradient_4d(width: usize, height: usize, depth: usize, time: usize) -> GradientSettings { let mut dim = NoiseDimensions::default(4); dim.width = width; dim.height = height; dim.depth = depth; dim.time = time; GradientSettings::default(dim) } ``` ```rust pub fn gradient_4d_offset( x_offset: f32, ``` -------------------------------- ### fbm_1d Source: https://docs.rs/simdnoise/3.1.6/simdnoise/avx2/index.html Get a single value of 1D fractal Brownian motion. ```APIDOC ## fbm_1d ### Description Get a single value of 1D fractal Brownian motion. ### Parameters (No specific parameters documented in source) ``` -------------------------------- ### 4D Simplex Noise Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/scalar.rs.html Get a single value of 4D simplex noise. Results are not scaled. ```APIDOC ## simplex_4d ### Description Get a single value of 4D simplex noise. Results are not scaled. ### Parameters * `x`, `y`, `z`, `w`: The coordinates in 4D space. * `seed`: An integer to seed the noise generator. ### Signature `pub unsafe fn simplex_4d(x: f32, y: f32, z: f32, w: f32, seed: i32) -> f32` ``` -------------------------------- ### Create 4D Ridge Settings with Offset Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes RidgeSettings for a 4D noise generation with specified dimensions and X/Y/Z/W offsets. Use this to precisely control the starting point for 4D ridge noise sampling, including temporal aspects. ```rust pub fn ridge_4d_offset( x_offset: f32, width: usize, y_offset: f32, height: usize, z_offset: f32, depth: usize, w_offset: f32, time: usize, ) -> RidgeSettings { let mut dim = NoiseDimensions::default(4); dim.width = width; dim.height = height; dim.depth = depth; dim.time = time; dim.x = x_offset; dim.y = y_offset; dim.z = z_offset; dim.w = w_offset; RidgeSettings::default(dim) } ``` -------------------------------- ### 3D Simplex Noise Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/scalar.rs.html Get a single value of 3D simplex noise. Results are not scaled. ```APIDOC ## simplex_3d ### Description Get a single value of 3D simplex noise. ### Signature `pub unsafe fn simplex_3d(x: f32, y: f32, z: f32, seed: i32) -> f32` ``` -------------------------------- ### Generate a block of noise with runtime SIMD detection Source: https://docs.rs/simdnoise/latest/simdnoise Demonstrates how to generate blocks of 2D FBM noise or 4D ridge noise using NoiseBuilder, with options for scaling and custom settings. ```APIDOC ## Get a block of noise with runtime SIMD detection The library will, at runtime, pick the fastest available options between SSE2, SSE41, and AVX2 ```rust use simdnoise::* // Get a block of 2d fbm noise with default settings, 100 x 100, with values scaled to the range [0,1] let noise = NoiseBuilder::fbm_2d(100, 100).generate_scaled(0.0,1.0); // Get a block of 4d ridge noise, custom settings, 32x32x32x32 unscaled let (noise,min,max) = NoiseBuilder::ridge_4d(32,32,32,32) .with_freq(0.05) .with_octaves(5) .with_gain(2.0) .with_seed(1337) .with_lacunarity(0.5) .generate(); ``` ``` -------------------------------- ### Configure CellularSettings with Frequency Source: https://docs.rs/simdnoise/latest/simdnoise/struct.CellularSettings.html Sets the base frequency for the noise generation. Higher frequencies result in more detailed noise. ```rust pub fn with_freq(&mut self, freq: f32) -> &mut CellularSettings ``` -------------------------------- ### get_2d_scaled_noise Source: https://docs.rs/simdnoise/3.1.6/simdnoise/sse41 Gets a width X height sized block of scaled 2d noise. ```APIDOC ## get_2d_scaled_noise ### Description Gets a width X height sized block of scaled 2D noise. `start_x` and `start_y` can be used to provide an offset in the coordinates. `scaled_min` and `scaled_max` specify the range you want the noise scaled to. ### Parameters * **width** (usize) - The desired width of the noise block. * **height** (usize) - The desired height of the noise block. * **start_x** (f32) - An offset in the x-coordinate. * **start_y** (f32) - An offset in the y-coordinate. * **scaled_min** (f32) - The minimum value of the desired scaled range. * **scaled_max** (f32) - The maximum value of the desired scaled range. ### Returns A `Vec` of the generated scaled noise. ### Example ```rust // Assuming appropriate setup and imports // let noise_data = simdnoise::sse41::get_2d_scaled_noise(width, height, start_x, start_y, scaled_min, scaled_max); ``` ``` -------------------------------- ### Create 1D Turbulence Settings with Offset Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes TurbulenceSettings for a 1D noise generation with a specified width and an X-axis offset. Use this when you need to shift the starting point of the 1D turbulence noise. ```rust pub fn turbulence_1d_offset(x_offset: f32, width: usize) -> TurbulenceSettings { let mut dim = NoiseDimensions::default(1); dim.width = width; dim.x = x_offset; TurbulenceSettings::default(dim) } ``` -------------------------------- ### get_2d_noise Source: https://docs.rs/simdnoise/3.1.6/simdnoise/sse41 Gets a width X height sized block of 2d noise, unscaled. ```APIDOC ## get_2d_noise ### Description Gets a width X height sized block of 2D noise, unscaled. `start_x` and `start_y` can be used to provide an offset in the coordinates. Results are unscaled; 'min' and 'max' noise values are returned so you can scale and transform the noise as you see fit in a single pass. ### Parameters * **width** (usize) - The desired width of the noise block. * **height** (usize) - The desired height of the noise block. * **start_x** (f32) - An offset in the x-coordinate. * **start_y** (f32) - An offset in the y-coordinate. ### Returns A tuple containing the minimum noise value, the maximum noise value, and a `Vec` of the generated noise. ### Example ```rust // Assuming appropriate setup and imports // let (min_val, max_val, noise_data) = simdnoise::sse41::get_2d_noise(width, height, start_x, start_y); ``` ``` -------------------------------- ### get_2d_scaled_noise Source: https://docs.rs/simdnoise/3.1.6/simdnoise/sse41/index.html Gets a width X height sized block of scaled 2d noise. ```APIDOC ## get_2d_scaled_noise ### Description Gets a width X height sized block of scaled 2d noise. `start_x` and `start_y` can be used to provide an offset in the coordinates. `scaled_min` and `scaled_max` specify the range you want the noise scaled to. ### Parameters #### Query Parameters - **start_x** (integer) - Optional - Offset in the x-coordinate. - **start_y** (integer) - Optional - Offset in the y-coordinate. - **scaled_min** (f32) - Required - The minimum value of the desired scaled noise range. - **scaled_max** (f32) - Required - The maximum value of the desired scaled noise range. - **width** (integer) - Required - The desired width of the noise block. - **height** (integer) - Required - The desired height of the noise block. ### Returns - **noise** (Vec) - A vector containing the scaled noise values. The data is laid out row by row. ``` -------------------------------- ### Create 2D Gradient Noise Builder Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/lib.rs.html Initializes a NoiseBuilder for 2D gradient noise with specified dimensions. Used for generating noise patterns. ```rust let _ = NoiseBuilder::gradient_2d(3, 2).generate(); ``` -------------------------------- ### get_2d_noise Source: https://docs.rs/simdnoise/3.1.6/simdnoise/sse41/index.html Gets a width X height sized block of 2d noise, unscaled. ```APIDOC ## get_2d_noise ### Description Gets a width X height sized block of 2d noise, unscaled. `start_x` and `start_y` can be used to provide an offset in the coordinates. Results are unscaled, ‘min’ and ‘max’ noise values are returned so you can scale and transform the noise as you see fit in a single pass. ### Parameters #### Query Parameters - **start_x** (integer) - Optional - Offset in the x-coordinate. - **start_y** (integer) - Optional - Offset in the y-coordinate. - **width** (integer) - Required - The desired width of the noise block. - **height** (integer) - Required - The desired height of the noise block. ### Returns - **min** (f32) - The minimum noise value in the generated block. - **max** (f32) - The maximum noise value in the generated block. - **noise** (Vec) - A vector containing the unscaled noise values. The data is laid out row by row. ``` -------------------------------- ### Create 2D Ridge Settings Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes RidgeSettings for a 2D noise generation with specified width and height. Use this for standard 2D ridge noise. ```rust pub fn ridge_2d(width: usize, height: usize) -> RidgeSettings { let mut dim = NoiseDimensions::default(2); dim.width = width; dim.height = height; RidgeSettings::default(dim) } ``` -------------------------------- ### Create 1D Ridge Settings Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes RidgeSettings for a 1D noise generation with specified width. Use this for basic 1D ridge noise. ```rust pub fn ridge_1d(width: usize) -> RidgeSettings { let mut dim = NoiseDimensions::default(1); dim.width = width; RidgeSettings::default(dim) } ``` -------------------------------- ### 3D Turbulence Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/scalar.rs.html Get a single value of 3D turbulence. Turbulence is characterized by chaotic, swirling patterns. ```APIDOC ## turbulence_3d ### Description Get a single value of 3D turbulence. ### Parameters * `x`, `y`, `z`: The coordinates in 3D space. * `lac`: Lacunarity, controls the spacing between successive octaves. * `gain`: Gain, controls the amplitude of successive octaves. * `octaves`: The number of noise layers to combine. * `seed`: An integer to seed the noise generator. ### Signature `pub unsafe fn turbulence_3d(x: f32, y: f32, z: f32, lac: f32, gain: f32, octaves: u8, seed: i32) -> f32` ``` -------------------------------- ### Get a block of noise with runtime SIMD detection Source: https://docs.rs/simdnoise Demonstrates how to generate blocks of 2D FBM or 4D ridge noise using `NoiseBuilder`. The library automatically selects the fastest available SIMD instruction set (SSE2, SSE41, AVX2) at runtime. ```APIDOC ## Get a block of noise with runtime SIMD detection The library will, at runtime, pick the fastest available options between SSE2, SSE41, and AVX2 ```rust use simdnoise::*; // Get a block of 2d fbm noise with default settings, 100 x 100, with values scaled to the range [0,1] let noise = NoiseBuilder::fbm_2d(100, 100).generate_scaled(0.0,1.0); // Get a block of 4d ridge noise, custom settings, 32x32x32x32 unscaled let (noise,min,max) = NoiseBuilder::ridge_4d(32,32,32,32) .with_freq(0.05) .with_octaves(5) .with_gain(2.0) .with_seed(1337) .with_lacunarity(0.5) .generate(); ``` ``` -------------------------------- ### get_3d_noise Source: https://docs.rs/simdnoise/latest/src/simdnoise/scalar.rs.html Gets a width X height X depth sized block of 3d noise, unscaled. ```APIDOC ## get_3d_noise ### Description Gets a width X height X depth sized block of 3d noise, unscaled, `start_x`,`start_y` and `start_z` can be used to provide an offset in the coordinates. Results are unscaled, 'min' and 'max' noise values are returned so you can scale and transform the noise as you see fit in a single pass. ### Signature `pub unsafe fn get_3d_noise(noise_type: &NoiseType) -> (Vec, f32, f32)` ``` -------------------------------- ### Create 4D Ridge Settings Source: https://docs.rs/simdnoise/latest/src/simdnoise/lib.rs.html Initializes RidgeSettings for a 4D noise generation with specified width, height, depth, and time dimensions. Use this for time-varying 4D ridge noise. ```rust pub fn ridge_4d(width: usize, height: usize, depth: usize, time: usize) -> RidgeSettings { let mut dim = NoiseDimensions::default(4); dim.width = width; dim.height = height; dim.depth = depth; dim.time = time; RidgeSettings::default(dim) } ``` -------------------------------- ### 4D Turbulence Source: https://docs.rs/simdnoise/3.1.6/src/simdnoise/scalar.rs.html Get a single value of 4D turbulence. This function extends turbulence noise to four dimensions. ```APIDOC ## turbulence_4d ### Description Get a single value of 4D turbulence. ### Parameters * `x`, `y`, `z`, `w`: The coordinates in 4D space. * `lac`: Lacunarity, controls the spacing between successive octaves. * `gain`: Gain, controls the amplitude of successive octaves. * `octaves`: The number of noise layers to combine. * `seed`: An integer to seed the noise generator. ### Signature `pub unsafe fn turbulence_4d(x: f32, y: f32, z: f32, w: f32, lac: f32, gain: f32, octaves: u8, seed: i32) -> f32` ```