shown in other instead.
Configuring Landscape Terrain Visualization and Performance
The global Landscape Terrain settings (and the corresponding console parameters) provide set of parameters for fine-tuning of the Landscape Terrain in order to achieve stable work, high performance and great level of detail. All settings are interdependent and have huge influence on performance, therefore they are to be considered to the full extent.
The vast majority of parameters causes the Landscape Terrain object to reload all its graphic data, which is unacceptable at run time. The Making it Run-Time section lists parameters that are safe to be changed at run time.
First, the Texel Size parameter defines the maximum possible density of the components of the main virtual texture. Set this value (from 0.0001 to 1 unit) to limit the density for albedo, normal and height components up to 1 mm per pixel.
The geometry of the landscape terrain is split down to a number of detail levels using adaptive hardware tesselation. The intensity of displacement is controlled by the group of geometry parameters: adjust the Progression value to configure displacement progression with the distance and control the density of tesselated geometry separately using the Polygon Size parameter (in comparison with the Texel Size the maximum value is used).
For optimization purposes you can increase the Subpixel Reduction value to get rid of too small polygon patches. This feature is performed on-the-fly, so make note that high values may cause slight but noticeable visual artifacts when the camera moves.
Levels of tesselation detail can be faded with each other via increasing the Intensity of LODs fading to remove sharp edges between areas with different geometry density.
The Culling Parameters provide additional optimization techniques, such as Backface Culling and Frustum Culling.
During rasterization the renderer selects the mip-level of textures according to the distance to the camera, as well as to the angle of the surface to the camera, i.e. the screen size of the polygon: distant polygons and polygons that are not faced right to the camera are rendered at a lower quality. The Texture Filtering mode controls the way of treating such situations, it has the following presets:
- Low — use the lower mip-level. This option has the best performance but low quality: there is a noticeable edge of mip-levels change.
- Medium — use the higher mip-level. Though the quality is better, the edge still remains. This option has a moderate effect on the performance.
- High — linearly interpolate adjacent mip-levels. This option uses appropriate mip-levels and interpolates pixels, so the edge between mip-levels disappears. This is the most performance-consuming mode.
You can force selecting a higher-quality mip-level by using the Detail Level By Angle parameter:
Target Resolution defines the maximum viewport resolution available for the Landscape Terrain renderer, which guarantees that VRAM limits will not be exceeded if the Application is launched with a higher screen resolution. When being equal to the current viewport size, the parameter provides pixel perfect quality. Decrease it, to gain more performance at a cost of visual quality.
The final quality of details (if there are some on the Landscape Terrain object) is defined by the resolution of the detail textures: albedo, height and additional mask. The available range is [0, 8]:
- 0 — 64×64 pixels,
- 8 — 16384×16384 pixels.
By changing the Visibility Distance value you can control the distance from the camera on which the surface of the Landscape Terrain is visible.
The Landscape Terrain is a sophisticated and powerful system for landscape simulation featuring scopes/binoculars support, multiple cameras and run-time modification. Using these advantages may significantly increase performance consumption and requires careful adjustment.
Flexible streaming settings make it possible to configure terrain rendering even for computers with a limited VRAM capacity, but these settings depend on the content used (distances, level of detail, etc.) and requirements (the number of cameras and viewports, etc.) and are to be adjusted for each project individually.
On the very loading of a world with a Landscape Terrain and later, when the camera moves and the point of view is changed, graphic data is being asynchronously loaded. Asynchronous data streaming of Landscape Terrain implies that tiles appearing in the viewport are first cached into RAM and video memory, and afterwards passed to the Virtual Texture to be rendered on the screen. This process is performed on demand, so appropriate streaming settings are required for seamless loading of graphic data.
Streaming is based on using previously loaded geometry to define the visible areas of terrain. The Culling flag of Landscape Layer Maps enables uploading preliminary low-level data of the map to CPU (about 2 meters per pixel) to be used for checking what tiles are to be streamed next. For maps with the Culling option disabled, only high-detail data of the base map is uploaded on CPU, provided there is data loaded in the visible area.
For landscape layer maps that form basic shape of the landscape keep the Culling flag enabled, otherwise no graphic data will be loaded.
The overall terrain detail level and memory consumption depend on the size of the Virtual Texture components. Higher Texture Memory Size lets more tiles to be presented in video memory enabling you to have more tiles loaded at a moment. This parameter has the highest effect on the amount of VRAM consumption and is defined in the [0, 1] range, where:
- The lowest value of 0 corresponds to the size of 3072×3072 pixels for each of 3 Landscape Terrain textures (~140 MB of VRAM),
- The highest value of 1 stands for the size of 16384×16384 pixels for each of 3 Landscape Terrain textures (~3.1 GB of VRAM).
The more the CPU Cache Size, the faster intersection and collision detection is, overall loading of tiles is faster. The GPU cache contains graphic data of tiles to be transferred to the GPU for rendering. It is also accountable for fast work of GPU-based run-time modification of the Landscape Terrain surface. Control the volume of GPU cache using the GPU Cache Size parameter.
Check memory consumption using the Terrain Cache CPU and Terrain Cache GPU counters of Rendering Performance Profiler.
GPU cache has the Update Limit — the maximum time of cache validation. By using lower values you can reduce possible spikes when tiles are updated, but be careful, as setting too low values may result in growing cache size due to slower unloading of textures. GPU Cache Life Time for landscape tiles can be increased to speedup landscape modification (less cache misses), but this will increase memory consumption.
Even having high cache memory limits and texture resolution, you can have a bottleneck in the speed of tiles being loaded. Control the number of tiles loaded to memory per each frame via the Tiles Load Per Frame parameter. The Tiles Update Per Frame parameter controls the number of tiles updated and presented on the Landscape Terrain per each frame. Make note that by using high values of these parameters you will increase load on CPU and GPU cache and the Virtual Texture but make streaming of tiles really fast.
Use the Landscape Terrain VT Streaming helper (or the render_show_landscape_terrain_vt_streaming 1 console command) to enable visualization of tiles being streamed. In this mode colored areas show the tiles that are currently being rendered in a lower resolution until the highest mip-level is loaded.
Making It Run-Time#
Asynchronous nature of the Landscape Terrain system make it possible to modify the landscape surface at run time: vehicles leaving tracks while moving, procedural pit holes or even an excavator digging trenches are easy to simulate by using a separate Landscape Layer Map.
It is crucial to understand that operating a Landscape Layer Map is not the same as operating a mesh or another familiar type of object. No matter what is going on to Landscape Layer Maps: they are toggled on and off, moved, their settings are changed (e.g. Scale) or the graphic data is modified either via API or by using Brush Editor — it causes the touched tiles of the Landscape Terrain to be reloaded with the changes taken into account. Thus, when creating and moving a Landscape Layer Map to a certain position in a separate frame update, at least two reloading events will take place. Instead, it is better first to move the map and then enable its node.
Control the number of reloaded tiles per each frame via the Tiles Reload Per Frame parameter, in all cases described above it might be worth increasing this value for better performance. You may also need to increase the GPU Cache Update Limit and the GPU Cache Life Time for better performance.
Nonetheless, don't forget to check performance consumption of applied changes by using Rendering Performance Profiler. The Terrain Reload Bounds counter shows the number of unprocessed events causing restreaming some area of the Landscape Terrain surface. Obviously, a big number of tiles can be subject to reloading at the same moment due to these changes, so the Terrain Reload Tiles counter will help you to estimate this number.
Changing most render and streaming settings, as well as operations on Landscape Terrain Details (switching detail masks on and off, assigning materials to details or specifying textures) initiate reloading of all Landscape Terrain graphic data, which is unacceptable at run time. The following parameters are safe to be changed when running a project using Landscape Terrain:
- Cache parameters
- Culling settings
- Geometry Fade Lods parameter
- Holes toggle
- Geometry Subpixel Reduction
- Detail Level By Angle
- Target Resolution
- Tiles Load Per Frame, Tiles Reload Per Frame and Tiles Update Per Frame parameters.
As an example, you can modify these parameters to achieve variable level of detail for different fields of view of the camera. Observing Landscape Terrain through a camera with a narrow FOV may drop performance and make streaming issues noticeable.
Perform the following steps:
- Set the lowest camera FOV your project requires. Degrade the quality a bit for better performance by tweaking safe parameters, e.g. Detail Level By Albedo, Target Resolution and Geometry Subpixel Reduction.
- Switch to the highest possible camera FOV. Adjust the listed render settings.
- Use coding or scripting to linearly interpolate between target values if the FOV is changed gradually or simply change the values for instantly changing field of view of the camera.
Configuring Landscape Terrain Streaming#
To sum up, when configuring a Landscape Terrain pay the closest attention to the following steps:
- Prepare all cameras in the project, open all viewports if your project requires more than one. Two cameras observing the same area of the terrain at the same time don't increase the resources consumption (however, there may be performance drop due to rendering) while cameras that visualize different parts of the landscape will require more performance-consuming settings.
- Adjust the Texture Memory Size so the size of all terrain render textures fits your VRAM and the terrain surface doesn't have noticeable flickering.
- Check the performance and resources consumption using the Rendering Profiler tool and the Render Textures helper at the full screen size and resolution of the target platform, specify the maximum Target Resolution.
- Adjust cache memory limits and the render parameters to avoid visual artifacts, streaming errors and performance spikes.
- Tweak the streaming parameters, especially if your project implies run-time terrain modification.
Though DirectX is the recommended graphic API for the Landscape Terrain system, OpenGL is also supported but has quite serious limitations: asynchronous operations are not available regarding the Landscape Terrain system. Additional setup may be required in order to achieve acceptable performance. Consider following these suggestions:
|gl_terrain_use_async 0||Disable asynchronous data loading to get rid of spikes at the cost of the loading speed.|
|gl_terrain_waiting_frames||Number of frames to wait for streaming. Increase this value (4-16 frames) to avoid more performance spikes and slightly improve the loading speed by forcing deferred data loading that imitates asynchronous data streaming without synchronization points.|
|render_landscape_cache_cpu_size||Increase the memory limit of cache.|
|render_landscape_cache_gpu_size||Increase the memory limit of GPU cache.|
|render_landscape_cache_gpu_life_time||Increase the lifetime of GPU cache. Keep noted that memory limits of cache may be exceeded in the case when the lifetime is highly increased.|
|render_landscape_terrain_vt_tiles_load_per_frame||Decrease the number of loaded tiles per frame to 1 to get rid of performance drops. Low values make streaming slower and more noticeable.|