# Perlin 3D noise working correctly?

**URL:** <https://discourse.processing.org/t/perlin-3d-noise-working-correctly/18988>\
**Category:** Coding Questions\
**Created:** [March 24, 2020, 5:24pm UTC](https://discourse.processing.org/t/perlin-3d-noise-working-correctly/18988 "2020-03-24T17:24:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kubi](https://avatars.discourse-cdn.com/v4/letter/k/f04885/32.png) [@Kubi](https://discourse.processing.org/u/Kubi)\
**Post date:** [March 24, 2020, 5:24pm UTC](https://discourse.processing.org/t/perlin-3d-noise-working-correctly/18988/1 "2020-03-24T17:24:04Z")

</div>

I am working on a little sketch that uses 3d perlin noise:

[https://editor.p5js.org/Kubi/sketches/mTEiY6-dR](https://editor.p5js.org/Kubi/sketches/mTEiY6-dR)

Essentially, it’s just a moving background. I noticed, that there is some kind of rythmic motion going on… Hard to explain, but I think you’ll notice as well. Is 3d perlin noise supposed to work that way? I was expecting a more random, wave-like motion… How can I avoid this?

Thanks!

---

<div class="post-metadata">

**Author:** ![solub](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/solub/32/333_2.png) [@solub](https://discourse.processing.org/u/solub)\
**Post date:** [March 24, 2020, 5:36pm UTC](https://discourse.processing.org/t/perlin-3d-noise-working-correctly/18988/2 "2020-03-24T17:36:53Z")

</div>

Hi @Kubi,

How about using a 2d Perlin noise instead and adding (or subtracting) the `zOff` variable to the `x` and `y` coordinates of your noise space ?

`n = noise(xOff + zOff, yOff + zOff);`

The orientation of the wave motion will vary depending on where you chose to add/subtract your `zOff` variable:

- increment/decrement the `xOff` only = horizontal motion
- increment/decrement the `yOff` only = vertical motion
- increment/decrement both = diagonal motion

---

<div class="post-metadata">

**Author:** ![Kubi](https://avatars.discourse-cdn.com/v4/letter/k/f04885/32.png) [@Kubi](https://discourse.processing.org/u/Kubi)\
**Post date:** [March 24, 2020, 5:46pm UTC](https://discourse.processing.org/t/perlin-3d-noise-working-correctly/18988/3 "2020-03-24T17:46:15Z")

</div>

Hi @solub,

thanks for the reply! However, that is not what I mean… I don’t want waves moving across the canvas, I want random “highlights” appearing independently of each other… If you look at my sketch with unchanged settings, everything seems to change simultaneously every half second or so… The highlights seem to appear and disappear in some kind of pulsing motion all at once… Hard to explain what I mean 😕

---

<div class="post-metadata">

**Author:** ![solub](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/solub/32/333_2.png) [@solub](https://discourse.processing.org/u/solub)\
**Post date:** [March 24, 2020, 6:05pm UTC](https://discourse.processing.org/t/perlin-3d-noise-working-correctly/18988/4 "2020-03-24T18:05:09Z")

</div>

I think I understand what you mean.

Have you tried with OpenSimplex noise instead ? My guess is that you will probably get a smoother motion with it.

You can import it in your `index.html` folder with:

`<script src="https://cdn.rawgit.com/jwagner/simplex-noise.js/87440528bcf8ec89840e974d8f76cfe3da548c37/simplex-noise.min.js"></script>`

then adding to your sketch:

```auto
var simplex = new SimplexNoise();

n = simplex.noise3D(x, y, z); 
n = simplex.noise2D(x, y);

```

---

<div class="post-metadata">

**Author:** ![Kubi](https://avatars.discourse-cdn.com/v4/letter/k/f04885/32.png) [@Kubi](https://discourse.processing.org/u/Kubi)\
**Post date:** [March 24, 2020, 6:08pm UTC](https://discourse.processing.org/t/perlin-3d-noise-working-correctly/18988/5 "2020-03-24T18:08:51Z")

</div>

thanks @solub, I’ll look into that!

Edit:  
@solub you were right, Daniel Shiffmann mentions the same issue in this video at around 3:30

[![](https://img.youtube.com/vi/Lv9gyZZJPE0/maxresdefault.jpg "I.7 : What is OpenSimplex Noise?") ](https://www.youtube.com/watch?v=Lv9gyZZJPE0)

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 28, 2020, 2:39am UTC](https://discourse.processing.org/t/perlin-3d-noise-working-correctly/18988/6 "2020-03-28T02:39:01Z")

</div>

For more on Perlin vs Simplex noise – and in in-depth comparison of their outputs – see also: [Perlin vs Simplex noise performance](https://discourse.processing.org/t/perlin-vs-simplex-noise-performance/4189/2)

(That is for Processing (Java mode), but still relevant)
