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.
No language code for this page. You can select other language.
No language code for this page,
shown in other instead.
shown in other instead.
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.
If terrain relief is changed in the runtime, it is not recommended to use the occluder.
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.
The terrain occluder is generated based 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:
- Set a height map texture (in R8, R16 or RG8 format) via setHeightsImageName() . Cone-step mapping will be calculated and a new image (inRGB8 format) will be generated. It contains all data necessary to perform occlusion.
- Get newly generated occluder image (RGB8) via getHeightsImage() .
- Save this occluder image (RGB8) to disk with same name.
static WorldOccluderTerrainPtr create(const Math::vec3 & size)Constructor. Creates a new terrain occluder of the specified size.
- const Math::vec3 & size - Size of the terrain occluder in units.
Ptr<WorldOccluderTerrain> cast(const Ptr<Node> & node)Casts a WorldOccluderTerrain out of the Node instance.
- const Ptr<Node> & node - Pointer to Node.
Return valuePointer to WorldOccluderTerrain.
void setDistance(float distance)Sets the distance for disabling terrain occluder.
- float distance - Distance in units. If a negative value is provided, 0 will be used instead.
float getDistance()Returns the current distance for disabling terrain occluder.
Return valueDistance in units.
Ptr<Image> getHeightsImage()Returns the height map image that repeats terrain heights.
Return valueHeight map image.
int setHeightsImageName(const char * name)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.
- const char * name - Height map name.
Return value1 if the height map was successfully loaded; otherwise, 0.
const char * getHeightsImageName()Returns the name of the height map that repeats terrain heights.
Return valueThe name of the height map.
void setRadius(float radius)Radius of ray tracing to perform occlusion. The radius is counted off starting from the camera.
- float radius - Radius of occlusion in units.
float getRadius()Returns the current ray tracing radius to perform occlusion.
Return valueRadius of occlusion in units.
void setSize(const Math::vec3 & size)Sets the dimensions of the terrain occluder.
- const Math::vec3 & size - Size of the terrain occluder in units. If a negative value is provided, vec3(0.0f) will be used instead.
Math::vec3 getSize()Returns the current dimensions of the terrain occluder.
Return valueSize of the terrain occluder in units.
Last update: 2017-07-03
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)