Mesh Shaders on the GPU to Enhance the Graphics of Your Games

Both NVIDIA and AMD have talked about a technology called Mesh Shaders, which is one of the rams for visual advancement through GPUs in the coming years. But what really are Mesh Shaders and what is the reason for their existence? We explain it to you together with the changes in the hardware of the graphics cards.

game graphics

If we asked game developers for 4K consoles and for PC if Ray Tracing is more important for the future or the change in the “geometric” part of the 3D pipeline, many of them would not know what to say. Mesh Shaders are part of an evolution in the geometry of the scene, which will allow much more detailed objects in games.

What is a Shader?

Shaders sobre objeto

A Shader is a program that is run by a series of specialized units in the GPUs that have the ability to run programs. Shaders differ from programs that run on a CPU by the fact that they are used to manipulate the attributes of one or more graphical primitives.

A graphic primitive can be a pixel, a vertex or a triangle if we are talking about the 3D pipeline. But a Shader can also be what we call a Compute Shader, which manipulates any type of data, but is independent of the graphical pipeline and is used outside of it.

The units that execute the shader programs are in all the GPUs and today there are dozens of these in each GPU, including the low-end ones. Since a pixel, a triangle, a vertex or the map of a protein are nothing more than data for a processor, the units used to execute these programs are the same regardless of the type of shader.

What are Mesh Shaders?

Mesh Shaders

The concept of Mesh Shaders starts from giving the versatility of Compute Shaders to the different types of Shaders that are used in what we call the World Space Pipeline in Pipeline 3D. In other words: those used to manipulate the geometry of the scene.

To understand it, it must be taken into account that what differentiates a Compute Shader from the rest of Shaders except the Pixel Shader, are the input data that they receive to manipulate and the output that they emit. The idea of the Mesh Shader is none other than to unify all the graphic Shaders that have to do with the manipulation of the geometry of the scene in a single type of Shader.

That is, the Mesh Shader unifies the Vertex, Hull, Domain or Geometry Shader into a single type of Shader program. Since it allows developers to define the input and output parameters of shader programs with total freedom, which in addition to simplifying and redefining the World Space Pipeline also gives it greater versatility.

The Meshlet concept

DX12 Ultimate

The 3D pipeline will not be modified, but the way you work with the geometry of the scene in the World Space Pipeline will be. Currently the entire geometric mesh that makes up the scene is calculated in unison. Each one of the polygons of the objects that make up the scene are referenced within the screen list that is generated by the CPU and each and every one of them must be processed in the order that they have been generated in the list.

So we find ourselves with the paradox of something that works in series in a GPU that is designed for the parallel calculation of data. The solution? Well, reinventing how the World Space Pipeline works deals with geometry, and this is where the so-called Meshlets come in.

Mesh Shaders Meshlets

In the same way that a Chiplet is a smaller part of a Chip, a Meshlet is a smaller part of a polygon mesh. Its operation is very simple, instead of having Instead of having a single list for the geometry what we have are several small lists that are processed in parallel in which each part takes care of a part of the polygonal mesh of the scene. Thanks to this, the ability to calculate the geometry of the scene increases at the same time that it becomes less rigid for the programmers.

In addition, since Mesh Shaders can act as any type of shader, it is possible to work at different stages of the pipeline with the different Meshlets asynchronously, and even execute them in a different order from the traditional pipeline if necessary.

The Amplification Shader

Amplification Shader

The Amplification Shader is a type of Shader program that occurs in the pipeline before Shaders. Although unlike other Shaders in the 3D pipeline, they do not manipulate any kind of graphic primitive, apart from being completely optional.

Its function is to control the execution of Mesh Shaders, that is, through them we can decide which Mesh Shaders are going to be executed and which are not, in what order they are going to do it and they have the ability to add and remove data from the Meshlets that manipulate the Mesh Shaders.

Without the Amplification Shaders, the generation of the Meshlets geometry indexes is generated by the CPU, with the Amplification Shader these lists can be manipulated from the GPU itself. This allows to generate scenarios in which it is necessary to add or remove geometry much more easily, such as tessellation and Culling.

What are the advantages of Amplification and Mesh Shaders in games?

Demo de Unreal Engine 5

The advantages they provide are several, we are going to list the best known:

  • They allow the elimination of superfluous and therefore not visible geometry without having to calculate the entire pipeline.
  • They allow tessellation adaptively, this means being able to select the degree of tessellation, allowing extremely detailed modeling close to the camera.
  • You can dynamically generate geometry at different levels of detail without 3D modelers having to do multiple versions of the same model to do so.
  • Improves the animation of objects by giving more versatility when it comes to manipulating geometry-related shaders.

We will see all of them implemented in all games once DX12 Ultimate becomes the API of reference when developing games on PC. This will lead to the disappearance of techniques such as the use of maps of normals and derivatives to represent surfaces in relief and a higher level of detail.