This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine::WorldOccluderTerrain Class

Terrain occluder introduces a cheaper and more efficient way of handling intersections with terrains. The objects behind the terrain occluder are not sent to the GPU, which saves performance.

Notice
If terrain relief is changed in the runtime, it is not recommended to use the occluder.

Usage

To provide increased performance, terrain occluders should be used wisely.

  • A terrain occluder can be a great benefit in case of mountains or complex urban environments.
    • If a terrain is flat, occluder can reduce FPS since there are no surfaces that can be culled.
    • On the contrary, an occluder is highly effective if there are many objects that are costly to render (they have a lot of polygons and/or heavy shaders). However, these objects should not be too large since if any part of their surface is seen, it cannot be culled.
  • When the camera is high above the ground (for example, for flight simulators), an occluder should be disabled. At the same time, when it is near or on the ground (during a takeoff or landing), occluders can be enabled to provide performance gain.
  • If terrain relief is changed in the runtime, it is not recommended to use the occluder.

Generation

The terrain occluder is generated basing on its downsized height map using cone-step mapping. Generation of an occluder texture is a time-consuming operation that should be done only once rather than each time on world load.

To set a texture for WorldOccluderTerrain in real-time, use the following steps:

  1. Set a height map texture (in R8, R16 or RG8 format) via setHeightsImageName(). Cone-step mapping will be calculated and a new image (in RGB8 format) will be generated. It contains all data necessary to perform occlusion.
  2. Get newly generated occluder image (RGB8) via getHeightsImage().
  3. Save this occluder image (RGB8) to disk with same name.
This way there will be no need to perform time-consuming cone-step recalculation the next time a world is loaded.

Unigine::WorldOccluderTerrain Class

Members


static int type ()

WorldOccluderTerrain type.

Return value

WorldOccluderTerrain type identifier.

static Ptr< WorldOccluderTerrain > create (const NodePtr & node)

WorldOccluderTerrain constructor.

Arguments

  • const NodePtr & node - Node smart pointer.

static Ptr< WorldOccluderTerrain > create (const vec3 & size)

WorldOccluderTerrain constructor.

virtual Ptr< Node > getNode () const =0

Returns a node pointer.

Return value

Node pointer.

virtual void setSize (vec3 & size) =0

Sets the dimensions of the terrain occluder.

Arguments

  • vec3 & size - Size of the terrain occluder in units. If a negative value is provided, vec3(0.0f) will be used instead.

virtual vec3 getSize () const =0

Returns the current dimensions of the terrain occluder.

Return value

Size of the terrain occluder in units.

virtual void setRadius (float radius) =0

Radius of ray tracing to perform occlusion. The radius is counted off starting from the camera.

Arguments

  • float radius - Radius of occlusion in units.

virtual float getRadius () const =0

Returns the current ray tracing radius to perform occlusion.

Return value

Radius of occlusion in units.

virtual void setDistance (float distance) =0

Sets the distance for disabling terrain occluder.

Arguments

  • float distance - Distance in units. If a negative value is provided, 0 will be used instead.

virtual float getDistance () const =0

Returns the current distance for disabling terrain occluder.

Return value

Distance in units.

virtual int setHeightsImageName (const char * name) =0

Sets the name of the height map that repeats terrain heights. The height map can be smaller in size compared to terrain's one. It will be automatically converted into the RGB8 format.

Arguments

  • const char * name - Height map name.

Return value

1 if the height map was successfully loaded; otherwise, 0.

virtual const char * getHeightsImageName () const =0

Returns the name of the height map that repeats terrain heights.

Return value

The name of the height map.

virtual ImagePtr getHeightsImage () const =0

Returns the height map image that repeats terrain heights.

Return value

Height map image.
Last update: 2017-07-03
Build: ()