0
$\begingroup$

I'm just getting started trying to understand noise generation algorithms. What I'm trying to achieve is to get a 2D (or 3D) grid of random directional vectors (again, 2D or 3D) according to a noise distribution like Perlin, ie. not just a grid of totally randomly generated vectors (which would be easy to do).

Before starting to figure this out, I had assumed that 1D noise functions would be those that produce a series of float values (ranging from -1 to 1, for example), and that 2D noise functions would produce float2 values, 3D noise would produce float3 values, and so on.

However, searching for so-called 2D noise functions, it seems that they are used to produce a 2D grid (ie. texture) of single float values. However, what I'm looking for is a 2D grid of 2D (float2 / vector2) values, or a 3D grid of 3D (float3 / vector3) values.

From my (still pretty limited) understanding of a gradient-based noise like Perlin, I feel like I could probably hack something together from an existing Perlin function - doing a bi-linear/tri-linear interpolation of the surrounding gradient vectors which are ordinarily used for the subsequent dot product in Perlin noise. But I have no idea if that's the correct approach.

Are there existing libraries/methods for something like this?

$\endgroup$

2 Answers 2

3
$\begingroup$

Why don't you just use Perlin noise twice on the same grid, or volume? Each with slightly different parameters (a phase shift, or different pseudo-random vectors). In this case both component of your float2 are smoothly defined by a Perlin Noise field. A float2 $v$ could be defined as $v = \{P(u,v), P(u+0.5, v+0.5)\},$ where $P(u,v)$ is the Perlin noise function. However, this will make the $x$ and $y$ component of $v$ very close depending on the scaling of the grid values.

$\endgroup$
2
  • $\begingroup$ I did wonder about that, but it seems unnecessarily computationally intensive to need to run the function twice. This is for a real-time application, so I want it to be as fast as possible ideally. But I will definitely investigate it, thanks! $\endgroup$ Commented Feb 21, 2019 at 13:04
  • $\begingroup$ Perlin noise is already a very efficient means to obtain noise. It is not uncommon to see multiple evaluations of Perlin noise per pixel for procedural textures. The performance loss will not be severe. $\endgroup$
    – Reynolds
    Commented Feb 21, 2019 at 13:08
1
$\begingroup$

You can use the gradient of the noise/hash which for a function $f:\mathbb{R}^n\rightarrow\mathbb{R}$ would be $n$ dimensional (depending on the application this may not work for you). Another possibility, as Reynolds mentioned is to generate the noise by calling the function multiple times.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.