Stop Using Nodes for Everything in Godot — Transcript
Full transcript
- 0:00See this screen? It used to take 115
- 0:03milliseconds to render. That's nearly
- 0:05seven dropped frames. Now, it takes
- 0:07under 10 milliseconds. Why did this
- 0:10screen take 115 milliseconds to render
- 0:12and how did I fix it? This is for my
- 0:14game Alchemortis, a dark fantasy
- 0:17roguelite auto battler where you can
- 0:18create your own builds using alchemy.
- 0:20You can wishlist the game now and
- 0:22there's a playtest available now. So,
- 0:24head on over to the Steam page, give the
- 0:26game a wishlist, download the playtest,
- 0:28try it, and let me [music] know what you
- 0:29think in the Discord server. The link to
- 0:32the Steam page is in the description
- 0:33below. In my game, I have cards. Each
- 0:36card has a shape, unique art, abilities,
- 0:39and several visual effects. Previously,
- 0:42I was handling all of my cards' visual
- 0:44needs the straightforward way. I had a
- 0:46card scene which contained all of the
- 0:47relevant nodes and materials to render
- 0:50everything from the card background to
- 0:51the art to the visual effects for
- 0:53various statuses. As you can see here,
- 0:56this scene tree ended up having a lot of
- 0:58nodes. This wasn't a problem though
- 1:00until I wanted to display all of the
- 1:02cards in this unlock screen. It turns
- 1:05out trying to instantiate roughly 100
- 1:07card scenes like this in a single frame
- 1:09wasn't doable without a massive process
- 1:12time spike. I tried a number of things
- 1:14to address this. Object pooling, [music]
- 1:16instantiating the cards over several
- 1:18frames instead of in one frame, and
- 1:20others, but all of these things
- 1:21presented their own challenges and
- 1:23ultimately felt more like hacks or
- 1:25workarounds that were liable to break. I
- 1:27narrowed the problem down to this. It is
- 1:29simply not feasible to do what I was
- 1:31doing with the card scene and expect the
- 1:33kind of performance that I needed. The
- 1:35instantiation of each card scene and the
- 1:37addition of all those nodes to the tree
- 1:39was simply taking too long and the only
- 1:41way to truly fix the problem was to
- 1:43reduce the number of nodes being added
- 1:45to the tree. I've heard a lot in Godot
- 1:47circles about how using the rendering
- 1:49server directly can improve performance,
- 1:52but if you're like me, that sounds kind
- 1:53of intimidating. But after trying and
- 1:55failing to get these cards rendering
- 1:57within the time of a single frame with
- 1:58the other approaches, I decided to try
- 2:00using the rendering server. And you know
- 2:02what? It ended up being way more
- 2:04straightforward than I anticipated. The
- 2:06core idea is simple. Instead of creating
- 2:08nodes and letting them work with the
- 2:10rendering server for you, you work with
- 2:12the rendering server directly. The
- 2:13rendering server is responsible
- 2:15ultimately for drawing textures,
- 2:16assigning materials, and basically
- 2:18anything else related to drawing to the
- 2:19screen. When you add a Sprite2D to your
- 2:22scene, for example, what's happening
- 2:23under the hood is that the Sprite2D is
- 2:25leveraging the rendering server to draw
- 2:27the sprite you configure. The Sprite2D
- 2:29isn't responsible for doing the drawing.
- 2:31It's basically just a configuration
- 2:33object that passes its data along to the
- 2:35rendering server. Now, that's a
- 2:36simplified explanation, but it's helpful
- 2:38to think about it in that way. What this
- 2:40means is that any node which leverages
- 2:42the rendering server under the hood can
- 2:43be bypassed entirely by using the
- 2:45rendering server directly yourself.
- 2:48Here's a quick breakdown to set up
- 2:49something to use the rendering server.
- 2:51First, you need to create a canvas item.
- 2:53This registers a new canvas item which
- 2:55can have a transform, a texture, a
- 2:57material, among other things. This
- 2:59create canvas item call will return an
- 3:02RID. This is a resource ID that
- 3:04represents the canvas item. The trick
- 3:06here is that with the rendering server,
- 3:08you need to manage RIDs yourself,
- 3:10meaning that when you no longer are
- 3:11using RIDs, you need to free them
- 3:13explicitly. Once you have the canvas
- 3:15item, you can assign a texture or a
- 3:17material, among other things. To assign
- 3:19a texture, you use canvas item add
- 3:21texture rect, [music] for example. You
- 3:23can also change the transform of a
- 3:25canvas item using canvas item set
- 3:27transform. A transform includes not just
- 3:29the position, but rotation and scale as
- 3:31well. I won't list out all the
- 3:33functionality of the rendering server,
- 3:34but hopefully you can see how the
- 3:35pattern works. But, [music]
- 3:37here's where it gets interesting. You
- 3:38can also set canvas items created
- 3:41through the rendering server as children
- 3:43of other canvas items so that they can
- 3:45inherit the transforms of their parents,
- 3:47just like you'd expect from Node2Ds you
- 3:50configure in the Godot editor. So, with
- 3:52all that in place, I think you can start
- 3:53to see how easy it was for me to replace
- 3:55my card scene node structure with an
- 3:58almost pure rendering server
- 4:00implementation. Here's my new card
- 4:02class. We can see that this still
- 4:04inherits control so that I can detect
- 4:05mouse events and retain the possibility
- 4:07of reparenting cards to other nodes.
- 4:09However, there are no other nodes
- 4:11created during instantiation of a card.
- 4:14In the card's [music] setup method, I'm
- 4:16just establishing a tree of canvas
- 4:18items, each one designed to replace a
- 4:20node from the previous card scene. I've
- 4:22got my background canvas item, my art
- 4:24canvas item, as well as canvas items
- 4:27that are assigned materials to render
- 4:29some of my special card visual effects.
- 4:31By leveraging the canvas item parenting
- 4:33that I mentioned before, I can also
- 4:35apply transformations to any canvas item
- 4:37I want to in order to create a scaling
- 4:40or positional animation, for example.
- 4:42So, after that refactor, here is the end
- 4:45result. That card screen that I
- 4:47mentioned before now renders
- 4:48approximately 100 cards in about 8
- 4:50milliseconds, and that's on a debug
- 4:52build. That is a huge improvement
- 4:54compared to the 115 milliseconds to
- 4:56render the same number of cards prior.
- 4:58So, basically, the rendering server has
- 5:00functionality that serves as a
- 5:01one-to-one replacement of whatever my
- 5:03card nodes were doing previously. By
- 5:05using the rendering server directly, I
- 5:07get to bypass the overhead of
- 5:09instantiating a scene and adding many
- 5:11nodes to the scene tree in a single
- 5:12frame, and this isn't just a slight
- 5:14improvement either. It's a massively
- 5:16noticeable difference. Now, all of these
- 5:18cards render within the time of a single
- 5:20frame with plenty of headroom to spare.
- 5:22[music]
- 5:23115 milliseconds down to 8 on a debug
- 5:26build. If your game has a similar
- 5:28bottleneck, the rendering server is
- 5:30worth your time. This video wasn't
- 5:32designed to be a comprehensive rendering
- 5:33server tutorial, but hopefully I've
- 5:35given you a place to start. Again, my
- 5:37game is Alchemortis. Give it a wishlist
- 5:39if the game sounds interesting to you,
- 5:41and again, the playtest is available
- 5:43right now for 1 week, which you can join
- 5:45from the Steam page. If you try it, let
- 5:47me know what you think in the Discord
- 5:49server. The Steam page and Discord are
- 5:51linked below.
- 5:53Thanks for watching this video. If you
- 5:55want to support my work, please consider
- 5:56wishlisting Alchemortis on Steam,
- 5:58subscribing to my Patreon, joining the
- 5:59Discord server, or purchasing one of my
- 6:01courses. You can also sign up for my
- 6:03email list at firebelly.com. The links
- 6:05for everything are in the description
- 6:07below.
About this transcript
This page contains the full transcript of Stop Using Nodes for Everything in Godot by Firebelley Games, generated from the public captions YouTube serves with the video. The transcript has 1,219 words across 187 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.