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

Поділитися
Вставка
  • Опубліковано 29 чер 2024
  • In this video, I discuss how the godot engine can render millions of blades of grass efficiently using multiple techniques and plugins. We explore how GPU instancing, multi mesh instancing, particle shaders and the scatter plugin works, similar to Breath of the Wild in Godot
    This is a Godot tutorial not Brackeys 2022.1 game jam indie devlog It is an indie game devlog tutorial with indie games like Breath of the wild 2. Godot is a open source game engine like unity and Godot tutorial how much money did my indie game make!? it is a game made by 1 person - a solo devlog! This indie game unity devlog is a unity 3D tutorial devlog. Godot
    Grass project files:
    github.com/LeonStansfield/god...
    The grass shader I used:
    godotshaders.com/shader/styli...
    Acerolas grass series:
    • How Do Games Render So...
    Follow me on Twitter:
    / leonstansfield0
    And check out the game on Itch.io:
    leon-stansfield.itch.io/
    Don't forget to like and subscribe if you liked the video!
    ua-cam.com/channels/Myg.html...
  • Ігри

КОМЕНТАРІ • 37

  • @leonstansfield
    @leonstansfield  2 роки тому +52

    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 Рік тому +3

      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.

  • @psuw
    @psuw Рік тому +28

    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 роки тому +44

    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 Рік тому +17

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

    • @leonstansfield
      @leonstansfield  Рік тому +6

      That is super cool! Thanks for letting me know!

  • @Uwishiii
    @Uwishiii 2 роки тому +3

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

  • @boerbol9422
    @boerbol9422 Рік тому +1

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

  • @avivshvitzky2459
    @avivshvitzky2459 Рік тому +2

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

  • @AnnCatsanndra
    @AnnCatsanndra 7 місяців тому

    Excellent video! Thank you!

  • @ThiccestMayo
    @ThiccestMayo 2 роки тому

    you are almost at 1k! Good job!

  • @HeyItsDoodler
    @HeyItsDoodler 2 роки тому +4

    Just noticed the description engineering 🤣

  • @HeyItsDoodler
    @HeyItsDoodler 2 роки тому

    Subscribed!
    Race to a thousand

  • @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

  • @warsin8641
    @warsin8641 9 місяців тому +1

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

  • @lecloutpanda
    @lecloutpanda 2 роки тому

    well made

  • @narrenschlag
    @narrenschlag 2 роки тому +1

    Good video

  • @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.

  • @sanaysspace
    @sanaysspace 3 місяці тому

    A Short Hike? ❤

  • @Aragubas
    @Aragubas Рік тому

    raccoons are so cute!

  • @yudi8204
    @yudi8204 2 роки тому

    📌

  • @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!

  • @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.

  • @sakamotoshinonome
    @sakamotoshinonome 2 роки тому +3

    Am I first ?

    • @davidmurphy563
      @davidmurphy563 2 роки тому +3

      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.