Razaekel / noise-rs

Procedural noise generation library for Rust.
Apache License 2.0
843 stars 119 forks source link

Strange results with perlin noise #304

Closed temiaj closed 1 year ago

temiaj commented 1 year ago

Hi, I'm new to rust and experimenting with perlin noise. With a little test program based on the example I get strange results from perlin noise:

`use noise::{NoiseFn, Perlin, Seedable};

fn main() { let perlin = Perlin::new(1); println!("{}", perlin.get([42.4, 37.7])); // => -0.23845001564978627 println!("{}", perlin.get([0.0, 0.0])); // => 0 println!("{}", perlin.get([1.0, 1.0])); // => 0 println!("{}", perlin.get([10.0, 10.0])); // => 0 println!("{}", perlin.get([0.00001, 0.0])); // => 0.000014142135637872595 }`

Is that the intended behaviour? Am I doing something wrong?

amaranth commented 1 year ago

Yep, perlin noise always returns 0 on integer values. If you're feeding it coordinates from an integer grid people usually apply some scale factor (division) to their coordinates to make them not all be whole numbers.