Before all the complaints start streaming in - I'm aware that this is more of an "approximation" to Perlin noise rather than defacto Perlin noise, however it shares the same periodicity and distribution properties. Instead of using dot products of gradients, The original noise map is used as a height map, through which gradient is implied via linear interpolation between neighbouring heights at different spatial scales.
I appreciate the void you fill in the youtube space for development tutorials, your explanations are excellent and have helpes me significantly in ways that channels like Brackeys are unable to. I see a lot of comments noting that the speed of your videos is too fast, I believe that there is a large community that will find your speed refreshing.
The creator Brackeys doesn't have a background in math nor programming. He's just a creative mind that happened to stumble across unity and picked up game development due to it. It's not bad perse, it just gives a whole different style of content because he doesn't know what is actually happening under the hood of the code or the engine. I still learned some stuff from brackeys and they were really good at showing how the engine (unity) works. But Javidx9 knows what actually is happening under the hood and that's why he can make a lot more educational focused content because he actually knows how to make an engine.
This is genius. Whilst it isn't "true" perlin noise, it's damn close to it, and I'm sure you could use this to get practically the same results in nearly every project you could think of. Well done :P
Thanks Avana - though I will say I've seen this method used in the wild, so I cant lay exclusive rights to it! It's closest relative is an algorithm called "Simplex Noise".
I've been searching for this for so long! Everybody else just uses functions already implimented so I don't really learn how the perlin noise works. Thanks :)
I started learning C++ about a month ago, coming in with knowing matlab from engineering and C# from making a lot of little games in Unity. You are a blessing, because you explain the topic so well I could probably write the code myself.
After looking through papers and tutorials, i just couldnt get my head around it. thanks to this tutorial i implemented it & fully understand it. thanks alot
When writing/showing code, you could use the Alt+Shift+Enter shortcut to show code in fullscreen. It makes code much easier to visualize and follow up.
Another way of linear interpolation is ((nSample2 - nSample1) * fBlend) + nSample1 I code in Scratch (because I'm too lazy to learn Java, C++, python or literally anything else) and this helped me create some code that can create a map using your "Perlin noise." It may not be true Perlin noise, but it does the same job and works very similarly. Thanks!
Hi and thanks Kevin, I think most people can code, like all things it just takes practice and patience and effort, which are traits that should be respected regardless of discipline.
@@javidx9 Maths isn't my friend lol! But you're right, you get out what you put in i guess👍 It may sound strange, but when i see code, to me it looks like art. It has a beauty to it - anyway much respect to you!
kevin smith That is what good is haha, you can achieve things differently. It truly is an art, you can do it really verbose and unreadable, or simple but yet effective.
@@kevinsmith-dn1px A recent quote I found that I really like, "code is art that does something". Other than that, you'd be surprised how little day-to-day programming has to do with maths! The only part they have in common is the general logic aspect (which applies to so many other disciplines that it's not fair to claim it makes programming close to maths) - I'd say the real crucially common part is being able to deconstruct complex operations into simpler ones to solve an issue, like you would when writing up a demonstration to a theorem (or anything else really) in maths for instance. EDIT: I'd say generally some types of programmers are math enthusiasts like OLC and (probably) much of the audience, but not really math nerds (what's a covector again? differential topology? no thanks) : I think high school maths is the most interesting and useful, having a basic understanding of moderately advanced geometry like vector dot product, as well as some calculus, but really most of the problems I think of as "interesting" that would involve me using those tools are essentially problems that are already solved, and I could just copypaste some maths formula in my code if I didn't enjoy solving the puzzle.
This was really useful for a fog effect I'm experimenting with. I put it into a header file as a couple classes. Only problem is I want the clouds to change over time, and for that I'd need noise with a 3 dimensional input. I've tried figuring it out myself, expanding on the 2D noise, but it seems I'm too stupid for it. Edit: nevermind, got it working... to an extent.
I rellay like the idea of explaining this. I literally won't use anything unless I understand how it works. It just feels wrong to me. Any wathincg this was faster than figuring it out myself.
I would have given you a *big* thumb's up (as you request at 27:49) , but UA-cam allows only an ordinary thumb's up. I hope that that is adequate. I have been in need of noise generation like this for a while. My own algorithms are fast-executing, but don't have the look and simple parameterization of the Perlin noise. Now I know what to do!
At 18:17, going from 1 octave to 2 octaves, it makes the line drop in the middle. Shouldn't octaves only be able to add on to what we already have? I am wondering if the seed noise somehow contains negative numbers.
One thing to note about the seed array, Perlin's original algorithm uses a precomputed array containing 0-255(inclusive) in a randomized order, in my understanding this is done to prevent getting into situations where the majority of the numbers in the array are too similar to eachother(and of course performance, it was created in the 80s after all, memory and CPU cycles weren't cheap). What you can then instead do is randomly shuffle the elements in the array, that way you keep all numbers from 0-255 but in a new order. Although this implementation is completely different than the original Perlin noise, using a float array instead of int array, so I don't know how you would fit that in here. Not really a big deal, but sticking to the "true" perlin noise might give some slightly more predictable results, besides the video still shows very well how perlin noise is used and why it's useful
I've read about the >> operator but never used it before. So I just wanna make sure I got the concept. The expression (nWidth >> o) is there to divide nWidth by 2^o is that right? Furthermore do you only use it because it's faster to compute? Are there any drawbacks or other potential advantages?
Hi Flo, Yes your calculation is correct. In most cases, your compiler will choose the most optimal division strategy, but in the case of integers that are powers of 2, then bit shifting is the most optimal. The >> and
Hello! I have a question. I know that this is similar to Perlin noise, but is an approximation. I was wondering if one is better to use than the other. Is there a big difference? Also I really like how you explained how it worked first with the diagram. 😁
Hi Trent, then end results from the algorithms are pretty much the same, Perlin interpolates a little differently, focusing on interpolating the gradients directly, and is why I use the term "approximating", as I calculate the gradients and interpolate the lines instead. The approach shown in this video is quite common, as it is more visual to grasp.
Just nitpicking here, but fScaleAcc will be the same number for all samples, so you you can compute it only once and re-use the value. You don't even need to calculate it inside one of the loops: fScaleAcc = 2.0 - 1.0/(float)(1
Thanks Erwin, I dont see things a nitpicks, I find them often to be valuable contributions, which I hope others get to see. I dont make any claim that my methods are the best, just a way to have fun coding. The challenge I face is I try to write code in such a way that things are obvious, so viewers can follow - but you are right of course.
I found it nitpicking, as the presentation is otherwise perfect. Especially because the second part where you can alter the divisor, the formula involves some quite advanced math and is quite obviously not on the level of the intended audience.
wont work on linux, there are math errors that where not solved and also: int nSampleX1 = (x / nPitch) * nPitch; int nSampleY1 = (y / nPitch) * nPitch; why this? it's literally the same as just int nSampleX1 = x; int nSampleY1 = y;
@@javidx9 But doesn't that result in that a lot of the time the samples are 0? I have this problem where my samples are 0 a lot of the time which results in terrain with a smooth line from the top Left to the bottom right of my screen en the rest is still just noise?
My humble understanding seeds length is 256. Which is 8 octaves. But how do I generate infinite continues noise? Can you make a video improve this algorithm to infinite continues noise generator?
You can still use everything as presented here but you will need to wrap the RNG so it can do stuff like: random(x, y, seed). Then you use this instead of a precalculated random array to create your fSampleT and fSampleB. Now you are no longer bound to any dimensions. Next you could remove any "array-like" stuff from the perlin function and use it to only calculate ONE sample at one specific (x,y). And here you go: A perlin-generator that takes x, y, bias, oct, etc (whatever you want) as input and outputs a single Value between 0 and 1. I havent coded it yet but i think it should work that way.
I can't seem to find anything on the interpolation method you used ( linear interpolation between neighbouring heights). Any idea where I could read more about it?
@@javidx9 I was having a little problem seeing that x=(1-mu)*x0+mu*x1 was actually a linear interpolation formula. Tried it on Excel and that answered my question. Thanks and nice video!
Thanks Grub! Most of my videos use a custom library I created that exploits the windows command prompt as a graphical surface. All the source is available in the descriptions below each video.
Hey Javidx9! Beautiful work! Excellent theoretical intro. vey pedagogical. Questions: i) How compatible is olcConsole...h with linux? ii) Why windows man, why?
Hey Thanks GTS! I appreciate that. 1) Not very. Members of this community have tried with different levels of success. Fundamentally, the consoles between the two OSs are very different in their use and implementation. 2) See 1 :D Only displaying the screen is incompatible. The algorithms in my videos are very much cross compatible. Maybe it's time I took a look at a linux implementation. I don't think I'd be able to do much better than the others that have tried, it seems to be quite performance restricted due to how the linux terminal works. There was an SDL2 port made of the game engine via github, which could also help.
this video's sadly WAY too fast and lacks a lot of the explanation needed to understand exactly how it works. I've needed to do LOADS of de-bugging in order to use this generation algorithm. I had troubles because I couldn't tell where my code went wrong, because I had to do a lot of blind faith in the code you had written. I'd recomend re-doing this tutorial and splitting it up into two parts, and explain every single bit in extream detail, and when going into 2D, explain the changes. Either way, this is prety much the only tutorial on generating your own perlin noise on youtube, so credit where credit is due.
Hi bysTaXx, I'm sorry you've not found this video very clear. It is quite a complicated subject matter. I probably won't redo the video, but I'll take on board your concerns. I often get criticized that my videos are too slow! I'm still new at this, so still working on finding a balance that suits everybody.
javidx9 well then, i find that in many casses it is better to have more videos with narrow subjects explained in depth rather than one video with multiple topics to be helpfull, for instance, having an "intro to perlin noise" then a "1D perlin noise" then a "2D perlin noise" video would be better, as an example. And you are correct, perlin noise is a complicated topic, like PRNG algorithms are complicated. I would recommend typing out the code as much as possible, rather than copying and pasting predefined code to be most effective. Another suggestion is that after finishing a block of code, pause for a few seconds to let the viewers pause the video to review the new code. Either way, you have excellent delivery, you are engaged with your viewers, and i'm happy you dive into topics that most people just use a pre-defined library for. So all in all, i'd say you are doing quite well, just could use a little improvement.
Before all the complaints start streaming in - I'm aware that this is more of an "approximation" to Perlin noise rather than defacto Perlin noise, however it shares the same periodicity and distribution properties. Instead of using dot products of gradients, The original noise map is used as a height map, through which gradient is implied via linear interpolation between neighbouring heights at different spatial scales.
dont worry people are going to complain anyways :D, great tutorial thanks a lot
هجهححعحععض
عضغضضضضضضض
فضفضفضڤ في فض ففي في غ١٦غضغضضضضغضضضضضضضغغضغضغضععععععضضغغغضضغضضضضضضضضغضضغضضضضضغضضغضضغضضعضعغضععه
رح وز لءظاللذالننح مع ههشهشهههههههعععععععععععع٦ض١١ضضضع
I appreciate the void you fill in the youtube space for development tutorials, your explanations are excellent and have helpes me significantly in ways that channels like Brackeys are unable to. I see a lot of comments noting that the speed of your videos is too fast, I believe that there is a large community that will find your speed refreshing.
Hi Mime and thanks for the positive feedback, I appreciate that!
This! A hundred times! javidx speed is DEFINITELY refreshing compared to most tutorials (whatever the topic)
Agreed! I'm really enjoying this pace.
The creator Brackeys doesn't have a background in math nor programming. He's just a creative mind that happened to stumble across unity and picked up game development due to it. It's not bad perse, it just gives a whole different style of content because he doesn't know what is actually happening under the hood of the code or the engine. I still learned some stuff from brackeys and they were really good at showing how the engine (unity) works. But Javidx9 knows what actually is happening under the hood and that's why he can make a lot more educational focused content because he actually knows how to make an engine.
This is genius. Whilst it isn't "true" perlin noise, it's damn close to it, and I'm sure you could use this to get practically the same results in nearly every project you could think of. Well done :P
Thanks Avana - though I will say I've seen this method used in the wild, so I cant lay exclusive rights to it! It's closest relative is an algorithm called "Simplex Noise".
I like that you used musical elements as an example; really helps me out.
Thanks Benjamin! I'm pleased you've found it useful!
You are a great teacher. Thank you for making these. I'm learning a lot.
that first picture of true random static was trippy. it started waving and flowing on me like one of those magic eye hidden image puzzles.
I've been searching for this for so long! Everybody else just uses functions already implimented so I don't really learn how the perlin noise works. Thanks :)
Hi Olav, no problem!
The time passes so quickly when I watch your videos.
You make interesting and quality videos, hope your channel will grow soon
Thanks Black Magic!
@@javidx9 thats not his name?
It was 2 years ago 😁
@@javidx9 haha
I started learning C++ about a month ago, coming in with knowing matlab from engineering and C# from making a lot of little games in Unity. You are a blessing, because you explain the topic so well I could probably write the code myself.
After looking through papers and tutorials, i just couldnt get my head around it. thanks to this tutorial i implemented it & fully understand it. thanks alot
When writing/showing code, you could use the Alt+Shift+Enter shortcut to show code in fullscreen. It makes code much easier to visualize and follow up.
All the toolbars, console, taskbar, solution explorer etc. are too distracting and add no useful information to the video.
Thanks for the tutorial. I'm going to be implementing the 2D version of this algorithm into my game, Solar Lander.
I think you just saved my weekend and semester project as my method was getting increasingly repetitive. Thank you very much!!!
Another way of linear interpolation is ((nSample2 - nSample1) * fBlend) + nSample1
I code in Scratch (because I'm too lazy to learn Java, C++, python or literally anything else) and this helped me create some code that can create a map using your "Perlin noise." It may not be true Perlin noise, but it does the same job and works very similarly. Thanks!
Bro move to c++ or something you'll like it better I promise
Omg, much respect to people who can code!
Hi and thanks Kevin, I think most people can code, like all things it just takes practice and patience and effort, which are traits that should be respected regardless of discipline.
@@javidx9 Maths isn't my friend lol! But you're right, you get out what you put in i guess👍
It may sound strange, but when i see code, to me it looks like art. It has a beauty to it - anyway much respect to you!
kevin smith
That is what good is haha, you can achieve things differently.
It truly is an art, you can do it really verbose and unreadable,
or simple but yet effective.
free respect
@@kevinsmith-dn1px A recent quote I found that I really like, "code is art that does something". Other than that, you'd be surprised how little day-to-day programming has to do with maths! The only part they have in common is the general logic aspect (which applies to so many other disciplines that it's not fair to claim it makes programming close to maths) - I'd say the real crucially common part is being able to deconstruct complex operations into simpler ones to solve an issue, like you would when writing up a demonstration to a theorem (or anything else really) in maths for instance.
EDIT: I'd say generally some types of programmers are math enthusiasts like OLC and (probably) much of the audience, but not really math nerds (what's a covector again? differential topology? no thanks) : I think high school maths is the most interesting and useful, having a basic understanding of moderately advanced geometry like vector dot product, as well as some calculus, but really most of the problems I think of as "interesting" that would involve me using those tools are essentially problems that are already solved, and I could just copypaste some maths formula in my code if I didn't enjoy solving the puzzle.
Hey javidx9! Can you do a tutorial about liquid simulation? I found that there arent any proper tutorial on how to do liquid simulation from scratch.
brilliant video, clear explanation of an abstract concept then an implementation to demonstrate
This was really useful for a fog effect I'm experimenting with. I put it into a header file as a couple classes.
Only problem is I want the clouds to change over time, and for that I'd need noise with a 3 dimensional input. I've tried figuring it out myself, expanding on the 2D noise, but it seems I'm too stupid for it.
Edit: nevermind, got it working... to an extent.
I rellay like the idea of explaining this. I literally won't use anything unless I understand how it works. It just feels wrong to me. Any wathincg this was faster than figuring it out myself.
I would have given you a *big* thumb's up (as you request at 27:49) , but UA-cam allows only an ordinary thumb's up. I hope that that is adequate. I have been in need of noise generation like this for a while. My own algorithms are fast-executing, but don't have the look and simple parameterization of the Perlin noise. Now I know what to do!
At 18:17, going from 1 octave to 2 octaves, it makes the line drop in the middle. Shouldn't octaves only be able to add on to what we already have? I am wondering if the seed noise somehow contains negative numbers.
One thing to note about the seed array, Perlin's original algorithm uses a precomputed array containing 0-255(inclusive) in a randomized order, in my understanding this is done to prevent getting into situations where the majority of the numbers in the array are too similar to eachother(and of course performance, it was created in the 80s after all, memory and CPU cycles weren't cheap). What you can then instead do is randomly shuffle the elements in the array, that way you keep all numbers from 0-255 but in a new order. Although this implementation is completely different than the original Perlin noise, using a float array instead of int array, so I don't know how you would fit that in here. Not really a big deal, but sticking to the "true" perlin noise might give some slightly more predictable results, besides the video still shows very well how perlin noise is used and why it's useful
You probably wont see this, but you spared me a headache. Thanks for all the work you do!
Always appreciate feedback, cheers buddy!
I've read about the >> operator but never used it before. So I just wanna make sure I got the concept.
The expression (nWidth >> o) is there to divide nWidth by 2^o is that right? Furthermore do you only use it because it's faster to compute? Are there any drawbacks or other potential advantages?
Hi Flo, Yes your calculation is correct. In most cases, your compiler will choose the most optimal division strategy, but in the case of integers that are powers of 2, then bit shifting is the most optimal. The >> and
At 23:40, I see SampleT and SampleB. What do 'T' and 'B' stand for?
Top and bottom
@@javidx9 Thank you
Hello! I have a question. I know that this is similar to Perlin noise, but is an approximation. I was wondering if one is better to use than the other. Is there a big difference? Also I really like how you explained how it worked first with the diagram. 😁
Hi Trent, then end results from the algorithms are pretty much the same, Perlin interpolates a little differently, focusing on interpolating the gradients directly, and is why I use the term "approximating", as I calculate the gradients and interpolate the lines instead. The approach shown in this video is quite common, as it is more visual to grasp.
javidx9 Thanks! :)
Great video, as always!
Thank you Carsten, was a bit worried about this one!
I have f.lux, and it took me about half a minute to realize that you were probably using yellow, not white, on the white background.
lol, I shall be more late night yet sensible video watcher aware going forward!
Just nitpicking here, but fScaleAcc will be the same number for all samples, so you you can compute it only once and re-use the value. You don't even need to calculate it inside one of the loops: fScaleAcc = 2.0 - 1.0/(float)(1
Thanks Erwin, I dont see things a nitpicks, I find them often to be valuable contributions, which I hope others get to see. I dont make any claim that my methods are the best, just a way to have fun coding. The challenge I face is I try to write code in such a way that things are obvious, so viewers can follow - but you are right of course.
I found it nitpicking, as the presentation is otherwise perfect. Especially because the second part where you can alter the divisor, the formula involves some quite advanced math and is quite obviously not on the level of the intended audience.
I know this is a pretty old video, but i'd like to ask what this implementation is called exactly? Or did you make it up?
wont work on linux, there are math errors that where not solved and also:
int nSampleX1 = (x / nPitch) * nPitch;
int nSampleY1 = (y / nPitch) * nPitch;
why this? it's literally the same as just int nSampleX1 = x; int nSampleY1 = y;
Did you make up this approximation?
Is this like the diamond square algorithm in 2d?
how do I make it to 3d mesh?
Also, why do you say that this is "only an approximation of Perlin noise" in the video description?
I kinda wish I could use bicubic interpolation instead of bilinear but I just don't know how to get it working
Int sample1 x = (x/npitch) * npitch ???? What's the difference with just int sample1x = x
Yeah it's a fun one this 😄 I'm taking advantages of the property of integer divide to round down X, before scaling it up to be a multiple of nPitch.
Ahhh now I understand.
@@javidx9 But doesn't that result in that a lot of the time the samples are 0? I have this problem where my samples are 0 a lot of the time which results in terrain with a smooth line from the top Left to the bottom right of my screen en the rest is still just noise?
can you do 3d perlin noise?
i wish javid made this without olc so it could be helpful for an person like me that is trying to implement this in his own console game engine
Can you make a video extending to 3D? 🙂 Maybe even 4D? 😀
My humble understanding seeds length is 256. Which is 8 octaves. But how do I generate infinite continues noise? Can you make a video improve this algorithm to infinite continues noise generator?
You can still use everything as presented here but you will need to wrap the RNG so it can do stuff like: random(x, y, seed). Then you use this instead of a precalculated random array to create your fSampleT and fSampleB. Now you are no longer bound to any dimensions. Next you could remove any "array-like" stuff from the perlin function and use it to only calculate ONE sample at one specific (x,y). And here you go: A perlin-generator that takes x, y, bias, oct, etc (whatever you want) as input and outputs a single Value between 0 and 1. I havent coded it yet but i think it should work that way.
I can't seem to find anything on the interpolation method you used ( linear interpolation between neighbouring heights). Any idea where I could read more about it?
It is nothing more complicated than simple linear interpolation. Even has it's own function now std::lerp()
@@javidx9 I was having a little problem seeing that x=(1-mu)*x0+mu*x1 was actually a linear interpolation formula. Tried it on Excel and that answered my question. Thanks and nice video!
when i run the program, it tells me that "olcConsoleGameEngine.h" has no such file or directory.
Have you downloaded the "olcConsoleGameEngine.h" file as well?
Hello, Nice Video.
Can you call which Graphic Library you use? Thank you!
Thanks Grub! Most of my videos use a custom library I created that exploits the windows command prompt as a graphical surface. All the source is available in the descriptions below each video.
Thanks. I will research this.
Your 2d function only works when the width and height are the same size.
Hi Joe, correct it also prefers power of 2 dimensions also.
Thank you for this!
it would be interesting to hear how perlin noise sounds
thank you ser! even I don't understands the code and the mathematical thing, but i get the idea of perlin noise hehe
Do you know Minecraft uses this algorithm to generate its terrain?
Out of context, but, what font do u use at thumbnails?
Hey André, it's called Press Start and I stretch it vertically a little.
Hey Javidx9! Beautiful work!
Excellent theoretical intro. vey pedagogical.
Questions:
i) How compatible is olcConsole...h with linux?
ii) Why windows man, why?
Hey Thanks GTS! I appreciate that.
1) Not very. Members of this community have tried with different levels of success. Fundamentally, the consoles between the two OSs are very different in their use and implementation.
2) See 1 :D Only displaying the screen is incompatible. The algorithms in my videos are very much cross compatible.
Maybe it's time I took a look at a linux implementation. I don't think I'd be able to do much better than the others that have tried, it seems to be quite performance restricted due to how the linux terminal works. There was an SDL2 port made of the game engine via github, which could also help.
that's cool for Worlds terrains.
Bisqwit and javidx9, which one is the best programmer?
Bisqwit. The guy's a machine.
javidx9 heh. His videos are alien in nature. His c++ nearly impossible to understand for me.
cold you do one lloop whit (mod)% of 1,2,4,8,16
thank you
Maube someone can tell me how to make more plains?
Cool, Im in.. Nice font size
Hi ProCactus!
thanks
Worms terrain generator :)
wow
this video's sadly WAY too fast and lacks a lot of the explanation needed to understand exactly how it works. I've needed to do LOADS of de-bugging in order to use this generation algorithm. I had troubles because I couldn't tell where my code went wrong, because I had to do a lot of blind faith in the code you had written. I'd recomend re-doing this tutorial and splitting it up into two parts, and explain every single bit in extream detail, and when going into 2D, explain the changes. Either way, this is prety much the only tutorial on generating your own perlin noise on youtube, so credit where credit is due.
Hi bysTaXx, I'm sorry you've not found this video very clear. It is quite a complicated subject matter. I probably won't redo the video, but I'll take on board your concerns. I often get criticized that my videos are too slow! I'm still new at this, so still working on finding a balance that suits everybody.
javidx9 well then, i find that in many casses it is better to have more videos with narrow subjects explained in depth rather than one video with multiple topics to be helpfull, for instance, having an "intro to perlin noise" then a "1D perlin noise" then a "2D perlin noise" video would be better, as an example. And you are correct, perlin noise is a complicated topic, like PRNG algorithms are complicated. I would recommend typing out the code as much as possible, rather than copying and pasting predefined code to be most effective. Another suggestion is that after finishing a block of code, pause for a few seconds to let the viewers pause the video to review the new code. Either way, you have excellent delivery, you are engaged with your viewers, and i'm happy you dive into topics that most people just use a pre-defined library for. So all in all, i'd say you are doing quite well, just could use a little improvement.
"Because I had to do a lot of blind faith in the code you had written"
Are you very familiar with c++ or is it already going wrong there?
Screw everything I want to do Pc stuff
12550821, only true gamers know what this number means.
I'm trying to convert your algorithm to generate a bitmap but somehow the bw_pixel value is always 4? Why is that?