LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Perlin Noise

Root / Submissions / [.]

SimeonCreated:
Download:N3Q5Z3AD
Version:2.0Size:14.9KB
This enables efficient access to a 1D, 2D, or 3D infinite space of Perlin Noise by calling NOISE(X,Y,Z).

Instructions:

You can grab a value at any position, at any given point in time. This makes procedural world generation very easy to comprehend and implement, for an infinitely spanning map. To use this, you simply type
DIM _P[512] INITNOISE
In the beginning of the program, and place the DEF NOISE code anywhere else in the program.

NOISE(X,Y,Z) will always return a value between 0 and 1.

Included are 8 sample programs to show how it works. Say you only want to use 1D noise for a 2D map like terraria, then you would just do Y=NOISE(X/10,0,0) where 10 can be any value to define how zoomed out the map will be.

Why does it have strange squiggly lines all over it? My version is white noise being diluted over and over, yet yours is entirely different. Can you please explain why this is? I would download it and check the source code, but unfortunately i am unable to.

Replying to:RNGesus
Why does it have strange squiggly lines all over it? My version is white noise being diluted over and over, yet yours is entirely different. Can you please explain why this is? I would download it and check the source code, but unfortunately i am unable to.
OH yes right, that is because the noise gives you negative and positive values, instead of adding the value so it's all positive, I used absolute value because I thought it looked cooler. But it doesn't really matter how the program is visualized.

Minecraft SB when? please don't kill me lumage

A better way to load the data would be using COPY Array[,Start],@Label,Length
DIM _P%[512]
COPY _P%,@_NOISEDATA,256
COPY _P%,256,@_NOISEDATA,256
You should also use integer variables wherever you can.

Replying to:12Me21
A better way to load the data would be using COPY Array[,Start],@Label,Length
DIM _P%[512]
COPY _P%,@_NOISEDATA,256
COPY _P%,256,@_NOISEDATA,256
You should also use integer variables wherever you can.
Well I mean, that code only gets ran a single time, it'll speed it up an unnoticeable amount on startup, but it's much cleaner code so thank you

Replying to:12Me21
A better way to load the data would be using COPY Array[,Start],@Label,Length
DIM _P%[512]
COPY _P%,@_NOISEDATA,256
COPY _P%,256,@_NOISEDATA,256
You should also use integer variables wherever you can.
I wish there was a way to generate these values instead of using DATA. seems like just calling RND(256) 256 times would be just as good.

Replying to:JustGreat
Minecraft SB when? please don't kill me lumage
Minecraft would look like you're living in a sponge.

Replying to:RNGesus
Why does it have strange squiggly lines all over it? My version is white noise being diluted over and over, yet yours is entirely different. Can you please explain why this is? I would download it and check the source code, but unfortunately i am unable to.
Oh, that's interesting. Well, two differnt styles leads to two differnt options for randomly generating things. Great job!

Replying to:12Me21
A better way to load the data would be using COPY Array[,Start],@Label,Length
DIM _P%[512]
COPY _P%,@_NOISEDATA,256
COPY _P%,256,@_NOISEDATA,256
You should also use integer variables wherever you can.
^ i did that, i wanted different sponges

Can this produce 1 dimentional noise?

Replying to:MochaProbably
Can this produce 1 dimentional noise?
consistently only change one value if you want one-dimensional noise. ex. keep y and z the same value and only use the x value to read from the space.

Replying to:MochaProbably
Can this produce 1 dimentional noise?
I tired doing that and it didn't work, could you show an example?

Yeah when I get the time I'll upload a better example code to show 1D, 2D, and 3D noise It's pretty easy to do, you call NOISE(X/10,10,10) Y and Z are constant numbers, X/10 can be X/anything, higher number = more spread out noise

Replying to:Simeon
Yeah when I get the time I'll upload a better example code to show 1D, 2D, and 3D noise It's pretty easy to do, you call NOISE(X/10,10,10) Y and Z are constant numbers, X/10 can be X/anything, higher number = more spread out noise

Replying to:Simeon
Yeah when I get the time I'll upload a better example code to show 1D, 2D, and 3D noise It's pretty easy to do, you call NOISE(X/10,10,10) Y and Z are constant numbers, X/10 can be X/anything, higher number = more spread out noise
Download the new key, it has example programs to show how it works. And the NOISE_TERRAIN example generates images exactly like the ones in that link. And the NOISE_1D_TEST2 example generates images like that with infinite scrolling left and right. And ISLAND_XPLORER example generates 2D images like that with infinite scroll up, down, left, and right. Now NOISE(X,Y,Z) generates a value between 0 and 1, instead of -1 and 1. So it's easier to implement.

Replying to:Simeon
Yeah when I get the time I'll upload a better example code to show 1D, 2D, and 3D noise It's pretty easy to do, you call NOISE(X/10,10,10) Y and Z are constant numbers, X/10 can be X/anything, higher number = more spread out noise
Ahh child you knew exactly what I wanted! Thank you!

Someone tell Perlin to quite down. He’s too noisy.

Replying to:rando
Someone tell Perlin to quite down. He’s too noisy.
I think he's going through a phase.

I'm a little late to the party, but I think there's a typo in the _GRAD(...) function. I was comparing your code to Ken Perlin's when I was making my own implementation when noticed on the last line you have
RETURN ... + (!(H AND 2)*2+1)*V
That particular piece of math should return the value of V when (H AND 2)==0 is true and -V when (H AND 2)==0 is false. Should be written as
RETURN ... + (!!(H AND 2)*-2+1)*V
The 2 was positive instead of negative and the double-! is to convert to boolean.