Tessellation – DirectX 11

Tesselation, the word as is, means, an arrangement of shapes closely fitted together, especially of polygons in a repeated pattern without gaps or overlapping.
In terms of 3D Graphics programming, it means using our GPU hardware to break down polygon into smaller pieces.


Why is this useful?
It can help create Level of Details for objects depending upon its distance from the camera. It is also very useful when rendering Terrain as it can allow the terrain closer to the player/camera have a high level of detail and gradually decrease in detail as it get’s further away from the player/camera. It can also be used with rendering water as it helps us replicate waves with the help of height maps and by manipulating the vertices.

Now to the implementation,
The tesselation pipeline is a new addition to the DirectX11 programmable pipeline. It allows us to manipulate the hull shader and the domain shader, while the Tesselator is a non-programmable fixed function.
While using the tessellation pipeline the basic pipeline, i.e, Vertex Shader -> Pixel Shader, becomes, Vertex Shader -> Hull Shader -> Tessellator -> Domain Shader -> Pixel Shader.


Hull Shader:
This is made up of two authored functions, the hull shader itself and a “constant function”. The constant function is executed once per patch, it outputs an array of SV_TessFactor and SV_InsideTessFactor values. These values determine how the polygon is divided.
The main hull shader declares how many output control points will be generated. This determines how many times the individual hull shader is executed, once for each of the declared output control points.

Tessellator:
This is a non-programmable stage of the pipeline except for the two inputs, SV_TessFactor and SV_InsideTessFactor values output by the hull shader constant function.
The output from the tessellator is a set of weights corresponding to the primitive topology selected in the hull shader. Each of those weights is fed into each of the separate domain shader invocations.

Domain Shader:
The domain shader can see all the control points and per patch constants output in the hull shader stage. The domain shader takes the topology provided by the tessellator and use the control points by the hull shader to create a new renderable vertex.

Github link

Future Work:

  • Add dynamic tessellation
  • Generate terrain using tessellation
  • Using it in Water simulation

References:

Leave a comment