rust-simd-noise
rust-simd-noise copied to clipboard
Grid-like artifacts in turbulence_3d.
Below is a screenshot from a slice of turbulence_3d using default parameters except octaves, which is set to 8. There are some pretty obvious grid-like artifacts at 45 deg angles. This is not what turbulence is supposed to look like. Call generating the attached image:
let z_offset = 10; // will be animated later
...
let noise = simdnoise::NoiseBuilder::turbulence_3d_offset(
z_offset,
1,
0.0,
1920,
0.0,
1080,
)
.with_octaves(8)
.generate_scaled(0.0, 255.0);

interesting, I'll double check the turbulence code. Have you taken a look, any ideas?
Well it doesn't happen in 2d, but does in 3d or 4d, so that is a clue.
It looks like a bug in the simplex3d/4d itself
probably related to how I am hashing in grad3d/4d, looking into it
I like how you update the ticket while debugging. People should make this a habit.
Any findings?
I've made some progress, just slow, because life.
Ok this should be fixed in the 3d case in the latest version and master branch. Let me know how it looks for you, if all is well I'll apply the same process to the 4d case.
This still happens, but it becomes more pronounced with slightly higher frequency and lower octaves.

Code that produces the image
use minifb::{Key, Window, WindowOptions};
const WIDTH: usize = 2048;
const HEIGHT: usize = 1024;
const FREQ: f32 = 0.125;
const OCTAVES: u8 = 6;
fn get_buffer() -> Vec<u32> {
let noise = simdnoise::NoiseBuilder::turbulence_3d_offset(0.0, WIDTH, 0.0, HEIGHT, 0.0, 1)
.with_freq(FREQ)
.with_octaves(OCTAVES)
.generate_scaled(0.0, 255.0);
noise.iter().map(|x| *x as u32 * 0x00010101).collect()
}
fn main() {
let buffer = get_buffer();
let mut window = Window::new(
"Test - ESC to exit",
WIDTH,
HEIGHT,
WindowOptions::default(),
)
.unwrap_or_else(|e| {
panic!("{}", e);
});
// Limit to max ~60 fps update rate
window.limit_update_rate(Some(std::time::Duration::from_micros(16600)));
while window.is_open() && !window.is_key_down(Key::Escape) {
// We unwrap here as we want this code to exit if it fails. Real applications may want to handle this in a different way
window.update_with_buffer(&buffer, WIDTH, HEIGHT).unwrap();
}
}