Unity Terrain Streaming Performance Measurement and Debugging Guide
Measuring the terrain streaming performance.
What to Measure
The StreamedTerrainExtension’s performance can be measured using the Vortex profiler (see
Measuring Performance Using the Content Debugger and Profiler for more details on the Profiler). The timings for the streamed terrain can be found in the DynamicsEngine->ExtensionPostStep->VortexIntegration->Application Extension Handler->Steamed Terrain.
Setting up the Profiler
To use the profiler, the Vortex configuration file must be modified. The following extensions should be in the Vortex setup Document (.vxc file) used.
Profiler Page.
CSV Writer.
To do this, go to the Vortex tab in unity and click on Edit Setup / Create Setup next to the Play Mode Setup Document field. This will open the setup file in the Vortex Editor.
In the Vortex Editor, add the Profiler Page and CSV Writer extensions from the Toolbox.
Once this is done, build the unity project and run it.
When you run the simulation, a Vortex Studio Player window will appear where you will find the Profiler. In the profiler, you will find the timings for the streamed terrain in the DynamicsEngine->ExtensionPostStep->VortexIntegration->Application Extension Handler->Steamed Terrain.
If you want to record the performance measurements in a csv file to analyze it, click on Start Capture. This will record the timings for each time step and save it in a csv file in the Capture Folder which was set.
Performance Tuning
There are two Unity Terrain Settings on the Terrain’s GameObject that have a great impact on the Terrain’s Compute time: Heightmap Resolution and Control Texture Resolution.
The Heightmap Resolution defines the pixel resolution of the Terrain’s heightmap. The values stored in the heightmap define the height of each point on the Terrain. The greater the value, the more the Terrain’s surface will be refined, and by extension the more compute and memory expensive it will be for Vortex.
The Control Texture Resolution controls the blending resolution of the different Terrain Textures. The higher the resolution, the more precise the material mapping will be when determining the Vortex Contact Materials.
These resolutions are relative to the Terrain’s Width and Length values. For example, a 1024x1024 Terrain with a Heightmap Resolution of 1025x1025 will have a cell size of 1 meters. Increasing the Heightmap Resolution to 2049x2049 decreases the cell size to 0.5 meters.
We recommend limiting the cell size to no less than 0.5 meters. Exceeding this resolution may lead to performance degradation. In addition, only one vehicle driving on the terrain is currently supported. Having multiple vehicles may also lead to performance degradation.
Debugging the streamed terrain
To help in debugging the streamed terrain, the dynamics visualizer and content debugger can be used. To use these, the following extensions and modules should be in the Vortex setup document:
Dynamics Visualizer + Dynamics Visualizer Page.
Graphics Module.
3D Display.
Note: The Dynamics Visualizer Page must have a link with the Dynamics Visualizer extension.
When the simulation is started, the dynamics visualizer will appear in a separate window. In this window, all of the debug display options available in the Vortex editor can be used using keyboard shortcuts. (See The Dynamics Visualizer Tab for more details on the various debug settings/keyboard shortcuts.) The collision geometries can be displayed by pressing shift+G to see the geometry of the terrain which is being streamed from Unity into Vortex. The contacts can be shown by pressing shift+C. Everything can be displayed in wireframe by pressing F2. The contact materials can be shown by enabling Display Contact Material Names in the Streamed Terrain extension using the Content Debugger.