# Perlin Noise Implementation?

**URL:** https://discourse.processing.org/t/perlin-noise-implementation/45773
**Category:** Development
**Created:** [February 16, 2025, 12:08am UTC](https://discourse.processing.org/t/perlin-noise-implementation/45773 "2025-02-16T00:08:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mario60](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@mario60](https://discourse.processing.org/u/mario60)
#### Post date: [February 16, 2025, 12:08am UTC](https://discourse.processing.org/t/perlin-noise-implementation/45773/1 "2025-02-16T00:08:29Z")

</div>

~~I am not able to locate the file where the Perlin noise function noise() has been implemented. Please let me have the precise url, thanks.~~

**There it is,** at [core/src/processing/core/PApplet.java](https://github.com/processing/processing4/blob/main/core/src/processing/core/PApplet.java), line 4814

ps.  
I see p5.js’ implementation at [https://github.com/processing/p5.js/blob/main/src/math/noise.js](https://github.com/processing/p5.js/blob/main/src/math/noise.js);  
I see the further implementation at [https://discourse.processing.org/t/2d-perlin-noise-function/17602](https://discourse.processing.org/t/2d-perlin-noise-function/17602) too.

---

<div class="post-metadata">

### Author: ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)
#### Post date: [February 18, 2025, 12:28pm UTC](https://discourse.processing.org/t/perlin-noise-implementation/45773/2 "2025-02-18T12:28:52Z")

</div>

Glad you found it!

For some context about the `noise()` function in Processing/p5.js and where it came from, you might be interested in this recent discussion on the p5.js GitHub:

> <https://github.com/processing/p5.js/issues/7430>
>
> \### noise() is not Perlin noise
> 
> Hi,
> 
> I've been browsing the documentation o…f the noise function 
> 
> \> \[...\] Ken Perlin invented \`noise()\` while animating the original Tron film in the 1980s
> 
> and continued to study its implementation. From a first sight, I believe that the implementation found in p5.js deviates from Perlin noise in two characteristics:
> 
> \### Perlin noise defines gradients at integer grid locations
> 
> The noise value associated with a grid locations is given by the dot-product between the stored gradient and the offset vector. If I read your implementation correctly, you are directly assigning a random value to each integer location that is later interpolated.
> 
> \### Perlin noise is zero at all integer grid locations
> if the dot-product becomes zero, either because of orthogonality between the gradient direction and the offset vector or because the offset vector is zero (at integer locations), the resulting noise value becomes zero. Hence, at integer locations the resulting noise should be zero. See https://en.wikipedia.org/wiki/Perlin\_noise. In p5.js \`noise(x=0,0,0)\` will not return a zero noise value in general.
> 
> Hence, \`noise()\` provides smooth noise, but not Perlin noise. I don't believe that's an issue for the intended audience, but in case one relies on the above Perlin characteristics to hold true, you should mentioned the deviations in the docs.
