Graphics Reference
In-Depth Information
How it works…
By calculating the face normal, we were able to determine if, on average, the triangle was
facing towards or away from the camera. If a face is within the viewing threshold's cosine
angle, we keep the patch (in this case, larger than -0.25), otherwise it is discarded before it
even reaches the rasterizer stage (remember to turn off back-face culling in the rasterizer to
test this). Setting the patch tessellation factor to zero tells the fixed function tessellator stage
to discard the patch. This method of using the face normals occasionally results in some
visual artifacts, such as partially visible triangles popping in and out, that is, where one of the
three vertices' normals is within the threshold and the other two are not. The more the source
mesh is detailed, the smaller threshold necessary to remove the artifact.
In our second approach, we look at each vertex's normal. If any of the normals are within the
threshold, we keep the patch; otherwise, we set the tessellation factor to zero in order to tell
the fixed function tessellator stage to discard the patch.
A couple of benefits to this approach are that the popping of triangles is mostly fixed, and
the threshold can be reduced resulting in even fewer extraneous triangles. In the example of
the vertex normal, we were able to use -0.125 (or 97.18 degrees), whereas the face normal
approach needed -0.25 for the same model (or 104.5 degrees). This approach does have a
slightly higher cost.
Finally, we have implemented a very basic dynamic LoD within the patch constant function.
Rather than applying the modifier to the edge and inner tessellation factors, we have only
changed the inside factor. This is because the neighboring/adjacent edges must have the
same tessellation factor in order to maintain water tightness; otherwise, the resulting mesh
will have visible seams (especially near curves). We have done this to keep the example
simple and fast. It is important to note that this method of dynamic LoD does not work well
with the fractional_odd partitioning type, due to the additional inside vertices that are
nearer to the edges.
It is important to remember that tessellation is not free; it should be used wisely where
tessellation will benefit the image quality the most.
There's more…
Tessellation can be optimized in many ways and we have only covered a few of them.
Other options might include analyzing the complexity of a patch's location in a displacement
map or using a feature complexity map (feature adaptive), frustum culling, checking the
triangle size, distance, or based on edge length, and screen adaptive.
 
Search WWH ::




Custom Search