Level Of Detail Planets in Unity #1 | Quadtrees and basics | Programming Projects 1.0

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ม.ค. 2025
  • Ever wonder how those big planets seen in games like KSP and No Man's Sky don't destroy your framerate? It's quite difficult to do, but here is how I did it using a quadtree.
    Github: github.com/Hol...
    Sebastian Lagues video on Procedural Planets: • [Unity] Procedural Pla...
    Inspired by: • [Unity] Procedural Pla...
    Background music is Four Seasons by Vivaldi
    Broll by @Justinodisho www.justinodisho.com

ความคิดเห็น • 68

  • @archeroliver6078
    @archeroliver6078 5 ปีที่แล้ว +10

    Holy Cow, I've been searching for Generated Planet using quadTree. Good tutorial, keep going and I will definitely be following!

  • @ethanhermsey
    @ethanhermsey 5 ปีที่แล้ว +4

    Hey! Thank you for this explanation.
    I've had some trouble implementing a LOD system into an octree, there were some great points in this video that helped me a lot :D

  • @DerkJanSpeelman
    @DerkJanSpeelman 4 ปีที่แล้ว +8

    It might sound weird, but your voice and the background music combined provide for a relaxed, but very informative video, thank you!

  • @НиколайШироков-т7л
    @НиколайШироков-т7л หลายเดือนก่อน

    Thanks for the content! How to ensure, that LOD difference between neighboring quadtree patches not greater than 1 ?

  • @ThoughtsOrange
    @ThoughtsOrange ปีที่แล้ว +2

    Why do you have two sizes (Radius and Planet.size)? I checked your GitHub scripts and, in the terrainFace constructor, you input planet.size as the radius. In some places you use planetscript.size and in other places you use "radius". Is there something I don't see or you can completely get rid of radius?

    • @quartzar
      @quartzar ปีที่แล้ว

      He has a weird implementation of setting the base Planet Radius manually so it can be used after he makes new child Chunks, passing in half of the Planet radius (or previous Chunk radius) each time. It's not a good way of doing it.
      I just made a variable in Planet.cs called size (so it's hard to confuse with the radius parameter that gets halved repeatedly), and set it to the Planet Radius setting in Initialise().

  • @JeanLuemusic
    @JeanLuemusic 2 หลายเดือนก่อน

    Increase the details based on player proximity. Also can be achieved with camera rendering

  • @Chevifier
    @Chevifier 2 ปีที่แล้ว +3

    So glad I learn about and created a quadtree in 2D this is so much easier to understand now. But I dont use Unity.

    • @nickgennady
      @nickgennady 2 ปีที่แล้ว +1

      I actually use Unity for research and development as it’s much faster for that than most things for that. I than move it over to Unreal when I get good understanding of topic(current platform of choice). Most recent example was actually just few past days. I implemented a solar system and using Newtons physics and real world sun and planet values (had to simulate whole thing using doubles). I just finished porting to unreal.

  • @ayoubbelatrous9914
    @ayoubbelatrous9914 ปีที่แล้ว +3

    i really like when tutorials give you the source code

  • @NeoShameMan
    @NeoShameMan 4 ปีที่แล้ว +3

    "instead of making multiple one"
    the office NO .gif
    dark vader NO .gif
    the scream .jpg

  • @realdka13
    @realdka13 3 ปีที่แล้ว +2

    If youre still watching these comments, just from the code in this video, why is the size change so finicky? It only seems to work at an editor size of 10 and a script size of 1. Anything else and I just get crazy weird spiky geometry, usually pretty huge as well.

    • @simonholmqvist1951
      @simonholmqvist1951  3 ปีที่แล้ว

      Hello! Unfortunately, I don't quite understand your question. I've been busy with school the last couple of months and have not worked on the planet, so I've become a bit unfamiliar with my own work haha. Could you specify what you mean by "editor size" and "script size", perhaps by leaving a timestamp to when this is shown in the video?

    • @ThoughtsOrange
      @ThoughtsOrange ปีที่แล้ว

      I have the same question. When you refer to the editor size, you mean the one in shapeSettings?

  • @platoathens7583
    @platoathens7583 3 ปีที่แล้ว +2

    Hi, i've got my version of this implemented and it works except for one part. I'm having issues with the distance check between player position and the current node position. I believe it has something to do with the node position not being in world space while the player position is, resulting in wrong parts of the sphere having increased resolution. Any tips?

    • @simonholmqvist1951
      @simonholmqvist1951  3 ปีที่แล้ว +1

      Hi! I'd suggest either converting the node positions to world space or the player position to local space. Also, be careful and use the right position. It is very easy to accidentally use the non-spherified positions, which would give incorrect distances. There is also the option of working with bounding boxes instead of radial distances, but that might not fix your problem. Good luck!

  • @abdurahmanayesha608
    @abdurahmanayesha608 2 ปีที่แล้ว

    I implemented LOD for my planets but it seems to show only the top right corner if I get closer to the planet. For some reason It starts to work if I am closer to the planet at the exact radius.

  •  4 ปีที่แล้ว +2

    Which is the best method: recreate the face meshes always (the 6 sides) or create multiple meshes when dividing the face meshes?

  • @iclosed7932
    @iclosed7932 5 ปีที่แล้ว +2

    Thank you so much for sharing ideas.

  • @polyk302
    @polyk302 4 ปีที่แล้ว

    when I try Implementing your things into my project when I press play nothing shows up

  • @chocolatemilk9036
    @chocolatemilk9036 3 ปีที่แล้ว +3

    is there a repository for just this part of the series instead of the whole thing

    • @simonholmqvist1951
      @simonholmqvist1951  3 ปีที่แล้ว

      No, unfortunately. You can, however, look at old commits. The files you are looking for were published on October 3 2019, so just click on the "commits" text and scroll to the bottom :)

  • @gaschneidr
    @gaschneidr 5 ปีที่แล้ว +3

    Nice video and explanation, thank you! If you wanted to place assets on the planet surface and make the player walk around it, what other things would you have to consider and implement?

    • @simonholmqvist1951
      @simonholmqvist1951  5 ปีที่แล้ว +2

      For player movement you would need a faux gravity system so that you don't fall off the planet, as well as a collider for the terrain. The collider doesn't have to be as detailed as the mesh though. Placing assets could be a bit tricky because you don't want to place something like a tree somewhere where the less detailed mesh could cover it. The best solution might be to not render the trees at all until the difference between the current lod and the max lod wouldn't change the ground height by more than one meter. Assets like skyscrapers however could be rendered before that because they are clearly visible even when the ground rises by 5 meters.

    • @gaschneidr
      @gaschneidr 5 ปีที่แล้ว

      @@simonholmqvist1951 I was thinking that assets could be rendered only in certain levels of details from the LOD, or maybe for skyscrapers and big things like that there could be less detailed versions of the assets. Would something like that work?

    • @simonholmqvist1951
      @simonholmqvist1951  5 ปีที่แล้ว +1

      @@gaschneidr Yes, that would definitely work! A lot of games do that, like fortnite for example. For things like trees, you could just have a low, mid and high detail version instead of a complex lod script since such a small mesh wouldn't take up much memory at all.

    • @gaschneidr
      @gaschneidr 5 ปีที่แล้ว +1

      @@simonholmqvist1951 yes, it makes sense! I was looking around on youtube and it seems some developers also make like a transition from the sphere planet to a plane map instead. Would you say it is a better solution than to implement the faux gravity system and all that?

    • @simonholmqvist1951
      @simonholmqvist1951  5 ปีที่แล้ว +1

      @@gaschneidr I'd say it depends on the game. I think KSP uses a faux gravity system, which is fitting because that game is all about the physics and thus the most realistic option would probably be the best, given that the performance is acceptable. However, a game that focuses less on the transition from atmosphere to space might benefit from not having a faux gravity system. They would still have to replecate some properties of a sphere though, like being able to walk around it forever without hitting a world border.

  • @darkstormheute
    @darkstormheute 3 ปีที่แล้ว

    Hello, have you any tips to generate plants (i maybe will have plant generator)? I know it isn't your specialization, but maybe you have a way

    • @simonholmqvist1951
      @simonholmqvist1951  3 ปีที่แล้ว

      Hi! It depends a lot on which type of plant you want to generate. The following video describes one way of generating branches th-cam.com/video/094y1Z2wpJg/w-d-xo.html. You can create the mesh like this: First create a skeleton of the plant, for example by placing points connected together with lines. Then place a ring of vertices at each point so that the surface of the ring points towards the next or previous point. Lastly, connect the vertices of different rings with triangles. By doing this and decreasing the size of the rings the further away they are from the root you get something that resembles a plant.

    • @darkstormheute
      @darkstormheute 3 ปีที่แล้ว

      @@simonholmqvist1951 thanks

  • @Mr.Epsilion
    @Mr.Epsilion 5 ปีที่แล้ว +1

    *Guys, I need help with abyss of oceans, how do I make it's idea on the planet? (I'm develop a game tps diving)*

    • @simonholmqvist1951
      @simonholmqvist1951  5 ปีที่แล้ว +1

      I'd suggest you create two "planets", one for the water and one for the ocean floor. You'll probably need to fix the cracks that appear with the current version of the planet too, which I will adress in my next video :)

  •  3 ปีที่แล้ว +1

    I'm trying to develop my own LOD system and I have a problem with it: sometimes chunks have other chunk neighbours where subdivision level difference is greater than 1. Did you manage this problem or your distance calculation or appropriate distance limit values for each levels solved it?

    • @simonholmqvist1951
      @simonholmqvist1951  3 ปีที่แล้ว +1

      Yes, I set the LOD distance limits so I never have that problem. You'll have to do some testing yourself to see what settings suit your needs, but the default values should be good enough (scaled according to the size of your planet, of course).

  • @impsycheer
    @impsycheer 4 ปีที่แล้ว +2

    Can you make tutorial for finished project of procedural generated planets? :)

    • @simonholmqvist1951
      @simonholmqvist1951  4 ปีที่แล้ว

      I don't think I will be able to make a meaningful tutorial on everything that goes into creating the planet. This is pretty advanced stuff by my standards, so I think that the people who will be able to understand and use this planet are the types of people who will know how to write the code if they grasp the underlying concepts, which I explain in my videos. I am, however, working on implementing the planet into a game that I'm making, which means that I will have to improve it further. When I create something worth posting, I will make another video :)

    • @impsycheer
      @impsycheer 4 ปีที่แล้ว

      @@simonholmqvist1951 But I mean make video like this but for Sebastian's full project of generated planet, cause first and last part ofplaylist is so different in code... and idk where to implement all this stuff and what was what :D and zour video is only one on youtube which was able to make this so easy and good... but with changed code is only inspiration how to make :/ at least for me

    • @simonholmqvist1951
      @simonholmqvist1951  4 ปีที่แล้ว

      @@impsycheer Ah, okay! So if I understand you correctly, you want a video in the same style as this one but for Sebastians finished planet? There are some major differences between his planet and mine. Sebastian's planet is only meant to be viewed from far away, whereas the player is supposed to be able to land and walk around on mine. If you want me to explain his way of doing things, then I'd have to contact him to make sure that he's okay with it. Besides, I'm pretty busy with school and working on my own planet. I will see what I can do, but that type of video will probably not be posted in the near future. It's an interesting project though, for sure :)

    • @impsycheer
      @impsycheer 4 ปีที่แล้ว

      @@simonholmqvist1951 Have you discord or something? For better communication about some things...

    • @simonholmqvist1951
      @simonholmqvist1951  4 ปีที่แล้ว

      ​@@impsycheer discord.gg/TH97tD

  • @brodakarat6340
    @brodakarat6340 2 ปีที่แล้ว

    is there any reason to having the 6 faces as seperate objects as opposed to all one mesh? is it more or less performant to have multiple objects?

    • @unigolde
      @unigolde ปีที่แล้ว

      you have 6 faces because it's a lot simpler to generate planes through a script and then to create a cube throught that, then vector normalizing the vertices to get a sphere. It is less performant to have to multiple objects.

  • @vladimir4663
    @vladimir4663 4 ปีที่แล้ว

    Hi, great video.
    Can you tell me how did you set settings to show wireframe on unselected objects in scene (while explaining you moved Player and wireframe on Planet was visible). When i select something other then Planet i don't see wireframe anymore.

    • @simonholmqvist1951
      @simonholmqvist1951  4 ปีที่แล้ว

      In the top-left corner of the scene view, there is a button that probably has the text "Shaded" for you. Click it, and select "Shaded Wireframe" from the dropdown.

    • @vladimir4663
      @vladimir4663 4 ปีที่แล้ว +1

      @@simonholmqvist1951 Thx for the reply.
      For anyone having trouble with something similar, try different unity version or different pipeline (for me HDRP, unity 2019.1 broke wireframe, shaded was working in scene but wireframe was created On Object Select so it would delete itself once that object was deselected).

    • @simonholmqvist1951
      @simonholmqvist1951  4 ปีที่แล้ว

      @@vladimir4663 I'm happy to hear that you got it working!

  • @mauroabidalcarrer4083
    @mauroabidalcarrer4083 4 ปีที่แล้ว

    Hi, awsemoe video!
    I was wandering, how do you manage to update the quad trees now tht the player can move in 3d space, do you check if the distance between a quad and the player surpasses a certain treshold?
    It seems pretty expensive to do on every frame.
    Again, awesome video.

  • @RegulusFen
    @RegulusFen 5 ปีที่แล้ว

    A Thanks for this, The planet script goes on the planet but where do the other two go? I can see wireframe but its not changing, I know there has to be more than just dropping the planet script onto the planet

    • @simonholmqvist1951
      @simonholmqvist1951  5 ปีที่แล้ว +1

      The TerrainFace script is added automatically by the Planet script, so you should not add that to any object manually. The Presets script can be applied to any object that you want since its variables are static. I've put it on an empty GameObject :)

    • @RegulusFen
      @RegulusFen 5 ปีที่แล้ว

      @@simonholmqvist1951 I am really digging this but I just cannot seam to get it to generate geometry when moving the Camera, I have an Empty tagged as Player parented to the camera, preset script on the Player (empty) and of course Planet.cs on the sphere, with the player transform set to the player empty, sorry for being dense and I do Thank you. I am watching over this video again... okay , after further investigating I was not zoomed out far enough, this is so interesting, Thank you, I do hope you have great success and many wishes come true, I hope you continue to develop this!

    • @simonholmqvist1951
      @simonholmqvist1951  5 ปีที่แล้ว +1

      @@RegulusFen Thank you so much for your kind words! Just so I understand things correctly, does it all work now?

    • @RegulusFen
      @RegulusFen 5 ปีที่แล้ว

      @@simonholmqvist1951 Yes Sir, it is working as intended. now I need to figure out how to implement it, do I just add a texture and a normal map? I am new to Unity and C# I never thought I would like trying to understand Code but you have my interest Peaked - Just a hobbyist, Thank you!

    • @simonholmqvist1951
      @simonholmqvist1951  5 ปีที่แล้ว

      @@RegulusFen ​ Otto That is what I'm working on at the moment, which means that it will be the topic of the next video! Textures can be applied using either a cylindrical unwrapping of the sphere or a technique called triplanar mapping.

  • @rickb6476
    @rickb6476 5 ปีที่แล้ว +2

    Great video! I'd love to look at more of the changes to code you made! Do you upload these projects to Github or anything?

    • @simonholmqvist1951
      @simonholmqvist1951  5 ปีที่แล้ว +4

      Oh yes, I have! I've added it to the description now, but I'll leave a link here too: github.com/Didgeridooblastblock/LOD-Planets-in-Unity

    • @rickb6476
      @rickb6476 5 ปีที่แล้ว +2

      @@simonholmqvist1951 Wonderful! Thanks! Can't wait for more videos! :D

  • @Кирилл-с3п9у
    @Кирилл-с3п9у 2 ปีที่แล้ว

    you best, thanks for video and i want to try it. I try to do it alone, but my quadtree not the best)

  • @theothercreare
    @theothercreare 4 ปีที่แล้ว +1

    Can I use this for my space game? Ill give appropriate credit, if and how u want.
    Edit: just read the License.txt and from what I read I have full access to the code, credit free. Am I right?

    • @simonholmqvist1951
      @simonholmqvist1951  4 ปีที่แล้ว +1

      Thank you for asking Ben! You can absolutely use this code. I'd, of course, appreciate it if you credited me, but it's not a requirement. If you wish to credit me, you can mention my full name (Simon Holmqvist) somewhere it's visible.

    • @theothercreare
      @theothercreare 4 ปีที่แล้ว +1

      @@simonholmqvist1951 Ok thank you soo much :)

  • @ChronischeDepressie
    @ChronischeDepressie 4 ปีที่แล้ว

    Assets/TerrainFace.cs(61,20): error CS1525: Unexpected symbol `['

  • @xKeray
    @xKeray 3 ปีที่แล้ว

    unity sucks, do plain opengl