DI-Guy SDK Documentation  13.5
4.1 - Techniques for Maximizing DI-Guy Performance

DI-Guy provides tools, techniques, and functions for improving runtime performance.

You can use these tools to create simulations that look great and run quickly. In this section performance refers to the efficient update and drawing of DI-Guy characters so as to maximize graphics frame rate (draw) and update rate, and minimize CPU load.

The following basic techniques help scale performance of DI-Guy characters:

  • Draw Culling. If a character is not visible in the view frustum, eliminating a draw call to that character will improve performance.
  • Update Culling. If a character is not visible in the view frustum, eliminating an update call to that character will improve performance. Non-visible characters still need to be updated periodically so that their general position is known (and thus whether they have entered the view frustum). It is often also important to stagger these updates to maintain performance consistency.
  • Shader LODs. DI-Guy supports use of shader LODs to improve graphic performance. This include bump mapping, per pixel shaders, per vertex, and unlit shaders. Shader LODs let you balance visual quality against performance.
  • Instancing. The instancing system lets you add 100s of identical characters to scene without compromising performance.
  • Graphics LOD. Graphics LOD specifies how detailed a model to display. In the following illustration, we see 4 LODs, with polygon counts of 6500, 3250, 1280, and 425 respectively. LOD4 is clearly an unacceptable appearance if the character is in the foreground, but if the character is far away, it is visually indistinguishable from LOD 1, but takes only a fraction of the time to render.
dig_sdk_lods.png
Levels of Detail

You can set the graphics LOD of a character using the diguyCharacter function call set_graphics_lod(). However, typically LODs are controlled automatically. You can query and set the distances that define LOD ranges on a per-character basis using the diguyCharacter::set_lod_ranges(…) and get_lod_ranges(…) function calls.

The DI-Guy Character Viewer is an excellent way to review a model’s LODs, both visually and numerically.

  • Multi-Threading. DI-Guy takes advantage of multiple cores to animate its characters. Use diguyApp::set_num_threads() to control how many different threads DI-Guy uses for animating.
  • DI-Guy Load Manager. The DI-Guy Load Manager allows you to apply the culling and LOD methods described previously to a single view application in a simplified manner so that you do not need to handle the details. The Load Manager is described in 4.1.1 Using the Load Manager.
  • Shader LODs. Shaders can be instrumented for characters farther away from the origin.
  • Advanced Performance Techniques. Advanced performance techniques can increase your DI-Guy performance. The use of skinned versus segmented characters often affects the relevance of these techniques. A benchmark program is included to help measure the effect of these advanced performance options. Advanced techniques include:

    • Disabling motion blends.
    • Disabling update.
    • Disabling draw.
    • Disabling motion accumulation.
    • Enabling cached pointers.
    • Enabling quaternion precomputation.
    • Enabling axis motions optimization (aim).

4.1.1 Using the Load Manager

When there are many characters in a scene, the DI-Guy Load Manager (class diguyLoadManager) uses update culling and motion LODs to improve runtime performance. Characters far from the camera are made to articulate less often than characters close to the camera. Through this process the Load Manager reduces the total amount of CPU processing used to update DI-Guy characters, with little to no degradation of the visuals.

The Load Manager divides the world into four zones: near zone, intermediate zone, far zone, and out-of-view (figure). Characters in the near zone articulate fully at full rate. Characters in the medium and far zones articulate at a reduced rate and use motion LODs to limit the joints articulated. Characters in the out-of-bounds zone are not articulated at all, and have their location calculated at a reduced rate. (The Load Manager does not support multiple viewports.)

dig_sdk_lodxones.png
LOD Zones

4.1.1.1 Enabling Load Management

By default, the Load Manager is disabled. To enable the Load Manager, create it using the diguyApp function create_load_manager(). This function returns a pointer to an instantiated diguyLoadManager class.

You must also associate a camera with the Load Manager so that it knows which characters are visible and which are not. Do this by calling the Load Manager’s member function add_view_camera(). Any time the properties of the view change, the Load Manager must be advised using the function change_view_camera_settings() or move_camera() or using the callback camera_changed().

4.1.1.2 Setting Zone Boundaries

Call the diguyLoadManager member function set_zone_bounds() to set the distances from the camera that define your zones. The default distances are 10 and 25 meters respectively.

4.1.1.3 Setting Zone Parameters

Call the diguyLoadManager member function set_zone_parameters() to assign the percentage of time the character’s location is updated, percentage of time the joints are updated, and the motion level of detail (MLOD) for any zone. The following are the default settings expressed in terms of calls to the Load Manager functions:

Set_zone_bounds(10, 25);
Set_zone_parameters(0, 100, 100, 1); # Near Zone: 100% pos, 100% joint, MLOD 1
Set_zone_parameters(1, 100, 50, 2); # Intermediate Zone: 100% pos, 50% joint, MLOD 2
Set_zone_parameters(2, 100, 20, 5); # Far Zone: 100% pos, 20% joint, MLOD 5

4.1.1.4 Setting the Maximum Update Period for Out-of-Frustum Characters

Characters located outside of the view frustum will by default have their location updated at a lower rate (once per second) with no articulation when using the load manager. Use the set_max_update_period() function to specify a longer or shorter interval between position updates.

4.1.2 Using DI-Guy as Part of a Networked Image Generator

A typical DI-Guy use case is to use the DI-Guy SDK to provide the lifeform visuals for an image generator that is part of a distributed simulation receiving entity state information using DIS or HLA. You can improve performance by using the following techniques:

  • Draw culling, update culling, motion LODS, and load management. Draw culling, update culling, and motion LODs are powerful methods for improving performance. The DI-Guy Load Manager is an easy way to apply those methods with minimum coding. But the DI-Guy Load Manager is not the correct solution, in some cases.

    If your application provides multiple views of a scene, do not use the DI-Guy Load Manager. You will have to create your own load manager to manage the DI-Guy draw culling, update culling, and motion LODs functions.

    Do not use any load management if all the characters are close by and always in the view frustum.

  • Graphic LODs. Set your LOD ranges in each view carefully to maximize draw time performance by reducing polygon count and draw calls.
  • Disable motion accumulation. Do this if you are setting the position of your DI-Guy character every frame. If you are only periodically updating, use the drift guide and do not disable motion accumulation.
  • Shader LODs. Picking the simplest shader that you need can greatly increase the speed of drawing. Please see the diguyGraphicsShaderTechnique class for more details.

4.1.3 Notes on Compressed Geometry, Textures, and Preloading

Compression of geometry and textures has been emphasized in DI-Guy to improve load-time performance, disk footprint, memory footprint, and runtime performance.

DI-Guy ships with compressed geometry (.bdg) files. DI-Guy Data CD3 includes the uncompressed version of these models. By default, when loading a model that does not have compressed geometry, DI-Guy will try to compress and save the .bdg file for future use.

DI-Guy supports multi-texturing. To minimize texture memory, it automatically compresses .png and .rgb textures to .dds files.

Normal map textures use the DXT5_nm texture compression format. DI-Guy reference shaders only support compressed normal map textures.

DI-Guy does not load characters, motions, geometry, and textures when it reads the configuration file during initialization, it just catalogs them to know what is available. This saves time during loading, but at a performance cost during runtime. To ensure that no frames are dropped when a character is first used at runtime, there are various preloading methods available that force loading at startup.

The following functions load geometry and texture for an appearance:

The following functions load motion data for character actions:

The following functions load motion data for a gesture:

DI-Guy keeps references to things it has loaded, and does not reread files.

[Home] [Top of Page]