Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs or learn how to Submit Your Own Blog Post
This is the second article in a series about a modern asset pipeline.
Find the previous post in this series here: A modern asset pipeline: Introduction.
The reasons to why and how to optimize content differs a lot from case to case, depending on asset complexity, platform, game engine, viewing distances etc. I will give you a brief overview of a number of reasons why optimizing content is a good idea if you want to keep your game running smoothly.
Small polygons are not utilizing the hardware efficiently. In order to get maximum performance out of the hardware the recommendations from many vendors is that triangles rendered should be at least 16 pixels in size. Sliver triangles are not recommended, because they have long edges but small contributing areas.
Here we have two triangles, and a few pixels on a screen. The pixels are organized on the hardware into 2x2 quads, and all pixel processing is done on the quads.
When shading, a pixel will be drawn if the triangles overlaps the center position of the pixel.
However, most GPUs have even wider SIMD units. In this example we would need 16 pixels to utilize the hardware most efficiently. In the case to the right the triangle only covers small portions of each unit.
Since pixel processing is done per quad, we have to disable some of the edge pixels, and output results only from the covered pixels.
This is a bigger issue with smaller triangles. You can see in the example images that the left triangle has really bad usage, but the triangle on the right have much better usage, even though it is only a bit larger.
In short, highly tesselated objects are more expensive to render. Here is a video that hihglights the difference in cost of rendering. The mesh to the left contains a large number of triangles while the object to the right contains fewer and larger polygons.
Example techniques to reduce over shading are:
Use LOD’s to replace highly tessellated objects as they are further away from the viewing position.
Even though you have a lot memory at disposal in today’s consoles the data transfer bandwidth limits how much you can use per frame. Realistically you cannot count on using much more than 100GB/s in a PS4 or Xbox One. Which means that if you are running a game at 60FPS the amount of data you can render to screen per frame is around 1.6GB. When this becomes the bottleneck you optimize content so that you don’t send unnecessary data to the GPU.
Example techniques to reduce data per frame are:
Use LOD’s to avoid having to send vertex intense objects to the renderer.
Use mip-mapping to send lower resolution textures to the renderer
Pre-process objects to remove internal geometry that cannot be viewed from the distance.
One of the most common bottle necks in game development today is the number of draw calls per frame. Modern GPUs are very fast at processing vertex and polygon data, but the cost of starting a new batch is significant. Hence it’s a good idea to optimize content so that the number of draw calls per frame are reduced. Each new material and object is likely to generate a new draw call, depending on engine architecture.
Example techniques to reduce draw calls are:
Merging objects so that they can be drawn in one draw call. This is especially applicable when building games using modular building pieces.
Merging textures for several objects so that they exist in one texture atlas and can be drawn in one draw call.
Simplifying shaders so that a more generic one can be used to render objects when they are far away.
In games where you have a lot of animated objects animation cost may become a bottle neck. This is especially true if you are using procedural animations, for example physics-driven, you would prefer not to calculate things that aren’t visible from the viewing position.
Example techniques to reduce animation cost are:
Using LOD’s to remove skin weights when the object is far away and only making calculations for the larger bones. Removing vertices will make the skinning cheaper to calculate as well.
Replacing the head with a very simply skinned one to not have to do facial animations at a distance.
Assets are usually created around the origin and then placed in the world. Each frame vertices for the each asset has to be transformed into world space. Each operation is quite cheap, but when you do this a million times per frame it adds up to a significant cost. Reducing the number of vertices that are drawn every frame will decrease the cost to render.
Example techniques to reduce transformation cost are:
Burning in the world positions for static when baking the world. This will reduce the amount of transformations needed, but it will also consume memory if you have assets that are used in many places.
Using LOD’s to reduce the amount of vertices that needs to be transformed for far away objects.
Overdraw is covering a pixel multiple times, with overlaying triangles.
Most engines use a Z-pre pass to fill in the Z-buffer beforehand and reject layers behind the first layer.
However, this is ineffective on meshes with multiple layers of triangles that are really close. The reason is that the Z-pre pass uses hi-z early rejection, but it is coarse and cannot reject surfaces close to the nearest surface.
Transparent surfaces are also a huge time sink as every pixel behind the surface will have to be drawn at least twice.
Example techniques to reduce overdraw cost are:
Using LOD’s can alleviate this by only keeping the outer visible surface of the mesh.
Removing transparent surfaces by burning in the background on the object when it’s far away.
For example, the skin shader is typically one of the most expensive in games with characters. There are a lot traits of skin that makes it expensive to simulate in a natural way. As a character gets further away a lot of those traits would not be noticeable. Hence it’s a good idea to use a cheaper shader at a distance.
Example techniques to reduce shading cost are:
Merging materials so that a more generic and cheap shader can be used when an object is further away.
Baking procedural textures and blend networks in to static textures.
In the next post in this series we will look into some stats regarding optimization.
Read more about:
Featured BlogsYou May Also Like