Traveling Trees - Explaining My Multimesh Instancer / Godot 4 Tutorial

  Рет қаралды 18,315

devmar

devmar

9 ай бұрын

#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 ай бұрын
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 8 ай бұрын
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 6 ай бұрын
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 9 күн бұрын
Can we have an update? it's been 8 months and I was looking forward to this game
@willyamcarkey717
@willyamcarkey717 9 ай бұрын
Unity has Sebastian Lague, Godot has Devmar! Great and super professional job! Love your work
@mbg4681
@mbg4681 9 ай бұрын
Speaking of, you might enjoy a video by Athillion titled "I Made Sebastian Lague's Procedural Planet In Godot 4".
@user-ub4hw4zo8s
@user-ub4hw4zo8s 27 күн бұрын
@@mbg4681 And Martin Donalds videos of course!
@loycross
@loycross 9 ай бұрын
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 ай бұрын
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 ай бұрын
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 ай бұрын
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 ай бұрын
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 ай бұрын
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 ай бұрын
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 8 ай бұрын
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” 😄
@aomadeira
@aomadeira 9 ай бұрын
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!
@thFaust
@thFaust 9 ай бұрын
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. :-)
@neozoid7009
@neozoid7009 9 ай бұрын
I was soo hyped to watch your videos
@SCP6820
@SCP6820 7 ай бұрын
i love how dark this game looks
@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,
@zikaura
@zikaura 9 ай бұрын
Babe wake up, devmar just dropped
@squarerootof2
@squarerootof2 9 ай бұрын
The Tooth Ferry sounds creepy awesome. I'm sure it won't disappoint. I'll be waiting for that.
@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
@bertilorickardspelar
@bertilorickardspelar 9 ай бұрын
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.
@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
@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.
@Thomas_Lo
@Thomas_Lo 9 ай бұрын
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
@aguest5394
@aguest5394 7 ай бұрын
mur godot awesome tutorials please and thank you!
@fafo_o
@fafo_o 8 ай бұрын
THANK YOU THIS IS COOL AF
@somedude5951
@somedude5951 9 ай бұрын
Great video. Thank you.
@Inferryu
@Inferryu 9 ай бұрын
It is VERY usefull, thank you for it.
@errorhostnotfound1165
@errorhostnotfound1165 9 ай бұрын
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)
@fridyrogide8752
@fridyrogide8752 9 ай бұрын
Really interesting technique ; quite advanced for a beginner like me hehehhehe
@andreasng
@andreasng 2 ай бұрын
This is magic! 😢😢
@Zurpanik
@Zurpanik 9 ай бұрын
Freaking rad!
@DodgerEcho
@DodgerEcho 9 ай бұрын
This super video 👍👍👍
@thesleepyfox3295
@thesleepyfox3295 8 ай бұрын
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! 👍
@Polygarden
@Polygarden 9 ай бұрын
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 ай бұрын
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.
@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. 7 ай бұрын
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.
@TheSunriseGames
@TheSunriseGames Ай бұрын
where are you? come back, it's been 7 months.. we need updates
@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
@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!
@noiJadisCailleach
@noiJadisCailleach 8 ай бұрын
Quick question: Why pastebin, and not github?
@frogguygame
@frogguygame 8 ай бұрын
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.
@actualdevmar
@actualdevmar 8 ай бұрын
Sure
@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.
@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 ай бұрын
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 ай бұрын
@@ViktorsJournal short answer is no. This is a different technique.
@portalpony477
@portalpony477 2 ай бұрын
13:36 One second longer video and it would be perfect
@yeroboersma4845
@yeroboersma4845 9 ай бұрын
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.
@ITHINKTHTSDON
@ITHINKTHTSDON Ай бұрын
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!
@feidev
@feidev 8 ай бұрын
This is solid, do you have a discord?
@actualdevmar
@actualdevmar 8 ай бұрын
not yet
@feidev
@feidev 8 ай бұрын
Gotcha! Whenever you create, i will be there@@actualdevmar
@elchippe
@elchippe 9 ай бұрын
Wow and all made in GDScript, no C# or C++, GDScript.
@RexSacriticulus
@RexSacriticulus 9 ай бұрын
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
Каха и суп
00:39
К-Media
Рет қаралды 6 МЛН
KINDNESS ALWAYS COME BACK
00:59
dednahype
Рет қаралды 162 МЛН
Heartwarming moment as priest rescues ceremony with kindness #shorts
00:33
Fabiosa Best Lifehacks
Рет қаралды 37 МЛН
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 9 МЛН
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 491 М.
Improving Environment Graphics in Godot 4 - Tutorial
6:54
Wrobot
Рет қаралды 1,9 М.
10+2 AWESOME ADDONS for GODOT 4
8:36
MrElipteach
Рет қаралды 131 М.
5 Games Made in Godot To Inspire You
5:02
StayAtHomeDev
Рет қаралды 30 М.
Adam Savage Reacts to Hacksmith's Newest Lightsaber!
14:35
Adam Savage’s Tested
Рет қаралды 109 М.
Hiding texture repetition in Godot 4 | Tutorial
16:05
quwatz_
Рет қаралды 16 М.
50 МЕГАЯЩИКТЕН НЕ ТҮСЕДІ ЕКЕН?!
18:41
Асхат Gaming
Рет қаралды 58 М.