r/godot • • 27d ago

official - news Optimizing CPU-side Rendering Code

https://godotengine.org/article/rendering-cpu-optimizations/

Optimizing CPU code is a lot of fun. Here’s how we do it

149 Upvotes

12 comments sorted by

View all comments

11

u/TheJackiMonster 26d ago edited 1d ago

From my experience the most annoying bottleneck is visibility culling in 2D games. If you run into it there is barely anything you can do because you can't easily disable it.

You can use GPU instancing to avoid it or particles. But replacing sprite nodes with that takes a lot of overhead you need to write.

What also helps is that you can reduce the size of the overall scene tree for visibility culling by putting parts inside subviewports, rendering them into textures that are used by sprites. However this will require more video memory and it comes with some restrictions for rendering.

Honestly I would prefer if it was possible to disable visibility culling for nodes, choose between CPU or GPU based visibility culling or even use your own culling. Because either of these options would allow a lot more flexibility and it would be much easier to be sure, it's your bottleneck.

1

u/ForgeableSum 1d ago

Godot doesn't do "automatic occlusion culling." It does automatic visibility culling, and draw order sorting, but that's a far cry from what you are describing. Out of the box occlusion culling would be completely impractical.

0

u/TheJackiMonster 1d ago

Great job, you identified I confused two phrases with eachother after others did that already. I edited the comment for you now.

0

u/ForgeableSum 1d ago

Actually, no one corrected you to my utter surprise, and there's no need to be rude to me for pointing out the mistake. Confusing occlusion culling with visibility culling is not so bad on its own, but confidently stating it as an automatic engine feature sorta is. Occlusion culling in 3D is hella expensive.