How to use Multimeshes in Godot | Game Dev Tutorial 10

Поделиться
HTML-код
  • Опубликовано: 5 сен 2024
  • Welcome back to the Dave the Dev channel. In this tutorial, I'll demonstrate how to render thousands of objects to the screen while maintaining a solid frame-rate. It's possible using Multimeshes in Godot. Comments and questions are welcomed below, even if its just to say hi.
    Dave the Dev GitHub Link: github.com/Dav...
    Follow along with what I'm doing on Twitter: / exp_worlds
    RUclips Music Library
    Song: Nidra in the Sky with Ayler
    by Jesse Gallagher
    / @jessegallagher
    Song: Dreamer
    by DivKid
    / @divkid
    Song: Ruminate
    by R.LUM.R
    / @r.lum.r

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

  • @okayoni6342
    @okayoni6342 14 дней назад

    I really love the smiley face at 1:40 ^~^

  • @Rezgi
    @Rezgi 4 года назад +12

    Love your tutorials ! Well explained and very interesting, keep up the good work !

  • @benjaminpattison1907
    @benjaminpattison1907 4 года назад +18

    5:00 "For this tutorial, we won't go overboard. We'll stick to a conservative *400* objects."

    • @possiblyzslot838
      @possiblyzslot838 6 месяцев назад

      Found this equally entertaining

    • @jimmio3727
      @jimmio3727 Месяц назад

      Considering it will happily do millions of quads, I'd say 400 is pretty conservative :)

  • @BatyushkiDev
    @BatyushkiDev 2 года назад +1

    Great explanation of some basics that I have never fully understood, thank you!

  • @ahmedsan4065
    @ahmedsan4065 4 года назад +2

    Awesome, very educational, Godot is really powerful

  • @iuripugliero9106
    @iuripugliero9106 4 года назад

    Man, I had to pause the video just to like it after the rendering and architecture explanation. As a electronics engineer student, I couldn't said it better. Keep up your amazing work buddy.

    • @DavetheDev
      @DavetheDev  4 года назад +2

      Computer architecture has always been interesting to me. Thanks. ^_^

  • @DarkShroom
    @DarkShroom 2 года назад

    nice clear tutorial with added nostaglia

  • @wongwong5819
    @wongwong5819 4 года назад +3

    great tutorial!thank you!

  • @dandymcgee
    @dandymcgee 4 года назад +1

    Fantastic editing and explanation. Love it.

  • @skepsys_d
    @skepsys_d 4 года назад +1

    Nice work, thank you for sharing this!

  • @SamFX
    @SamFX 4 года назад +1

    Nice tutorial. Thanks a lot. Congrats for the good work

  • @TheGruselmops
    @TheGruselmops 4 года назад +2

    Cool stuff, keet it coming!

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

    the picture for the gpu eating through the data.... that's funny

  • @TokisanGames
    @TokisanGames 4 года назад +1

    Excellent, thank you!

  • @sovietdolphin
    @sovietdolphin 3 года назад

    Very informative, well explained!

  • @randompast
    @randompast 2 года назад

    Excellent work!

  • @jeffg4686
    @jeffg4686 4 года назад +4

    This is really cool. So, in terms of underlying technology, is a Multimesh essentially using a VAO to store data in GPU for all instances, or is it more of a matter of sending 1 set of vertex data (for single mesh) plus another array of data that holds transformations for the instances?

    • @gano9744
      @gano9744 4 года назад

      You can just google it

  • @bigbodge
    @bigbodge 2 года назад

    I knew multimeshing was good, but trying it out for myself Im stunned by it. I'm rendering roughly 50,000 (admittedly primitive, its just 2 planes intersecting each other with a sprite on each one) objects, and it takes less time to load than it does for me to find the play button, and runs like nothing

  • @Hajdew
    @Hajdew 4 года назад +1

    I love ur tutorials ! Could you make tut about procedural animations?

    • @DavetheDev
      @DavetheDev  4 года назад +1

      I sure can. Procedural animation is a topic I'm really interested in. Do you have something specific in mind?

    • @Hajdew
      @Hajdew 4 года назад +1

      @@DavetheDev like legs know where is the surface in 3D env

    • @Hajdew
      @Hajdew 4 года назад +1

      ruclips.net/video/DVGGkPiYmE0/видео.html like this

  • @rinkusan978
    @rinkusan978 3 года назад +1

    Hello. Will it be inefficient to use a multimesh for only 2 copies of an object?
    I want to have a 3D object that, when clicked, may enable the player to temporarily manipulate a clone of that object (Like dragging around a phantom copy of the object, while the original object remains in the original position).
    Originally I thought of using two instances of the object (one that acts as the original and the other as the phantom) and manipulating them separately as I see fit.

  • @larrybird3729
    @larrybird3729 4 года назад

    amazing

  • @unfa00
    @unfa00 4 года назад +3

    0:50 there's actually way more computers in every modern computer. Every hard drive is a computer for example, and has its own OS (someone managed to install Linux on a HDD controller board).

  • @gakkiwoo5452
    @gakkiwoo5452 4 года назад

    follow you,best tutorials,hope you will do 3d fps series.

  • @JayComedyDirector
    @JayComedyDirector 3 года назад

    I have a question.
    Do you remember Warcraft 3 ? Specifically the tower defense games ?
    I wonder. How, at that time, they were able to have over 30-40 towers shooting projectiles at the same time.
    - find target.
    - moving object.
    - colision detection or position match
    - damage dealt.
    All this times 40-200 times at all time (some towers used to shoot VERY fast)
    I;m asking because, once i have over 50 projectiles, im already losing performances in my TD.
    Multimesh wouldnt work righ ? because the position of my target moves, so i'd need to update it at all time.
    What do you advice ?

  • @RyanScottForReal
    @RyanScottForReal 4 года назад

    Awesome. Dave could you increase the font size on the code window when you record, please?

  • @jwerlley
    @jwerlley 4 года назад

    awesomeeee

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

    peak

  • @skaruts
    @skaruts 4 года назад

    Since you know about shaders, if you don't mind, I'd like to ask you something (related to 2D though): I've been for quite a while trying to emulate a text terminal in Godot to make text roguelikes, using a cp437 ascii font image, where I have to colorize each character on the screen, as well as the space around it (the background). I managed to do it but the overall performance isn't that great. This is because I'm using a grid of Sprites (80x50 = 4000 sprites), each with a simple fragment shader that does the trick (4000 shaders), instead of a TileMap, because the tilemap has a limitation that if you color a cell, it colors the tile instead, such that all the other cells with the same tile will get that color too.
    But I wonder, could a single shader bypass that limitation of the TileMap?
    (I'm thinking in terms of applying a shader to the resulting image that godot renders on screen, or something like that.)

    • @DavetheDev
      @DavetheDev  4 года назад

      Oh my, kinda impressed you were able to do all that. Not sure exactly what you're trying to do, but maybe instead of doing this with shaders take a look at the RichTextLabel Node. You can use BBCode to make any character any font or color. It doesn't support background colors by default, but the BBCode can be easily extended to make all kinds of effects. Here's a link about all that: docs.godotengine.org/en/latest/tutorials/gui/bbcode_in_richtextlabel.html
      Let me know if it was useful. Good luck!

    • @skaruts
      @skaruts 4 года назад

      @@DavetheDev I thought about rich text before, but unfortunately it has a few limitations. Namely that with font images I can then edit the images and replace ASCII characters with actual graphics, like people do for Dwarf Fortress, and I would lose that with rich text. And basically I'm doing something vaguely similar to Drawf Fortress. One of those games where the player is an '@' symbol and everything is made of ASCII characters.
      In reality the serious bottleneck isn't the rendering, it's the field of view algorithm (FOV). But there's nothing I can do about the FOV, except going down to gdnative, (which I may do), and so if the rendering could be done more efficiently, maybe it could loosen up some extra frame-time for the FOV, and might improve frame rates.
      (Godot 3 could render things faster too, but this is out of my control: github.com/godotengine/godot/issues/27230 )
      So I was thinking, if there's a way to replace those 4000 shaders with 1 that applies colors to the entire screen in a grid pattern, at cell positions, then I'd love to try it out. I assume it would be more efficient then 4000 separate ones, and maybe it would even allow me to use a TileMap, which is much more efficent than a bunch of Sprite nodes. Problem is I know next to nothing about shaders... I intend to learn them at some point, but I'm prioritizing other stuff.
      But, well, if I can't get rendering faster I'll start looking into gdnative.
      (Just btw, there's a game like this made in Godot, and in 3D, and it looks pretty cool: ruclips.net/video/DUKtc5s5o-E/видео.html . But because it's in 3D it doesn't emulate a terminal/console (but has a nice camera movement)).

    • @Kobrar44
      @Kobrar44 4 года назад

      @@skaruts sounds like you may be creating 4000 independent materials for the shaders. You could try to optimize that, but if you just want to change the color, modulate properly would be enough.

    • @skaruts
      @skaruts 4 года назад

      ​@@Kobrar44 Well I do have to create 4000 materials, or otherwise a change to one cell's shader will apply to all other cells (iirc, it's been a while since I tested it, but I think that was the reason).
      Modulating works but only if I use two layers of sprites. This is because I need to apply two colors, one for the text characters (foreground) and one for the surrounding space (background). With two layers the background layer can use glyph 219 (which is a full white square) for all the cells, and each cell can be modulated, and if I make the texture transparent through code so the foreground cells don't cover the background ones, it gives me the effect I want.
      However, I tried that method before, and the perfomance is even worse.
      There's some good news though: Lately I tested using a MeshInstance2D (with two meshes for two layers) and it's quite a bit faster than all the alternatives I had tried, such as the sprites with shaders, the two layers of sprites with modulate, using the VisualServer directly and using "_draw" functionalities. When nothing is happening (no cells being updated), fps just goes through the roof (like 700 or something). When I stress tested it, updating every cell at once every frame, I still had over 100 fps.
      But that's raw performance, and once I started including FOV algorithms and that sort of thing, the frame rates droped below 60.
      However, I've been delving into gdnative as well, lately (using Nim), and the MeshInstance2Ds perform quite a lot better there. Surprisingly, though, I found little to no improvement in the performance of all the alternatives. Godot's rendering speed still caps them. So currently I'm using a MeshInstance2D in gdnative (and doing FOV and other heavy work there too). :)
      If by any change you're curious you can take a look at my test project here:
      github.com/Skaruts/Terminal_Rendering_Tests

  • @kaypro2872
    @kaypro2872 2 года назад

    Are you able to parent an individual multimesh instances to another node? Say, if you have a multimesh of 20 plane shapes and you want to parent the instances to individual path follows nodes?

    • @DavetheDev
      @DavetheDev  2 года назад

      Yes and No. Yes, you could do it, but no you shouldn't. You can manually set the transform of an individual multimesh instance to copy the transform of any node, however, that calculation is done on the CPU side and must be sent over to the GPU. If you do that for every instance every frame it negates the purpose of using a multimesh altogether.
      What you should be doing instead is calculating the paths from within the shader on the GPU side.

  • @ItzNero69
    @ItzNero69 2 года назад

    I think it does not work anymore, I've watched the video 3 times and copied the code step by step, and there only appears to be one instance appearing

    • @ItzNero69
      @ItzNero69 2 года назад +1

      There's a bug! Godot resets the "Transform Format" option to 2D inadvertently. If you first set the instance count and then change the transform format, it resets it back to 2D.

  • @LORDSofCHAOS333
    @LORDSofCHAOS333 Год назад

    will this work for godot 3.5

  • @classicguy7813
    @classicguy7813 4 года назад +1

    Who can dislike this!?

  • @sekaus9158
    @sekaus9158 Месяц назад

    Dose this only work with the same mesh or can I use multiple meshes?

    • @DavetheDev
      @DavetheDev  Месяц назад

      My understanding is you can only use a single mesh per multimesh, but you can use as many multimeshes as you want.

    • @sekaus9158
      @sekaus9158 Месяц назад

      @@DavetheDev Okay I'm just trying to make a Minecraft looking game (and no, not all blocks are kubes or useing the same texture).

    • @DavetheDev
      @DavetheDev  Месяц назад

      @@sekaus9158 For the blocks, Minecraft like games usually use the CPU to generate a mesh dynamically from voxel data; one mesh per chuck.
      Multi-meshes won't be particularly useful for the blocks because each chuck mesh is different. However, if you have a lot of the same mesh whose properties don't need to be updated frequently cpu-side, like flowers or trees, then multi-meshes might be useful.

  • @canaldosoninho
    @canaldosoninho 2 года назад

    fucking gold m8

  • @flyingjudgement
    @flyingjudgement 11 месяцев назад

    If you learnt something usefull and like your game running at 60 frame per second consider hiting the like button... XD

  • @lukostello
    @lukostello 3 года назад

    anyone have a copy of the fish demo file I can't for the life of me get the vertex shader to work at the same time as the normal shaders

    • @DavetheDev
      @DavetheDev  3 года назад

      You can download an implementation of it from the Godot Asset Lib directly in the Editor. Just search for "fish" and it'll pop up. It's called "Fish shader".

    • @lukostello
      @lukostello 3 года назад

      @@DavetheDev are you talking about templates? because I just searched for it and found nothing

    • @DavetheDev
      @DavetheDev  3 года назад

      @@lukostello I don't understand what you're talking about. Can you provide a bit more context regarding what you're looking for?

    • @lukostello
      @lukostello 3 года назад

      @@DavetheDev I just found the thing you're refering to. But it doesn't have a texture applied to the fish. I was hoping there would be a 1000s of fish demo that uses both a vertex shader and the multimesh feature. I'm having trouble getting both the vertex shader and the normal shader to work simultaneously especially when I have multiple materials

    • @DavetheDev
      @DavetheDev  3 года назад

      @@lukostello Oh okay. It sounds to me like you have a textbook case of trying to do too many things at once. My advice is to slow down a bit. Try getting one fish with one material working first, then build from there.

  • @GNamimates
    @GNamimates 3 года назад +1

    my GPU is so trash it runs like a CPU

  • @Pakrohk
    @Pakrohk 3 года назад

    Hello, please sync your video with odysee, in my country, RUclips is a filter and I can not follow you well.
    odysee.com

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

    How can I use webview inside godot

  • @william8106
    @william8106 4 года назад

    This is really good. Thanks