Traveling Trees - Explaining My Multimesh Instancer / Godot 4 Tutorial

Поделиться
HTML-код
  • Опубликовано: 17 окт 2023
  • #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/zSgkTkHb
    Link to grid creator script:
    pastebin.com/1pbHfqHf
    Link to optimized instancer script (multithreaded):
    pastebin.com/crsLyHph
    If asked for a pass code, put 'devmar'.
  • ИгрыИгры

Комментарии • 72

  • @actualdevmar
    @actualdevmar  9 месяцев назад +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 9 месяцев назад +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 7 месяцев назад

      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 7 месяцев назад

      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 2 месяца назад

      the links are not working

    • @pairless
      @pairless 23 дня назад

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

  • @willyamcarkey717
    @willyamcarkey717 9 месяцев назад +55

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

    • @mbg4681
      @mbg4681 9 месяцев назад +6

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

    • @user-ub4hw4zo8s
      @user-ub4hw4zo8s Месяц назад

      @@mbg4681 And Martin Donalds videos of course!

  • @loycross
    @loycross 9 месяцев назад +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  9 месяцев назад +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.

  • @BastiaanOlij
    @BastiaanOlij 9 месяцев назад +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  9 месяцев назад +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.

  • @rje613
    @rje613 7 месяцев назад +1

    Super useful content man. Love these videos, truly.

  • @mbg4681
    @mbg4681 9 месяцев назад

    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! 👍

  • @ryant2389
    @ryant2389 9 месяцев назад +3

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

  • @makebreakrepeat
    @makebreakrepeat 9 месяцев назад +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.

  • @Alpha_GameDev-wq5cc
    @Alpha_GameDev-wq5cc 9 месяцев назад

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

  • @GarmrNL
    @GarmrNL 9 месяцев назад +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” 😄

  • @thFaust
    @thFaust 9 месяцев назад +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. :-)

  • @aomadeira
    @aomadeira 9 месяцев назад +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!

  • @neozoid7009
    @neozoid7009 9 месяцев назад

    I was soo hyped to watch your videos

  • @bsangel1276
    @bsangel1276 4 месяца назад

    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,

  • @jakem6120
    @jakem6120 9 месяцев назад

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

  • @generrosity
    @generrosity 9 месяцев назад

    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

  • @squarerootof2
    @squarerootof2 9 месяцев назад +1

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

  • @bertilorickardspelar
    @bertilorickardspelar 9 месяцев назад +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.

  • @SCP6820
    @SCP6820 7 месяцев назад +2

    i love how dark this game looks

  • @goldenbuster493
    @goldenbuster493 9 месяцев назад

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

  • @RaveYoda
    @RaveYoda 9 месяцев назад

    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.

  • @zikaura
    @zikaura 9 месяцев назад +1

    Babe wake up, devmar just dropped

  • @Thomas_Lo
    @Thomas_Lo 9 месяцев назад +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.

  • @Marandal
    @Marandal 2 месяца назад

    Oooo an epic tutorial on godot instancing

  • @fafo_o
    @fafo_o 9 месяцев назад

    THANK YOU THIS IS COOL AF

  • @somedude5951
    @somedude5951 9 месяцев назад

    Great video. Thank you.

  • @aguest5394
    @aguest5394 7 месяцев назад

    mur godot awesome tutorials please and thank you!

  • @Inferryu
    @Inferryu 9 месяцев назад

    It is VERY usefull, thank you for it.

  • @Polygarden
    @Polygarden 9 месяцев назад +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  9 месяцев назад +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.

  • @thesleepyfox3295
    @thesleepyfox3295 9 месяцев назад

    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! 👍

  • @TheSunriseGames
    @TheSunriseGames Месяц назад +1

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

  • @DodgerEcho
    @DodgerEcho 9 месяцев назад

    This super video 👍👍👍

  • @fridyrogide8752
    @fridyrogide8752 9 месяцев назад +1

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

  • @andreasng
    @andreasng 3 месяца назад

    This is magic! 😢😢

  • @Zurpanik
    @Zurpanik 9 месяцев назад

    Freaking rad!

  • @errorhostnotfound1165
    @errorhostnotfound1165 9 месяцев назад +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)

  • @MangaGamified
    @MangaGamified 9 месяцев назад

    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.

  • @cprn.
    @cprn. 8 месяцев назад

    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.

  • @Carson.Rhodes
    @Carson.Rhodes 9 месяцев назад

    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!

  • @frogguygame
    @frogguygame 9 месяцев назад

    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.

  • @ViktorsJournal
    @ViktorsJournal 9 месяцев назад

    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  9 месяцев назад +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 9 месяцев назад

      @@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  9 месяцев назад +1

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

  • @cjdaylight3407
    @cjdaylight3407 4 месяца назад

    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 3 месяца назад

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

  • @ThotTee
    @ThotTee 9 месяцев назад

    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 9 месяцев назад

      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  9 месяцев назад

      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 9 месяцев назад

      @@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 9 месяцев назад

      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.

  • @noiJadisCailleach
    @noiJadisCailleach 9 месяцев назад +1

    Quick question: Why pastebin, and not github?

  • @feidev
    @feidev 9 месяцев назад +1

    This is solid, do you have a discord?

    • @actualdevmar
      @actualdevmar  9 месяцев назад

      not yet

    • @feidev
      @feidev 9 месяцев назад

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

  • @yeroboersma4845
    @yeroboersma4845 9 месяцев назад +1

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

    • @actualdevmar
      @actualdevmar  9 месяцев назад

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

  • @elchippe
    @elchippe 9 месяцев назад

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

  • @ITHINKTHTSDON
    @ITHINKTHTSDON 2 месяца назад

    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!

  • @RexSacriticulus
    @RexSacriticulus 9 месяцев назад +1

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

  • @wherearemypants2213
    @wherearemypants2213 3 месяца назад

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