[Explained] Perlin Noise and Unity

  Рет қаралды 10,232

BearTheCoder

BearTheCoder

Күн бұрын

Пікірлер: 59
@ichikunk
@ichikunk 2 жыл бұрын
> here is a screenshot of a code if you want to copy it Ah, I see you're a man of culture as well
@ian.ambrose
@ian.ambrose Жыл бұрын
Great and professionally presented video! May I ask you some mathematical questions regarding some parts of your video? Thank you.
@BearTheCoder
@BearTheCoder Жыл бұрын
Of course, I may be a bit rusty, but the math is still in there somewhere.
@crckrbrrs
@crckrbrrs Жыл бұрын
WHAT i looked down at your subscription counmt and you desperately need about a thousand times more PLEASE make more
@BearTheCoder
@BearTheCoder Жыл бұрын
I’m working on it!
@BearTheCoder
@BearTheCoder Жыл бұрын
Thank you!
@Shlenx
@Shlenx Жыл бұрын
Any news on part 2? :)
@BearTheCoder
@BearTheCoder Жыл бұрын
I've had the script written for probably about a year, just haven't gotten around to it.
@MSouzaGameDev
@MSouzaGameDev Жыл бұрын
what a nerdy video. loved it. also, very well explained.
@griffinvella8069
@griffinvella8069 Жыл бұрын
Awesome video! really well explained and clear to understand and focus on. sad there hasnt been a part 2 released yet tho.
@BearTheCoder
@BearTheCoder Жыл бұрын
I’m sorry 😭part 2 has been in the works for months. I’m just a lazy creator.
@koushikvss6277
@koushikvss6277 2 жыл бұрын
How your videos are such underrated
@BearTheCoder
@BearTheCoder 2 жыл бұрын
:') Thank you.
@simondhoine
@simondhoine 2 жыл бұрын
Nice work, really !! Still waiting for part 2
@BearTheCoder
@BearTheCoder 2 жыл бұрын
Part 2 coming soon!
@tipler10
@tipler10 2 жыл бұрын
Good explanation in this video! Sebastian's videos are good but your explain it a lot better! Hope part two comes soon :)
@BearTheCoder
@BearTheCoder 2 жыл бұрын
Thank you! Part two should come out in the next few months! I am working on it!
@olaxe360
@olaxe360 3 жыл бұрын
I'm looking forward for the next part!
@CopiousAmountsOfDerp
@CopiousAmountsOfDerp 2 жыл бұрын
Nice 1984 reference, touché! (2+2=5)
@sekvojs
@sekvojs 2 жыл бұрын
+1 sub *Don't be discourage from nerding out ;)
@ThankYouESM
@ThankYouESM 2 жыл бұрын
I figured on my own how to make 4 Perlin Noise generators in PYS60 (Python for Nokia) many years ago. The first one is from having a floating-point variable representing the bell curving offset by at least by 5 pixels to see it beautifully. The 2nd and 3rd is quite the same as the 1st... but made into 2D and 3D. The 4th... is from layering sine waves of various sizes which I can have absolute control of... and also can seamlessly wrap around, able to even make animated 3D blobs.
@daedalusrasmus3278
@daedalusrasmus3278 Жыл бұрын
Wow cool, could you make one for Simplex noise too? and other noises as well hahaha, this is easier to understand
@kech-agmaio8620
@kech-agmaio8620 2 жыл бұрын
Why do you have so little followers? This is a top notch coding KZbin channel, you should have blown up by now!
@BearTheCoder
@BearTheCoder 2 жыл бұрын
Huge compliment! Thank you!
@malukp_nopedaco7220
@malukp_nopedaco7220 Жыл бұрын
very very nice
@rediculaid
@rediculaid Жыл бұрын
this tutorial was confusing or im stupid but why is it looking around for neighbouring points and they are all aligned so wont it make so it will be 0.5?
@BearTheCoder
@BearTheCoder Жыл бұрын
Hmm? At which point are we talking?
@rediculaid
@rediculaid Жыл бұрын
@@BearTheCoder 3:36 i understand why its 0.5 but if i divide sample points by 2 for coordinates wont they point still be aligned so they gradient will stay the same? im sorry if im being stupid
@BearTheCoder
@BearTheCoder Жыл бұрын
@@rediculaid Ok, I think I know what you are thinking. Each pixel of Perlin noise, when taken in the context of 2d noise, is a combination of 4 different gradients, one for each adjacent coordinate. So, I think what you are asking is, why isn't the output the same as the gradient shown, how do we get perlin noise and not the gradient? Because, the sample's coordinates doesn't change, but the context from which we are grabbing the sample changes based on the coordinate and the angle assigned to the coordinate. The sample's location, the coordinate, and the angle are then used to determine the gradient using the dot product. So, for that one sample you are give 4 different numbers 0.25, 0.1,0 .9, and 0.7 for example, and then those are blended together. It can be confusing not understanding the math, if you want, join my discord and I can explain it in more detail if you want. discord.gg/mZ5vKkS7
@dood7625
@dood7625 2 жыл бұрын
Your videos are amazing you deserve more views!
@zmichael4114
@zmichael4114 2 жыл бұрын
Amazing
@BearTheCoder
@BearTheCoder 2 жыл бұрын
Thank you very much!
@razanomer10
@razanomer10 2 жыл бұрын
Awesome video! Thanks dude
@nagillbeats
@nagillbeats Жыл бұрын
Next part please
@anonphil
@anonphil Жыл бұрын
Wheres the second video!!!
@pirateskeleton7828
@pirateskeleton7828 Жыл бұрын
This video would have been great to see two years ago. I also home brewed a Perlin noise function for a game I’m making. For my random function, I had a very long array deterministic “random” values, and I pull values from the array using a sort of shifting cipher algorithm, so that the values don’t repeat themselves as I get farther away. Otherwise it just uses normal bilinear interpolation.
@Auios
@Auios 3 жыл бұрын
Your videos are awesome. Keep it up! :)
@BearTheCoder
@BearTheCoder 3 жыл бұрын
Thank you! I have a lot of fun making them!
@ian.ambrose
@ian.ambrose Жыл бұрын
Thanks for your response! Here are my (rather lengthy) questions. I’m not a programmer and all the questions below are purely for mathematical understanding purposes. I also skipped all the coding parts because I don’t understand them. ----------- Q1. 3:21 People call this random vector (arrow) as “Gradient” Vector, do you have any idea on why it’s called that? Is it because it’s involved in the Dot Product to create values that form a gradual transition (aka a “gradient”) inside a cell (aka grid tile)? ----------- Q2. 3:28 You said that the Dot Product values inside a cell has the Range of [0,1], but there’s always a chance for Dot Product to output negative values, isn’t it? ----------- Q3. (Please read the whole Q3 before answering) 3:30 About the “4 cells forming *ONE* gradient”, doesn’t *EACH* (sorry, I'm not screaming, I'm emphasizing) cell have its own “gradient”? Like it’s illustrated in this video's timestamp here: kzbin.info/www/bejne/kKSon6F4Z9ylmKs As explained in many other videos, the visual “gradient” we see is formed by placing hundreds of pixels (that are evaluated by performing Dot Product between one Gradient Vector and hundred of distance vectors) together. Each cell (aka grid tile) possesses 4 Gradient Vectors at its 4 corners, if we are using only 1 out of 4 to create a “gradient”, that means each cell has a completely separate “gradient” (4 Gradient Vectors means 4 different “gradient”) from the neighboring cells, that means there will be a sudden jump in value at the border in between 2 cells, leading to the visual that you see in the link I sent above. To visually smooth out those “sudden jumps”, we use Linear / SmoothStep / SmootherStep Interpolators. Does *your* Perlin Noise use the same algorithm that I addressed above? If it does, then there’s no way that the gradients of 4 adjacent cells would connect that smoothly as you illustrated. Also, if the transitions of values between cells were that smooth, then there would be no reason for any interpolator to be involved because there’s no sudden transitions at the borders. OR, were you showing what it would look like if *ONE* Gradient Vector was used to perform Dot Product with *ALL* distance vectors across *ALL* cells instead of just the distance vectors inside of *ONE* cell? ----------- Q4. I’ve watched and read almost 20 videos / articles and you are the only person to say that Perlin Noise function interpolates the Dot Product values using Cosine Interpolator, whereas all other resources said the interpolators were either SmoothStep or SmootherStep Interpolator. Or is your video here specifically made for Unity’s Perlin Noise implemented function? I’m not familiar with Unity though. ----------- Thank you so much!
@BearTheCoder
@BearTheCoder Жыл бұрын
Q1. A random unit vector (arrow) is not a gradient vector until you get the dot product involved. A unit vector is strictly an arrow with length 1 and a direction. The dot product is what makes it a gradient vector.
@BearTheCoder
@BearTheCoder Жыл бұрын
Q2. Correct. The dot product outputs a value from -1 to 1 if using the unit vector and an input coordinate with less than length 1 . I may have explained it poorly in the video, but you can see at the time stamp the values are originally from -1 to 1 but I say “the values are then shifted to 0 to 1” which is a somewhat incorrect statement to make as the value isn’t shifted until the last step. But for explanation purposes it kinda works out.
@BearTheCoder
@BearTheCoder Жыл бұрын
Q4. Yes smooth step is more common and probably the correct way to do it. Years ago when I wrote my first Perlin Noise algorithm I had quite a few gaps in my knowledge that I filled with poor research. Earlier this year, because of a request in my discord, I wrote a new Perlin Noise script and started editing a new video overviewing the correct algorithm but was scrapped because ChatGPT came out and for quite a while I've had the mood of "Why make a video, they can just ask ChatGPT to write the script for them". But if you are interested, here is the algorithm I wrote in JavaScript using p5js for that video: github.com/BearTheCoder/p5/blob/master/Perlin%20Noise/VanillaJS/main.js
@BearTheCoder
@BearTheCoder Жыл бұрын
Q3. Is a dense one, and something that I would like to talk at length using discord. discord.gg/aeAukyWn You are not wrong, but also not right. Probably more of a misunderstanding. If we take a single point on a grid, let's say (1, 1), that single point is the center of the dot product. Which is why if you reference whole number coordinates in a Perlin Noise algorithm, the result comes back 50% gray every time. But also at the same time, if you are observing the gradient vector around (1, 1) with an angle of 45 degrees, if you pull the dot product from a coordinate closer to (2, 2), the output will be closer to 1 or "white", if you pull using a coordinate closer to (0, 0) it will be -1 or "black". Meaning that the gradient spans 4 grid tiles centered around (1, 1). So, when you refence a pixel at location (0.2, 0.4) or (1.5, 1.2), they both will reference the same gradient that is at (1, 1). This is also why if you put the same values into a Perlin noise algorithm, the result will always return the same. Also this is why you can feed Minecraft (which is basically Perlin Noise the Game) a seed and end up at the same spot every time although the world is fairly endless. As far as the actual output, yes, if we pull the value for (0.2, 0.4) the output will be an combination of values from the gradient at (0 0), (0, 1), (1, 0) , and (1, 1)
@lirmi9469
@lirmi9469 Жыл бұрын
r u know how to add some octaves?
@BearTheCoder
@BearTheCoder Жыл бұрын
github.com/BearTheCoder/p5/blob/master/Perlin%20Noise/p5%20Noise/main_p5.js
@BearTheCoder
@BearTheCoder Жыл бұрын
Here’s an example using JavaScript but it should be the same in any other language. Basically you add another for loop that iterates over the amount of octaves you want and change the input with a opacity and frequency value. Hard to explain, hopefully the code will be enough to get you going.
@ludboy9333
@ludboy9333 2 жыл бұрын
I love the videos
@BearTheCoder
@BearTheCoder 2 жыл бұрын
Thank you!
@maftplays
@maftplays Жыл бұрын
I liked you just for that intro
@insideyrmind4873
@insideyrmind4873 2 жыл бұрын
awesome video
@BearTheCoder
@BearTheCoder 2 жыл бұрын
Thank you!
@ezwelds-g6t
@ezwelds-g6t 2 жыл бұрын
I’m tracking so far you know how to teach
@jozejerse6777
@jozejerse6777 2 жыл бұрын
good video. too bad you never made the follow up video tho.
@BearTheCoder
@BearTheCoder 2 жыл бұрын
It’s still in the works. Life gets in the way, ya know.
@jozejerse6777
@jozejerse6777 2 жыл бұрын
@@BearTheCoder Very true. Hope you're doing well.
@FilmFactry
@FilmFactry 2 жыл бұрын
This was very good. Coming from a novice, I just want to understand how Text to image AI like MidJourney/Stable Diffusion works. Thanks.
@crckrbrrs
@crckrbrrs Жыл бұрын
a good way to visualize it is: the dataset that the model uses is like a bucket of legos. the algorithm is told to create a certain type of structure, so it looks at other structures like the one it's being asked to make, then picks up the pieces used to make those previous structures and throws something together. essentially its looking at things it knows about the prompt subject, chopping up all the elements making up those images, then attempts to imitate the qualities with those elements, picked out randomly. im sorry if this made you even more confused lmao im not a very good explainer
@blablablablablablablablablbla
@blablablablablablablablablbla Ай бұрын
You don't need to act like most people are so afraid of math. I can guarantee that most people clicking on a perlin noise video are not afraid of dot products etc. And most of us are probably enthusiastic about math. Good vid tho
Better Mountain Generators That Aren't Perlin Noise or Erosion
18:09
Josh's Channel
Рет қаралды 413 М.
Perlin Noise in GameMaker Studio 2
14:01
SamSpadeGameDev
Рет қаралды 13 М.
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 41 МЛН
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 80 МЛН
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,2 МЛН
When u fight over the armrest
00:41
Adam W
Рет қаралды 26 МЛН
Minecraft terrain generation in a nutshell
25:49
Henrik Kniberg
Рет қаралды 160 М.
Programming Perlin-like Noise (C++)
27:54
javidx9
Рет қаралды 105 М.
Running "Hello World!" in 10 FORBIDDEN Programming Languages
18:07
How do non-euclidean games work? | Bitwise
14:19
DigiDigger
Рет қаралды 2,4 МЛН
How to turn a few Numbers into Worlds (Fractal Perlin Noise)
15:24
The Taylor Series
Рет қаралды 195 М.
An introduction to Raymarching
34:03
kishimisu
Рет қаралды 152 М.
Procedural Rivers in Unity - P1 Finding river start and end points
14:33
Sunny Valley Studio
Рет қаралды 11 М.
Coding Adventure: Portals
16:06
Sebastian Lague
Рет қаралды 1,3 МЛН
How Minecraft ACTUALLY Works 💎⛏️
46:02
Alan Zucconi
Рет қаралды 1,6 МЛН
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 41 МЛН