How to Render MILLIONS of Blades of Grass Efficiently in Godot (godot 3.X)

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 พ.ย. 2024

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

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

    Hi I recently noticed something about the scatter plugin which is pretty important. It seems to store each blade of grasses transform in the scene file, making larger scenes (like the one in my repo) absolutely massive... like over 100MB massive. It is still a great solution for smaller scenes though.
    In other news I saw this new plugin called spatial gardener which is a great solution for larger scenes. I haven't tried it out much yet, but it looks like it has automatic chunking of multi mesh instances and has built in LOD switching as well... It can be used for more than just grass as well, with the demo showing off an entire forest instanced using the plugin. It seems like a really good option and the demo runs smoothly in a large scene, make sure to check it out!
    Link: github.com/dreadpon/godot_spatial_gardener

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

      I was also missing these features from scatter so I decided to make them. The chunking was done a couple months ago and its called split multimesh in scatter. Just yesterday I also created a PR that enables you to not save the transforms of the instances to disk but generate them on the fly when loading the scene so they only live in ram. This obviously means it is only practical in case of modifiers that are quck to generate, like random distribution.
      Separating the chunking to a different thread is a good idea, maybe Ill implement it later! For now, it doesnt seem to impact the game much.
      A nice way to deal with the blocky edge of the chunks is to lower the grass blades in shader by the time they are about to be culled. That leads to a quite nice effect where the grass blends into the texture below it.

  • @thygrrr
    @thygrrr 2 หลายเดือนก่อน +3

    Ace Roller mentioned!

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

    You can speed up the chunking system at the end of the video by using math and hashmaps/dictionaries. Assign each chunk with a chunk position.(0,0),(1,0)... Then keep a small list of all active chunks. (Chunks around the player). So if the player is at global 12.5,5.4 and the chunk size is 10 -> 12.5/10 = 1, 5.4/10= 0 => (1,0). Then get the all chunks with in that area (x+cull ->x -cull,y+cull->y-cull) and update the active map. This way time complexity remains constant (O(1) per chunk and total O(4*(cull**2)). This way you dont need a timer to check for the grass but rather have to check if the players chunk position changed.
    This technically also works for infinite worlds.
    Edit : this should work if i didnt do a thinking mistake.

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

    You can also do it with draw passes. It's quite good for clouds too. You start on the surface of the mesh and put a load of green dots surrounded with alpha. Then in the next pass you raise it a bit and add a little movement. Repeat until you have grass. As long as you're not looking sideways on it looks pretty good and it's dirt cheap.

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

      is there a video of this technique in action?

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

      Isn't that also used for fur in games, also called "alpha shell"

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

      @@danyCD17 yes. It's called shells because usually the dots are an alpha texture on concentric polygonal shells that surround the object.

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

    Just in the past few days someone contributed multimesh splitting to Scatter, so now it will automatically "chunk" the multimesh nodes.

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

      That is super cool! Thanks for letting me know!

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

    The bg music is perfect. I can sit down with a cup of coffee, relax, and listen to your explanation

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

    I like how grass has been one of the most unexpectidly hardest things I've had to do 🤣

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

    Just noticed the description engineering 🤣

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

    Instead of looping through all the grass and cull per timeout, you could do 1 (or more) chunk per frame to smooth it out.

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

      This is true and would be optimal. However I could not be bothered haha. This is the best solution tho

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

    Thanks so much for this great tutorial. This is the kind of tutorials we need in the Godot community. It was so helpful.

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

    Awesome video! Really entertaining on top of being helpful :)

  • @auto7385
    @auto7385 19 วันที่ผ่านมา

    whats the music you used in the intro? Its so beautiful?

  • @user-og6hl6lv7p
    @user-og6hl6lv7p ปีที่แล้ว +3

    You really should be using "distance_squared_to" instead of "distance_to" for this particular scenario. It is even recommended by the documentation if you have read it. Precision doesn't matter because you're just activating/de-activating giant "chunks, you don't need to calculate collision or anything. You will most likely need to scale the resulting value. You should seriously do this straight away, because although it may run well initially, you're gonna have problems when you start adding AI and collision.
    Use "distance_squared_to". Do it.

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

    Excellent video! Thank you!

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

    Subscribed!
    Race to a thousand

  • @sanaysspace
    @sanaysspace 8 หลายเดือนก่อน

    A Short Hike? ❤

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

    raccoons are so cute!

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

    Good video

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

    well made

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

    what's the music in background uwu ?

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

      Mix between animal crossing, Zelda and a short hike in this one!

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

    2018 goty?

  • @Allen-cx6yi
    @Allen-cx6yi ปีที่แล้ว

    where can i get the grass blades?

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

      I just made them in blender, they are also in the github repo in the description.

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

    📌

  • @FriskDreemurr66669
    @FriskDreemurr66669 3 หลายเดือนก่อน

    outdated

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

    Am I first ?

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

      No, that was Neil Armstrong.

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

      No it was yuri gagarin

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

      @@leonstansfield I was going to say we were both wrong and it was Ernest Shackleton but it turns out it was Billy Simmons in third grade behind the bike sheds.

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

    you are almost at 1k! Good job!