Procedural Landmass Generation (E03: Octaves)

  Рет қаралды 361,342

Sebastian Lague

Sebastian Lague

Күн бұрын

Пікірлер: 368
@8lusk
@8lusk 4 жыл бұрын
4 years after and i still cant find something better. you did an amazing job.
@pie3i940
@pie3i940 4 жыл бұрын
Hey just wondering do you know if this tutorial works with unity 2019.3 on URP?
@wudolph4255
@wudolph4255 4 жыл бұрын
PIE3I9 i use unity 2020.1
@oliverlabudik3355
@oliverlabudik3355 3 жыл бұрын
kinda tru
@supremedeity9003
@supremedeity9003 3 жыл бұрын
@@pie3i940 For anyone wondering, the underlying mechanics relating to the things discussed thus far have not been changed and work on the current latest version (Unity 2020.3)
@plantgum
@plantgum 3 жыл бұрын
​@@supremedeity9003 5 years later and it still works beautifully
@PolyRocketMatt
@PolyRocketMatt 6 жыл бұрын
Even after 2 years after uploading it... This is the best tutorial I can find on how to generate a nice, smooth perlin noise value. Clear explanation if you have basic knowledge over C#, and easy to carry over to other languages such as Java because of the way you indicate what every variable does! Really helpful!
@MrNerd-ll9my
@MrNerd-ll9my 4 жыл бұрын
Gotta say, still an incredible tutorial now. Stay healthy mate
@nicolasseydoux5985
@nicolasseydoux5985 3 жыл бұрын
5 years after uploading it and still the best =) I learned more on the editor GUI than the perlin noise btw
@absolutewisp
@absolutewisp 2 жыл бұрын
@@nicolasseydoux5985 me too, editor scripts were just pure magic to me before this.
@tonychristney2728
@tonychristney2728 5 жыл бұрын
Minor bug: when checking the min/max, you should not have an else there (at least for the first value). The first pixel in map should always be both greater than the maximum and less than the minimum. So you could miss the global minimum there.
@Sandflakes
@Sandflakes Жыл бұрын
7 years later and these are still the best tutorials out there! Great work Sebastian! For anyone watching this now, here is a fix for the parallax seen at 9:04 when changing the offset: float sampleX = ((x - halfWidth) / scale - octaveOffsets[i].x) * frequency; float sampleY = ((y - halfHeight) / scale - octaveOffsets[i].y) * frequency; Note: This also flips the scroll direction in x and y which makes more sense when you are dragging the values in the editor but might break eventual minimap code etc. If you do not desire this just flip the sign again.
@colbywinfield
@colbywinfield 7 ай бұрын
Thanks for that! I do prefer the parallax effect though, but man is this comment section a treasure trove!
@THEspindoctor84
@THEspindoctor84 3 жыл бұрын
this might be one of the best tutorials I've ever watched. It's got real MEAT to it, and the concepts are challenging (at least to me), but the explanation is great and the code is clear.
@AliveNotDeadmund
@AliveNotDeadmund Жыл бұрын
Absolutely phenomenal tutorial. Truly one of those lessons that makes the work of thousands better.
@jastorgallywix4424
@jastorgallywix4424 10 ай бұрын
Minor tip: If you're still bothered by the resolution despite all the operations and think it's blurry, the reason is that you're entering pixel values for localScale in your MapDisplay script. The transform values of components in Unity specify their coordinates in the world, not their resolutions in pixels. Therefore, you need to keep the localScale variable lower so that pixels are compressed instead of spread out, resulting in increased resolution. You can achieve this by dividing the height and width variables in the MapDisplay script or passing other variables to the Renderer.
@Weckacore
@Weckacore 6 жыл бұрын
This is honestly an amazing and educational tutorial.
@theeleb
@theeleb 5 жыл бұрын
This videos are amazing, im don't have any experience in unity, im a programmer. But following your videos now im have knowledge about many things (perlin noise, octaves, frequency, etc etc etc) included Unity. Thanks for sharing, im a new FAN. Where i am in 2016 DAMN!
@josepadilla9735
@josepadilla9735 6 жыл бұрын
for the moment, the most difficult code i have seen in unity program tutorials. Thanks!
@triangle4studios
@triangle4studios 4 жыл бұрын
If anyone plays around with the noise settings and notices there is a secondary layer of noise, and wants to know how to control that... Just do something like this: Declare a variable for secondary noise scale however you choose, I did this: [Range(0,10)] public float secondaryScale; and then pass it in to the samples under the loop. This allows for some extra flexibility in creating interesting shapes later on. float sampleX = (secondaryScale * x) / scale * frequency; float sampleY = (secondaryScale * y) / scale * frequency; As always, thank you sebastian!
@Gwynbleidd27_
@Gwynbleidd27_ 3 жыл бұрын
I don't really know how you came up with this but you are an absolute genius! thank you so much
@jwlewis777
@jwlewis777 3 жыл бұрын
I have just spent the last week going over every terrain generator out there and none of them seem to give me what I want. This series is one of the best I've seen for anyone looking at getting into creating their own generator. Absolutely awesome! Definitely worth a patreon sub! Side note, at 5:50, my texture doesn't have the blacker black areas that the video shows with the same values in the generator. There were only a few values in the noisemap that had a value of < 0.1 and only 1 that had a value of 0. Strange I really appreciate the time and effort you put into this, it is definitely the best resource I found for procedural map generation. Thank you!
@jwlewis777
@jwlewis777 3 жыл бұрын
Lol, somehow when I reorganized the project, the plane lost my MapMaterial material so it was using the default material. Switching it back to the MapMaterial fixed it so it now shows the correct black values. That was actually pretty funny. I thought it was due to the editor default lighting, directx vs opengl, I was changing all kinds of things trying to fix it! Its ok now though so don't anyone fret! :)
@alexpitt7900
@alexpitt7900 3 жыл бұрын
Definite the best Tutorial on this subject I have found. Fantastic Work Sebastian !
@JamieBainbridge
@JamieBainbridge Жыл бұрын
This is such a great tutorial. I managed to implement a terrain generator in C and curses with this. It looks so good. Thank you!
@whiteline4157
@whiteline4157 3 жыл бұрын
subscribing to your channel is one of the best decisions I've ever made
@LordAikido
@LordAikido 8 жыл бұрын
Your tutorials are always amazing. You're a boon to experience!
@mollymilesweb
@mollymilesweb 7 жыл бұрын
Thank you for making these, you are an amazing presenter of just the thing I need to learn.
@sagitswag1785
@sagitswag1785 3 жыл бұрын
I was working on a procedurally generated 2d top-down game and was using the default Mathf.PerlinNoise texture with no added processing to generate my terrain. Needless to say, it did not look very good. I tried all kinds of solutions, even switching to cellular automaton generation for terrain, and while it looked better, it did not generate infinitely. Using your tutorial my terrain looks even better and is now generated infinitely. Thank you so much for this!
@ChosusQT
@ChosusQT Жыл бұрын
I tried this on my C project and IT'S WORK! You are my legend
@danh9676
@danh9676 5 жыл бұрын
I grabbed a bunch of code from github for open simplex noise. I had to remove a bunch of code for 3D and 4D noise, then modified it to make it work. The noise in my implementation is extremely slow. It gives different values than the Unity perlin. When you average the two noises then multiply it by amplitude the results are amazing
@patientzerogms
@patientzerogms 8 жыл бұрын
i have noticed that the offsets are not working well. when you're changing them the noise map is not moving but it looks like a layer of clouds moving at differend speeds - this is because the various octaves are not moving as they they should. fixed it with: float sampleX = x / scale * frequency + octaveOffsets[i].x * frequency; float sampleY = y / scale * frequency + octaveOffsets[i].y * frequency;
@patientzerogms
@patientzerogms 8 жыл бұрын
another issue with this is that it will dynamically change the shading due to different minimums and maximums (as they can change as you move around the noise) so I think that inverseLerp should work in a different way.
@daluur
@daluur 8 жыл бұрын
Thanks a lot! I couldn't figure out why changing the offset actually changed the scenery, and did not just move it :) this worked perfectly (though I did add sat (x - halfSize) instead of just x (same with y), but it does not really matter)
@patientzerogms
@patientzerogms 8 жыл бұрын
+daluur yes, I wrote that comment before the end of the video - before the zooming to center option was added, i also cahnged the whole thing later so it looked like float sampleX = (x - halfSize / scale + octaveOffsets[i].x) * frequency;
@daluur
@daluur 8 жыл бұрын
+vooood I think you forgot to put x - halfSize in parenthesis should be ((x - halfSize) / scale + octaveOffsets[i].x) * frequency; But again, thanks, really needed a way to make the map 'the same' regardless of the offset :)
@patientzerogms
@patientzerogms 8 жыл бұрын
daluur indeed, i was not copy/pasting from my project and looks like i have missed that. :)
@jay22alco
@jay22alco 7 жыл бұрын
thanks. been banging my head on the keyboard until I check your vids again. now I got an idea on how to implement this by multiple chunks. hope it will work though.
@KeenanWoodall
@KeenanWoodall 8 жыл бұрын
Great tutorial as always! One thing I figured out is that you can ditch the custom editor and call GenerateMap from the OnValidate method. Then it also updates when you undo variables changes.
@donutbedum9837
@donutbedum9837 3 жыл бұрын
hey its you who asked the question on cubes terrain generation on unity
@apemant
@apemant 5 жыл бұрын
I think maybe the offset should also take scale and frequency into account, like so: float sampleX = ((x - halfWidth) / scale * frequency) + (octaveOffsets[i].x / scale * frequency); float sampleY = ((y - halfHeight) / scale * frequency) + (octaveOffsets[i].y / scale * frequency); This way the offset value will scroll/translate through the perlin noise at each octave's own level of detail.
@antoniokezele909
@antoniokezele909 7 ай бұрын
you are a king
@SethDecker89
@SethDecker89 8 жыл бұрын
This is pretty awesome. I was playing around with generating blocks with the map so more granularity in making the noise map is great. Hopefully you go over chunking in the future as that's where I'm stuck when trying to combined the meshes and hit the max vert limit.
@SebastianLague
@SebastianLague 8 жыл бұрын
+Seth Decker Chunking will be implemented :)
@Jamesthe1
@Jamesthe1 8 жыл бұрын
Thank you! I now have a basic understanding of what "noise" is, and I hope to use this for a lot of games.
@CurtisJensenGames
@CurtisJensenGames 2 жыл бұрын
11:17 you may know this at this point but putting [Min(1)] next to the public variable will also clamp it there.
@minecraftyo-gh-oh6405
@minecraftyo-gh-oh6405 Жыл бұрын
6 Years Still the Best one ever
@Trunks7j
@Trunks7j 8 жыл бұрын
Thanks for these great tutorials! For clamping the height, you can actually just do: noiseHeight = Mathf.clamp(noiseHeight, minNoiseHeight, maxNoiseHeight)
@SebastianLague
@SebastianLague 8 жыл бұрын
+Trunks7j My pleasure. Clamping won't achieve quite the same thing. Think of it as though we want to squash all the data so that it fits within 0;1.
@Trunks7j
@Trunks7j 8 жыл бұрын
+Sebastian Lague Oh, i actually meant for line 46 not the normalization function, but i misread your code as (if noiseHeight > max) { noiseHeight = max } -- Sorry about that!
@SebastianLague
@SebastianLague 8 жыл бұрын
+Trunks7j Ah, not to worry. Glad you're enjoying the series! :)
@haachamachama7
@haachamachama7 4 жыл бұрын
Here's a fun little thing I did, Add this to the editor script, if (GUILayout.Button("Generate Random")) { mapGen.GenerateRandomMap(); } Then add a Generate Random Map method into the Generate Map script, just copy the GenerateMapMethod(I suck so this is what I did lol, probably a cleaner way), and put seed = Random.Range(-10000,10000) at the start. It gives you a second button to generate a randomly seeded map instead of just whatever seed you input :)
@NStripleseven
@NStripleseven 3 жыл бұрын
Well that’s cool. Allows you to see different maps easily.
@analol123
@analol123 8 жыл бұрын
Thx,thx!!! Sebastian. I really appreciate your efforts for this goods tutorials. Nice job!!!
@bubucast
@bubucast 4 жыл бұрын
That's a very increadible job. Thank you very much!
@antoniokezele909
@antoniokezele909 7 ай бұрын
Just a note if anyone is trying to implement this in a real game that needs to be chunked or tiled in any way, this works only if your noise texture is generated once and then sampled. Offsetting and changing scale will dramatically change the features in the next tile since the average is being calculated locally and offsets are being offset too much. You can see the artefacts as he scrolls through terrain in the video, it is not continuous terrain. Solution is to first change the offsets so they match the scale : float sampleX = ((x - halfWidth) / scale * frequency) + (octaveOffsets[i].x / scale * frequency); float sampleY = ((y - halfHeight) / scale * frequency) + (octaveOffsets[i].y / scale * frequency); and after that you can either remove the scale (not recommended) or you can calculate the max value globally. Since your noise map outputs 0-1 , you can either use geometric series to pre compute the maxValue, or you can just send a dummy value of 1 through the loop, applying the function, and saving the result as maxValue. Another thing is you want to not scale the terrain -0.5,0.5 if you are not working with Z component, if you are, you need to compute the minValue using the above technique.
@BluMacaw
@BluMacaw 3 ай бұрын
Thanks a bunch mate. I'm doing a factorio like prototype for my bachelor thesis and you saved me many more hours right now. I mean I still have like 5 months or so, but just the fact I don't have to deal with this problem anymore, well, lets just say I am very grateful for time you put into writing this. I was thinking about what you said before reading, I was pretty sure things were happening out of order, but I couldn't nail it down and there you are, thanks a bunch again.
@lukemacri6557
@lukemacri6557 4 жыл бұрын
You can now clean up those messy if checks for if a value is < 1 with the Min Attribute. ie: [Min(1)]public int mapWidth;
@user-nt8gt8sz2f
@user-nt8gt8sz2f 5 жыл бұрын
I had an issue where applying the octave offsets caused the code to produce a height map with bumpy square artifacts. If anyone else happens to be struggling with this, I fixed it by modifying the code like so; float sampleX = (octaveOffsets[i].x + x - halfWidth) / scale * frequency; float sampleY = (octaveOffsets[i].y + y - halfHeight) / scale * frequency;
@WannabeCanadianDev
@WannabeCanadianDev 4 жыл бұрын
I think this breaks the ability to have scale be centered.
@fromptech2210
@fromptech2210 4 жыл бұрын
It does, and it's broken in the official source code as well. To be able to scale the noise for a minimap, I Added a new float variable "zoom" to the function and update the code to be: float halfWidth = (mapWidth*zoom) / 2; float halfHeight = (mapHeight*zoom) / 2; float sampleX = ((x*zoom) - halfWidth + octaveOffsets[i].x) / scale * frequency; float sampleY = ((y*zoom) - halfHeight + octaveOffsets[i].y) / scale * frequency; Not sure if that's correct for other applications, but it works for a minimap.
@Hamstray
@Hamstray 2 жыл бұрын
up to 100000 is too high an offset and will give floating point precision problems
@oaklai303
@oaklai303 2 жыл бұрын
@@fromptech2210 What is zoom equal to?
@Sandflakes
@Sandflakes Жыл бұрын
A better fix for both the issue with parallax and the scaling is to not apply the scale the the octaveOffset but only the frequency. Also a tiny nice to have is to flip the y offset so that when you drag the value in the editor up and down will be correct. float sampleX = ((x - halfWidth) / scale + octaveOffsets[i].x) * frequency; float sampleY = ((y - halfHeight) / scale - octaveOffsets[i].y) * frequency;
@dipaknitnawre7581
@dipaknitnawre7581 3 жыл бұрын
Thankyou sebastian league very cool 👍👍👍👍👍👍
@SustainedDissonance
@SustainedDissonance 8 жыл бұрын
Your tutorials are the best.
@gorkemvids4839
@gorkemvids4839 5 жыл бұрын
Max and min noise height can be calculated with float limit = 0; for(int i=0;i
@Paul-qs3kh
@Paul-qs3kh 5 жыл бұрын
This is the theoretical limit, yes, however in practise this does not work, because there will (basciallaly always) be a huge difference between the theoretical max value and the actual. I ran it a few times and the max value was never above 1, while the theoretical max value was 1.875. The result of that is, that you have a lot of grey and no white or black.
@Paul-qs3kh
@Paul-qs3kh 5 жыл бұрын
edit: (I'm implementing this series into UE4) It might be the case that I'm wrong, because my output (without your optimisation) is not looking correct at all. So I might have broken my Perlin Noise function...
@Paul-qs3kh
@Paul-qs3kh 5 жыл бұрын
Ok, my Perlin Noise function has a problem with large input numbers. However, the main problem with your optimisation is still there: You don't have pure white and black. If you can get those later with other methods (I think we can?), then thats not a problem of course.
@collinbarker
@collinbarker 4 жыл бұрын
Thank you for the great tutorial. Only one that I have been able to find on layering noise to create heightmaps. Currently using it through Java to try to create good Cities Skylines maps. Most on workshop are "my first map" or the really good ones based on a specific location.
@FacePalmProduxtnsFPP
@FacePalmProduxtnsFPP 6 жыл бұрын
7:50 It's because 100,000 units is the max width and length of the terrain object.
@MrZaneMan
@MrZaneMan 4 жыл бұрын
I don't know how to code, probably never will, probably won't ever get into making games or any kind of simulations, but these videos are super interesting to me for some reason.
@fyndor
@fyndor 4 жыл бұрын
I believe there is a flaw in the min/max noise height part of the procedure. Because you used an "else if" for the minimum height part, if the first sample happens to be the minimum value for the entire map, the minNoiseHeight value will never be assigned to that minimum because the first sample will always be greater than the initial maxNoiseHeight value and it will not go in to the minNoiseHeight part of the conditional statement. If you make both parts if statements instead of if/else if then it should correct this flaw.
@ConnorMoody
@ConnorMoody 8 жыл бұрын
Once you finish this, you should show us how to add random objects (tree's, etc) in the map as well as a way to use water asset's with this system and if you've ever played rust things like Rad Town's etc.
@dasdadwaswad7358
@dasdadwaswad7358 4 жыл бұрын
You somehow make one of the most boring subjects in the world interesting, keep up the good work!
@andreadst
@andreadst 8 жыл бұрын
Hi! Thanks for the videos! somehow the line the InverseLerp returns 0.5f for all values (I'm at the middle of the video, can't reproduce what you have at 5:40 because of this). Any clue on why that would happen (all the other input values appear to be correct)? noiseMap[x, y] = Mathf.InverseLerp(minNoiseHeight, maxNoiseHeight, noiseMap[x, y]);
@Daednumai
@Daednumai 8 жыл бұрын
Same problem here
@andreadst
@andreadst 8 жыл бұрын
Found it (for me). In my case the following code was the problem (this is the correct one): float maxNoiseHeight = float.MinValue; float minNoiseHeight = float.MaxValue; I inverted float.MinValue and float.MaxValue. I still don't understand exactly why this is setup as it is (*maybe Sebastian can pitch in and explain?*)
@pololabete
@pololabete 8 жыл бұрын
Finding the max value (or the min) of an array starts with initializing the variable with the smallest value possible float maxNoiseHeight = float.MinValue; This is the only way to make sure you program will find a value in your array that is larger than the smallest one.
@jinxshaddix
@jinxshaddix 8 жыл бұрын
Thanks, had exactly the same problem. Cheers
@andreadst
@andreadst 8 жыл бұрын
Thanks for the explanation pololabete!
@enkimarduk7028
@enkimarduk7028 5 жыл бұрын
Great tutorial up to the point where persistance gets turned into a slider. It didn't work for my version of Unity initially (2019.1.8) but a quick google search revealed a Unity tutorial about sliders in inspector and just modifying [Range(0,1)] to [Range(0f,1.0,)] seems to have made the trick. Moving on to episode 4...
@enkimarduk7028
@enkimarduk7028 5 жыл бұрын
@Violet Radd Sorry I missed your question. I hope you found a way around. You just need something like this: [Range(0f,1.0f)] public float persistance;
@voidling2632
@voidling2632 3 жыл бұрын
10:50 its easier to add a [Min (1)] attribute to your variable.
@TheProGamingWolf
@TheProGamingWolf 6 жыл бұрын
noiseMap[x, y] = Mathf.InverseLerp(minNoiseHeight, maxNoiseHeight, noiseMap[x, y]); This is making my plane come out just pure white in texture.
@matthewwilson5249
@matthewwilson5249 6 жыл бұрын
Make sure you're initializing the minNoise as float.Max and maxNoise as float.Min.
@bombmk2590
@bombmk2590 5 ай бұрын
Excellent tutorial. Clear and concise. One question: The *2-1 operation on the noise is somewhat superfluous, no? It normalises to the same terrain topography in the end - just offset 0.5 down? As in, that can be shifted afterwards if needed? Or if not normalised just sneaks in extra amplitude?
@AndersAstrand
@AndersAstrand Жыл бұрын
The else at approx 3:51 will make it so that if the first value generated is the lowest, the normalization will fail. (as the first value will be both the highest and the lowest value seen so far regardless of value, it needs to update both). It should just be a separate if statement.
@JonathanKanelis
@JonathanKanelis 8 жыл бұрын
I was wondering if eventually you'd show a way to use this for 2D terrains, and would add editors for the final version of your terrain (provided you may like to move the vertices by hand after the generation).
@Ony_mods
@Ony_mods 8 жыл бұрын
+Jonath Kane would love to see this too, hoping! :)
@SebastianLague
@SebastianLague 8 жыл бұрын
+Jonath Kane Great suggestion. I'll probably do a spin-off series on 2D terrains (with an editor as you described) after this series is finished.
@JonathanKanelis
@JonathanKanelis 8 жыл бұрын
Sebastian Lague Wow haha many thanks !
@StephenWebb1980
@StephenWebb1980 6 жыл бұрын
I'm currently working on an implementation using EditorWindows, that also makes use of Temperature maps, Moisture maps, Humidity maps, and Air Pressure maps to generate biomes based on earth climate principles. It will be ready probably in 5 months from the time of this post. The idea is to create a 2D campaign / cartographic map with point of interest features that can be explored in a 3D setting. I'm hoping to use it in a demo game called medieval as a proof of concept.
@MrMelonMonkey
@MrMelonMonkey 5 жыл бұрын
@@StephenWebb1980 did you finish it?
@PauloHenrique-jr7ir
@PauloHenrique-jr7ir 5 жыл бұрын
Great content! Thank you very much!
@TD-uk9by
@TD-uk9by 11 ай бұрын
the octave offset also make the perlinValues not symmetric around the center because perlin noise return the same value for coordinates with the same absoluate values, at least that my case
@DilkielGaming
@DilkielGaming 4 жыл бұрын
for anyone wanting to know how to make some what decent multilayered noise this is what i managed to make, its decent but not great XD private float CalculateNoise(float x, float z) { float noise; noise = Mathf.PerlinNoise(x, z) * 10; for (float i = 0; i < 1; i+=0.1f) { if (Mathf.PerlinNoise(x, z) > i) { noise += Mathf.PerlinNoise(x, z) * (5 + (i * 2)); } } return noise; }
@JDoucette
@JDoucette 3 жыл бұрын
Offset -100,000 to 100,000 works, but no larger, since float only has 6-7 decimal digits of accuracy. You're dealing with fractions of numbers after this. 100,000 is already using up 5 decimal digits, but you're requesting 6, 7, or more. (E.g. 10 million + 1 in float will still be exactly 10 million.)
@OrekiBurd
@OrekiBurd Жыл бұрын
How do people get this smart man....
@designer.trifonov
@designer.trifonov 2 ай бұрын
This is super lesson!) Thank"s)
@nychold
@nychold 8 жыл бұрын
Personally, I would say octaves should never go below 1, not 0. Otherwise, your Noise.GenerateNoiseMap function will only return a bunch of 0s. Which, if that's what you want, great, but it doesn't make much sense to me to have that.
@AdriBlt
@AdriBlt 6 жыл бұрын
The "* 2 - 1" is actually useless and does not change anything as the map is then normalized... But I was wondering about a more effective way to normalize because I guess the InverseLerp is pretty expensive. As all Perlin noises are between 0 and 1, the sum of the octaves should be between 0 and P = sum(persistence^i). So we could also just write "noiseMap[x, y] = noseHeight / P" and we'll have something normalized... What do you think?
@AdriBlt
@AdriBlt 6 жыл бұрын
+ Sebastian, you should remove the "else" when decreasing the min value. If the min value is the first to be computed, you'll have an error.
@noneofyourbusiness5343
@noneofyourbusiness5343 6 жыл бұрын
I get four minutes into the video, and my map doesn't show perlin noise. Instead it shows a black plane. Does anybody know how to fix this ? I have checked through the Noise script three times already, and still cannot find any errors. Unity doesn't point out any errors either. (im stuck after typing the code from 0:00 - 5:34)
@Catman-ze2gr
@Catman-ze2gr 6 жыл бұрын
Change the plane Map Mat to Unlit/Texture.
@jaweiit2479
@jaweiit2479 6 жыл бұрын
make sure octaves are above or below 0
@fuhll
@fuhll 4 жыл бұрын
set your material texture to "none"
@AllyG1967
@AllyG1967 7 жыл бұрын
I'm loving this series as well but have come stuck at 8:55 - the seed section. I don't have the seed slider in the inspector. Obviously I've done something but I can't track it. The error in unity says " scripts/mapGenerator.cs(20, 29): error CS1501: no overload for method 'GenerateNoiseMap' takes '8' arguments" but I have all 8 in the brackets. I don't get the offset adjusters either. Can somebody read minds and suggest some magic for me please
@SebastianLague
@SebastianLague 7 жыл бұрын
+Alister Gray That error message means that there should NOT be 8 parameters. Go check the method definition and make sure the parameters you're passing in match up correctly with the method's arguments.
@jamauro18
@jamauro18 8 жыл бұрын
Really awesome! can't wait for more, are these coming out twice a week or is it just whenever you can get them done?
@SebastianLague
@SebastianLague 8 жыл бұрын
+Joe Mauro Thanks. Twice weekly is the plan, but things are a bit unpredictable at the moment so that may change.
@MrXander032
@MrXander032 7 жыл бұрын
I was having trouble with the "Plane" object showing default material rather than the noise "Map Material", after going thought the noise script letter by letter, I found that on the 2nd last line which reads "noiseMap [x, y] = Mathf.InverseLerp (minNoiseHeight, maxNoiseHeight, noiseMap [x, y]);" i had written "(minNoiseHeight, minNoiseHeight, noiseMap [x, y])" while using the auto complete. Defiantly makes you think but its all very logical :D
@nietzsche14
@nietzsche14 3 жыл бұрын
Im at 4:18 And I mega confused I have this error CS0136 A local or parameter named 'y' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter Am O doinf something worng in my script
@atur94
@atur94 3 жыл бұрын
Instead of writing validation ifs like this if(value > otherValue){ { value = otherValue; } you can write Mathf.Clamp(value, min, max) which will do clamping for you
@lowfuel6089
@lowfuel6089 Жыл бұрын
Sorry if this should be obvious, but at 3:22 why is minNoiseHeight = float.MaxValue and maxNoiseHeight = float.MinValue? was counterintuitive to me.
@Console.Log01
@Console.Log01 Жыл бұрын
if it were the opposite, then the minNoiseHeight and maxNoiseHeight values would stay at -Infinity and Infinity, we make them opposite because any number is bigger than -Infinity, and any number is smaller than Infinity, so the minNoiseHeight and maxNoiseHeight values are always initialized at least once
@Sohneg
@Sohneg 2 жыл бұрын
If somebody has this error: IndexOutOfRangeException: Index was outside the bounds of the array. Noise.GenerateNoiseMap (System.Int32 mapWidth, System.Int32 mapHeight...... Check if the for loops has x and y at the right spot! If they are turned around it won't work!
@donohms7827
@donohms7827 2 жыл бұрын
this can also happen if you have one of your lines with noiseMap [x, y] in it entered as noiseMap [y, x] by mistake
@Console.Log01
@Console.Log01 Жыл бұрын
@@donohms7827 I was looking through recent comments to try and find why I was getting this error, and I figured out this was the reason. tysm!
@nationdemon
@nationdemon 7 жыл бұрын
Last comment an year ago, nevertheless a great tutorial. Thank you very much!
@RetroGamingClashOfClans
@RetroGamingClashOfClans 4 жыл бұрын
Inverse lerp makes my texture go completely either gray or black when persistence 30+ .. but lerp kind of works but theres only full black and white.. edit: nvm figured it out.. im setting minHeight = float.MinValue… supposed to be minHeight = float.MaxValue
@conormoloney4986
@conormoloney4986 3 жыл бұрын
this happened to me too, reading this saved me ty
@jesse2535
@jesse2535 Жыл бұрын
If when resizing your map causes an out of bouds error for width less than height greater than change y * height +x to y * width+x this will scale it properly and not use a height * height in case y = height and width < height it would generate gigantic indexes compared to the size.
@ricky_en
@ricky_en 6 ай бұрын
Hi, I dont understand what you mean, could you please explain what code specifically I should be changing?, thnx
@jesse2535
@jesse2535 6 ай бұрын
@@ricky_en Sorry I haven't touched the project code in months, I cannot remember, but I assume, the issue here, is that the code which scales the noise to fit within the size of the texture, on my end was multiplying by the wrong axis, ironically, multiplying y by height(it's corresponding axis) causes values to become larger than the pixel indexes on the screen, multiplying it by width fixed the issue, as width would be smaller than height and, if y scales towards the value height it would become height^2. I cannot remember why this was the case. Shouldn't be anyway, I'd try to multiply y by (height -1) so the index is never larger or equal to the length of the array(presume it to be the vertex array). In regards to where the code to change is suppose to be, I presume it is within the function for generating the noise height for the current x,y coordinate within a given chunk.
@mrslake7096
@mrslake7096 3 жыл бұрын
Great work
@iamseamonkey6688
@iamseamonkey6688 4 жыл бұрын
for some reason my persistance variable isnt working and my noise still looks like blurry static. help.
@CurtisJensenGames
@CurtisJensenGames 3 жыл бұрын
Wanna post your code? You did put in that texture line of code thingey, right (I know; I sound like a dummy but I don't want to look it up)
@toroidgames1728
@toroidgames1728 4 жыл бұрын
First of all I have to say your teaching method and clarity is refreshing to say the least. Tried this in Unity 2019.3.15f1 (3D URP) and at 5:34 saved and tried to adjust lacunarity. This makes Unity hang and I think it corrupts the Scene as it does not load back up on re-load. I'm guessing this is a .NET 3 / .NET 4 thing. Can you make a version for more recent Unity Versions?
@Dragonmaster047
@Dragonmaster047 8 жыл бұрын
Instead of normalizing the noise values with the min and max values wouldn't it be better to normalize them between -1 and 1? If you normalize between min and max the value of the sampled points changes depending on the cut of the noise map you can see, if for example you have one really low point like -1 and change the offset a little so your min value is now 0 all values you could see before change their value, a noiseValue of 0 is now 0 where it was before 0.5. That's just something I found out while coloring the heightmap, points on the map that where blue would change to another color depending on where the "camera" (offset) is on the heightmap.
@thulko
@thulko 2 жыл бұрын
I was implementing something similar to this video using chunks and was noticing the normalized values were creating distortions which appeared as lines between the chunks. Normalizing between -1 and 1 instead of a min and max, as you and others have suggested removes this.
@crazyfox55
@crazyfox55 8 жыл бұрын
I find this extremely fascinating. Have you considered changing how the scale should be different for each frequency? Done the way I'm imagining it should look more like your zooming in and out rather than stretching and shrinking. You'll notice when you reduce the noise scale it starts looking like flat noise and when you increase the noise scale it starts looking like one color. Let me know what you think. Thanks for the video.
@casssaph2287
@casssaph2287 4 жыл бұрын
man i honestly dont understand any of the maths behind this but im copying it in lua and its working for me so like, hey, whatever works, right? thanks for the tutorials, appreciate it.
@Skreperiukas
@Skreperiukas 5 жыл бұрын
When i generate my plate turns black... Any idea?
@knightoftheblood1841
@knightoftheblood1841 5 жыл бұрын
I have the same problem. And I have fixed it. It's because there is something wrong in your code, probably in the Noise class.
@pie3i940
@pie3i940 4 жыл бұрын
Hey did you ever fix this? I have the same problem
@fuhll
@fuhll 4 жыл бұрын
You should set your material texture to none. that worked for me.
@Coroebus107
@Coroebus107 4 жыл бұрын
I was running into this as well. In my case, if the Noise Scale variable is close to 0 or negative, the entire plane will be black. Probably something to do with the normalization code.
@greaterFool3765
@greaterFool3765 8 жыл бұрын
Can you explain to me, where is the point of first modify perlinNoise to get values from -1 to 1 and then bring it back to 0 to 1? Do youd do anything with the height Value where you need it to be negative?
@matchuhuki
@matchuhuki 8 жыл бұрын
Yeah I'm wondering the same thing
@matchuhuki
@matchuhuki 8 жыл бұрын
Nevermind it's to potentially reduce the noiseHeight and afterwards the noiseHeight gets clamped. I don't know why I didn't realise that.
@matchuhuki
@matchuhuki 8 жыл бұрын
Well if it's a negative. It reduces the overall height. And afterwards it gets clamped. If it's always positive it can only go up with each octave.
@wylie2835
@wylie2835 7 жыл бұрын
Im 11 months late. But this allows the ground to look like it "dips". If you didnt modift perlinNoise the first time and continued with the rest of the video it would look like mountains rise from a very clear bottom level.
@johngrey5806
@johngrey5806 7 жыл бұрын
Three thumbs up! Just awesome!
@projectb6573
@projectb6573 3 жыл бұрын
i have a problem thats not a error in the script but unity says for the MapGenerator script "No overload for method 'GenerateNoiseMap' takes 6 arguments" this makes it so that the Octave, persistance and lacunarity does not show up in Unity and i cant change them.
@MrHDPigs
@MrHDPigs 2 жыл бұрын
If anyone is looking to allow a string for their seed instead of a number, you can use this code: Set your seed in your MapGenerator to be a string and name it something like seedString. Then, just before calling the GenerateNoiseMap method, you can use this line of code to convert your string into the required int. int seed = seedString.Select(x => Convert.ToUInt16(x)).ToList().Sum(x => Convert.ToInt32(x));
@cavalier4789
@cavalier4789 8 жыл бұрын
I think the range for perlin noise is -999999 to 999999, so it can't be over a million.
@raik1766
@raik1766 3 жыл бұрын
Its probably just me being dumb but changing the octaves seems to just mess up my noise instead of changing it
@letonz
@letonz 3 жыл бұрын
5:40 once i changed the ocatave number the plane just went black not sure sure timestamp is where it started at
@abrobot9261
@abrobot9261 2 жыл бұрын
Did you find a fix?
@dragnothlecoona
@dragnothlecoona 5 жыл бұрын
whenever I change the seed it changes the width or the height of the terrain. How do I fix that.
@rubenleejohnsen2037
@rubenleejohnsen2037 5 жыл бұрын
Are you still struggling? If so, a little code snippet would be nice, so i can see what you've done wrong (-:
@derf6060
@derf6060 7 жыл бұрын
Nice tutorial sir. :)
@nicolaihoegsbjerg
@nicolaihoegsbjerg 2 жыл бұрын
The persistance value for me, does not change anything on the map. What am i doing wrong?
@WPCraft
@WPCraft 5 жыл бұрын
funny. I did all same things step by step and at 10:20 I get a different texture than on video =) I was thinking about what I get the same texture what in a video if I do all the same settings... Why textures is different?
@gorkemvids4839
@gorkemvids4839 5 жыл бұрын
because it's a random noise. Random.
@WPCraft
@WPCraft 5 жыл бұрын
as I understand, if the generator settings are exactly repeated as it is implemented by the author, the card should be completely repeated. so when I fully repeated all settings I get a much different map what shown on the video, but when I generating map time to time with the same setting on my project - I always get a fully same map if settings are same.
@herobrain_3person748
@herobrain_3person748 10 ай бұрын
if you want to fix the scale that create a new map instead of scaling the noise, here the the fix: Change this in Noise.cs: float offsetX = prng.Next(-100000, 100000) + (settings.offset.x + sampleCentre.x)/ settings.scale; float offsetY = prng.Next(-100000, 100000) - (settings.offset.y - sampleCentre.y)/ settings.scale; float sampleX = (x - halfWidth) / settings.scale * frequency + octaveOffsets[i].x * frequency; float sampleY = (y - halfHeight) / settings.scale * frequency - octaveOffsets[i].y * frequency; it's a modified version of this fix kzbin.info/www/bejne/jqGqZIynitB2irs that work with the final version of this tutorial (ep: 21)
@AsyncVoid
@AsyncVoid 4 жыл бұрын
MAKE SURE YOU TURN FOG OFF IN THE EDITOR NOW Shouldn't it be the other way around? maxNoiseHeight = float.MinValue ----> float.MaxValue minNoiseWidth = float.MaxValue ----> float.MinValue Also, I changed the InverseLerp values to -1, +1
@mikolai_spocinski
@mikolai_spocinski 4 жыл бұрын
no the way he did it is correct as he wants the value to be updated on the first run of the loop, hes basically searching for the min and max values of the array.
@volkmardeadguy1557
@volkmardeadguy1557 3 жыл бұрын
mine worked from the last video, but after following this one to see if it worked i got a pitch black plane. turns out i was watching on lower quality so i was getting * and = mixxed up in some places, so it turnes out that when you code noiseHeight += perlinValue = amplitude; you get a black texture instead of noiseHeight += perlineValue * amplitude; which is what you did and said you did
@User74773
@User74773 3 жыл бұрын
im at 4:59 but all of a sudden i have gotten loads of errors in my console, saying "type or namespace defenition, or end of file expected" and i dont know how to fix it
@User74773
@User74773 3 жыл бұрын
i really need help
@kiranrajput4167
@kiranrajput4167 3 жыл бұрын
thats what happens when you don't follow a tutorial
@sfoot3882
@sfoot3882 5 жыл бұрын
what is the point of the octaves for loop? Am I missing something? it only seems to multiply amplitude and frequency for a number of iterations, everything else keeps getting overwritten until the last loop. Isn't it easier just to amplitude *= persistance^octaves and frequency *= lacunnarity^octaves and skip the (x*y*octave) number of loops for octaves?
@sfoot3882
@sfoot3882 5 жыл бұрын
nevermind, NoiseHeight builds with each iteration of the loop. Wonder if there is a simpler way though,
@Flexgamestudios
@Flexgamestudios 2 жыл бұрын
Im doing these tutorials and for some reason my plane is just black no matter what i change in the inspector. I also get an error (index was outside the bounds of the array) although i copied the code exactly the same way. Can anyone help me?
@blaster47974
@blaster47974 Жыл бұрын
i have same issue did you figure it out?
@Flexgamestudios
@Flexgamestudios Жыл бұрын
@@blaster47974 sorry no lol i stuck to 2d for the time
@bjarnes.4423
@bjarnes.4423 7 жыл бұрын
My Perlin Noise looks pretty repetitive... I don't know if you'll fix this in future episodes.. I this I kind of see a repetitive pattern in your Video too. Its when you zoom out at 10.02, you can see straight lines and repeating bumps. But my pattern looks very tiled. Also I get the weirdest pattern ever on scale 0.000001! Its like a plus! Edit: After copying your code it seems to be fine. I also made a few adjustments to the MapGenerator: private void OnValidate() { if (mapWidth < 1) { mapWidth = 1; } if (mapHeight < 1) { mapHeight = 1; } if (noiseScale
@kristianthaler6525
@kristianthaler6525 3 жыл бұрын
Me: bowing in holy reverence to your knowledge of the universe and its workings. Also me: slightly annoyed by your spelling of "persistence".
@McWithers
@McWithers 4 жыл бұрын
I can update all values from the editor via sliding except for Map Width & Map Height. It throws exceptions on the fly for "Index was outside the bounds of the array". If I adjust them both to be a value it will then generate as normal. It wouldn't shrink/expand as he showed in the video. Not sure if this is a new unity issue or I did something wrong. Looked over the source code and can't spot anything
@Sohneg
@Sohneg 2 жыл бұрын
Same problem. Did you found a solution?
@Sohneg
@Sohneg 2 жыл бұрын
Found a solution: If somebody has this error: IndexOutOfRangeException: Index was outside the bounds of the array. Noise.GenerateNoiseMap (System.Int32 mapWidth, System.Int32 mapHeight...... Check if the for loops has x and y at the right spot! If they are turned around it won't work!
@nathanav1634
@nathanav1634 Ай бұрын
Not sure if this is a problem or not, everything works, however if I increase Octaves above say 7-8, the plane stops updating, if i go above 10-11 the noise turns into a series of lines, if i increasing to 100 odd the plane goes completely black. Is that right?
@RobinPortnoff
@RobinPortnoff 8 жыл бұрын
Great tips!
@777redhood
@777redhood 5 жыл бұрын
Auto update on.. changing value of lacunarity and persistence has no effect on map..if octave is 0 i have no image..if its 1 i have the generated map.. increasing octaves, lacunarity, persistence does not change map at all and it looks the same pls help
Procedural Landmass Generation (E04: Colours)
10:32
Sebastian Lague
Рет қаралды 327 М.
I Spent a Week Making an AI's Video Game Idea
17:51
Sebastian Lague
Рет қаралды 3,2 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 153 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 53 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 24 МЛН
[PRIII] :: 2024/25 :: P9 :: 01
22:10
Denis Mušić
Рет қаралды 1
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Рет қаралды 2,6 МЛН
How to turn a few Numbers into Worlds (Fractal Perlin Noise)
15:24
The Taylor Series
Рет қаралды 197 М.
Procedural Landmass Generation (E05: Mesh)
16:51
Sebastian Lague
Рет қаралды 331 М.
Better Mountain Generators That Aren't Perlin Noise or Erosion
18:09
Josh's Channel
Рет қаралды 425 М.
How a Microcontroller starts
28:49
Artful Bytes
Рет қаралды 55 М.
The ONE Texture Every Game NEEDS
9:00
SimonDev
Рет қаралды 251 М.
The Wave Function Collapse algorithm
21:45
CodingQuest
Рет қаралды 288 М.
My Adventure with 3D Perlin Noise
4:28
Nova840
Рет қаралды 479 М.