Hi everyone, welcome to this new series on procedural planet generation. Episode two is out on early access for patrons here: www.patreon.com/posts/20806385, and will be publicly available sometime next week. As a rough guide of what to expect from this series, the current episode plan is as follows: 1: Generating a sphere 2: Creating a settings editor for planet properties 3: Combining multiple layers of simplex noise to create terrain 4: Creating mountain ridges with a different noise filter 5: Combining different noise types for more varied terrain 6: Using shadergraph to create a terrain shader 7+ Some extra stuff maybe, not fully planned yet.
I really love the idea, however, I have a suggestion on an interesting twist to this tutorial: Let's suppose you have a planet system an fly through it in a spaceship. If there are hundreds of planets like this around, wouldn't it make the game really, really slow? Wouldn't it be better to assign some material with height and normal maps to the four faces instead of generating the actual geometry? You could make it so that the geometry is generated and then baked onto some textures and use those textures instead at runtime!
+Sebastian Lague Aha! I have just started working on implementing planets in my game using the very method of "spherical cubes" and this guide: catlikecoding.com/unity/tutorials/cube-sphere/ . I couldn't believe my eyes when you added this video just a few days later. Absolutely love it! THANKS!!! :D +IndieMarkus I'm not sure whether it solves your problem, but my approach was to store planets as simple data types in arrays (terrain type, height etc) and only re-constructing a GameObject and a mesh when a planet is visible. Then you can have practically unlimited number of planets and rebuilding a single mesh occasionally isn't intensive enough to noticeably slow down a framerate. I couldn't use static assets since my planets can actually change during the game due to terraforming/bombardment etc.
Hey , when you talk about a more even distribution, you will use this mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html right? Looking forward to the normal calculation. I've making procedural planet approaches since 2012 and the normal seams are always a headache especially when using LOD patches. It will be very interesting to see how you will solve that your way.
@IndieMarkus unless you're targeting mobile, modern hardware will usually be able to handle a few million polygons just fine. the trick would be to implement a level-of-detail system to reduce the number of polygons on planets as their distance to the camera increases. bump maps could be used on the normally used textures anyway to simulate even finer detail between the vertices.
with some tuning it could be done. You would have to change from tricking downwards to trickling to the planet middle. It would however completely mess up the already existing formula, so while you can use hyraulic erosion it would require a specifically written one for spheres.
@@G4merSylver I think, one could leverage that the sphere is actually just a stretched cube. If you apply the generation first for each face of the cube and afterwards stretch out the terrain, the old function could theoretically work.
@@olivertressler633 Perhaps, maybe you could apply the algorithm as if the mesh was already stretched? I mean stretching out or squashing the forces in certain directions depending on where the force is being applied, and doing so in a way that counteracts the bulging out of the cube later on.
Nice video. Thanks. To get rid of the seam, I added: Vector3[] normals = new Vector3[resolution * resolution]; then normals[i] = vertices[i].normalized; after you added the vertex. then mesh.normals = normals; and comment out //mesh.RecalculateNormals(); It's a sphere so the smooth normals will all be pointing along the vertex vector. Hope you add to the series.
@@zaraf Try setting scope for a project you want. Make a google doc or write in a notebook what you want to do. So if you print hello world, remove it from the main and build a function that takes and prints a string. Just keep going from there and add options for adding numbers. One simple program I wrote was just rock paper scissors with a simple AI. Don't give up if you get stuck or lose motivation. If you need to, just step away for a while and let your mind refresh.
@@zaraf Dont feel bad just straight up copying the code from turials such as these, get it working, then just play around with the code and see what changes what and see if you can understand it. Doing that for a month teaches you more than you'll learn in a comp sci uni.
Yeah, that's the difference between code and logic. It's like reading an academic research paper on chromodynamics or something. You know the words on the page, but don't understand the concepts they are presenting. This is why almost every accredited software program and almost any decent university will always have a dedicated "Algorithms" course between Junior and Senior years. It's hard stuff. Half the battle is knowing how to code. The other half is knowing how to translate logic into code, let alone geometric logic, and later in these tutorials, real life physics phenomenon.
Until recently, the procedural planet and country simulator I've been working on in pure Lua used an inefficient method for generating its planets that involved looping through a cube and calculating whether each and every point lied on the surface of a sphere. I just got through implementing this distortion algorithm you showed, and it's reduced my generation times by a quarter on average. You rock, man! :D
I've been looking for a tutorial like this in Unreal, and eventually I decided that I should just go back to your videos and figure out how to get them to work in Unreal since none of the other tutorials seem to do it quite as well as you
every time you go back in the code to write something in, it would be nice if you would compile it and show us why it needs to be written in. just my 2 cents. love this tut series and can't wait to see you do more.
Love the idea of this new series, but what’s going on with the neural network series? Is it over? Will it continue alongside this series? Will it continue after this series? Really want some info of what’s going on there
I've been looking for these during ages. Now, that I already completly forgotten this times, I found it in a random youtube channel. You won a new subscriber! Amzing!!! :)
Just finished my own inplementation of a system like this based on your landmass tutorial. I'm glad you do this series so i can see what i can improve in my own. Thx for all your awesome series and i hope you will continue to make more interesting tutorials.
I had so much fun following along. Excited to learn procedural mesh generation and this video is my starting point. Thank you so much. Interesting note! The issue with the seams is gone in the current version of Unity 2020.3.17f1. I got a beautifully smooth sphere when I turned wireframe off.
I am excited for this series! I have wanted to make an RTS that takes place on the INSIDE of a sphere for awhile now. I was hoping to use an icosphere, but everything here will still be wonderful and useful :]
I'm really looking forward to finishing this series, but I don't know Unity coding very well yet. You did a great and quick job at instructing the steps, but I wish you would've explained things more so that I could make better comments as I followed along. That's all.
Many thanks for all your work and priceless knowledge. I feel a little like I haven't really earned this progress. Without you laying it out for me ; I would have never gotten past a simple cube or sphere. Very grateful nonetheless...
th-cam.com/video/GhQdlIFylQ8/w-d-xo.html is probably the best free tutorial out there that i've came across. this'll get you started in c# if your still interested to learn.
This might be something that doesn't happen in unity, but when drawing triangles from an origin like this, you need to take into account that when you're drawing triangles left-to-right like this, you're drawing them as if you're facing the sphere from the inside. This makes the normals face inside if you wind the triangles clockwise. Thus in order to make this work in pure opengl you need to technically wind these triangles counter-clockwise because you'll be looking at this thing from the outside.
I'm very excited for this series and since a friend and I once had an idea about a small space game I'll probably follow along and implement this stuff myself for once! 0:14 Is that a Code Geass reference? :P 0:30 would the cube-based approach later not use power-of-2 detail steps again (like in your infinite terrain series), meaning that the control over detail would be roughly the same? would then not be the fact that the vertices on this sphere can't be unwrapped in a simple way to get nice UV coordinates on a single flat texture be the bigger problem? or would that not be an issue with the shader later on? if there are textures involved I'd imagine it to be easier with the inflated cube approach. unless you're using triplanar mapping... 0:44 gotta say I love that you put in the extra amount of work to animate this stuff just to explain things, even if it doesn't land in the final project! same with the other spheres! 1:03 I'm guessing this will be resolved the same way you did with the infinite terrain where you added an extra ring of vertices which were not connected via triangles, right? 2:22 might as well call them "localRight" and "localForward", no? or "localX", "localY" and "localZ"? :P 4:09 actually writing "2 * 3" instead of "6" could maybe help as a step of documentation I think. 5:22 if the center is at (0,0,0) and the corners have a y value of 1 then the cube will have a "radius" of 1 instead of a diameter of 1, making it not a "unit cube" though, right? 7:04 why not use this version then? it's simpler in both reading and number of math operations used (though it probably won't matter much performance-wise). if you feel fancy you could even write "vertices[i++] = pointOnUnitCube;" ^^ 7:35 you could also use 0,1,5 and 5,4,0. that way they'd actually go clockwise and not zig-zag and around again :D 10:00 good call! Keep 'em coming!
When referring to a "unit" object, most often the measurement of 1 unit in that context is the radius, giving a diameter of 2. A unit circle also has a radius of 1. :)
"Error: Cannot implicitly convert type" on the "directions" index. Mine looks just like the demonstration though. EDIT: I used parentheses instead of curly brackets. whoops
Yup. Not a lot of good info out there. I will post a quad-tree LOD when I finish mine. Programming is a scientific endeavour, yet many horde their knowledge to prevent the masses from profiting from it. That needs to end.
Finally something to get exited. But I was hoping for it to be the successor for the procedural landmass generation series. But no worries. Lets see how it goes. Cheers
Haha, I used your previous procedural generation tutorials to generate a procedural planet much like this for my final year thesis (with LOD algorithm though). It will be nice to see how I could have improved it by watching this. It would be great to know how a system for LOD could be implemented efficiently. Mine wasn't very efficient. Thanks btw.
Hello everyone! To smooth out the seams between meshes, normal vectors of each vertex along the seam need to be averaged out with normals of neighbouring triangles. While this algorithm would probbably give the most precise lighting, it' is very hard for a beginner to design, so let me know if you designed such algorithm. On the other hand, a simple solution is to set the normal vector of each vertex to the vector of it's position normalized. This way, normals along the seams have the same direction and thus give smooth lighting. Vector3[] SphereNormals(Vector3[] vertices) { Vector3[] normals = new Vector3[vertices.Length]; for(int i = 0; i < vertices.Length; i++) { normals[i] = vertices[i].normalized; } return normals; } The solution is very simple, but many people don't notice it right away. I hope it helped.
The vertices are already normalized, aren't they? Couldn't you just assign normals = vertices and be done with it? It's all type Vector3 right? I have no experience with unity and its internal data structure, but it seems reasonable to me.
@@moonman3658 So far I think whats happening here is that we can't use GameObject functions like SetActive(true) in OnValidate because Unity developers are a little dumb and it potentially leads to "undefined behavior". You need to reorganize OnValidate so it doesn't call any sequence of functions ending up with a GameObject method being called?
For anyone getting this message and their planet looks pink: In the "Planet" script, line that looks like this: meshObj.AddComponent().sharedMaterial = new Material(Shader.Find("Standard")); change "Standard" to "Universal Render Pipeline/Lit" Explanation: The material name "Standard" is a shader that the Universal Render Pipeline doesn't like to use, so it turns the material shader pink since it isn't compatible. The default material shader normally used is in the Universal Render Pipeline has the name "Universal Render Pipeline/Lit". I'm guessing that this video used an older version of Unity that uses the Legacy shaders.
After correcting errors in the code and writing lines that I skipped I have made some scripts that do absolutely nothing but hey, at least I made some scripts xD
If you have a problem of "flipped normals" just change order of triangle vertecies from clockwise to anticlockwise in TerrainFace.ConstructMesh like this: triangles[triIndex]=i, then =i+resolution, then i+resolution+1.
Cool how you just keep building and building on this, and eventually you have what it is now, an entire solar system with atmosphere and gravity and things
Try adding more realistic gravity, so gravity on the moon is weaker than gravity on the planet, it currently feels a little bit off. Btw, the planets look beatiful!
I totally agree in learning how to create an sphere out of a Cubr. It's super useful, but I don't understand why you choose to work with a triangle face sphere and not a quad one.
I don't understand why he thinks you have to increase the detail of an icosahedron 4 fold each time. You can turn each of the initial triangles into any value of n^2 smaller triangles, just like he does with the initial faces of the cube, turning it into any number of n^2 smaller squares.
just some advice on this tutorials, when you make a drawing, don't delete it straight away. If you made it to explain a piece of code, wait until you have written that piece of code, and then delete de drawing. It's a really small detail, but I think it's kind of nicer to do it that way, so you can look at the code and at the drawing at the same time.
I do not know 3d game things (not a master at 2d too :D) Im finally made a sphere with resolution setting as you describe in 1 week from zero mesh knowladge and in Godot game engine.I just want to say Thank you please keep up with good work as usual. (Sorry for any mistakes. English is not my native language)
First of all, THANK YOU for your gorgeous detailed and informative tutorials! I, and we, really appreciate that! I have a question about the Noise-Pattern. Is it possible to have a more "roughly" gradient, so we can form some voxel-inspired world creation? E.g. Cube World's engine (which has been coded in C++, as the Developer, who ran away in 2013 from further developing his game, says...), I love the voxel design and world creation, but think that the noise colorrange won't really fit from the very deep see up to the highest mountain (not the structural objects like actually mountains attached to the surface-mask). Can you make a small tutorial about that part how to achieve a voxel terrain? Thank you!
This is useful, thanks. I'm going to look at using this method with an icosahedron base, using 10 bent diamond shapes instead of 6 squares. Should be able to achieve the same flexibility of resolution.
Could you place take this series longer than the "basic" stuff. I would love to see a river system that sinks the terrain on it's way to the nearest lake/sea.
Great vid and narration. I just wanted to ask, I can see that this case with a cube sphere works for small planets that you possibly look on from afar, but what if you want to create a space game with large planets you can fly between and land on. In that case, wouldn't the hexagon approach with a high resolution be easier to work with and look nicer? Just wondering.
Hey Sebastian, For clarity and understanding: Would axis A be the same as Local Forward and Axis B be the same as Local Right? Would this be always true, sometimes true or never true?
The argument for using Cubic rather than Icosahedral symmetry doesn't make sense. You can subdivide Triangles with exactly the same freedom that you can subdivide Squares, there is no reason that you would be limited to powers of 2. That's like saying you can only divide squares into quarters and sub-quarters.
THANK YOU, I have been trying to figure out how to make procedural planets for a while, and boom, your videos and tutorials pop up.... Now two questions, both with a basic premise, do you cover rotation of planets for a day/night cycle and with your solar system for calculation of a year in a game? or can we do this in Unity? Additionally add in weather effects with the planet solar year. like if the position of the planet to its sun and its axis, where we would have summer in the northern hemisphere and winter in the southern hemisphere and vice versa...it would be nice to explore such ideas...
can someone explain me something?. can i create big planets with this method? big enough to don't see the planet curve while walking with the character, build houses, farms and other things?
If I recall correctly from somewhere that escapes me atm, after some lin alg and simplification, the matrix that rotates the axis by 90 can be simplified down to just swapping the coords of the vector. I think that the trade off is you dont know which direction the line is facing or something like that, but for the purpose of this series, that does not matter.
Super late to the party, I know. How easy is it to scale this up? as in, break each face down into smaller 256x256 chunks? my coding adventure is getting this up and running on a bigger scale, and creating a full planet with logical landforms one day. Also, thanks for all of your work! you really inspired me to finally delve into programming!
Hi everyone, welcome to this new series on procedural planet generation.
Episode two is out on early access for patrons here: www.patreon.com/posts/20806385, and will be publicly available sometime next week.
As a rough guide of what to expect from this series, the current episode plan is as follows:
1: Generating a sphere
2: Creating a settings editor for planet properties
3: Combining multiple layers of simplex noise to create terrain
4: Creating mountain ridges with a different noise filter
5: Combining different noise types for more varied terrain
6: Using shadergraph to create a terrain shader
7+ Some extra stuff maybe, not fully planned yet.
I really love the idea, however, I have a suggestion on an interesting twist to this tutorial:
Let's suppose you have a planet system an fly through it in a spaceship. If there are hundreds of planets like this around, wouldn't it make the game really, really slow? Wouldn't it be better to assign some material with height and normal maps to the four faces instead of generating the actual geometry? You could make it so that the geometry is generated and then baked onto some textures and use those textures instead at runtime!
+Sebastian Lague
Aha! I have just started working on implementing planets in my game using the very method of "spherical cubes" and this guide: catlikecoding.com/unity/tutorials/cube-sphere/ . I couldn't believe my eyes when you added this video just a few days later. Absolutely love it! THANKS!!! :D
+IndieMarkus
I'm not sure whether it solves your problem, but my approach was to store planets as simple data types in arrays (terrain type, height etc) and only re-constructing a GameObject and a mesh when a planet is visible. Then you can have practically unlimited number of planets and rebuilding a single mesh occasionally isn't intensive enough to noticeably slow down a framerate.
I couldn't use static assets since my planets can actually change during the game due to terraforming/bombardment etc.
Hey , when you talk about a more even distribution, you will use this mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html right?
Looking forward to the normal calculation. I've making procedural planet approaches since 2012 and the normal seams are always a headache especially when using LOD patches. It will be very interesting to see how you will solve that your way.
@IndieMarkus
unless you're targeting mobile, modern hardware will usually be able to handle a few million polygons just fine. the trick would be to implement a level-of-detail system to reduce the number of polygons on planets as their distance to the camera increases. bump maps could be used on the normally used textures anyway to simulate even finer detail between the vertices.
@Sebastian Lague
for the 7+ part(s): how about some rings (like Saturn) and/or an atmosphere (with a shader for nice lighting effects)?
Would it be possible to mix this with your hydraulic erosion coding
with some tuning it could be done. You would have to change from tricking downwards to trickling to the planet middle. It would however completely mess up the already existing formula, so while you can use hyraulic erosion it would require a specifically written one for spheres.
@@G4merSylver I think, one could leverage that the sphere is actually just a stretched cube. If you apply the generation first for each face of the cube and afterwards stretch out the terrain, the old function could theoretically work.
@@olivertressler633 Perhaps, maybe you could apply the algorithm as if the mesh was already stretched? I mean stretching out or squashing the forces in certain directions depending on where the force is being applied, and doing so in a way that counteracts the bulging out of the cube later on.
Oh someone already said this
Reading all this comments is just making me feel dumb
Most of the time, I don't need to learn from these tutorials, I just watch them while I do my physics homework. Your voice is just so soothing.
This is something I would need in my next game.
Lol I just find a 2 years old comment from you with only 3 likes.
@@ceddyd Heh
Wow I didn’t think you’d respond. Kudos for that.
Hi stef! I love your game btw.
WAIT IS THIS WHO I THINK IT IS?! I LOVE SFS!
One of the few channels where it's wise to slow the video down instead of speeding it up. 🤯
Nice video. Thanks.
To get rid of the seam, I added: Vector3[] normals = new Vector3[resolution * resolution];
then normals[i] = vertices[i].normalized; after you added the vertex.
then mesh.normals = normals; and comment out //mesh.RecalculateNormals();
It's a sphere so the smooth normals will all be pointing along the vertex vector.
Hope you add to the series.
You can also just add the line "mesh.normals = vertices;" since the vertices are already normalized.
Thanks! this helped
it doesn't work for me...I get a very strange lighting instead and the shapes are no longer clearly visible...
Thanks this is exactly what I was looking for in the comments :D
@@BlackwoodHDEnglish Yup
Finally how to make No man's sky
Abd ElRahman Mohammed lol
Not quite, unless he'll cover implementing a voxel system with Dual Contouring.
MapMagic and Voxeland can be added to this to do just this.
No where near
More like Spore
Seeing this just reminds me how terrible I am at coding.
Takes a lot of practice, you will get there! Just keep on learning.
Every time I want to start a project all I end up doing is printing hello world
@@zaraf Try setting scope for a project you want. Make a google doc or write in a notebook what you want to do. So if you print hello world, remove it from the main and build a function that takes and prints a string. Just keep going from there and add options for adding numbers. One simple program I wrote was just rock paper scissors with a simple AI. Don't give up if you get stuck or lose motivation. If you need to, just step away for a while and let your mind refresh.
ditto
@@zaraf Dont feel bad just straight up copying the code from turials such as these, get it working, then just play around with the code and see what changes what and see if you can understand it. Doing that for a month teaches you more than you'll learn in a comp sci uni.
Man, this is an odd feeling: I fully understand your code, but I am 100% lost with what its doing.
Then how do you _fully_ understand it?
@@BlueGrovyle he knows what the methods and loops do but not how they effect the world
Yeah, that's the difference between code and logic. It's like reading an academic research paper on chromodynamics or something. You know the words on the page, but don't understand the concepts they are presenting.
This is why almost every accredited software program and almost any decent university will always have a dedicated "Algorithms" course between Junior and Senior years. It's hard stuff. Half the battle is knowing how to code. The other half is knowing how to translate logic into code, let alone geometric logic, and later in these tutorials, real life physics phenomenon.
Sebastian codes like a Yogi approaching nirvana, you need to muster all the calmness you can in your spirit body and soul before you pay attention.
I am a physics PhD and love your videos, but sometimes I watch them just to hear your calming voice.
These videos are by far the best and most interesting coding videos on youtube imo, can't stop watching
Agreed
I've waited so mush time for a tutorial like this, and then in addition, by sebastion lague. IT'S TOO MUCH COOL
Until recently, the procedural planet and country simulator I've been working on in pure Lua used an inefficient method for generating its planets that involved looping through a cube and calculating whether each and every point lied on the surface of a sphere. I just got through implementing this distortion algorithm you showed, and it's reduced my generation times by a quarter on average. You rock, man! :D
Years passed, and this video is still useful and interesting, cool
Dear man, you saved me a huge amount of time and nerves. Thank you endlessly!
Sebastian is the best teacher i found so far on TH-cam, thank you for your content
I've been looking for a tutorial like this in Unreal, and eventually I decided that I should just go back to your videos and figure out how to get them to work in Unreal since none of the other tutorials seem to do it quite as well as you
every time you go back in the code to write something in, it would be nice if you would compile it and show us why it needs to be written in. just my 2 cents. love this tut series and can't wait to see you do more.
Love the idea of this new series, but what’s going on with the neural network series? Is it over? Will it continue alongside this series? Will it continue after this series? Really want some info of what’s going on there
Ohhhh it’s sooooo coooooool, sooooo cooooooool, my computer can’t handle the rendering.
Great tutorial, explains a lot, and the voice makes me calm and able to focus.
I've been looking for these during ages. Now, that I already completly forgotten this times, I found it in a random youtube channel.
You won a new subscriber! Amzing!!! :)
Just finished my own inplementation of a system like this based on your landmass tutorial.
I'm glad you do this series so i can see what i can improve in my own.
Thx for all your awesome series and i hope you will continue to make more interesting tutorials.
small mistake: the max resoluion needs to be < 256 because the max number of vertices is 2^16-1 (65535)
Thanks for this amazing series though!
I had so much fun following along. Excited to learn procedural mesh generation and this video is my starting point. Thank you so much.
Interesting note! The issue with the seams is gone in the current version of Unity 2020.3.17f1. I got a beautifully smooth sphere when I turned wireframe off.
On second look the seams are there but only at very low resolutions. Weird.
Recently subbed. A very excellent tutorial. I always wanted to do something like this but never seen a good way to do it. This method is spectacular!!
I am excited for this series! I have wanted to make an RTS that takes place on the INSIDE of a sphere for awhile now. I was hoping to use an icosphere, but everything here will still be wonderful and useful :]
I'm really looking forward to finishing this series, but I don't know Unity coding very well yet. You did a great and quick job at instructing the steps, but I wish you would've explained things more so that I could make better comments as I followed along. That's all.
Many thanks for all your work and priceless knowledge.
I feel a little like I haven't really earned this progress.
Without you laying it out for me ; I would have never gotten past a simple cube or sphere.
Very grateful nonetheless...
just love how this beautifully explained. really makes me want to start coding.
th-cam.com/video/GhQdlIFylQ8/w-d-xo.html is probably the best free tutorial out there that i've came across. this'll get you started in c# if your still interested to learn.
Yes! Thank you so much for this. I hope you never stop making these awesome advanced tutorials
I wanted a series on this for ages! Thanks Seb!
This might be something that doesn't happen in unity, but when drawing triangles from an origin like this, you need to take into account that when you're drawing triangles left-to-right like this, you're drawing them as if you're facing the sphere from the inside.
This makes the normals face inside if you wind the triangles clockwise. Thus in order to make this work in pure opengl you need to technically wind these triangles counter-clockwise because you'll be looking at this thing from the outside.
I'm very excited for this series and since a friend and I once had an idea about a small space game I'll probably follow along and implement this stuff myself for once!
0:14 Is that a Code Geass reference? :P
0:30 would the cube-based approach later not use power-of-2 detail steps again (like in your infinite terrain series), meaning that the control over detail would be roughly the same? would then not be the fact that the vertices on this sphere can't be unwrapped in a simple way to get nice UV coordinates on a single flat texture be the bigger problem? or would that not be an issue with the shader later on? if there are textures involved I'd imagine it to be easier with the inflated cube approach. unless you're using triplanar mapping...
0:44 gotta say I love that you put in the extra amount of work to animate this stuff just to explain things, even if it doesn't land in the final project! same with the other spheres!
1:03 I'm guessing this will be resolved the same way you did with the infinite terrain where you added an extra ring of vertices which were not connected via triangles, right?
2:22 might as well call them "localRight" and "localForward", no? or "localX", "localY" and "localZ"? :P
4:09 actually writing "2 * 3" instead of "6" could maybe help as a step of documentation I think.
5:22 if the center is at (0,0,0) and the corners have a y value of 1 then the cube will have a "radius" of 1 instead of a diameter of 1, making it not a "unit cube" though, right?
7:04 why not use this version then? it's simpler in both reading and number of math operations used (though it probably won't matter much performance-wise). if you feel fancy you could even write "vertices[i++] = pointOnUnitCube;" ^^
7:35 you could also use 0,1,5 and 5,4,0. that way they'd actually go clockwise and not zig-zag and around again :D
10:00 good call!
Keep 'em coming!
When referring to a "unit" object, most often the measurement of 1 unit in that context is the radius, giving a diameter of 2. A unit circle also has a radius of 1. :)
"Error: Cannot implicitly convert type" on the "directions" index. Mine looks just like the demonstration though.
EDIT: I used parentheses instead of curly brackets. whoops
A quadtree LOD system would be great.
Yup. Not a lot of good info out there. I will post a quad-tree LOD when I finish mine. Programming is a scientific endeavour, yet many horde their knowledge to prevent the masses from profiting from it. That needs to end.
WHA THE BALLS?! I SPENT ALL YESTERDAY DOING EXACTLY THIS!
Finally something to get exited. But I was hoping for it to be the successor for the procedural landmass generation series. But no worries. Lets see how it goes. Cheers
Watched your coding adventures series, decided to take a crack at this. Love your content.
Haha, I used your previous procedural generation tutorials to generate a procedural planet much like this for my final year thesis (with LOD algorithm though). It will be nice to see how I could have improved it by watching this.
It would be great to know how a system for LOD could be implemented efficiently. Mine wasn't very efficient.
Thanks btw.
Always good watching the way you tackle these
Have been looking for a series like this for a long time! Thanks :D
Yes! I have been waiting for this.
Literally abandoned a personal project because I couldn't figure this out.
2021 and this videos still amazing
I follow you long time ago, you are an awesome developer and you have very creative/awesome ideas! Thanks for all!
Thank you, Sabastion Lague, you have no idea how long i've been wating for this seires.
Hello everyone!
To smooth out the seams between meshes, normal vectors of each vertex along the seam need to be averaged out with normals of neighbouring triangles. While this algorithm would probbably give the most precise lighting, it' is very hard for a beginner to design, so let me know if you designed such algorithm. On the other hand, a simple solution is to set the normal vector of each vertex to the vector of it's position normalized. This way, normals along the seams have the same direction and thus give smooth lighting.
Vector3[] SphereNormals(Vector3[] vertices)
{
Vector3[] normals = new Vector3[vertices.Length];
for(int i = 0; i < vertices.Length; i++)
{
normals[i] = vertices[i].normalized;
}
return normals;
}
The solution is very simple, but many people don't notice it right away. I hope it helped.
The vertices are already normalized, aren't they? Couldn't you just assign normals = vertices and be done with it? It's all type Vector3 right? I have no experience with unity and its internal data structure, but it seems reasonable to me.
I'm really looking forward to this series, it seems to have come out at the perfect time for me, thanks.
Love the idea! I'll be waitting for the next episode.
Thank you for the content!
Amazing! Didn't know you made in depth videos like this!
Does anyone else get spammed by the warning of "SendMessage cannot be called during Awake"?
I have what should I do?
@@moonman3658 So far I think whats happening here is that we can't use GameObject functions like SetActive(true) in OnValidate because Unity developers are a little dumb and it potentially leads to "undefined behavior". You need to reorganize OnValidate so it doesn't call any sequence of functions ending up with a GameObject method being called?
my cube just turns black when i turn the res really high then turn it back down... and i get spammed with that warning
For anyone getting this message and their planet looks pink:
In the "Planet" script, line that looks like this:
meshObj.AddComponent().sharedMaterial = new Material(Shader.Find("Standard"));
change "Standard" to "Universal Render Pipeline/Lit"
Explanation: The material name "Standard" is a shader that the Universal Render Pipeline doesn't like to use, so it turns the material shader pink since it isn't compatible. The default material shader normally used is in the Universal Render Pipeline has the name "Universal Render Pipeline/Lit". I'm guessing that this video used an older version of Unity that uses the Legacy shaders.
You are a hero
btw axisA is the same as localRight and axisB is the same as localForward
After correcting errors in the code and writing lines that I skipped I have made some scripts that do absolutely nothing but hey, at least I made some scripts xD
Make sure that your == arnt =
If you have a problem of "flipped normals" just change order of triangle vertecies from clockwise to anticlockwise in TerrainFace.ConstructMesh like this: triangles[triIndex]=i, then =i+resolution, then i+resolution+1.
i didnt understand anything, but you helpd me sleep.
Cool how you just keep building and building on this, and eventually you have what it is now, an entire solar system with atmosphere and gravity and things
Absolutely great, looking forward to the next installment. Excellently presented.
Damn, I really respect people like you. Great work.
0:16 Thaaaat's spherist !
Try adding more realistic gravity, so gravity on the moon is weaker than gravity on the planet, it currently feels a little bit off.
Btw, the planets look beatiful!
Looking for procedural planets tutorial, ended on questioning my programming skill.
I totally agree in learning how to create an sphere out of a Cubr. It's super useful, but I don't understand why you choose to work with a triangle face sphere and not a quad one.
I don't understand why he thinks you have to increase the detail of an icosahedron 4 fold each time. You can turn each of the initial triangles into any value of n^2 smaller triangles, just like he does with the initial faces of the cube, turning it into any number of n^2 smaller squares.
just some advice on this tutorials, when you make a drawing, don't delete it straight away. If you made it to explain a piece of code, wait until you have written that piece of code, and then delete de drawing. It's a really small detail, but I think it's kind of nicer to do it that way, so you can look at the code and at the drawing at the same time.
I do not know 3d game things (not a master at 2d too :D) Im finally made a sphere with resolution setting as you describe in 1 week from zero mesh knowladge and in Godot game engine.I just want to say Thank you please keep up with good work as usual. (Sorry for any mistakes. English is not my native language)
I just did the same but my normals are inverted Did you fix that? (EDIT) Fixed all I has to do was flip the loop x the iterate y
i learned python, and im learning unity and i like totorials for ideas
Thank you for this. Looking forward to follow up episodes.
There should be more chanels like you rather than mainstream chanel which only talk about basic stuff without thinking so much...
SebstianLangue makes me spend 30-60 mins coding this, me afterwards goes onto blender, takes cube, add subdivision modifier, done!
I am so glad that you are making this tutorial series! Thank you so much!
First of all, THANK YOU for your gorgeous detailed and informative tutorials! I, and we, really appreciate that!
I have a question about the Noise-Pattern. Is it possible to have a more "roughly" gradient, so we can form some voxel-inspired world creation? E.g. Cube World's engine (which has been coded in C++, as the Developer, who ran away in 2013 from further developing his game, says...), I love the voxel design and world creation, but think that the noise colorrange won't really fit from the very deep see up to the highest mountain (not the structural objects like actually mountains attached to the surface-mask).
Can you make a small tutorial about that part how to achieve a voxel terrain?
Thank you!
This is useful, thanks. I'm going to look at using this method with an icosahedron base, using 10 bent diamond shapes instead of 6 squares. Should be able to achieve the same flexibility of resolution.
I know it's been a few months but how has this gone for you? I was looking for a tutorial on how to do it this way as well.
Could you place take this series longer than the "basic" stuff. I would love to see a river system that sinks the terrain on it's way to the nearest lake/sea.
like using the unity Standart assets water?
Wow you are so smart and helpful, you rock!
Great vid and narration. I just wanted to ask, I can see that this case with a cube sphere works for small planets that you possibly look on from afar, but what if you want to create a space game with large planets you can fly between and land on. In that case, wouldn't the hexagon approach with a high resolution be easier to work with and look nicer? Just wondering.
Hi Sebastian! Fantastic tutorials and code. Any chance you will update to 2019 versions of Unity. I tried and got lots of problems.
Did you found out how to be able to resize the sphere in the newer Unity version?
yes, YES YESSSSSS, FINALLY, YEARS OF WAITING
How could people downvote this :) Most helpful
Hey Sebastian, For clarity and understanding:
Would axis A be the same as Local Forward and Axis B be the same as Local Right? Would this be always true, sometimes true or never true?
He is back
Why is this not the standard method to mesh a sphere? It looks so much better!
FINALY A TUTORIAL
Fantastic! This was a pleasure to watch! Thanks for putting in the effort into making this!
Welcome back Sebastian :)
great - as always seb :) and this looks to be a nice framework we can go off on a tangent on. Very very useful. Thanks :)
Thanks for the tutorial, i've wanted to do this for months ago
The argument for using Cubic rather than Icosahedral symmetry doesn't make sense. You can subdivide Triangles with exactly the same freedom that you can subdivide Squares, there is no reason that you would be limited to powers of 2. That's like saying you can only divide squares into quarters and sub-quarters.
This is one spicy MESH ball!!! 😂😅😂 Your like a human chatGPT 😊
very nice tutorial series, i'll be looking forward to this :)
FUCK THIS IS COOL
You upload the best videos man, and explain with enough detail
THANK YOU, I have been trying to figure out how to make procedural planets for a while, and boom, your videos and tutorials pop up.... Now two questions, both with a basic premise, do you cover rotation of planets for a day/night cycle and with your solar system for calculation of a year in a game? or can we do this in Unity? Additionally add in weather effects with the planet solar year. like if the position of the planet to its sun and its axis, where we would have summer in the northern hemisphere and winter in the southern hemisphere and vice versa...it would be nice to explore such ideas...
Expected the difficult part to be turning the surfaces spherical, amazed it was just one line of code.
can someone explain me something?. can i create big planets with this method? big enough to don't see the planet curve while walking with the character, build houses, farms and other things?
Yes you can, but it will be very, very, very, very, very laggy if you attempt to do so.
Finally!
Looking forward to this series :)
Nice tutorials man. Thanks alot! Grate start for learning how to work with bigger projects!
Finally, how to make Spore
I'm confused by line 19. Shouldn't axisA be orthogonal to normal vector? Simply swapping the coordinates won't do that though.
If I recall correctly from somewhere that escapes me atm, after some lin alg and simplification, the matrix that rotates the axis by 90 can be simplified down to just swapping the coords of the vector. I think that the trade off is you dont know which direction the line is facing or something like that, but for the purpose of this series, that does not matter.
Very clear explanation, thank you
Very cool. Thanks for this series
Super late to the party, I know.
How easy is it to scale this up? as in, break each face down into smaller 256x256 chunks?
my coding adventure is getting this up and running on a bigger scale, and creating a full planet with logical landforms one day.
Also, thanks for all of your work! you really inspired me to finally delve into programming!
I am terrible with C sharp, I am just following along so I can hopefully learn something.
This might be a bit too much if you are just starting out. But good luck