Click or drag to resize

Set Hint

The SetHint enumeration allows you to indicate to Insight3D how to optimize a primitive for your expected usage.

Infrequent

Use SetHint.Infrequent for static primitives, that is, primitives you do not plan on updating frequently by calling a Set or SetPartial method. For example, this could be used for a polyline primitive that represents a country boundary. Insight3D will do several things to optimize performance:

  • Ask the renderer to use video memory to store the primitive's vertices.

  • If needed, divide up the primitive to get the desired precision. The CPU will not have to touch each vertex during rendering.

  • The triangle mesh primitive will reorder indices for the GPU's vertex cache.

Note Note

Technical Details: Insight3D's vertex cache optimization is based on the 2007 SIGGRAPH paper Fast Triangle Reordering for Vertex Locality and Reduced Overdraw.

SetHint.Infrequent provides significant performance gains when used with the triangle mesh primitive. The following image shows the result of rendering every STK Area Target for all countries. This creates 603 triangle mesh primitives with a total of 651,494 triangles.

Triangle Meshes for Countries

SetHint.Infrequent is also faster than alternatives for polyline primitives. The following table shows the frame rate of each hint when rendering static polyline primitives for each STK Area Target, as shown in the Batching topic.

Multiple Polylines

Similar performance improvements are achieved when using SetHint.Infrequent with the point batch and text batch primitives.

Frequent

If you plan on updating the entire primitive frequently with a Set method, use SetHint.Frequent. This is common for data that may be completely recomputed every animation cycle, such as a polyline representing a sensor's intersection with the Earth. To demonstrate the performance differences, we used the same data from the above section. 134 polyline primitives with a total of 13,691 were continuously updated with Set every animation cycle. The frame rates are shown below:

The code for the OnAnimationUpdate event is:

C#
for (int i = 0; i < positions.Count; ++i)
{
    lines[i].Set(positions[i]);
}
Partial

Use SetHint.Partial if you plan on updating a small percentage of a primitive's vertices with a SetPartial method. Using the same 134 polyline primitives from the above section, several tests were run using SetPartial to modify different percentages of vertices in each primitive. The code for the OnAnimationUpdate event is:

C#
for (int i = 0; i < positions.Count; ++i)
{
    lines[i].SetPartial(positions[i], indices[i], IndicesOrderHint.SortedAscending);
}

As shown in the table below, SetPartial becomes more efficient than updating all the vertices with Set (218 fps) as the number of vertices updated is becomes small.

% Vertices Modified with SetPartial

fps

100%

165

90%

173

80%

182

70%

191

60%

201

50%

213

40%

225

30%

242

20%

260

10%

282

1%

310

If your indices are stored in ascending order, pass IndicesOrderHint.SortedAscending to SetPartial to achieve the best performance. This indicates that no CPU time should be spent sorting indices.