Procedural Landmass Generation (E02: Noise Map)
Welcome to this series on procedural landmass generation. In this episode we create a grid of perlin noise values and render them to the screen as a texture.
The source code for this episode can be found here:
github.com/SebLague/Procedura...
If you'd like to support these videos, I have a Patreon page over here: / sebastianlague
Пікірлер: 674
For anyone getting the "Multi-object editing not supported" issue when adding the [CustomEditor] code. All you have to do is deselect your MapGenerator object, and then select it again. So for example just click your 'Plane' object, and then click back on to 'MapGenerator', and the button will show up.
@benjamin.burton
6 жыл бұрын
Thank you!
@bjarnes.4423
6 жыл бұрын
Thanks!
@kevinalexisvaldezzamora6916
6 жыл бұрын
Thanks!!!
@makethemdieslow
5 жыл бұрын
Yup, thanks a ton!
@BeautifulLuxury
5 жыл бұрын
Thank you Scattershot. For a moment there I thought it was a feature only supported in the pro version of Unity :)
Some scripting tutorials I set to 1.25 speed. With yours I don't want to miss a fraction of a second.
@OliOAKASquekyboy
5 жыл бұрын
ok thx
@matthewspencer6669
4 жыл бұрын
I love the way he talks, so I'm the same. No homo
@MoonJumpMania
4 жыл бұрын
I just got used to watching every single video to 2.0 speed. Regular speed has just become too weird for me. The only problem is that heavy accents become extremely difficult to understand.
@InsertName74284
4 жыл бұрын
thanks bud
@Josh_Gone
3 жыл бұрын
Me after skipping 3 minutes of programming: *I'm gonna pretend I didn't see that*
Shout out to the comment section for saving me hours of messing about with the code. You guys truly are godsent.
Dude this tutorial is awesome. The best thing is that it does not only teaches you landmass generation it also shows you how to make a custom editor and write better codes. thanks a lot
In case anyone else gets tripped up and the texture is not applying: make sure your material's 'Shader' is set to "Unlit/Texture".. I had it set to "Unlit/Color" and it took me a while to realize why it was grey.
@WolfsRainESP
6 жыл бұрын
MVP
@briannasingh1421
5 жыл бұрын
Thank you! I had same issue.
@benevolenttumour
4 жыл бұрын
Thanks man, thought I was going insane for a while there.
@advancex_87
2 жыл бұрын
I have it set to Unlit/Texture and its still gray
Would just like to give a massive thank you for this tutorial having spent an entire day reading, listening and watching, with growing impatience, to a large swathe of Unity information (or lack of it). This was a breath of fresh air and nothing less than inspiring. It is deserving of chocolate :-)
This is the most interesting way to learn unity and game development. Thank you.
Finally youtube recommended something great for once, subbing to this channel now. : ) Good a/v quality, well designed format and useful universal topics. I'm here to stay. :D
There is one thing VERY important that you NEVER even ONCE mention in this series, and that is ram memory management. the thing about your stuff is that it eats up alot of ram, make sure you clear your array and null them when done clears up ram memory I work with a cube based component building game. and I noticed lots of ram usage from un-nulled arrays. fixed that up and almost no overhead. i am currently revisiting your tutorials to use them with my pixel cube stuff to create a procedural voxel map. other than ram management your tutorials are awesome
Love your video's mate! A lot of other tutorials say that the tutorial isn't for beginners yet carry on for ages explaining the basics of what they're doing. You get straight to the point while still explaining what your doing in a quick and understandable fashion. Thanks! :)
Extremely excited for this series. Off to a great start.
Whoa! This was one of the best tutorial what I've seen for unity. Thanks!
All I have to say is thank you!! For your help, explaining and no afraid to try to teach hard subjects in coding unity.
9:40 If you are doing this in the new HDRP or URP to know what material texture to replace with your noise to display it. You need to use sharedMaterial.SetTexture("_UnlitColorMap", texture); Instead of sharedMaterial.MainTexture = texture; To find the textureID ("_UnlitColorMap") for the shader you use right click the dropdown menu for selecting your shader(at the top in the inspector) in your material, and "Select shader". The textureID is in the properties of the shader where you will find a list of names that often makes sense. The shaders no longer use the textureID that mainTexture references so you have to find it your self. Hopefully this saves anyone the 2h I spent on finding this.
@firad2526
3 жыл бұрын
Thank you!
@-vanitas5229
3 жыл бұрын
Thanks !
@jordanjob7656
3 жыл бұрын
Thank you
@thomassjoholm8623
3 жыл бұрын
Thanks!
@RoverFlushed
3 жыл бұрын
thank you
i love your tutorials already. This perlin noise editor is so helpful!
By far the best tutorial for procedurally generated landmasses!! You are quick but there is a rewind button XD. Thank you for the tutorials! Please keep them coming!
Hi everyone, welcome to episode two! Source code for each episode will become available over here: github.com/SebLague/Procedural-Landmass-Generation I hope to get the next video out this Wednesday (10th Feb). On the off-chance that anyone wishes to transcribe/translate this video, you can do so here: kzread.info_video?v=WP-Bm65Q-1Y
@cousinofcelsius6860
8 жыл бұрын
This gave me an idea for a platforming game. ...The platform heights change over time periodically xD Keep up the good work
@tymewiz806
8 жыл бұрын
+Sebastian Lague ive transcribed it
@SebastianLague
8 жыл бұрын
+tymewiz Thank you very very much, that's awesome! I've made some small edits and added them to the video.
@MrSteenstra
8 жыл бұрын
+Sebastian Lague I've translated the video to Dutch, and have submitted it for verification. Hope it helps!
@SebastianLague
8 жыл бұрын
+MrSteenstra Awesome, thanks for making it accessible to a wider audience!
This is awesome as a Unity tutorial for people who already can program! Excellent work mate!
I dont understand a word I just watch this for the soothing voice and the nice images
thank you so much for this! this will totally help me get into programming like i've always wanted.
Brilliant !!Never found anyone like this before! You're just amazing !
Firstly, great tutorial. Good speed, perfect amount of explanation of what certain things are and why they're done and overall just useful tutorial. Quick note to hopefully help save some people time if they're following along using LWRP. I wasn't getting anything shown on my plane despite the code being run, checked w/ logging, and went to the internet. Turns out the fog feature in LWRP boilerplate got me again. Go to Window > Rendering > Lighting Settings. Under "Other Settings" uncheck the fog or lower it.
These are well done tutorials indeed, keep up the good work!
Exactly what I needed, thanks for the amazing work! I'll be using this tomorrow
I love how you use 'color' and 'colour' to make everyone happy XD
In 15 minutes this taught me more about actually doing stuff with/in Unity than five hours of official Unity Learn courses. Of course those courses have to assume zero programming experience, but still -- very impressed with the clarity and information density. Still useful half a decade later!
can't wait for the next episode !! Thanks !
I have never been so excited to see snow on my monitor - ty
I'm having so much fun scaling my noise texture, this video taught me a lot.
I have absolutely no idea what you're doing, but thank you, your tutorials helped me a lot :D
@bukkit_esp81
7 жыл бұрын
Dont follow a tutorial without knowing what are he doing, so, comment what is creating in every line, and you will know what is happening, easy
I feel like i need to pay you for this. Its too good.
thank you so much! Your videos are always very useful and I learn so much!
Thank you for the sweetest unity tutorials🍬
Lot of new tricks in here, looking forward to the next video
Just wanna say that as someone who has experience numerical programming (but not unity), it's really nice to find a tutorial that assumes programming knowledge and of such high quality.
Great job. This is fantastic.
Hi sebastian, great series. Keep it up.
Wow... This is so good and still free... I think I'll become a patron :)
Very helpful and well made series!
God I love this channel so much, it's so helpful
This is Very good! I'll have to adapt this to apply it to unreal, but thanks for this, it's exactly what i was looking for!
This is incredible. Thank you!
I watched the tutorial again for 3 minutes, slept for 1 hour, finally woke up and now your voice is gonna make me sleep again
Your videos are awesome. Just wanted to say that.
I found that with the finished code for this episode, certain Scale values would result in pure grey images. And, though the first 20~ seconds of this video reference something like this occuring... it didn't quite feel right to me so I did some tinkering. ***EDIT: But I should mention here that if you stick with the series, Sebastian later adds an "Offset" value, which appropriately picks from the Perlin Map - rather than the early code from this episode seemedly picking from the same point over & over.*** Looking at the current Unity Docs example for PerlinNoise, the prefered way to pick sampling co-ords is closer to what 'adrian anta' presented some time ago: float xCoord = x / noiseTex.width * scale; float yCoord = y / noiseTex.height * scale; float sample = Mathf.PerlinNoise(xCoord, yCoord); (I cast both x & y as floats in my example after seeing some systems had issues resulting in solid textures) Using the code example from my comment here I was able to achieve much more reliable / non-solid results. Hope this helps!
Bonus tutorial on some editor magic. I have used Unity quite a bit but never before done any custom editor stuff, so that was really interesting to learn about. Thanks for a great tutorial!
Great video. Looking at old videos and practicing to improve my understanding to understand your new amazing videos better :D
Thanks! I've been searching how to get it and this is brilliant :D
15 min tutorial but i use atleast 5 hour to learn gg
@ineeda12step92
3 жыл бұрын
Same here! Lol
@user-fr3pp5wu7o
2 жыл бұрын
Same here 😭😭
@JacobKinsley
2 жыл бұрын
Better than someone that needs 5 hours and just acts as if 15 minutes is enough to understand
@Sakupenny
Жыл бұрын
"I take"
You are incredible my man
Brilliant tutorial, thanks.
Thank you so much for making these videos for free I'm new to unity and want to get into gamedev : )
How would you go about making a variable to control the space between land masses? Like if you want there to be lots of water between them, also the size of the land masses?
You just got your 65,000th subscriber.
As usual... Awesome stuff (y)
it tooks me bout 3 hours to understand the code and get it right but it was worth it
If anyone is coming back to this and wants to use the HDRP, to get the texture to update, replace the ...sharedMaterial.mainTexture... part with "textureRenderer.sharedMaterial.SetTexture("_BaseColorMap", texture);"
@jordanjob7656
3 жыл бұрын
Thank you :)
When using LWRP, this is how you set the texture of a material: `TextureRenderer.sharedMaterial.SetTexture("_BaseMap", texture);` (but be sure to google what it actually does :) )
@jupiterbjy
4 жыл бұрын
You saved my life.. just a reminder, LWRP is renamed to URP.
@Hello-qg4yk
3 жыл бұрын
jupiterbjy And if you use HDRP?
@gustavbok4298
3 жыл бұрын
@@Hello-qg4yk To use it with HDRP you have to go with "textureRenderer.sharedMaterial.SetTexture("_BaseColorMap", texture);"
3:04, instead of doing the if statement and setting scale to be 0.0001, I made a ternary like so: scale = scale == 0 ? float.Epsilon : scale; will this work?
I've never used unity before. For c# I usually just used XNA or managed directX for 2D rendering - but this looks terribly easy! Definitely giving it a go. :) Thanks for the easy to digest video. Definitely subbing.
You are awesome man! 😃👌
Thank you for this tutorial!!
For anyone that have a blank or gray plane, dont forget of set sampleX and sampleY to x/scale and y/scale.
@mowztouch4873
6 жыл бұрын
also don't forget to cast x and y as floats float sampleX = (float)x / (mapWidth*scake); float sampleY = (float)y / (mapHeight*scale);
@colepoppleton1002
3 жыл бұрын
@@mowztouch4873 where would that go. In 'Noise'? if so what line?
Agradezco muchísimo los subtítulos en español, gracias por tu contenido
Awsome Tutorial!
That converting a 2d array to a normal array really threw me for a loop (no pun intended). i had to draw it out to understand what was going on there. As a newer programer I did have to watch through a couple times and comment my code to fully understand what was going on. Good tutorial I learned lots of stuff from it.
@a.p.3571
6 жыл бұрын
Hey I know you wrote this comment a really long time ago, but if you remember, could you please explain how you understood the conversion? I'm trying to figure it out myself and am having a really hard time doing so.
@Aethelvlad
2 жыл бұрын
@@a.p.3571 2D array looks like (x1, x2, x3, y1, y2, y3). multiply the length of x entries against the length of y entries, in this case the result is 6. your new 1D array with a length of 6 will hold the same values (x1, x2, x3, y1, y2, y3). the result of doing this is the same as separating the dimensions x/y of the array and stringing them together in sequence x/y. as he said, this had to be done because our noise/height maps are 2D arrays but color maps for textures can only be stored in 1D arrays, no x/y.
I remember watching this as it was coming out, thinking that I could understand and follow everything, just having started programming. Wouldn't say that I'm any good at it right now either, but the fact that I can actually follow this, makes me so happy.
This is a goldmine.
Hey, I may barely know any programming whatsoever. And Unity may not even run on my laptop. But this stuff is great, thanks man for all you do. Hope you see this.
it worked! thank you so much!!
This is such a great tutorial. You have a great talent for making everything completely understandable! Any chance you plan on doing a procedural planet tutorial anytime in the future?
Masterpiece!!!
For everybody wondering why their noismap looks different than the mesh (later in these episodes): You have to mirror the x-values of the color[] from the noisemap ;-)
@Luciferdelight
Жыл бұрын
how did you solve gray mesh generated ..?
Really interesting!
thank you for this!
Amazing tutorial
I just stumbled upon your videos a few days ago and I must say they are excellent! Do you have notes on what to do exactly or do you just go off memory when making these? Either way, great job!
@SebastianLague
8 жыл бұрын
+Eeveelution Thank you :) I do prepare everything in advance for each video. It's a lot of extra work, but it helps to keep the videos focused and (to a certain extent) free of errors.
@eeveelution8035
8 жыл бұрын
Sebastian Lague Thanks for the fast response! The extra work really does help the quality of the video, keep up the good work :)
Every time I resize the mapwidth or height through the inspector, I encounter an index out of range exception. This does not happen within a certain threshold. Any help?
I find it fascinating that with 4 scripts and less than 100 lines of code you built the framework to one of my favorite games of all time: Civ 2, and thoroughly explained how and why the auto map generation feature works the way it does by selecting: age, size, and roughness in the pregame menu... That is insane considering that game is over 20 years old!
Great tutorial
I just totally ran into the issue a couple days back kinda doin this on my own. Where if you sample integers you get the same value(I ALWAYS GOT 0!). for like 3-4 hours I pulled my hair out xD. devided world coords by 100 and got my terrain. I was so happy. LOL
4:25 kinda sounds like an exploding creeper lol Awesome tutorial series Sebastian!
Damn what a roadster around 2:00
What did you do at 5:55 to make the empty object disappear from the scene window? Must have been a keypress as the mouse didn't move anywhere near a button after leaving the Y axis selection.
Hi Sebastian, Amazing tutorial man. I was just wondering if i could ask for some help. In regards to your AI path finding how would i get the AI to patrol between two points? any help would be greatly appreciated.
thank you so much!
its simple but teaches a lot of concepts :D
When I apply the map display script to the MapGenerator object it says “can’t add script component ‘MapDisplay’ because the script class cannot be found. Make sure that there are no compile errors and that the file name and class match”
For those getting just a grey plane try toggling fog off in scene / toggle effects
I faced a small problem with this tutorial but I realised my mistake after a while. Not paying enough attention to the video, I put in a value 1.0f for the noise scale in MapGenerator. This meant that the map showed a uniform colour without any 'noisy' variation - I thought it wasn't working. After using the 0.3f value Sebastian used I saw the expected behaviour. Just in case anyone else makes a similar mistake...
IF YOUR PLAIN IS GRAY: CHANGE YOUR NOISE SCALE TO 10, WIDTH TO 100 AND LENGTH TO 100 :) Unity changed their Perlin function, and it now requires smaller numbers for small Perlin. changing noise to 100 means our sampleX and sampleY get divided by a bigger number, making them smaller, making your plain display a very clear Perlin image rather than like, 1 grey pixel of Perlin. Hope this helps someone :)
@shubhrojyotikabiraj8322
2 жыл бұрын
you saved me
To make it work I had to alter Noise's method to (I was getting a grey plain texture) float sampleX = x / (mapWidth * scale); float sampleY = y / (mapHeight * scale); as Mathf.PerlinNoise parameters have to be within a range of 0..1 I don't understand why it works in your example though. Great tutorial. Keep it up!
@delano4047
7 жыл бұрын
Still doesnt work for me i get a black plain texture even after this
@mowztouch4873
6 жыл бұрын
try to cast x and y as floats: float sampleX = (float)x / (mapWidth*scake); float sampleY = (float)y / (mapHeight*scale); Perlin noise can get any value.
@nullifier_
5 жыл бұрын
WOW! Thanks! It worked for me.
@lawrencehoward460
5 жыл бұрын
I thought I'd way in here even though it's a 3 year old comment. It's important to note that Mathf.PerlinNoise's PARAMETERS do not have to be within 0.0f..1.0f, but rather what the function returns is between 0.0f..1.0f. I found that with the finished code for this episode, certain Scale values would result in pure grey images. But the first 20~ seconds of this video to reference something like this occuring... but it didn't quite sit right with me so I did some tinkering. Looking at the current Unity Docs example for PerlinNoise, the prefered way to pick sampling co-ords is closer to what 'adrian anta' presents: float xCoord = x / noiseTex.width * scale; float yCoord = y / noiseTex.height * scale; float sample = Mathf.PerlinNoise(xCoord, yCoord); So to demonstrate that the parameters can be outside of 1.0f: xCoord = 1 / 64 * 100.0f; xCoord = 1.5625f Using the code example from my comment here I was able to achieve much more reliable / non-solid results. Hope this helps!
@PolkanGames
2 жыл бұрын
You saved me, thank you
Nice tutorial!
I did a semester of java so i understand half of what you are doing but its still interesting
does anybody know how you could make the terrain bigger for example put a limit on how big the infinite terrain can be so that when you walked a certain amount of chucks it would stop spawning chunks or just resize the noise map maybe?
Working on this in 2d. If the plane is not showing, rotate the X axel . 45 degrees
How do we export the map as an asset for a level? I think it's awesome that we can make maps now but I'm still unable to use them.
thank you so much for these videos. you are a life saver :)
Awesome. When is the next video coming out? *Waiting anxiously* :)
how you make this smooth texture for the terrain in the begin of the video?