pvigier / perlin-numpy

A fast and simple perlin noise generator using numpy
https://pvigier.github.io/2018/06/13/perlin-noise-numpy.html
MIT License
304 stars 50 forks source link

Numerical issues #13

Open dli7319 opened 1 year ago

dli7319 commented 1 year ago

When I run generate_perlin_noise_2d((721, 1281), (7, 7), (True, True)) I get the following issue: ValueError: operands could not be broadcast together with shapes (722,1281,2) (721,1281,2)

This can be fixed by enumerating the grid manually instead of using np.mgrid:

    grid = np.stack(np.meshgrid(
        np.arange(0, shape[1]) * res[1] / shape[1],
        np.arange(0, shape[0]) * res[0] / shape[0],
    )[::-1], axis=-1)