# real arguments to Perlin Noise

This topic is 4843 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I posted a question like this on CG society but thought I'd ask here if that's alright.. I'm using Ken Perlin's Improved version: http://mrl.nyu.edu/~perlin/noise/ , and I am on the way to understanding how it works . However the input to the noise function are not integers x,y,z but real numbers x,y,z because it is a continuous function. My problem is how do you sample the n-space R^n that you're working in ? 1D, 2D or 3D ? It has been suggested to me to send the Perlin function a linear combination of x,y (for 2D) , something like: noise( ax+by+c,dx+ey+f) ; where (i think) b = d = 0 . the c and f are offsets so you dont get the value 0 (avoiding the same problem as giving the noise function integer values). But I can't get it to work and was wondering what people here are sending to the noise function if they want a 2D texture ? you can't just give it Regards

##### Share on other sites
You can rewrite the noise-functions to 2D; keep only X and Y and instead of blended samples from 8 corners of a cube (as mentioned at that link you posted), you take 4 samples from a square. The grad function is rather simple to fix too, take the lower 2 bits of the hash-input and combine (x, y) either horizontally and vertically or diagonally (or both if you take 3 bits). Maybe you could try to write this in 1D first?

For some help in understanding the noise-function, try Perlin's noise-presentation.

##### Share on other sites
Perlin's own code demonstrates coelurus's reply well. Seperate functions for 1, 2, and 3 dimensions. Using a 3D function for 2D noise is wasteful. You'd end up doing 7 lerps on 8 samples instead of 3 lerps on 4.

##### Share on other sites
he's right it is wastefull to impliment 3d noise for 2-d usage. any vectors can be passed to the 3d noise function to produce a 2-d image, the only condition is that the vectors be destribuited across some plane in 3 space. to be honest I see no reason to impliment a 2d version if you're generating off line textures to put in an image. there is a post about it a few days back "triangle slices" but if you're doing it a lot, it's wourth it to write a 2d version. suppose I got a square image I want 2 d noise on I could do this

suppose I want 100x100 pixel image

for i= 0 to 100
for j = 0 to 100
v = noise((j/100)*width, (i/100)*height, 0)
pixel(j, i) = (v, v, v)

this would give you a greyscale image. you could define the noise on any plane in 3 space, not just the x,y plane.

to generate a 1d noise funciton you define it across a line
L = p + t*d (vector equation of line)

for i= 0 to 100
L = p + t(i/100)*K*d
v = noise(L.x, L.y, L.z)

where K is a frequency paramater. the higher K the higher frequency signal

[Edited by - timw on August 12, 2005 11:46:36 PM]

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633328
• Total Posts
3011379
• ### Who's Online (See full list)

There are no registered users currently online

×