? Perlin Noise ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Perlin Noise

Submitted
Updated
Author
Simeon
Public Key
N3Q5Z3AD
Min. Compat.
All
Version
2.0
Size
14.9KB
Rating
7 votes
Description 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.
Categories
Keywords
16 Comment(s) Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies 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 MochaProbably MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies No matter what I try I just get vertical lines. It supposed to look like https://www.google.com/search?q=1+dimensional+perlin+noise&client=safari&hl=en-us&prmd=ivsn&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiYmpnx2PjVAhVHOiYKHX4XBbcQ_AUIECgB&biw=1024&bih=649#imgrc=JFB8KsfHo6Q9GM: Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies 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. MochaProbably MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies Ahh child you knew exactly what I wanted! Thank you! MochaProbably MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies Can this produce 1 dimentional noise? kenchic kenchic Avatar Taboo I didn't change my avatar for 180 days Website Second Year My account is over 2 years old Website Good Page Hidden Achievements 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. MochaProbably MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies I tired doing that and it didn't work, could you show an example? 12Me21 12Me21 Head Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Second Year My account is over 2 years old Website 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. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies 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 12Me21 12Me21 Head Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Second Year My account is over 2 years old Website 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. kenchic kenchic Avatar Taboo I didn't change my avatar for 180 days Website Second Year My account is over 2 years old Website Good Page Hidden Achievements ^ i did that, i wanted different sponges JustGreat JustGreat First Month Joined in the very first month of SmileBASIC Source Website Avatar Taboo I didn't change my avatar for 180 days Website Night Person I like the quiet night and sleep late. Express Yourself Minecraft SB when? please don't kill me lumage kenchic kenchic Avatar Taboo I didn't change my avatar for 180 days Website Second Year My account is over 2 years old Website Good Page Hidden Achievements Minecraft would look like you're living in a sponge. RNGesus 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. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies 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. RNGesus RNGesus Oh, that's interesting. Well, two differnt styles leads to two differnt options for randomly generating things. Great job!