Razaekel / noise-rs

Procedural noise generation library for Rust.
Apache License 2.0
842 stars 118 forks source link

Worley noise distance output unexpected. #315

Open Vixeliz opened 1 year ago

Vixeliz commented 1 year ago
image

This is how the normal Euclidian distance(also happens with Euclidian Squared) worley noise looks like. This screenshot is from nannou but ive also experienced the same in my own project using noise-rs. The circles are very annoying. Thanks for the awesome crate

Here is all the relevant code

    let noise: Worley = noise::Worley::default()
        .set_frequency(0.01251051)
        .enable_range(true)
        .set_range_function(noise::RangeFunction::Euclidean);
    let image = image::ImageBuffer::from_fn(1000, 1000, |x, y| {
        let n = noise.get([x as f64, y as f64]).abs() * 256.0;
        nannou::image::Rgba([n as u8, n as u8, n as u8, std::u8::MAX])
    });
Vixeliz commented 1 year ago

Here is the code from my project using latest noise-rs


    let noise = Worley::new(seed)
        .set_frequency(0.01251051)
        .set_distance_function(distance_functions::euclidean_squared)
        .set_return_type(noise::core::worley::ReturnType::Distance);
    for x in 0..=CHUNK_SIZE - 1 {
        for z in 0..=CHUNK_SIZE - 1 {
            for y in 0..=CHUNK_SIZE - 1 {
                let full_x = x as i32 + ((CHUNK_SIZE as i32) * pos.x);
                let full_z = z as i32 + ((CHUNK_SIZE as i32) * pos.z);
                let full_y = y as i32 + ((CHUNK_SIZE as i32) * pos.y);
                noise.get([full_x as f64, full_y as f64, full_z as f64]);