Traveling Trees - Explaining My Multimesh Instancer / Godot 4 Tutorial

Поділитися
Вставка
  • Опубліковано 29 вер 2024
  • #godottutorial #godotengine
    Welcome back to my Godot-focused channel! Today's video is a bit different - we're taking a closer look at a script I've been working on - one that utilises MultimeshInstance3D to spawn a bunch of trees around the player and make them follow the player around the world whilst remaining motionless at the same time. You can create infinite forests with this, or infinite anything (it doesn't need to be trees). The vid isn't necessarily a tutorial. It's more like a casual analysis, where I'll explain the thought process behind each line.
    For those of you who love getting into the nitty-gritty of game development, this one's for you. We'll be going through the script step by step, so if you're not into the coding game, you might find it a tad boring. But don't worry, I've got a fun devlog planned for the next video. I'll be introducing a new character - the Tooth Ferry! Stick around for some light-hearted game design fun.
    ===================
    Link to instancer script:
    pastebin.com/z...
    Link to grid creator script:
    pastebin.com/1...
    Link to optimized instancer script (multithreaded):
    pastebin.com/c...
    If asked for a pass code, put 'devmar'.

КОМЕНТАРІ • 75

  • @actualdevmar
    @actualdevmar  11 місяців тому +12

    Aloha! I've optimized the instancer script (see link in video description). In short, the script now packs locations, rotations and scales to Vector3 arrays (which are much faster than 'normal' or 'typed' arrays) and sends those to a separate thread to apply instance transforms. Collisions have got a simple queuing mechanism. Updates are only run when the player moves by a distance that justifies an update. These optimizations have given me a significant performance boost - ca. 30FPS. CPU throttling has been eliminated.

    • @SinisaSpasojevic
      @SinisaSpasojevic 11 місяців тому +1

      Do you really need to generate trees behind the camera as well? Or terrain "flow" can only be for what's in front of camera. Not talking about camera view clipping, rather to generate trees and terrain in different LODs only what is front part of camera near plane. Basically that would cut to half number of instances you generate as player moves around. Am I correct?

    • @ariffirdaus5376
      @ariffirdaus5376 9 місяців тому

      im using an addon to generate terrain, Heightmap Terrain just incase ya heard of it before, but i couldnt export the heightmap of the generated terrain to use with this custom node, what do i do?

    • @calebschmidt3577
      @calebschmidt3577 9 місяців тому

      Thank you for making this! I'm trying to implement this with a heightmap that's using png or exr image file. I find that when I point the script to the image file and reload the scene, no trees are generated. If I click reimport on the image asset, they will pop in. This works great in the editor but when loading the game, it does not work. I've tried looking for a way to trigger a reimport once the scene is loaded, but I haven't found a way. Any ideas on how to fix this?

    • @cjdaylight3407
      @cjdaylight3407 4 місяці тому

      the links are not working

    • @pairless
      @pairless 2 місяці тому

      Can we have an update? it's been 8 months and I was looking forward to this game

  • @willyamcarkey717
    @willyamcarkey717 11 місяців тому +63

    Unity has Sebastian Lague, Godot has Devmar! Great and super professional job! Love your work

    • @mbg4681
      @mbg4681 11 місяців тому +8

      Speaking of, you might enjoy a video by Athillion titled "I Made Sebastian Lague's Procedural Planet In Godot 4".

    • @ДаниилВалов-ж1э
      @ДаниилВалов-ж1э 3 місяці тому

      @@mbg4681 And Martin Donalds videos of course!

  • @ViktorsJournal
    @ViktorsJournal 11 місяців тому

    Hi again, lovely to see another video.
    I'm curious, was this necessary? Godot has auto lod which you can tweak how quickly they swap, it also has frustum culling and distance cullling and such. Was all of that not helpul for this case?

    • @actualdevmar
      @actualdevmar  11 місяців тому +1

      Techniques like this one are meant for scenarios where you have numerous geometries to render that share the same mesh. I mean numerous, as in hundreds or thousands or tens of thousands. Individual mesh nodes become suboptimal over, say, 50 (even with autolod and clipping, which is also quite taxing when you have too many meshes in your scene). In this showcase I have 1000+ trees. No way I'm laying them out manually and updating their positions every few frames.

    • @ViktorsJournal
      @ViktorsJournal 11 місяців тому

      @@actualdevmar Don't things like terrain plugin and scatter and their equivalents in other engines work like that too, painting tons of trees and foliage and so on?

    • @actualdevmar
      @actualdevmar  11 місяців тому +1

      @@ViktorsJournal short answer is no. This is a different technique.

  • @BastiaanOlij
    @BastiaanOlij 11 місяців тому +13

    Very well explained! Two small suggestions: move updating the multimeshes into a thread, and instead of triggering the update at fixed intervals, trigger the update if the player has moved beyond a certain radius of where they were before the last update.

    • @actualdevmar
      @actualdevmar  11 місяців тому +6

      Hey Bastiaan, I'm tinkering a bit to optimize this in case someone needs +10K trees to follow them around. Multithreading is a good suggestion. Indeed, in my implementation I update based on movement and not time. I didn't include this because I felt ppl could easily rewrite that part.

  • @loycross
    @loycross 11 місяців тому +19

    Not easy to follow for someone who hasn't really touched Godot yet, but as a web dev this feels way more useful than most tutorials, with full explanations on how things work and a general review of the code functionality. Great work, honestly.

    • @actualdevmar
      @actualdevmar  11 місяців тому +11

      Thank you. This was not meant to be a tutorial per se. If I were to explain everything from scratch (including what a multimesh is etc etc) the video would be an hour long probably. Instead I decided to share the script and provide a short 'user manual' for it. But yea, one needs to know their way around Godot to find this useful.

  • @Polygarden
    @Polygarden 11 місяців тому +4

    Great tutorial and great use of Multimeshes! I'm actually wondering how much the load of multi meshes is, when you have lots of different tree, grass and stone instances. (if there is a trade-off point when it's better to use normal meshes instead of multimeshes) All in all it's probably much much less nodes with this method. I will be looking into this technique aswell.

    • @actualdevmar
      @actualdevmar  11 місяців тому +4

      There is a tradeoff. If you want occasional trees (which you might, depending on your design) the it will be way more optimal to use individual meshes as you can then also benefit from geometry settings like autoLod or clipping/fading etc. If you look at the gameplay footage here I'm being accompanied by 625 trees total (chunked, so culled by frustum) for which it makes sense to use multimeshes. The scene in the thumbnail has 1225 trees. The other consideration is how tightly clustered your meshes are. If they're clumped together it's usually better to go with multimesh regardless of instance count. If they're dispersed, use a standard mesh.

  • @TheSunriseGames
    @TheSunriseGames 3 місяці тому +1

    where are you? come back, it's been 7 months.. we need updates

  • @noiJadisCailleach
    @noiJadisCailleach 10 місяців тому +1

    Quick question: Why pastebin, and not github?

  • @SCP6820
    @SCP6820 9 місяців тому +2

    i love how dark this game looks

  • @zikaura
    @zikaura 11 місяців тому +1

    Babe wake up, devmar just dropped

  • @superschizoscriptures
    @superschizoscriptures 15 днів тому

    fantastic implementation!!!! over and over I have wondered how far you could go just by instancing things centralized around the player like this. beautiful :)

  • @ryant2389
    @ryant2389 11 місяців тому +3

    This is fantastic! So awesome to see practical implementation of lod and object instancing/culling in Godot. Thanks for demoing your process.

  • @vertexdune
    @vertexdune 9 днів тому

    thank you for making this code open source, you are helping a lot of aspiring developers make their game look beautiful

  • @errorhostnotfound1165
    @errorhostnotfound1165 11 місяців тому +1

    Maybe he could make playlists for each of the different sets of videos (one for the main devlog, one for the tutorials, ones for the other devlog(s) series)

  • @makebreakrepeat
    @makebreakrepeat 11 місяців тому +2

    I actually really appreciate the code deep dive. You're giving me lots of ideas and the confidence to code them in my own projects.

  • @squarerootof2
    @squarerootof2 11 місяців тому +1

    The Tooth Ferry sounds creepy awesome. I'm sure it won't disappoint. I'll be waiting for that.

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

    Super useful content man. Love these videos, truly.

  • @cprn.
    @cprn. 10 місяців тому

    Hmm. Am I correct into thinking the right approach to cutting trees then would be to use a second texture that marks where a player cut the tree so that the shader wouldn't spawn there? This way I could use a timer to modify that "don't-spawn-here" texture's pixels over time to reflect re-growing (i.e. scaling the particles). Or am I overthinking this?
    Also, yes, very useful content. Although, I'd prefer it in C# simply because I feel like it'd give a more CV-ready skill. It's not hard to write C# looking at GD, though.
    And I came here because the boss fight demo... Cool as f**k.

  • @bertilorickardspelar
    @bertilorickardspelar 11 місяців тому +1

    A big thank you for all the hard work. I've known that Godot will be big since 2017. It just needs a few more solutions in videos like this to truly reach its potential. If they get a marketplace for paid assets going that will really help.
    Oh, by the way. When you do things like this you should really setup a patreon or something similar so we can show some love.

  • @RexSacriticulus
    @RexSacriticulus 11 місяців тому +1

    Evidently, you have attempted to make your video 13 minutes and 37 seconds long.

  • @envymak2254
    @envymak2254 Місяць тому

    We need a way longer and more detailed tutorial

  • @cjdaylight3407
    @cjdaylight3407 6 місяців тому

    I wonder how you gonna implement produceal roads lakes and other things but I think this game already ready to go to steam

  • @portalpony477
    @portalpony477 5 місяців тому

    13:36 One second longer video and it would be perfect

  • @elchippe
    @elchippe 11 місяців тому

    Wow and all made in GDScript, no C# or C++, GDScript.

  • @thFaust
    @thFaust 11 місяців тому +1

    Great Video, man. I think the code explantation wasn't boring at all! I don't like watching people code live on stream or things like that, but a concise explanation like that, I'd watch any day of the week. :-)

  • @GarmrNL
    @GarmrNL 11 місяців тому +1

    I started playing with the 3D side of Godot a while ago and stumbled on your content while looking for terrain stuff. Went on a binge and subscribed; I really like the way you explain things and especially the “why” 😄

  • @aguest5394
    @aguest5394 9 місяців тому

    mur godot awesome tutorials please and thank you!

  • @Thomas_Lo
    @Thomas_Lo 11 місяців тому +1

    keep it at this detail level. people will wanna try to build something similar and may lack the understanding in certain parts to be able to do it.

  • @fridyrogide8752
    @fridyrogide8752 11 місяців тому +1

    Really interesting technique ; quite advanced for a beginner like me hehehhehe

  • @aomadeira
    @aomadeira 11 місяців тому +1

    Everytime you release a new video you convince people of how capable Godot is to make amazing and stunning games, your content is truly amazing! Thank you!

  • @Marandal
    @Marandal 4 місяці тому

    Oooo an epic tutorial on godot instancing

  • @RaveYoda
    @RaveYoda 11 місяців тому

    Love the code breakdown!!
    Edit: I wish you would breakdown how you do the IK stuff too as that has been challenging for me to get working right.

  • @feidev
    @feidev 10 місяців тому +1

    This is solid, do you have a discord?

    • @actualdevmar
      @actualdevmar  10 місяців тому

      not yet

    • @feidev
      @feidev 10 місяців тому

      Gotcha! Whenever you create, i will be there@@actualdevmar

  • @andreasng
    @andreasng 5 місяців тому

    This is magic! 😢😢

  • @yeroboersma4845
    @yeroboersma4845 11 місяців тому +1

    i left a comment on the water lvl vid, its what i think could be a good boss and welp, that

    • @actualdevmar
      @actualdevmar  11 місяців тому

      Im definitely doing a crab boss. It's been on my list for a while.

  • @thesleepyfox3295
    @thesleepyfox3295 11 місяців тому

    Hey, Devmar, been a big fan of your work since watching your wandering clipmap vid a year ago!
    One thing that's always perplexed me though is why you always use square grids for clipping. Don't you end up with a whole lot of wasted detail at the corners and detail-distance missmatch when looking along an edge towards a corner?
    I tried a more circular wandering mesh (while still using square cells if that makes sense) in blender and got much better results, just wondering if there is a reason you don't do something similar in Godot.
    Keep up the amazing work, you're a true inspiration! 👍

  • @MangaGamified
    @MangaGamified 11 місяців тому

    Really good example, As an enjoyer of Horror games channels like Coryxkenshin & Peenoiseplays , it got that horror puzzle game vibe. You should use more horror if not creepy themes, no one complains about the graphics of horror games.

  • @goldenbuster493
    @goldenbuster493 11 місяців тому

    Found out about you 10 mins ago with the mower video, AND I'M INVESTED AS HECK

  • @Carson.Rhodes
    @Carson.Rhodes 11 місяців тому

    How come you use GD script instead of C#. Have you found any benefits of either with your "stress tests" of games, lol. Brilliant work! keep it up!

  • @jakem6120
    @jakem6120 11 місяців тому

    Heck yeah..thanks devmar...i wonder for the longest time when u will release this when i first saw ur videos... 🙏 Thanks

  • @bsangel1276
    @bsangel1276 6 місяців тому

    im new to godot and i didnt understand a shit, but you make it look so easy, found this video beacause wanted to learn about MultiMeshInstance and found something even better, what i can understand is that somehow you save resources by only loading what you need, cool,

  • @generrosity
    @generrosity 11 місяців тому

    If you enjoy doing this depth of video, keep doing it! Interesting topic - sparks ideas (and confirms some thoughts on gpu instances and multimesh) even tho I'm personally far far away from using them

  • @Alpha_GameDev-wq5cc
    @Alpha_GameDev-wq5cc 11 місяців тому

    Love this tutorial-esque style, I’m learning UE5 but a total beginner so this is still so intriguing and educational!

  • @mbg4681
    @mbg4681 11 місяців тому

    I've been following your project for two years. It's awesome to see it keep evolving and getting better! Keep up the awesome work! 👍

  • @Inferryu
    @Inferryu 11 місяців тому

    It is VERY usefull, thank you for it.

  • @somedude5951
    @somedude5951 11 місяців тому

    Great video. Thank you.

  • @neozoid7009
    @neozoid7009 11 місяців тому

    I was soo hyped to watch your videos

  • @frogguygame
    @frogguygame 11 місяців тому

    this is rad, it's almost exactly what I was trying to get out of some other addons/strategies.
    Is it ok to use this as a basis for my own project? Is it ok to use this as a basis for a more generalized/fleshed out addon? Credit will be given, of course.

  • @fafo_o
    @fafo_o 11 місяців тому

    THANK YOU THIS IS COOL AF

  • @DodgerEcho
    @DodgerEcho 11 місяців тому

    This super video 👍👍👍

  • @Zurpanik
    @Zurpanik 11 місяців тому

    Freaking rad!

  • @ITHINKTHTSDON
    @ITHINKTHTSDON 4 місяці тому

    Bro can you mentor me on Godot I’ve been using it for some weeks and don’t have any dev experience but I have been doin research but to no avail I have this huge game idea I have everything ready just can’t make it cuh idk what I’m doin in the game engine nor coding I truly believe my game will change the gaming industry TRULY!

  • @wherearemypants2213
    @wherearemypants2213 5 місяців тому

    Been a while since your last upload. Hope you alright.
    Cheers

  • @ThotTee
    @ThotTee 11 місяців тому

    If you write the multimesh packedarray data of positions, that is much faster than write the whole transform data with set_transform. The difference is a lot of fps.

    • @ThotTee
      @ThotTee 11 місяців тому

      I created a new data array from the current data, and i modified the important datas in there. After this i put it back to multimesh once in the and of process. I just modified the position values. I didn't test it with scale or rotation. At 50k meshes i got 70 fps instead of 40 with this way.

    • @actualdevmar
      @actualdevmar  11 місяців тому

      I tried this with data arrays but saw no benefit. You still have to create the arrays on each update so you can read back from them. Also you'd have to do it 3 times on each update to create arrays for pos, rot and scale. Those are extra steps which add up in the end.

    • @ThotTee
      @ThotTee 11 місяців тому

      @@actualdevmar I didn't test that if i write the full of array (pos,rot,scale) that has a benefit. I just wrote positions. But you don't need read that array 3 times, i think. It's a matrix4 array. Just you need put the new values correctly once in every update.

    • @ThotTee
      @ThotTee 11 місяців тому

      Maybe the reason of better performance was i wrote just the positions, and it is less oprations than set all values with set_transform. Idk.