Godot's physics is a controversial topic. If you have had the opportunity to play with
3D objects in Godot affected by the physics system, you may know what I mean, especially
if you have worked with a large number of them. Godot's physics engine does not stand out
especially for its performance, and if we compare it with how other engines manage physics,
it leaves a lot to be desired. However, today I bring you good news. There is huge enhancement that you can apply today: Jolt. Jolt is an alternative physics backend to
the physics that Godot brings by default and that can significantly improve the behavior
of physical objects in the engine, and for this today I bring you a performance benchmark
to show you to what extent Jolt can improve the performance of a game. To do this I am going to run the typical benchmark
that consists of spawning a bunch of objects in a three-dimensional space, but in this
case instead of doing the typical thing of throwing cubes at a plane I have decided to
create this kind of "saucepan" where at the bottom there is a paddle that goes around
without stopping. This will cause all the spawned cubes to be
moving constantly, so we will be able to stress the engine more quickly. In addition to telling you exactly what level
of improvement you will be able to achieve if you decide to use Jolt, I will also show
you how to install it within the Godot interface. So, stay with me, because in this video I'm
going to show you what Jolt is, and what can do for your game. Before getting into the benchmark itself,
let's review the recent history of physics engines in Godot. In the version before the current one, Godot
3, the engine allowed you to choose between the physics system developed in-house by the
Godot contributors or the Bullet physics engine. Bullet is an open source 3D physics library,
known for its high precision and performance, however while Godot 4 was being developed
we learned that the next major release of the engine was not going to provide official
support for Bullet, like Godot 3 did. The reason for this change is that the engine
contributors preferred to prioritize their in-house solution, which is simply called
"Godot Physics", this allows them to do a better integration of the physics engine within
Godot, thus optimizing it and making it more efficient. Additionally, using an in-house physics engine
breaks the dependency on using a third-party library, which can be a long-term problem
if that project is abandoned at some point. In this way, the official release of Godot
4 was launched with official support only for Godot Physics. However, the performance of this module is
not what many would like, and that is where Jolt comes in. Jolt is another open-source physics library,
in this case it stands out for having been used in the game Horizon Forbidden West, as
we can see highlighted on its Github page. It is possible to integrate this engine within
Godot using the godot-jolt plugin, which offers a really easy and fast integration, as I am
going to show you at the end of this video. The tests that I have been able to perform
to date are incredible, Jolt greatly improves not only the performance of the game, but
also the way in which bodies behave in space. But enough of the explanations and let's go
with the benchmark itself. This consists of the following: I have created
this example project which, as I said, contains this container with a paddle moving below. At the top I'm going to spawn cubes regularly,
I'm going to count the FPS every second. After a minute, this project calculates the
average FPS for the entire test. The higher this value is, the better the performance
will have been. But, before we start let me give you a couple
of disclaimers: First, the absolute numbers we're going to
look at here, 30 FPS, 40 FPS, 100 FPS, don't matter. This will always depend on the hardware and
the conditions in which the test is performed. What matters is the relative difference between
the value obtained with Godot Physics and Jolt. That is, what percentage of improvement we
have gained by changing the physics backend. So if you download this project and run it
yourself the FPS values will obviously be different, because your hardware is different, but the
relative difference between both engines should be similar. Second, I do this out of simple curiosity,
I do not intend for this to be a super exhaustive benchmark nor do I intend to draw conclusions
that can be used broadly. Each situation is different,
and what we are going to see here must be analyzed with a critical eye. Having said that, let's start with the Godot
Physics test: Let's start the test and what you are seeing
here is Godot Physics. As you can see the test starts quite well. The cube generation interval is 0.01
seconds. The interval management mechanism is written
directly from GDScript, since, as far as I know, the Timer node is not entirely reliable
when the time interval is so small. As you can see, the general performance declines
noticeably around 1000 cubes generated. In case you are wondering, the bottom paddle
is a Node of type AnimatableBody3D, which in this case allows it to move freely without
the cubes affecting it, but this in turn does affect the movement of the cubes. Pay close attention to the behavior of the
cubes. In the next test, which will be with Jolt,
you will see that the bodies behave differently. The final result of this test on my computer
is an average of 42 FPS. This value that I am giving you is the average
of having performed this test 3 times to rule out specific situations. Of course each test has been run in isolation
with most of my PC's processes turned off. Now let's look at this same test with Jolt: What you see on the screen right now is the
Jolt physics engine integrated through the godot-jolt plugin, which I will show you how
to add to your project easily and quickly at the end of this video. If you have been paying attention to the previous
test, one of the things that stands out is the behavior of the cubes. If you remember, in the previous test the
cubes seemed to go a little crazier, like they were triggered much more easily. The project is exactly the same, the only
thing that changes is the physics engine configuration. In the previous test, after 1000 cubes the
drop in framerate was visible and noticeable. On the other hand, in this test it seems to
be much more stable, and we only began to notice a loss of FPS after approximately 2500
cubes... as I told you at the beginning of this video, it's not bad at all. The final result of this test after having
performed it 3 times and having calculated its average value is 97 FPS. This means that Jolt, in this test, has performed
131% better than above Godot Physics...an absolutely incredible score. Another setting I wanted to look at after
reviewing these tests is the option to move physics computing to a dedicated thread. We can find this option in Project Settings,
Physics, 3D. I activated this option and ran the previous
tests again with the same methodology, same machine setup, repeating each of the tests
3 times and taking the average. I imagined that the performance would improve
somewhat, but it did not, the performance in both cases was very similar, even below
the previous in some cases. If anyone knows what this option of executing
in a separate thread is for, I would like you to explain it to me in the comments of
the video. Now I am going to explain how you can install
this plugin yourself so that you can try it in your game. To do this, the first thing I have done is
create an empty project. First we go to the AssetLib and search for
"jolt". We click on "Godot Jolt" and download the
plugin. Once downloaded, Godot will allow us to install
it in the project; upon completion we will have to restart Godot. Now we just have to go to Project, Project
Settings, go to the Physics section, and there click on 3D. Enable the advanced options if you have them
disabled, and there you will see the "Physics Engine" option to change from the default
to JoltPhysics3D. Once selected we will have to save and restart
Godot again for the changes to take effect. Once that is done, Jolt will be the backend
that will compute your physics, you don't have to do anything else. As you have seen, the performance of this
physics engine is much superior to the system that Godot 4 comes with by default. It is being so successful that there is even
a proposal to recognize Godot Jolt as an official Godot plugin; which would be fantastic. You can find the project you have seen in
this video in the description. If you feel like it, install it and perform
these same tests that I have done myself and leave me in the comments the results that
you have obtained comparing both physics engines. Thank you for watching the video until the
end, leave me a like if you found this video helpful and consider subscribing if you are
interested in seeing more content like this. I'll see you in the next video, goodbye.