In mid-May, the first technology demo of Unreal Engine 5 was presented . For those unfamiliar with the world of video games, Unreal Engine is a so-called 3D engine, or more precisely, a 3D framework that game developers use to create various games. The fourth version of Unreal Engine runs, for example, under popular games such as Tekken 7, Gears 5, and even Fortnite.
In the technology demo, we see a girl walking through a cave that appears with a reality that belies documentaries, while the Engine developers talk about how they solved the lighting and shading of individual elements.
In the middle of the presentation, the girl reaches a statue, and the developers explain that it is no longer necessary to dumb down various 3D models in order to display them in a game world, and that they can practically provide a level of realism similar to that of films.
When walking around the statue, a sentence is said that the statue consists of more than 33,000,000 triangles. What does this mean exactly? 3D objects in both movies and video games are built from triangles, so when we see a sphere in front of us, it is not actually a sphere, but a surface resembling a sphere made of hundreds (or thousands) of triangles. Of course, the more triangles we use, the more realistic our surface will be.

In the next scene, the hero of the demo moves on to a room where there are nearly 500 copies of the same statue, which means a total of 16,000,000,000 (or sixteen billion!) triangles... At this point, I remembered when, as a junior developer at one of the developer training courses, the instructor sent back the code of the application I had created with the comment that it worked, but it contained a lot of unnecessary code. I still remember how outraged I was by this. Does it matter how much code is in it? It works and it's done...
Now I know that, well, it really doesn't matter how much code is in it. Just think about what would happen in this case if the developers had left an unnecessary line of code or function call in the code when drawing a triangle. Let's assume that an unnecessary code call takes no more than 0.000.0001 seconds. Insignificant, right? Still, who would be bothered by losing so much time? Now, when displaying 16,000,000,000 triangles, this insignificant error would cause a 1600-second wait, which means we would have to wait half an hour for a single frame to be displayed...
We tend to believe that with today's seemingly unlimited hardware resources, code optimization and code refactoring are not important, but this is far from true. It is precisely because of the available resources that it is important for our code to run optimally, as by eliminating a single unnecessary call, we can increase the efficiency of our code many times over.
