Razaekel / noise-rs

Procedural noise generation library for Rust.
Apache License 2.0
854 stars 120 forks source link

[BUG] Worley Noise generates similar pattern regardless the seed #326

Open isiko opened 1 year ago

isiko commented 1 year ago

The Worley Noise Generation has a Bug were it generates the same pattern in some areas, regardless the seed

I'm instantiating a PlaneMapBuilder and sampling from it like this:

let noise_fn = Worley::new(seed)
    .set_frequency(frequency as f64)
    .set_return_type(if use_distance_fn { ReturnType::Distance } else { ReturnType::Value })
    .set_distance_function(match distance_function {
        DistanceFunction::Euclidean => distance_functions::euclidean,
        DistanceFunction::EuclideanSquared => distance_functions::euclidean_squared,
        DistanceFunction::Manhattan => distance_functions::manhattan,
        DistanceFunction::Chebyshev => distance_functions::chebyshev,
        DistanceFunction::Quadratic => distance_functions::quadratic,
    });

let luma_map = PlaneMapBuilder::<_, 2>::new(noise_fn).set_size(width as usize, height as usize).build();

for y in 0..height {
    for x in 0..width {
        let luminance: f64 = luma_map.get_value(x as usize, y as usize) / 2. + 0.5;
    }
}

When I take the resulting Image using 3 different Seeds and combine them by writing them to the RGB channels of a new Image, I get the following: (Using 50 as the Frequency and the 0, 1 and 2 as the seeds)

Untitled Document

You can see that there is an area near the Center where the Image is basically black and white, this happens no matter what seed you enter, although it gets a little bit more random with bigger seeds. Also, there are Patterns above and below that seem to be quite repetitive, I think there might also be a bug there.