America: The Godfather of Game Development
Chapter 545

Simple optimizations, a fivefold performance boost

1,780 words6 min read1 view1d agoSource
Next

Fog, an essential technology in modern video games.

However, in the 1990s, people had not yet realized the importance of fog effects.

The reason is simple: in the 8-bit era, running a slightly larger map required a pitiful amount of memory for constant data exchange.

A few kilobytes of memory are completely insufficient to create a vast world.

Even in the 16-bit era, the concept of a big world remains a false proposition.

A few megabytes of memory is enough to support large-scale, tile-based maps, but that's about it.

But Battlefield is different.

It is a true 3D battlefield.

This means that the world can no longer simply preserve a few tile data points as it did before.

[x:0-y:1-tile:0]

Previously, only these three parameters were needed to completely save the information of an entire cell.

When the client attempts to render, it can directly retrieve the corresponding tile from memory and place it at the coordinates. Of course, some translation transformation and view culling also need to be added.

This technique proved effective time and again in the 2D era, especially after the advent of graphics cards, which are inherently adept at batch parallel processing, resulting in a geometric increase in tile performance.

If Super Mario were developed using hardware of the current specifications, the tile density could be increased several times over, while still ensuring a stable frame rate.

In the 3D era, the rendering logic of maps has completely changed.

This is also why Lin Lixin is so certain that 3do is destined to fail.

3do's cel-shading method seems ingenious, a clever way to circumvent the limitations of triangle calculations.

However, once you delve deeper into the geometric space, it becomes clear that this path is absolutely impassable.

Perhaps in the future, when AI technology develops rapidly and frame interpolation and frame generation technologies become more sophisticated, it will be brought up again.

But at least in the short term, and for the next few decades, triangles will be the absolute mainstream for 3D computing.

Computers understand 3D space using... vertices.

In addition to the x and y coordinates, there is an additional z-axis.

Together, they are enough to construct a true 3D space with depth in the computer. So the question is, with so many vertices, how does the computer know how to render them?

Should we just blindly connect all the points and then apply a skin?

These perfectionist geeks would naturally not choose such a green-skinned method.

For those unfamiliar with computer graphics, this is a question that often arises when faced with this issue.

Why a triangle?

Wouldn't it be easier to render if it were rectangular? Dividing the map into pieces like tiles would be both convenient and easy to understand.

The answer lies in 3D.

In solid geometry, if there are four vertices, they are not necessarily in the same plane.

Let alone the graphics card not knowing how to draw it, even if you asked a real person to draw four points that are not on the same plane as a single surface, that would be utter nonsense.

It's probably only possible for higher-dimensional beings or in non-Euclidean space to achieve this.

But triangles are different.

Graphics and mathematics are inherently intertwined. In geometry, three points are always coplanar, but four points are not necessarily coplanar. Three non-collinear points can uniquely determine a plane.

This is the foundation upon which 3D accelerated graphics cards stand.

With just three points, and by using an index to specify how to connect them, the graphics card can easily fill in the pixels.

Want a rectangle? Easy, just make two triangles with the four vertices, right?

No one has stipulated that a vertex can only correspond to one plane.

In this way, it becomes clear that the rendering of 3D space suddenly becomes much easier.

The game involves continuously drawing triangles of various angles and shapes. As these triangles are continuously joined together along collinear lines, they eventually form a complete closed model.

The desert is made up of countless triangles, tanks are made up of countless triangles, guns are made up of countless triangles, people are made up of countless triangles, everything is made up of countless triangles.

Anything in 3D space can be represented by a sufficient number of triangles.

However, this has created new problems.

Just like the experience I had when researching parallax scrolling animations before.

Humans understand 3D space through two-dimensional images. This means that a living person could never actually see what's behind a model.

Even if you could see it, a monitor is still a flat surface.

Graphics engineers naturally discovered this early on. In fact, Lin Lixin and his team had already used occlusion culling extensively in the first generation of the Quake engine.

Anything that cannot be seen will not be exaggerated.

This idea is very important.

It can reduce the rendering load on the graphics card without affecting the player's visual experience.

Even in later generations, Minecraft used this same approach.

Players who play frequently may often encounter a strange situation.

If the server is lagging, or you get stuck inside a block due to some bug.

You can see directly into the entire world, including the chaotic underground caves and hidden lava lakes.

In the old days, there was even a technique circulating on folk forums where one could forcibly get stuck in this state using a minecart to make it easier to find mine tunnels.

This is actually a classic example of occlusion culling. In the process of rendering the world, Minecraft performs "face culling" in addition to dynamically loading blocks.

Although the entire world is made up of blocks, it is not actually rendered in blocks.

Each square will only show the side that it can see.

Imagine the entire block is a vast grassland.

By eliminating these elements, most of the grass blocks only require rendering their top surfaces, saving a significant amount of rendering costs by 5 faces.

Of course, with the rapid development of the mod community in the future, solutions such as "occlusion culling" were also born, which means that if something is not visible, it will not be rendered.

But that's a different route.

In conclusion, once you understand the basic principles of 3D rendering, the existence of "fog effects" is not difficult to understand.

The 3D world needs fog.

If fog forms 300 meters away, the graphics card won't need to render anything beyond that distance.

Simple and straightforward.

"So it's a... soft visual restriction?" Carmack nodded.

If the concept of fog effects is still somewhat unfamiliar, then the topic of visibility limitations is right there in his comfort zone.

In fact, Wolfenstein 3D has a lot of deliberate view distance control.

Each map consists of numerous small rooms, arranged in a straight line with walls everywhere.

This is to save as much of the viewpoint as possible.

Fog simply moved these elements into 3D.

"Yes, and more importantly, it feels very natural. Many players won't even notice the fog effect after playing the game."

Lin Lixin said with a smile.

Compared to other places, deserts have a unique advantage.

"We can make the fog effect look like... a sandstorm."

Fog effect is just an abstract and general concept. Fog is fog effect, smog is fog effect, and clouds can also be fog effect.

The difference lies only in how the designer presents it. The expert who truly excels in this area is Konami, with its grooves.

It must be admitted that although Konami is a complete mess, it has always had a lot of talented and innovative producers under its wing.

Looking at the entire history of games, the first game to truly master the art of fog effects was actually Konami's Silent Hill.

During the PS1 era, everyone knew that 3D could be done, but everyone also knew that the PS1's capabilities were quite limited.

The PS1 was stumped when it came to 3D spaces that included distant views.

The processor and graphics card both stopped working.

Even if you go ahead, you'd be doing your best if you could finish one frame per second.

So the Silent Hill development team had a brilliant idea.

If distant views are difficult to render, then simply prevent players from seeing them.

It creates fog even at a distance of tens of meters from the player.

This isn't some performance-wasting atmosphere rendering technique like adding a layer of fog after rendering the entire scene.

Instead, it's just a solid layer of fog, with nothing behind it, nothing rendered at all. And yet, this thing actually runs very well.

Far from being annoyed, players praised it highly.

This is how a town in Silent Hill should be!

Thick fog, low visibility, monsters lurking...

That's fucking amazing!

That's probably the art of optimization.

Not only will it not offend players, but it can also become a feature of the game and a tool to enhance the atmosphere.

"The heat haze effect reduces the accuracy of distant models due to LOD (Local Image Depth), and dust storms can reduce visibility at a distance, further limiting the line of sight."

After re-examining the entire optimization strategy, the whole project suddenly became clear.

Is it possible to create a large map?

"It seems... there really is a chance?"

Use high-poly models for things nearby, switch to low-poly models for things further away, and then directly use textures for things even further away. Anything further away will be completely swallowed up by a sandstorm. This back-and-forth process fully unleashes the performance of both the processor and the graphics card.

Carmack did some mental calculations and came to a frightening conclusion.

The performance improvement of the processor alone could be close to... 3 times...

The main beneficiary, the graphics card, is even more dramatic, with an overall improvement of nearly 5 times.

This is... it's practically magic!

The magic of code!

Hardware?

Only a spineless coward who gives up at the first sign of difficulty will be deterred by the limitations of hardware.

We're Gamenova!

Gamenova never loses, and it will never be limited by such things.

Strive for perfection!

Achieve the pinnacle of hardware, the pinnacle of algorithms, and the pinnacle of optimization! Squeeze every last drop of functionality from the hardware, ensuring that not a single transistor is idle.

This is the mindset a great developer should have!

Is the hardware insufficient?

First, ask yourself if you've truly pushed the optimization to its limits.

Michael Abrash, sitting a few seats back, stared intently at Lin Lixin was still eloquently explaining his optimization ideas.

He suddenly understood why Lin Lixin was so determined to build a truly optimized team.

They are willing to offer high prices to poach talent from all over the world.

There are just too many things he wants to do.

Hardware development cannot be accelerated rapidly by one person alone.

Only optimization can truly solve the problem.

End of Chapter
Prev
NovelSummaries
Next

Explore the wiki

Comments