Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid-like artifacts in turbulence_3d. #15

Open
virtualritz opened this issue May 9, 2020 · 9 comments
Open

Grid-like artifacts in turbulence_3d. #15

virtualritz opened this issue May 9, 2020 · 9 comments

Comments

@virtualritz
Copy link
Contributor

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);

Screen Shot 2020-05-09 at 04 27 38

@jackmott
Copy link
Collaborator

jackmott commented May 9, 2020

interesting, I'll double check the turbulence code. Have you taken a look, any ideas?

@jackmott
Copy link
Collaborator

jackmott commented May 9, 2020

Well it doesn't happen in 2d, but does in 3d or 4d, so that is a clue.

@jackmott
Copy link
Collaborator

jackmott commented May 9, 2020

It looks like a bug in the simplex3d/4d itself

@jackmott
Copy link
Collaborator

jackmott commented May 9, 2020

probably related to how I am hashing in grad3d/4d, looking into it

@virtualritz
Copy link
Contributor Author

I like how you update the ticket while debugging. People should make this a habit.

@virtualritz
Copy link
Contributor Author

Any findings?

@jackmott
Copy link
Collaborator

I've made some progress, just slow, because life.

@jackmott
Copy link
Collaborator

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.

@parasyte
Copy link

This still happens, but it becomes more pronounced with slightly higher frequency and lower octaves.

diagonals

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();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants