YouTube2Text

Stop Using Nodes for Everything in Godot — Transcript

by Firebelley Games · 1,219 words · 187 segments · language en · Watch on YouTube

Full transcript

  1. 0:00See this screen? It used to take 115
  2. 0:03milliseconds to render. That's nearly
  3. 0:05seven dropped frames. Now, it takes
  4. 0:07under 10 milliseconds. Why did this
  5. 0:10screen take 115 milliseconds to render
  6. 0:12and how did I fix it? This is for my
  7. 0:14game Alchemortis, a dark fantasy
  8. 0:17roguelite auto battler where you can
  9. 0:18create your own builds using alchemy.
  10. 0:20You can wishlist the game now and
  11. 0:22there's a playtest available now. So,
  12. 0:24head on over to the Steam page, give the
  13. 0:26game a wishlist, download the playtest,
  14. 0:28try it, and let me [music] know what you
  15. 0:29think in the Discord server. The link to
  16. 0:32the Steam page is in the description
  17. 0:33below. In my game, I have cards. Each
  18. 0:36card has a shape, unique art, abilities,
  19. 0:39and several visual effects. Previously,
  20. 0:42I was handling all of my cards' visual
  21. 0:44needs the straightforward way. I had a
  22. 0:46card scene which contained all of the
  23. 0:47relevant nodes and materials to render
  24. 0:50everything from the card background to
  25. 0:51the art to the visual effects for
  26. 0:53various statuses. As you can see here,
  27. 0:56this scene tree ended up having a lot of
  28. 0:58nodes. This wasn't a problem though
  29. 1:00until I wanted to display all of the
  30. 1:02cards in this unlock screen. It turns
  31. 1:05out trying to instantiate roughly 100
  32. 1:07card scenes like this in a single frame
  33. 1:09wasn't doable without a massive process
  34. 1:12time spike. I tried a number of things
  35. 1:14to address this. Object pooling, [music]
  36. 1:16instantiating the cards over several
  37. 1:18frames instead of in one frame, and
  38. 1:20others, but all of these things
  39. 1:21presented their own challenges and
  40. 1:23ultimately felt more like hacks or
  41. 1:25workarounds that were liable to break. I
  42. 1:27narrowed the problem down to this. It is
  43. 1:29simply not feasible to do what I was
  44. 1:31doing with the card scene and expect the
  45. 1:33kind of performance that I needed. The
  46. 1:35instantiation of each card scene and the
  47. 1:37addition of all those nodes to the tree
  48. 1:39was simply taking too long and the only
  49. 1:41way to truly fix the problem was to
  50. 1:43reduce the number of nodes being added
  51. 1:45to the tree. I've heard a lot in Godot
  52. 1:47circles about how using the rendering
  53. 1:49server directly can improve performance,
  54. 1:52but if you're like me, that sounds kind
  55. 1:53of intimidating. But after trying and
  56. 1:55failing to get these cards rendering
  57. 1:57within the time of a single frame with
  58. 1:58the other approaches, I decided to try
  59. 2:00using the rendering server. And you know
  60. 2:02what? It ended up being way more
  61. 2:04straightforward than I anticipated. The
  62. 2:06core idea is simple. Instead of creating
  63. 2:08nodes and letting them work with the
  64. 2:10rendering server for you, you work with
  65. 2:12the rendering server directly. The
  66. 2:13rendering server is responsible
  67. 2:15ultimately for drawing textures,
  68. 2:16assigning materials, and basically
  69. 2:18anything else related to drawing to the
  70. 2:19screen. When you add a Sprite2D to your
  71. 2:22scene, for example, what's happening
  72. 2:23under the hood is that the Sprite2D is
  73. 2:25leveraging the rendering server to draw
  74. 2:27the sprite you configure. The Sprite2D
  75. 2:29isn't responsible for doing the drawing.
  76. 2:31It's basically just a configuration
  77. 2:33object that passes its data along to the
  78. 2:35rendering server. Now, that's a
  79. 2:36simplified explanation, but it's helpful
  80. 2:38to think about it in that way. What this
  81. 2:40means is that any node which leverages
  82. 2:42the rendering server under the hood can
  83. 2:43be bypassed entirely by using the
  84. 2:45rendering server directly yourself.
  85. 2:48Here's a quick breakdown to set up
  86. 2:49something to use the rendering server.
  87. 2:51First, you need to create a canvas item.
  88. 2:53This registers a new canvas item which
  89. 2:55can have a transform, a texture, a
  90. 2:57material, among other things. This
  91. 2:59create canvas item call will return an
  92. 3:02RID. This is a resource ID that
  93. 3:04represents the canvas item. The trick
  94. 3:06here is that with the rendering server,
  95. 3:08you need to manage RIDs yourself,
  96. 3:10meaning that when you no longer are
  97. 3:11using RIDs, you need to free them
  98. 3:13explicitly. Once you have the canvas
  99. 3:15item, you can assign a texture or a
  100. 3:17material, among other things. To assign
  101. 3:19a texture, you use canvas item add
  102. 3:21texture rect, [music] for example. You
  103. 3:23can also change the transform of a
  104. 3:25canvas item using canvas item set
  105. 3:27transform. A transform includes not just
  106. 3:29the position, but rotation and scale as
  107. 3:31well. I won't list out all the
  108. 3:33functionality of the rendering server,
  109. 3:34but hopefully you can see how the
  110. 3:35pattern works. But, [music]
  111. 3:37here's where it gets interesting. You
  112. 3:38can also set canvas items created
  113. 3:41through the rendering server as children
  114. 3:43of other canvas items so that they can
  115. 3:45inherit the transforms of their parents,
  116. 3:47just like you'd expect from Node2Ds you
  117. 3:50configure in the Godot editor. So, with
  118. 3:52all that in place, I think you can start
  119. 3:53to see how easy it was for me to replace
  120. 3:55my card scene node structure with an
  121. 3:58almost pure rendering server
  122. 4:00implementation. Here's my new card
  123. 4:02class. We can see that this still
  124. 4:04inherits control so that I can detect
  125. 4:05mouse events and retain the possibility
  126. 4:07of reparenting cards to other nodes.
  127. 4:09However, there are no other nodes
  128. 4:11created during instantiation of a card.
  129. 4:14In the card's [music] setup method, I'm
  130. 4:16just establishing a tree of canvas
  131. 4:18items, each one designed to replace a
  132. 4:20node from the previous card scene. I've
  133. 4:22got my background canvas item, my art
  134. 4:24canvas item, as well as canvas items
  135. 4:27that are assigned materials to render
  136. 4:29some of my special card visual effects.
  137. 4:31By leveraging the canvas item parenting
  138. 4:33that I mentioned before, I can also
  139. 4:35apply transformations to any canvas item
  140. 4:37I want to in order to create a scaling
  141. 4:40or positional animation, for example.
  142. 4:42So, after that refactor, here is the end
  143. 4:45result. That card screen that I
  144. 4:47mentioned before now renders
  145. 4:48approximately 100 cards in about 8
  146. 4:50milliseconds, and that's on a debug
  147. 4:52build. That is a huge improvement
  148. 4:54compared to the 115 milliseconds to
  149. 4:56render the same number of cards prior.
  150. 4:58So, basically, the rendering server has
  151. 5:00functionality that serves as a
  152. 5:01one-to-one replacement of whatever my
  153. 5:03card nodes were doing previously. By
  154. 5:05using the rendering server directly, I
  155. 5:07get to bypass the overhead of
  156. 5:09instantiating a scene and adding many
  157. 5:11nodes to the scene tree in a single
  158. 5:12frame, and this isn't just a slight
  159. 5:14improvement either. It's a massively
  160. 5:16noticeable difference. Now, all of these
  161. 5:18cards render within the time of a single
  162. 5:20frame with plenty of headroom to spare.
  163. 5:22[music]
  164. 5:23115 milliseconds down to 8 on a debug
  165. 5:26build. If your game has a similar
  166. 5:28bottleneck, the rendering server is
  167. 5:30worth your time. This video wasn't
  168. 5:32designed to be a comprehensive rendering
  169. 5:33server tutorial, but hopefully I've
  170. 5:35given you a place to start. Again, my
  171. 5:37game is Alchemortis. Give it a wishlist
  172. 5:39if the game sounds interesting to you,
  173. 5:41and again, the playtest is available
  174. 5:43right now for 1 week, which you can join
  175. 5:45from the Steam page. If you try it, let
  176. 5:47me know what you think in the Discord
  177. 5:49server. The Steam page and Discord are
  178. 5:51linked below.
  179. 5:53Thanks for watching this video. If you
  180. 5:55want to support my work, please consider
  181. 5:56wishlisting Alchemortis on Steam,
  182. 5:58subscribing to my Patreon, joining the
  183. 5:59Discord server, or purchasing one of my
  184. 6:01courses. You can also sign up for my
  185. 6:03email list at firebelly.com. The links
  186. 6:05for everything are in the description
  187. 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.